Skip to content

Commit

Permalink
[Paperclip] updating syntax in specs (kreeti#11)
Browse files Browse the repository at this point in the history
* updating syntax in spec/support

* updating syntax in [spec] io_adapters, matchers, storage and validators

* updating syntax in [spec] paperclip

* change rubocop config
  • Loading branch information
sbhawsingka authored and ssinghi committed Dec 10, 2019
1 parent 18df9d4 commit bff50d3
Show file tree
Hide file tree
Showing 64 changed files with 1,442 additions and 1,443 deletions.
6 changes: 3 additions & 3 deletions .hound.yml
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ Metrics/CyclomaticComplexity:
Enabled: false
Max: 6
Metrics/LineLength:
Description: Limit lines to 80 characters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
Description: Limit lines to 120 characters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#120-character-limits
Enabled: true
Max: 80
Max: 120
AllowURI: true
URISchemes:
- http
Expand Down
10 changes: 5 additions & 5 deletions spec/paperclip/attachment_definitions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'spec_helper'
require "spec_helper"

describe "Attachment Definitions" do
it 'returns all of the attachments on the class' do
it "returns all of the attachments on the class" do
reset_class "Dummy"
Dummy.has_attached_file :avatar, {path: "abc"}
Dummy.has_attached_file :other_attachment, {url: "123"}
Dummy.has_attached_file :avatar, path: "abc"
Dummy.has_attached_file :other_attachment, url: "123"
Dummy.do_not_validate_attachment_file_type :avatar
expected = {avatar: {path: "abc"}, other_attachment: {url: "123"}}
expected = { avatar: { path: "abc" }, other_attachment: { url: "123" } }

expect(Dummy.attachment_definitions).to eq expected
end
Expand Down
30 changes: 15 additions & 15 deletions spec/paperclip/attachment_processing_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'spec_helper'
require "spec_helper"

describe 'Attachment Processing' do
describe "Attachment Processing" do
before { rebuild_class }

context 'using validates_attachment_content_type' do
it 'processes attachments given a valid assignment' do
context "using validates_attachment_content_type" do
it "processes attachments given a valid assignment" do
file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, content_type: "image/png"
instance = Dummy.new
Expand All @@ -14,7 +14,7 @@
attachment.assign(file)
end

it 'does not process attachments given an invalid assignment with :not' do
it "does not process attachments given an invalid assignment with :not" do
file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, not: "image/png"
instance = Dummy.new
Expand All @@ -24,7 +24,7 @@
attachment.assign(file)
end

it 'does not process attachments given an invalid assignment with :content_type' do
it "does not process attachments given an invalid assignment with :content_type" do
file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff"
instance = Dummy.new
Expand All @@ -34,9 +34,9 @@
attachment.assign(file)
end

it 'allows what would be an invalid assignment when validation :if clause returns false' do
it "allows what would be an invalid assignment when validation :if clause returns false" do
invalid_assignment = File.new(fixture_file("5k.png"))
Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff", if: lambda{false}
Dummy.validates_attachment_content_type :avatar, content_type: "image/tiff", if: lambda { false }
instance = Dummy.new
attachment = instance.avatar
expect(attachment).to receive(:post_process_styles)
Expand All @@ -45,30 +45,30 @@
end
end

context 'using validates_attachment' do
it 'processes attachments given a valid assignment' do
context "using validates_attachment" do
it "processes attachments given a valid assignment" do
file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment :avatar, content_type: {content_type: "image/png"}
Dummy.validates_attachment :avatar, content_type: { content_type: "image/png" }
instance = Dummy.new
attachment = instance.avatar
expect(attachment).to receive(:post_process_styles)

attachment.assign(file)
end

it 'does not process attachments given an invalid assignment with :not' do
it "does not process attachments given an invalid assignment with :not" do
file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment :avatar, content_type: {not: "image/png"}
Dummy.validates_attachment :avatar, content_type: { not: "image/png" }
instance = Dummy.new
attachment = instance.avatar
expect(attachment).not_to receive(:post_process_styles)

attachment.assign(file)
end

it 'does not process attachments given an invalid assignment with :content_type' do
it "does not process attachments given an invalid assignment with :content_type" do
file = File.new(fixture_file("5k.png"))
Dummy.validates_attachment :avatar, content_type: {content_type: "image/tiff"}
Dummy.validates_attachment :avatar, content_type: { content_type: "image/tiff" }
instance = Dummy.new
attachment = instance.avatar
expect(attachment).not_to receive(:post_process_styles)
Expand Down
30 changes: 15 additions & 15 deletions spec/paperclip/attachment_registry_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
require 'spec_helper'
require "spec_helper"

describe 'Attachment Registry' do
describe "Attachment Registry" do
before do
Paperclip::AttachmentRegistry.clear
end

context '.names_for' do
it 'includes attachment names for the given class' do
context ".names_for" do
it "includes attachment names for the given class" do
foo = Class.new
Paperclip::AttachmentRegistry.register(foo, :avatar, {})

assert_equal [:avatar], Paperclip::AttachmentRegistry.names_for(foo)
end

it 'does not include attachment names for other classes' do
it "does not include attachment names for other classes" do
foo = Class.new
bar = Class.new
Paperclip::AttachmentRegistry.register(foo, :avatar, {})
Expand All @@ -22,13 +22,13 @@
assert_equal [:lover], Paperclip::AttachmentRegistry.names_for(bar)
end

it 'produces the empty array for a missing key' do
it "produces the empty array for a missing key" do
assert_empty Paperclip::AttachmentRegistry.names_for(Class.new)
end
end

context '.each_definition' do
it 'calls the block with the class, attachment name, and options' do
context ".each_definition" do
it "calls the block with the class, attachment name, and options" do
foo = Class.new
expected_accumulations = [
[foo, :avatar, { yo: "greeting" }],
Expand All @@ -47,8 +47,8 @@
end
end

context '.definitions_for' do
it 'produces the attachment name and options' do
context ".definitions_for" do
it "produces the attachment name and options" do
expected_definitions = {
avatar: { yo: "greeting" },
greeter: { ciao: "greeting" }
Expand All @@ -70,7 +70,7 @@
assert_equal expected_definitions, definitions
end

it 'produces defintions for subclasses' do
it "produces defintions for subclasses" do
expected_definitions = { avatar: { yo: "greeting" } }
foo = Class.new
bar = Class.new(foo)
Expand All @@ -85,7 +85,7 @@
assert_equal expected_definitions, definitions
end

it 'produces defintions for subclasses but deep merging them' do
it "produces defintions for subclasses but deep merging them" do
foo_definitions = { avatar: { yo: "greeting" } }
bar_definitions = { avatar: { ciao: "greeting" } }
expected_definitions = {
Expand All @@ -112,7 +112,7 @@
assert_equal expected_definitions, definitions
end

it 'allows subclasses to override attachment defitions' do
it "allows subclasses to override attachment defitions" do
foo_definitions = { avatar: { yo: "greeting" } }
bar_definitions = { avatar: { yo: "hello" } }

Expand Down Expand Up @@ -141,8 +141,8 @@
end
end

context '.clear' do
it 'removes all of the existing attachment definitions' do
context ".clear" do
it "removes all of the existing attachment definitions" do
foo = Class.new
Paperclip::AttachmentRegistry.register(
foo,
Expand Down
Loading

0 comments on commit bff50d3

Please sign in to comment.