Commit 71727f49 by Jon Yurek

Give all spec names the correct tense

parent 244bb201
......@@ -7,7 +7,7 @@ describe 'Attachment Processing' do
rebuild_class
end
it 'process attachments given a valid assignment' 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
......@@ -17,7 +17,7 @@ describe 'Attachment Processing' do
attachment.assign(file)
end
it '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
......@@ -27,7 +27,7 @@ describe 'Attachment Processing' do
attachment.assign(file)
end
it '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
......@@ -37,7 +37,7 @@ describe 'Attachment Processing' do
attachment.assign(file)
end
it 'when validation :if clause returns false, allow what would be an invalid assignment' 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}
instance = Dummy.new
......@@ -49,7 +49,7 @@ describe 'Attachment Processing' do
end
context 'using validates_attachment' do
it 'process attachments given a valid assignment' 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"}
instance = Dummy.new
......@@ -59,7 +59,7 @@ describe 'Attachment Processing' do
attachment.assign(file)
end
it '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"}
instance = Dummy.new
......@@ -69,7 +69,7 @@ describe 'Attachment Processing' do
attachment.assign(file)
end
it '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"}
instance = Dummy.new
......
......@@ -6,14 +6,14 @@ describe 'Attachment Registry' do
end
context '.names_for' do
it 'include attachment names for the given class' 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 '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, {})
......@@ -22,13 +22,13 @@ describe 'Attachment Registry' do
assert_equal [:lover], Paperclip::AttachmentRegistry.names_for(bar)
end
it 'produce 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 'call the block with the class, attachment name, and options' do
it 'calls the block with the class, attachment name, and options' do
foo = Class.new
expected_accumulations = [
[foo, :avatar, { yo: 'greeting' }],
......@@ -48,7 +48,7 @@ describe 'Attachment Registry' do
end
context '.definitions_for' do
it 'produce the attachment name and options' do
it 'produces the attachment name and options' do
expected_definitions = {
avatar: { yo: 'greeting' },
greeter: { ciao: 'greeting' }
......@@ -62,7 +62,7 @@ describe 'Attachment Registry' do
assert_equal expected_definitions, definitions
end
it "produce defintions for subclasses" do
it "produces defintions for subclasses" do
expected_definitions = { avatar: { yo: 'greeting' } }
Foo = Class.new
Bar = Class.new(Foo)
......@@ -75,7 +75,7 @@ describe 'Attachment Registry' do
end
context '.clear' do
it 'remove all of the existing attachment definitions' do
it 'removes all of the existing attachment definitions' do
foo = Class.new
Paperclip::AttachmentRegistry.register(foo, :greeter, { ciao: 'greeting' })
......
require 'spec_helper'
describe Paperclip::ContentTypeDetector do
it 'give a sensible default when the name is empty' do
it 'gives a sensible default when the name is empty' do
assert_equal "application/octet-stream", Paperclip::ContentTypeDetector.new("").detect
end
it 'return the empty content type when the file is empty' do
it 'returns the empty content type when the file is empty' do
tempfile = Tempfile.new("empty")
assert_equal "inode/x-empty", Paperclip::ContentTypeDetector.new(tempfile.path).detect
tempfile.close
end
it 'return content type of file if it is an acceptable type' do
it 'returns content type of file if it is an acceptable type' do
MIME::Types.stubs(:type_for).returns([MIME::Type.new('application/mp4'), MIME::Type.new('video/mp4'), MIME::Type.new('audio/mp4')])
Paperclip.stubs(:run).returns("video/mp4")
@filename = "my_file.mp4"
assert_equal "video/mp4", Paperclip::ContentTypeDetector.new(@filename).detect
end
it 'find the right type in the list via the file command' do
it 'finds the right type in the list via the file command' do
@filename = "#{Dir.tmpdir}/something.hahalolnotreal"
File.open(@filename, "w+") do |file|
file.puts "This is a text file."
......@@ -28,12 +28,12 @@ describe Paperclip::ContentTypeDetector do
FileUtils.rm @filename
end
it 'return a sensible default if something is wrong, like the file is gone' do
it 'returns a sensible default if something is wrong, like the file is gone' do
@filename = "/path/to/nothing"
assert_equal "application/octet-stream", Paperclip::ContentTypeDetector.new(@filename).detect
end
it 'return a sensible default when the file command is missing' do
it 'returns a sensible default when the file command is missing' do
Paperclip.stubs(:run).raises(Cocaine::CommandLineError.new)
@filename = "/path/to/something"
assert_equal "application/octet-stream", Paperclip::ContentTypeDetector.new(@filename).detect
......
require 'spec_helper'
describe Paperclip::FileCommandContentTypeDetector do
it 'return a content type based on the content of the file' do
it 'returns a content type based on the content of the file' do
tempfile = Tempfile.new("something")
tempfile.write("This is a file.")
tempfile.rewind
......@@ -11,14 +11,14 @@ describe Paperclip::FileCommandContentTypeDetector do
tempfile.close
end
it 'return a sensible default when the file command is missing' do
it 'returns a sensible default when the file command is missing' do
Paperclip.stubs(:run).raises(Cocaine::CommandLineError.new)
@filename = "/path/to/something"
assert_equal "application/octet-stream",
Paperclip::FileCommandContentTypeDetector.new(@filename).detect
end
it 'return a sensible default on the odd chance that run returns nil' do
it 'returns a sensible default on the odd chance that run returns nil' do
Paperclip.stubs(:run).returns(nil)
assert_equal "application/octet-stream",
Paperclip::FileCommandContentTypeDetector.new("windows").detect
......
......@@ -2,12 +2,12 @@
require 'spec_helper'
describe Paperclip::FilenameCleaner do
it 'convert invalid characters to underscores' do
it 'converts invalid characters to underscores' do
cleaner = Paperclip::FilenameCleaner.new(/[aeiou]/)
expect(cleaner.call("baseball")).to eq "b_s_b_ll"
end
it 'not convert anything if the character regex is nil' do
it 'does not convert anything if the character regex is nil' do
cleaner = Paperclip::FilenameCleaner.new(nil)
expect(cleaner.call("baseball")).to eq "baseball"
end
......
require 'spec_helper'
describe Paperclip::GeometryDetector do
it 'identify an image and extract its dimensions' do
it 'identifies an image and extract its dimensions' do
Paperclip::GeometryParser.stubs(:new).with("434x66,").returns(stub(make: :correct))
file = fixture_file("5k.png")
factory = Paperclip::GeometryDetector.new(file)
......@@ -11,7 +11,7 @@ describe Paperclip::GeometryDetector do
expect(output).to eq :correct
end
it 'identify an image and extract its dimensions and orientation' do
it 'identifies an image and extract its dimensions and orientation' do
Paperclip::GeometryParser.stubs(:new).with("300x200,6").returns(stub(make: :correct))
file = fixture_file("rotated.jpg")
factory = Paperclip::GeometryDetector.new(file)
......
require 'spec_helper'
describe Paperclip::GeometryParser do
it 'identify an image and extract its dimensions with no orientation' do
it 'identifies an image and extract its dimensions with no orientation' do
Paperclip::Geometry.stubs(:new).with(
height: '73',
width: '434',
......@@ -15,7 +15,7 @@ describe Paperclip::GeometryParser do
assert_equal :correct, output
end
it 'identify an image and extract its dimensions with an empty orientation' do
it 'identifies an image and extract its dimensions with an empty orientation' do
Paperclip::Geometry.stubs(:new).with(
height: '73',
width: '434',
......@@ -29,7 +29,7 @@ describe Paperclip::GeometryParser do
assert_equal :correct, output
end
it 'identify an image and extract its dimensions and orientation' do
it 'identifies an image and extract its dimensions and orientation' do
Paperclip::Geometry.stubs(:new).with(
height: '200',
width: '300',
......@@ -43,7 +43,7 @@ describe Paperclip::GeometryParser do
assert_equal :correct, output
end
it 'identify an image and extract its dimensions and modifier' do
it 'identifies an image and extract its dimensions and modifier' do
Paperclip::Geometry.stubs(:new).with(
height: '64',
width: '64',
......@@ -57,7 +57,7 @@ describe Paperclip::GeometryParser do
assert_equal :correct, output
end
it 'identify an image and extract its dimensions, orientation, and modifier' do
it 'identifies an image and extract its dimensions, orientation, and modifier' do
Paperclip::Geometry.stubs(:new).with(
height: '50',
width: '100',
......
......@@ -2,54 +2,54 @@ require 'spec_helper'
describe Paperclip::Geometry do
context "Paperclip::Geometry" do
it "correctly report its given dimensions" do
it "correctly reports its given dimensions" do
assert @geo = Paperclip::Geometry.new(1024, 768)
assert_equal 1024, @geo.width
assert_equal 768, @geo.height
end
it "set height to 0 if height dimension is missing" do
it "sets height to 0 if height dimension is missing" do
assert @geo = Paperclip::Geometry.new(1024)
assert_equal 1024, @geo.width
assert_equal 0, @geo.height
end
it "set width to 0 if width dimension is missing" do
it "sets width to 0 if width dimension is missing" do
assert @geo = Paperclip::Geometry.new(nil, 768)
assert_equal 0, @geo.width
assert_equal 768, @geo.height
end
it "be generated from a WxH-formatted string" do
it "is generated from a WxH-formatted string" do
assert @geo = Paperclip::Geometry.parse("800x600")
assert_equal 800, @geo.width
assert_equal 600, @geo.height
end
it "be generated from a xH-formatted string" do
it "is generated from a xH-formatted string" do
assert @geo = Paperclip::Geometry.parse("x600")
assert_equal 0, @geo.width
assert_equal 600, @geo.height
end
it "be generated from a Wx-formatted string" do
it "is generated from a Wx-formatted string" do
assert @geo = Paperclip::Geometry.parse("800x")
assert_equal 800, @geo.width
assert_equal 0, @geo.height
end
it "be generated from a W-formatted string" do
it "is generated from a W-formatted string" do
assert @geo = Paperclip::Geometry.parse("800")
assert_equal 800, @geo.width
assert_equal 0, @geo.height
end
it "ensure the modifier is nil if not present" do
it "ensures the modifier is nil if not present" do
assert @geo = Paperclip::Geometry.parse("123x456")
assert_nil @geo.modifier
end
it "recognize an EXIF orientation and not rotate with auto_orient if not necessary" do
it "recognizes an EXIF orientation and not rotate with auto_orient if not necessary" do
geo = Paperclip::Geometry.new(width: 1024, height: 768, orientation: 1)
assert geo
assert_equal 1024, geo.width
......@@ -61,7 +61,7 @@ describe Paperclip::Geometry do
assert_equal 768, geo.height
end
it "recognize an EXIF orientation and rotate with auto_orient if necessary" do
it "recognizes an EXIF orientation and rotate with auto_orient if necessary" do
geo = Paperclip::Geometry.new(width: 1024, height: 768, orientation: 6)
assert geo
assert_equal 1024, geo.width
......@@ -73,7 +73,7 @@ describe Paperclip::Geometry do
assert_equal 1024, geo.height
end
it "treat x and X the same in geometries" do
it "treats x and X the same in geometries" do
@lower = Paperclip::Geometry.parse("123x456")
@upper = Paperclip::Geometry.parse("123X456")
assert_equal 123, @lower.width
......@@ -83,46 +83,46 @@ describe Paperclip::Geometry do
end
['>', '<', '#', '@', '%', '^', '!', nil].each do |mod|
it "ensure the modifier #{description} is preserved" do
it "ensures the modifier #{description} is preserved" do
assert @geo = Paperclip::Geometry.parse("123x456#{mod}")
assert_equal mod, @geo.modifier
assert_equal "123x456#{mod}", @geo.to_s
end
it "ensure the modifier #{description} is preserved with no height" do
it "ensures the modifier #{description} is preserved with no height" do
assert @geo = Paperclip::Geometry.parse("123x#{mod}")
assert_equal mod, @geo.modifier
assert_equal "123#{mod}", @geo.to_s
end
end
it "make sure the modifier gets passed during transformation_to" do
it "makes sure the modifier gets passed during transformation_to" do
assert @src = Paperclip::Geometry.parse("123x456")
assert @dst = Paperclip::Geometry.parse("123x456>")
assert_equal ["123x456>", nil], @src.transformation_to(@dst)
end
it "generate correct ImageMagick formatting string for W-formatted string" do
it "generates correct ImageMagick formatting string for W-formatted string" do
assert @geo = Paperclip::Geometry.parse("800")
assert_equal "800", @geo.to_s
end
it "generate correct ImageMagick formatting string for Wx-formatted string" do
it "generates correct ImageMagick formatting string for Wx-formatted string" do
assert @geo = Paperclip::Geometry.parse("800x")
assert_equal "800", @geo.to_s
end
it "generate correct ImageMagick formatting string for xH-formatted string" do
it "generates correct ImageMagick formatting string for xH-formatted string" do
assert @geo = Paperclip::Geometry.parse("x600")
assert_equal "x600", @geo.to_s
end
it "generate correct ImageMagick formatting string for WxH-formatted string" do
it "generates correct ImageMagick formatting string for WxH-formatted string" do
assert @geo = Paperclip::Geometry.parse("800x600")
assert_equal "800x600", @geo.to_s
end
it "be generated from a file" do
it "is generated from a file" do
file = fixture_file("5k.png")
file = File.new(file, 'rb')
assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) }
......@@ -130,14 +130,14 @@ describe Paperclip::Geometry do
assert_equal 434, @geo.width
end
it "be generated from a file path" do
it "is generated from a file path" do
file = fixture_file("5k.png")
assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) }
assert_equal 66, @geo.height
assert_equal 434, @geo.width
end
it 'calculate an EXIF-rotated image dimensions from a path' do
it 'calculates an EXIF-rotated image dimensions from a path' do
file = fixture_file("rotated.jpg")
assert_nothing_raised{ @geo = Paperclip::Geometry.from_file(file) }
@geo.auto_orient
......@@ -145,28 +145,28 @@ describe Paperclip::Geometry do
assert_equal 200, @geo.width
end
it "not generate from a bad file" do
it "does not generate from a bad file" do
file = "/home/This File Does Not Exist.omg"
expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
end
it "not generate from a blank filename" do
it "does not generate from a blank filename" do
file = ""
expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
end
it "not generate from a nil file" do
it "does not generate from a nil file" do
file = nil
expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
end
it "not generate from a file with no path" do
it "does not generate from a file with no path" do
file = mock("file", path: "")
file.stubs(:respond_to?).with(:path).returns(true)
expect { @geo = Paperclip::Geometry.from_file(file) }.to raise_error(Paperclip::Errors::NotIdentifiedByImageMagickError)
end
it "let us know when a command isn't found versus a processing error" do
it "lets us know when a command isn't found versus a processing error" do
old_path = ENV['PATH']
begin
ENV['PATH'] = ''
......@@ -187,27 +187,27 @@ describe Paperclip::Geometry do
@geo = Paperclip::Geometry.new(args[1], args[2])
end
it "#{args[3] ? "" : "not"} be vertical" do
it "is #{args[3]s ? "" : "not"} vertical" do
assert_equal args[3], @geo.vertical?
end
it "#{args[4] ? "" : "not"} be horizontal" do
it "is #{args[4] ? "" : "not"} horizontal" do
assert_equal args[4], @geo.horizontal?
end
it "#{args[5] ? "" : "not"} be square" do
it "is #{args[5] ? "" : "not"} square" do
assert_equal args[5], @geo.square?
end
it "report that #{args[6]} is the larger dimension" do
it "reports that #{args[6]} is the larger dimension" do
assert_equal args[6], @geo.larger
end
it "report that #{args[7]} is the smaller dimension" do
it "reports that #{args[7]} is the smaller dimension" do
assert_equal args[7], @geo.smaller
end
it "have an aspect ratio of #{args[8]}" do
it "has an aspect ratio of #{args[8]}" do
expect(@geo.aspect).to be_within(0.0001).of(args[8])
end
end
......@@ -223,11 +223,11 @@ describe Paperclip::Geometry do
@scale, @crop = @geo.transformation_to @dst, true
end
it "be able to return the correct scaling transformation geometry #{args[2]}" do
it "is able to return the correct scaling transformation geometry #{args[2]}" do
assert_equal args[2], @scale
end
it "be able to return the correct crop transformation geometry #{args[3]}" do
it "is able to return the correct crop transformation geometry #{args[3]}" do
assert_equal args[3], @crop
end
end
......@@ -242,10 +242,10 @@ describe Paperclip::Geometry do
@source = Paperclip::Geometry.parse original_size
@new_geometry = @source.resize_to size
end
it "have #{dimensions.first} width" do
it "has #{dimensions.first} width" do
assert_equal dimensions.first, @new_geometry.width
end
it "have #{dimensions.last} height" do
it "has #{dimensions.last} height" do
assert_equal dimensions.last, @new_geometry.height
end
end
......
......@@ -2,43 +2,43 @@ require 'spec_helper'
describe Paperclip::HasAttachedFile do
context '#define_on' do
it 'define a setter on the class object' do
it 'defines a setter on the class object' do
assert_adding_attachment('avatar').defines_method('avatar=')
end
it 'define a getter on the class object' do
it 'defines a getter on the class object' do
assert_adding_attachment('avatar').defines_method('avatar')
end
it 'define a query on the class object' do
it 'defines a query on the class object' do
assert_adding_attachment('avatar').defines_method('avatar?')
end
it 'define a method on the class to get all of its attachments' do
it 'defines a method on the class to get all of its attachments' do
assert_adding_attachment('avatar').defines_class_method('attachment_definitions')
end
it 'flush errors as part of validations' do
it 'flushes errors as part of validations' do
assert_adding_attachment('avatar').defines_validation
end
it 'register the attachment with Paperclip::AttachmentRegistry' do
it 'registers the attachment with Paperclip::AttachmentRegistry' do
assert_adding_attachment('avatar').registers_attachment
end
it 'define an after_save callback' do
it 'defines an after_save callback' do
assert_adding_attachment('avatar').defines_callback('after_save')
end
it 'define a before_destroy callback' do
it 'defines a before_destroy callback' do
assert_adding_attachment('avatar').defines_callback('before_destroy')
end
it 'define an after_commit callback' do
it 'defines an after_commit callback' do
assert_adding_attachment('avatar').defines_callback('after_commit')
end
it 'define the Paperclip-specific callbacks' do
it 'defines the Paperclip-specific callbacks' do
assert_adding_attachment('avatar').defines_callback('define_paperclip_callbacks')
end
end
......
......@@ -16,13 +16,13 @@ describe Paperclip::AbstractAdapter do
Paperclip.stubs(:run).returns("image/png\n")
end
it "return the content type without newline" do
it "returns the content type without newline" do
assert_equal "image/png", @adapter.content_type
end
end
context "nil?" do
it "return false" do
it "returns false" do
assert !TestAdapter.new.nil?
end
end
......@@ -34,7 +34,7 @@ describe Paperclip::AbstractAdapter do
end
[:binmode, :binmode?, :close, :close!, :closed?, :eof?, :path, :rewind, :unlink].each do |method|
it "delegate #{method} to @tempfile" do
it "delegates #{method} to @tempfile" do
@adapter.tempfile.stubs(method)
@adapter.public_send(method)
assert_received @adapter.tempfile, method
......@@ -42,18 +42,18 @@ describe Paperclip::AbstractAdapter do
end
end
it 'get rid of slashes and colons in filenames' do
it 'gets rid of slashes and colons in filenames' do
@adapter = TestAdapter.new
@adapter.original_filename = "awesome/file:name.png"
assert_equal "awesome_file_name.png", @adapter.original_filename
end
it 'be an assignment' do
it 'is an assignment' do
assert TestAdapter.new.assignment?
end
it 'not be nil' do
it 'is not nil' do
assert !TestAdapter.new.nil?
end
end
......@@ -21,32 +21,32 @@ describe Paperclip::AttachmentAdapter do
@subject.close
end
it "get the right filename" do
it "gets the right filename" do
assert_equal "5k.png", @subject.original_filename
end
it "force binmode on tempfile" do
it "forces binmode on tempfile" do
assert @subject.instance_variable_get("@tempfile").binmode?
end
it "get the content type" do
it "gets the content type" do
assert_equal "image/png", @subject.content_type
end
it "get the file's size" do
it "gets the file's size" do
assert_equal 4456, @subject.size
end
it "return false for a call to nil?" do
it "returns false for a call to nil?" do
assert ! @subject.nil?
end
it "generate a MD5 hash of the contents" do
it "generates a MD5 hash of the contents" do
expected = Digest::MD5.file(@file.path).to_s
assert_equal expected, @subject.fingerprint
end
it "read the contents of the file" do
it "reads the contents of the file" do
expected = @file.read
actual = @subject.read
assert expected.length > 0
......@@ -72,11 +72,11 @@ describe Paperclip::AttachmentAdapter do
@subject.close
end
it "not generate paths that include restricted characters" do
it "does not generate paths that include restricted characters" do
expect(@subject.path).to_not match(/:/)
end
it "not generate filenames that include restricted characters" do
it "does not generate filenames that include restricted characters" do
assert_equal 'image_restricted.gif', @subject.original_filename
end
end
......@@ -101,32 +101,32 @@ describe Paperclip::AttachmentAdapter do
@subject.close
end
it "get the original filename" do
it "gets the original filename" do
assert_equal "5k.png", @subject.original_filename
end
it "force binmode on tempfile" do
it "forces binmode on tempfile" do
assert @subject.instance_variable_get("@tempfile").binmode?
end
it "get the content type" do
it "gets the content type" do
assert_equal "image/png", @subject.content_type
end
it "get the thumbnail's file size" do
it "gets the thumbnail's file size" do
assert_equal @thumb.size, @subject.size
end
it "return false for a call to nil?" do
it "returns false for a call to nil?" do
assert ! @subject.nil?
end
it "generate a MD5 hash of the contents" do
it "generates a MD5 hash of the contents" do
expected = Digest::MD5.file(@thumb.path).to_s
assert_equal expected, @subject.fingerprint
end
it "read the contents of the thumbnail" do
it "reads the contents of the thumbnail" do
@thumb.rewind
expected = @thumb.read
actual = @subject.read
......
......@@ -7,7 +7,7 @@ describe Paperclip::DataUriAdapter do
end
end
it 'allow a missing mime-type' do
it 'allows a missing mime-type' do
adapter = Paperclip.io_adapters.for("data:;base64,#{original_base64_content}")
assert_equal Paperclip::DataUriAdapter, adapter.class
end
......@@ -22,46 +22,46 @@ describe Paperclip::DataUriAdapter do
assert_equal "data.png", @subject.original_filename
end
it "return a content type" do
it "returns a content type" do
assert_equal "image/png", @subject.content_type
end
it "return the size of the data" do
it "returns the size of the data" do
assert_equal 4456, @subject.size
end
it "generate a correct MD5 hash of the contents" do
it "generates a correct MD5 hash of the contents" do
assert_equal(
Digest::MD5.hexdigest(Base64.decode64(original_base64_content)),
@subject.fingerprint
)
end
it "generate correct fingerprint after read" do
it "generates correct fingerprint after read" do
fingerprint = Digest::MD5.hexdigest(@subject.read)
assert_equal fingerprint, @subject.fingerprint
end
it "generate same fingerprint" do
it "generates same fingerprint" do
assert_equal @subject.fingerprint, @subject.fingerprint
end
it 'accept a content_type' do
it 'accepts a content_type' do
@subject.content_type = 'image/png'
assert_equal 'image/png', @subject.content_type
end
it 'accept an original_filename' do
it 'accepts an original_filename' do
@subject.original_filename = 'image.png'
assert_equal 'image.png', @subject.original_filename
end
it "not generate filenames that include restricted characters" do
it "does not generate filenames that include restricted characters" do
@subject.original_filename = 'image:restricted.png'
assert_equal 'image_restricted.png', @subject.original_filename
end
it "not generate paths that include restricted characters" do
it "does not generate paths that include restricted characters" do
@subject.original_filename = 'image:restricted.png'
expect(@subject.path).to_not match(/:/)
end
......
......@@ -6,11 +6,11 @@ describe Paperclip::EmptyStringAdapter do
@subject = Paperclip.io_adapters.for('')
end
it "return false for a call to nil?" do
it "returns false for a call to nil?" do
assert !@subject.nil?
end
it 'return false for a call to assignment?' do
it 'returns false for a call to assignment?' do
assert !@subject.assignment?
end
end
......
......@@ -18,36 +18,36 @@ describe Paperclip::FileAdapter do
@subject = Paperclip.io_adapters.for(@file)
end
it "get the right filename" do
it "gets the right filename" do
assert_equal "5k.png", @subject.original_filename
end
it "force binmode on tempfile" do
it "forces binmode on tempfile" do
assert @subject.instance_variable_get("@tempfile").binmode?
end
it "get the content type" do
it "gets the content type" do
assert_equal "image/png", @subject.content_type
end
it "return content type as a string" do
it "returns content type as a string" do
expect(@subject.content_type).to be_a String
end
it "get the file's size" do
it "gets the file's size" do
assert_equal 4456, @subject.size
end
it "return false for a call to nil?" do
it "returns false for a call to nil?" do
assert ! @subject.nil?
end
it "generate a MD5 hash of the contents" do
it "generates a MD5 hash of the contents" do
expected = Digest::MD5.file(@file.path).to_s
assert_equal expected, @subject.fingerprint
end
it "read the contents of the file" do
it "reads the contents of the file" do
expected = @file.read
assert expected.length > 0
assert_equal expected, @subject.read
......@@ -60,11 +60,11 @@ describe Paperclip::FileAdapter do
@subject = Paperclip.io_adapters.for(@file)
end
it "prefer officially registered mime type" do
it "prefers officially registered mime type" do
assert_equal "image/png", @subject.content_type
end
it "return content type as a string" do
it "returns content type as a string" do
expect(@subject.content_type).to be_a String
end
end
......@@ -76,7 +76,7 @@ describe Paperclip::FileAdapter do
@subject = Paperclip.io_adapters.for(@file)
end
it "return content type without newline character" do
it "returns content type without newline character" do
assert_equal "application/vnd.ms-office", @subject.content_type
end
end
......@@ -96,11 +96,11 @@ describe Paperclip::FileAdapter do
@subject.close
end
it "not generate filenames that include restricted characters" do
it "does not generate filenames that include restricted characters" do
assert_equal 'image_restricted.gif', @subject.original_filename
end
it "not generate paths that include restricted characters" do
it "does not generate paths that include restricted characters" do
expect(@subject.path).to_not match(/:/)
end
end
......@@ -116,7 +116,7 @@ describe Paperclip::FileAdapter do
@subject.close
end
it "provide correct mime-type" do
it "provides correct mime-type" do
assert_match %r{.*/x-empty}, @subject.content_type
end
end
......
......@@ -14,45 +14,45 @@ describe Paperclip::HttpUrlProxyAdapter do
@subject.close
end
it "return a file name" do
it "returns a file name" do
assert_equal "thoughtbot-logo.png", @subject.original_filename
end
it 'close open handle after reading' do
it 'closes open handle after reading' do
assert_equal true, @open_return.closed?
end
it "return a content type" do
it "returns a content type" do
assert_equal "image/png", @subject.content_type
end
it "return the size of the data" do
it "returns the size of the data" do
assert_equal @open_return.size, @subject.size
end
it "generate an MD5 hash of the contents" do
it "generates an MD5 hash of the contents" do
assert_equal Digest::MD5.hexdigest("xxx"), @subject.fingerprint
end
it "generate correct fingerprint after read" do
it "generates correct fingerprint after read" do
fingerprint = Digest::MD5.hexdigest(@subject.read)
assert_equal fingerprint, @subject.fingerprint
end
it "generate same fingerprint" do
it "generates same fingerprint" do
assert_equal @subject.fingerprint, @subject.fingerprint
end
it "return the data contained in the StringIO" do
it "returns the data contained in the StringIO" do
assert_equal "xxx", @subject.read
end
it 'accept a content_type' do
it 'accepts a content_type' do
@subject.content_type = 'image/png'
assert_equal 'image/png', @subject.content_type
end
it 'accept an original_filename' do
it 'accepts an original_filename' do
@subject.original_filename = 'image.png'
assert_equal 'image.png', @subject.original_filename
end
......@@ -69,7 +69,7 @@ describe Paperclip::HttpUrlProxyAdapter do
@subject.close
end
it "return a file name" do
it "returns a file name" do
assert_equal "paperclip", @subject.original_filename
end
end
......@@ -89,11 +89,11 @@ describe Paperclip::HttpUrlProxyAdapter do
end
end
it "not generate filenames that include restricted characters" do
it "does not generate filenames that include restricted characters" do
assert_equal "paper_clip.jpg", @subject.original_filename
end
it "not generate paths that include restricted characters" do
it "does not generate paths that include restricted characters" do
expect(@subject.path).to_not match(/:/)
end
end
......
require 'spec_helper'
describe Paperclip::IdentityAdapter do
it "respond to #new by returning the argument" do
it "responds to #new by returning the argument" do
adapter = Paperclip::IdentityAdapter.new
assert_equal :target, adapter.new(:target)
end
......
......@@ -6,19 +6,19 @@ describe Paperclip::NilAdapter do
@subject = Paperclip.io_adapters.for(nil)
end
it "get the right filename" do
it "gets the right filename" do
assert_equal "", @subject.original_filename
end
it "get the content type" do
it "gets the content type" do
assert_equal "", @subject.content_type
end
it "get the file's size" do
it "gets the file's size" do
assert_equal 0, @subject.size
end
it "return true for a call to nil?" do
it "returns true for a call to nil?" do
assert @subject.nil?
end
end
......
......@@ -10,7 +10,7 @@ describe Paperclip::AttachmentRegistry do
@subject.register(AdapterTest){|t| Symbol === t }
end
it "return the class registered for the adapted type" do
it "returns the class registered for the adapted type" do
assert_equal AdapterTest, @subject.for(:target).class
end
end
......@@ -24,11 +24,11 @@ describe Paperclip::AttachmentRegistry do
@subject.register(AdapterTest){|t| Symbol === t }
end
it "return true when the class of this adapter has been registered" do
it "returns true when the class of this adapter has been registered" do
assert @subject.registered?(AdapterTest.new(:target))
end
it "return false when the adapter has not been registered" do
it "returns false when the adapter has not been registered" do
assert ! @subject.registered?(Object)
end
end
......
......@@ -8,51 +8,51 @@ describe Paperclip::StringioAdapter do
@subject = Paperclip.io_adapters.for(@stringio)
end
it "return a file name" do
it "returns a file name" do
assert_equal "data.txt", @subject.original_filename
end
it "return a content type" do
it "returns a content type" do
assert_equal "text/plain", @subject.content_type
end
it "return the size of the data" do
it "returns the size of the data" do
assert_equal 6, @subject.size
end
it "generate an MD5 hash of the contents" do
it "generates an MD5 hash of the contents" do
assert_equal Digest::MD5.hexdigest(@contents), @subject.fingerprint
end
it "generate correct fingerprint after read" do
it "generates correct fingerprint after read" do
fingerprint = Digest::MD5.hexdigest(@subject.read)
assert_equal fingerprint, @subject.fingerprint
end
it "generate same fingerprint" do
it "generates same fingerprint" do
assert_equal @subject.fingerprint, @subject.fingerprint
end
it "return the data contained in the StringIO" do
it "returns the data contained in the StringIO" do
assert_equal "abc123", @subject.read
end
it 'accept a content_type' do
it 'accepts a content_type' do
@subject.content_type = 'image/png'
assert_equal 'image/png', @subject.content_type
end
it 'accept an original_filename' do
it 'accepts an original_filename' do
@subject.original_filename = 'image.png'
assert_equal 'image.png', @subject.original_filename
end
it "not generate filenames that include restricted characters" do
it "does not generate filenames that include restricted characters" do
@subject.original_filename = 'image:restricted.png'
assert_equal 'image_restricted.png', @subject.original_filename
end
it "not generate paths that include restricted characters" do
it "does not generate paths that include restricted characters" do
@subject.original_filename = 'image:restricted.png'
expect(@subject.path).to_not match(/:/)
end
......
......@@ -20,32 +20,32 @@ describe Paperclip::UploadedFileAdapter do
@subject = Paperclip.io_adapters.for(@file)
end
it "get the right filename" do
it "gets the right filename" do
assert_equal "5k.png", @subject.original_filename
end
it "force binmode on tempfile" do
it "forces binmode on tempfile" do
assert @subject.instance_variable_get("@tempfile").binmode?
end
it "get the content type" do
it "gets the content type" do
assert_equal "image/x-png-by-browser", @subject.content_type
end
it "get the file's size" do
it "gets the file's size" do
assert_equal 4456, @subject.size
end
it "return false for a call to nil?" do
it "returns false for a call to nil?" do
assert ! @subject.nil?
end
it "generate a MD5 hash of the contents" do
it "generates a MD5 hash of the contents" do
expected = Digest::MD5.file(@file.tempfile.path).to_s
assert_equal expected, @subject.fingerprint
end
it "read the contents of the file" do
it "reads the contents of the file" do
expected = @file.tempfile.read
assert expected.length > 0
assert_equal expected, @subject.read
......@@ -66,11 +66,11 @@ describe Paperclip::UploadedFileAdapter do
@subject = Paperclip.io_adapters.for(@file)
end
it "not generate paths that include restricted characters" do
it "does not generate paths that include restricted characters" do
expect(@subject.path).to_not match(/:/)
end
it "not generate filenames that include restricted characters" do
it "does not generate filenames that include restricted characters" do
assert_equal 'image_restricted.gif', @subject.original_filename
end
end
......@@ -89,32 +89,32 @@ describe Paperclip::UploadedFileAdapter do
@subject = Paperclip.io_adapters.for(@file)
end
it "get the right filename" do
it "gets the right filename" do
assert_equal "5k.png", @subject.original_filename
end
it "force binmode on tempfile" do
it "forces binmode on tempfile" do
assert @subject.instance_variable_get("@tempfile").binmode?
end
it "get the content type" do
it "gets the content type" do
assert_equal "image/x-png-by-browser", @subject.content_type
end
it "get the file's size" do
it "gets the file's size" do
assert_equal 4456, @subject.size
end
it "return false for a call to nil?" do
it "returns false for a call to nil?" do
assert ! @subject.nil?
end
it "generate a MD5 hash of the contents" do
it "generates a MD5 hash of the contents" do
expected = Digest::MD5.file(@file.path).to_s
assert_equal expected, @subject.fingerprint
end
it "read the contents of the file" do
it "reads the contents of the file" do
expected_file = File.new(@file.path)
expected_file.binmode
expected = expected_file.read
......@@ -137,7 +137,7 @@ describe Paperclip::UploadedFileAdapter do
@subject = Paperclip.io_adapters.for(@file)
end
it "get the content type" do
it "gets the content type" do
assert_equal "image/png", @subject.content_type
end
end
......
......@@ -10,45 +10,45 @@ describe Paperclip::UriAdapter do
@subject = Paperclip.io_adapters.for(@uri)
end
it "return a file name" do
it "returns a file name" do
assert_equal "thoughtbot-logo.png", @subject.original_filename
end
it 'close open handle after reading' do
it 'closes open handle after reading' do
assert_equal true, @open_return.closed?
end
it "return a content type" do
it "returns a content type" do
assert_equal "image/png", @subject.content_type
end
it "return the size of the data" do
it "returns the size of the data" do
assert_equal @open_return.size, @subject.size
end
it "generate an MD5 hash of the contents" do
it "generates an MD5 hash of the contents" do
assert_equal Digest::MD5.hexdigest("xxx"), @subject.fingerprint
end
it "generate correct fingerprint after read" do
it "generates correct fingerprint after read" do
fingerprint = Digest::MD5.hexdigest(@subject.read)
assert_equal fingerprint, @subject.fingerprint
end
it "generate same fingerprint" do
it "generates same fingerprint" do
assert_equal @subject.fingerprint, @subject.fingerprint
end
it "return the data contained in the StringIO" do
it "returns the data contained in the StringIO" do
assert_equal "xxx", @subject.read
end
it 'accept a content_type' do
it 'accepts a content_type' do
@subject.content_type = 'image/png'
assert_equal 'image/png', @subject.content_type
end
it 'accept an orgiginal_filename' do
it 'accepts an orgiginal_filename' do
@subject.original_filename = 'image.png'
assert_equal 'image.png', @subject.original_filename
end
......@@ -62,11 +62,11 @@ describe Paperclip::UriAdapter do
@subject = Paperclip.io_adapters.for(@uri)
end
it "return a file name" do
it "returns a file name" do
assert_equal "index.html", @subject.original_filename
end
it "return a content type" do
it "returns a content type" do
assert_equal "text/html", @subject.content_type
end
end
......@@ -78,7 +78,7 @@ describe Paperclip::UriAdapter do
@subject = Paperclip.io_adapters.for(@uri)
end
it "return a file name" do
it "returns a file name" do
assert_equal "paperclip", @subject.original_filename
end
end
......@@ -90,11 +90,11 @@ describe Paperclip::UriAdapter do
@subject = Paperclip.io_adapters.for(@uri)
end
it "not generate filenames that include restricted characters" do
it "does not generate filenames that include restricted characters" do
assert_equal "paper_clip.jpg", @subject.original_filename
end
it "not generate paths that include restricted characters" do
it "does not generate paths that include restricted characters" do
expect(@subject.path).to_not match(/:/)
end
end
......
......@@ -71,13 +71,13 @@ describe Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher do
end
end
it "run the validation if the control is true" do
it "runs the validation if the control is true" do
dummy = Dummy.new
dummy.go = true
expect(matcher).to accept(dummy)
end
it "not run the validation if the control is false" do
it "does not run the validation if the control is false" do
dummy = Dummy.new
dummy.go = false
expect(matcher).to_not accept(dummy)
......
require 'spec_helper'
describe Paperclip::MediaTypeSpoofDetector do
it 'reject a file that is named .html and identifies as PNG' do
it 'rejects a file that is named .html and identifies as PNG' do
file = File.open(fixture_file("5k.png"))
assert Paperclip::MediaTypeSpoofDetector.using(file, "5k.html").spoofed?
end
it 'not reject a file that is named .jpg and identifies as PNG' do
it 'does not reject a file that is named .jpg and identifies as PNG' do
file = File.open(fixture_file("5k.png"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "5k.jpg").spoofed?
end
it 'not reject a file that is named .html and identifies as HTML' do
it 'does not reject a file that is named .html and identifies as HTML' do
file = File.open(fixture_file("empty.html"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "empty.html").spoofed?
end
it 'not reject a file that does not have a name' do
it 'does not reject a file that does not have a name' do
file = File.open(fixture_file("empty.html"))
assert ! Paperclip::MediaTypeSpoofDetector.using(file, "").spoofed?
end
it 'not reject when the supplied file is an IOAdapter' do
it 'does not reject when the supplied file is an IOAdapter' do
adapter = Paperclip.io_adapters.for(File.new(fixture_file("5k.png")))
assert ! Paperclip::MediaTypeSpoofDetector.using(adapter, adapter.original_filename).spoofed?
end
it 'not reject when the extension => content_type is in :content_type_mappings' do
it 'does not reject when the extension => content_type is in :content_type_mappings' do
begin
Paperclip.options[:content_type_mappings] = { pem: "text/plain" }
file = Tempfile.open(["test", ".PEM"])
......
......@@ -7,7 +7,7 @@ describe 'Metaclasses' do
reset_class("Dummy")
end
it "be able to use Paperclip like a normal class" do
it "is able to use Paperclip like a normal class" do
@dummy = Dummy.new
assert_nothing_raised do
......@@ -15,7 +15,7 @@ describe 'Metaclasses' do
end
end
it "work like any other instance" do
it "works like any other instance" do
@dummy = Dummy.new
rebuild_meta_class_of(@dummy)
......
......@@ -9,7 +9,7 @@ describe 'Missing Attachment Styles' do
File.unlink(Paperclip.registered_attachments_styles_path) rescue nil
end
it "enable to get and set path to registered styles file" do
it "enables to get and set path to registered styles file" do
assert_equal ROOT.join('tmp/public/system/paperclip_attachments.yml').to_s, Paperclip.registered_attachments_styles_path
Paperclip.registered_attachments_styles_path = '/tmp/config/paperclip_attachments.yml'
assert_equal '/tmp/config/paperclip_attachments.yml', Paperclip.registered_attachments_styles_path
......@@ -17,28 +17,28 @@ describe 'Missing Attachment Styles' do
assert_equal ROOT.join('tmp/public/system/paperclip_attachments.yml').to_s, Paperclip.registered_attachments_styles_path
end
it "be able to get current attachment styles" do
it "is able to get current attachment styles" do
assert_equal Hash.new, Paperclip.send(:current_attachments_styles)
rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
expected_hash = { Dummy: {avatar: [:big, :croppable]}}
assert_equal expected_hash, Paperclip.send(:current_attachments_styles)
end
it "be able to save current attachment styles for further comparison" do
it "is able to save current attachment styles for further comparison" do
rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles!
expected_hash = { Dummy: {avatar: [:big, :croppable]}}
assert_equal expected_hash, YAML.load_file(Paperclip.registered_attachments_styles_path)
end
it "be able to read registered attachment styles from file" do
it "is able to read registered attachment styles from file" do
rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles!
expected_hash = { Dummy: {avatar: [:big, :croppable]}}
assert_equal expected_hash, Paperclip.send(:get_registered_attachments_styles)
end
it "be able to calculate differences between registered styles and current styles" do
it "is able to calculate differences between registered styles and current styles" do
rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles!
rebuild_model styles: {thumb: 'x100', export: 'x400>', croppable: '600x600>', big: '1000x1000>'}
......@@ -60,7 +60,7 @@ describe 'Missing Attachment Styles' do
assert_equal Hash.new, Paperclip.missing_attachments_styles
end
it "be able to calculate differences when a new attachment is added to a model" do
it "is able to calculate differences when a new attachment is added to a model" do
rebuild_model styles: {croppable: '600x600>', big: '1000x1000>'}
Paperclip.save_current_attachments_styles!
......@@ -77,7 +77,7 @@ describe 'Missing Attachment Styles' do
end
# It's impossible to build styles hash without loading from database whole bunch of records
it "skip lambda-styles" do
it "skips lambda-styles" do
rebuild_model styles: lambda{ |attachment| attachment.instance.other == 'a' ? {thumb: "50x50#"} : {large: "400x400"} }
assert_equal Hash.new, Paperclip.send(:current_attachments_styles)
end
......
......@@ -13,17 +13,17 @@ describe Paperclip do
Cocaine::CommandLine.path = @original_command_line_path
end
it "run the command with Cocaine" do
it "runs the command with Cocaine" do
Paperclip.run("convert", "stuff")
end
it "save Cocaine::CommandLine.path that set before" do
it "saves Cocaine::CommandLine.path that set before" do
Cocaine::CommandLine.path = "/opt/my_app/bin"
Paperclip.run("convert", "stuff")
assert_equal [Cocaine::CommandLine.path].flatten.include?("/opt/my_app/bin"), true
end
it "not duplicate Cocaine::CommandLine.path on multiple runs" do
it "does not duplicate Cocaine::CommandLine.path on multiple runs" do
Cocaine::CommandLine.expects(:new).with("convert", "more_stuff", {}).returns(stub(:run))
Cocaine::CommandLine.path = nil
Paperclip.options[:command_path] = "/opt/my_app/bin"
......@@ -33,7 +33,7 @@ describe Paperclip do
end
end
it 'not raise errors when doing a lot of running' do
it 'does not raise errors when doing a lot of running' do
Paperclip.options[:command_path] = ["/usr/local/bin"] * 1024
Cocaine::CommandLine.path = "/something/else"
100.times do |x|
......@@ -52,14 +52,14 @@ describe Paperclip do
Paperclip.logger = ActiveRecord::Base.logger
end
it "not raise an error when log is called" do
it "does not raise an error when log is called" do
silence_stream(STDOUT) do
Paperclip.log('something')
end
end
end
context "Calling Paperclip.run with a logger" do
it "pass the defined logger if :log_command is set" do
it "passes the defined logger if :log_command is set" do
Paperclip.options[:log_command] = true
Cocaine::CommandLine.expects(:new).with("convert", "stuff", logger: Paperclip.logger).returns(stub(:run))
Paperclip.run("convert", "stuff")
......@@ -77,7 +77,7 @@ describe Paperclip do
after { @file.close }
it "yield every instance of a model that has an attachment" do
it "yields every instance of a model that has an attachment" do
actual = []
Paperclip.each_instance_with_attachment("Dummy", "avatar") do |instance|
actual << instance
......@@ -86,20 +86,20 @@ describe Paperclip do
end
end
it "raise when sent #processor and the name of a class that doesn't exist" do
it "raises when sent #processor and the name of a class that doesn't exist" do
assert_raises(LoadError){ Paperclip.processor(:boogey_man) }
end
it "return a class when sent #processor and the name of a class under Paperclip" do
it "returns a class when sent #processor and the name of a class under Paperclip" do
assert_equal ::Paperclip::Thumbnail, Paperclip.processor(:thumbnail)
end
it "get a class from a namespaced class name" do
it "gets a class from a namespaced class name" do
class ::One; class Two; end; end
assert_equal ::One::Two, Paperclip.class_for("One::Two")
end
it "raise when class doesn't exist in specified namespace" do
it "raises when class doesn't exist in specified namespace" do
class ::Three; end
class ::Four; end
assert_raises NameError do
......@@ -115,7 +115,7 @@ describe Paperclip do
after { @file.close }
it "not error when trying to also create a 'blah' attachment" do
it "does not error when trying to also create a 'blah' attachment" do
assert_nothing_raised do
Dummy.class_eval do
has_attached_file :blah
......@@ -132,7 +132,7 @@ describe Paperclip do
@dummy = Dummy.new
end
it "not assign the avatar on mass-set" do
it "does not assign the avatar on mass-set" do
@dummy.attributes = { other: "I'm set!",
avatar: @file }
......@@ -140,7 +140,7 @@ describe Paperclip do
assert ! @dummy.avatar?
end
it "still allow assigment on normal set" do
it "allows assigment on normal set" do
@dummy.other = "I'm set!"
@dummy.avatar = @file
......@@ -155,7 +155,7 @@ describe Paperclip do
class ::SubDummy < Dummy; end
end
it "be able to use the attachment from the subclass" do
it "is able to use the attachment from the subclass" do
assert_nothing_raised do
@subdummy = SubDummy.create(avatar: @file)
end
......@@ -167,11 +167,11 @@ describe Paperclip do
end
end
it "have an avatar getter method" do
it "has an avatar getter method" do
assert Dummy.new.respond_to?(:avatar)
end
it "have an avatar setter method" do
it "has an avatar setter method" do
assert Dummy.new.respond_to?(:avatar=)
end
......@@ -181,12 +181,12 @@ describe Paperclip do
@dummy.avatar = @file
end
it "be valid" do
it "is valid" do
assert @dummy.valid?
end
end
it "not have Attachment in the ActiveRecord::Base namespace" do
it "does not have Attachment in the ActiveRecord::Base namespace" do
assert_raises(NameError) do
ActiveRecord::Base::Attachment
end
......@@ -206,7 +206,7 @@ describe Paperclip do
end
end
it "be able to find the custom processor" do
it "is able to find the custom processor" do
assert_equal @freedom_processor, Paperclip.processor(:freedom)
end
......
require 'spec_helper'
describe 'Plural cache' do
it 'cache pluralizations' do
it 'caches pluralizations' do
cache = Paperclip::Interpolations::PluralCache.new
word = "box"
......@@ -11,7 +11,7 @@ describe 'Plural cache' do
cache.pluralize(word)
end
it 'cache pluralizations and underscores' do
it 'caches pluralizations and underscores' do
cache = Paperclip::Interpolations::PluralCache.new
word = "BigBox"
......@@ -22,13 +22,13 @@ describe 'Plural cache' do
cache.underscore_and_pluralize(word)
end
it 'pluralize words' do
it 'pluralizes words' do
cache = Paperclip::Interpolations::PluralCache.new
word = "box"
assert_equal "boxes", cache.pluralize(word)
end
it 'pluralize and underscore words' do
it 'pluralizes and underscore words' do
cache = Paperclip::Interpolations::PluralCache.new
word = "BigBox"
assert_equal "big_boxes", cache.underscore_and_pluralize(word)
......
require 'spec_helper'
describe Paperclip::Processor do
it "instantiate and call #make when sent #make to the class" do
it "instantiates and call #make when sent #make to the class" do
processor = mock
processor.expects(:make).with()
Paperclip::Processor.expects(:new).with(:one, :two, :three).returns(processor)
......@@ -9,7 +9,7 @@ describe Paperclip::Processor do
end
context "Calling #convert" do
it "run the convert command with Cocaine" do
it "runs the convert command with Cocaine" do
Paperclip.options[:log_command] = false
Cocaine::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
Paperclip::Processor.new('filename').convert("stuff")
......@@ -17,7 +17,7 @@ describe Paperclip::Processor do
end
context "Calling #identify" do
it "run the identify command with Cocaine" do
it "runs the identify command with Cocaine" do
Paperclip.options[:log_command] = false
Cocaine::CommandLine.expects(:new).with("identify", "stuff", {}).returns(stub(:run))
Paperclip::Processor.new('filename').identify("stuff")
......
......@@ -20,18 +20,18 @@ describe Rake do
@bogus_instance.avatar.stubs(:reprocess!).raises
end
it "catch the exception" do
it "catches the exception" do
assert_nothing_raised do
::Rake::Task['paperclip:refresh:thumbnails'].execute
end
end
it "continue to the next instance" do
it "continues to the next instance" do
@valid_instance.avatar.expects(:reprocess!)
::Rake::Task['paperclip:refresh:thumbnails'].execute
end
it "print the exception" do
it "prints the exception" do
exception_msg = 'Some Exception'
@bogus_instance.avatar.stubs(:reprocess!).raises(exception_msg)
Paperclip::Task.expects(:log_error).with do |str|
......@@ -40,14 +40,14 @@ describe Rake do
::Rake::Task['paperclip:refresh:thumbnails'].execute
end
it "print the class name" do
it "prints the class name" do
Paperclip::Task.expects(:log_error).with do |str|
str.match 'Dummy'
end
::Rake::Task['paperclip:refresh:thumbnails'].execute
end
it "print the instance ID" do
it "prints the instance ID" do
Paperclip::Task.expects(:log_error).with do |str|
str.match "ID #{@bogus_instance.id}"
end
......@@ -63,12 +63,12 @@ describe Rake do
@bogus_instance.stubs(:errors).returns(@errors)
end
it "continue to the next instance" do
it "continues to the next instance" do
@valid_instance.avatar.expects(:reprocess!)
::Rake::Task['paperclip:refresh:thumbnails'].execute
end
it "print the error" do
it "prints the error" do
error_msg = 'Some Error'
@errors.stubs(:full_messages).returns([error_msg])
Paperclip::Task.expects(:log_error).with do |str|
......@@ -77,14 +77,14 @@ describe Rake do
::Rake::Task['paperclip:refresh:thumbnails'].execute
end
it "print the class name" do
it "prints the class name" do
Paperclip::Task.expects(:log_error).with do |str|
str.match 'Dummy'
end
::Rake::Task['paperclip:refresh:thumbnails'].execute
end
it "print the instance ID" do
it "prints the instance ID" do
Paperclip::Task.expects(:log_error).with do |str|
str.match "ID #{@bogus_instance.id}"
end
......@@ -94,7 +94,7 @@ describe Rake do
end
context "Paperclip::Task.log_error method" do
it "print its argument to STDERR" do
it "prints its argument to STDERR" do
msg = 'Some Message'
$stderr.expects(:puts).with(msg)
Paperclip::Task.log_error(msg)
......
......@@ -18,7 +18,7 @@ describe Paperclip::Schema do
before do
ActiveSupport::Deprecation.silenced = false
end
it "create attachment columns" do
it "creates attachment columns" do
Dummy.connection.create_table :dummies, force: true do |t|
ActiveSupport::Deprecation.silence do
t.has_attached_file :avatar
......@@ -34,7 +34,7 @@ describe Paperclip::Schema do
expect(columns).to include(['avatar_updated_at', :datetime])
end
it "display deprecation warning" do
it "displays deprecation warning" do
Dummy.connection.create_table :dummies, force: true do |t|
assert_deprecated do
t.has_attached_file :avatar
......@@ -51,7 +51,7 @@ describe Paperclip::Schema do
rebuild_class
end
it "create attachment columns" do
it "creates attachment columns" do
columns = Dummy.columns.map{ |column| [column.name, column.type] }
expect(columns).to include(['avatar_file_name', :string])
......@@ -74,7 +74,7 @@ describe Paperclip::Schema do
rebuild_class
end
it "create attachment columns" do
it "creates attachment columns" do
columns = Dummy.columns.map{ |column| [column.name, column.type] }
expect(columns).to include(['avatar_file_name', :string])
......@@ -90,7 +90,7 @@ describe Paperclip::Schema do
rebuild_class
end
it "create attachment columns" do
it "creates attachment columns" do
columns = Dummy.columns.map{ |column| [column.name, column.type] }
expect(columns).to include(['avatar_file_name', :string])
......@@ -105,7 +105,7 @@ describe Paperclip::Schema do
end
context "with no attachment" do
it "raise an error" do
it "raises an error" do
assert_raises ArgumentError do
Dummy.connection.add_attachment :dummies
rebuild_class
......@@ -128,7 +128,7 @@ describe Paperclip::Schema do
before do
ActiveSupport::Deprecation.silenced = false
end
it "remove the attachment columns" do
it "removes the attachment columns" do
ActiveSupport::Deprecation.silence do
Dummy.connection.drop_attached_file :dummies, :avatar
end
......@@ -142,7 +142,7 @@ describe Paperclip::Schema do
expect(columns).to_not include(['avatar_updated_at', :datetime])
end
it "display a deprecation warning" do
it "displays a deprecation warning" do
assert_deprecated do
Dummy.connection.drop_attached_file :dummies, :avatar
end
......@@ -156,7 +156,7 @@ describe Paperclip::Schema do
rebuild_class
end
it "remove the attachment columns" do
it "removes the attachment columns" do
columns = Dummy.columns.map{ |column| [column.name, column.type] }
expect(columns).to_not include(['avatar_file_name', :string])
......@@ -179,7 +179,7 @@ describe Paperclip::Schema do
rebuild_class
end
it "remove the attachment columns" do
it "removes the attachment columns" do
columns = Dummy.columns.map{ |column| [column.name, column.type] }
expect(columns).to_not include(['avatar_file_name', :string])
......@@ -194,7 +194,7 @@ describe Paperclip::Schema do
end
context "with no attachment" do
it "raise an error" do
it "raises an error" do
assert_raises ArgumentError do
Dummy.connection.remove_attachment :dummies
end
......
......@@ -13,21 +13,21 @@ describe Paperclip::Storage::Filesystem do
after { @file.close }
it "allow file assignment" do
it "allows file assignment" do
assert @dummy.save
end
it "store the original" do
it "stores the original" do
@dummy.save
assert_file_exists(@dummy.avatar.path)
end
it "store the thumbnail" do
it "stores the thumbnail" do
@dummy.save
assert_file_exists(@dummy.avatar.path(:thumbnail))
end
it "be rewinded after flush_writes" do
it "is rewinded after flush_writes" do
@dummy.avatar.instance_eval "def after_flush_writes; end"
files = @dummy.avatar.queued_for_write.values
......@@ -35,14 +35,14 @@ describe Paperclip::Storage::Filesystem do
assert files.none?(&:eof?), "Expect all the files to be rewinded."
end
it "be removed after after_flush_writes" do
it "is removed after after_flush_writes" do
paths = @dummy.avatar.queued_for_write.values.map(&:path)
@dummy.save
assert paths.none?{ |path| File.exists?(path) },
"Expect all the files to be deleted."
end
it 'copy the file to a known location with copy_to_local_file' do
it 'copies the file to a known location with copy_to_local_file' do
tempfile = Tempfile.new("known_location")
@dummy.avatar.copy_to_local_file(:original, tempfile.path)
tempfile.rewind
......@@ -63,15 +63,15 @@ describe Paperclip::Storage::Filesystem do
after { @file.close }
it "store the file" do
it "stores the file" do
assert_file_exists(@dummy.avatar.path)
end
it "return a replaced version for path" do
it "returns a replaced version for path" do
assert_match /.+\/spaced_file\.png/, @dummy.avatar.path
end
it "return a replaced version for url" do
it "returns a replaced version for url" do
assert_match /.+\/spaced_file\.png/, @dummy.avatar.url
end
end
......
......@@ -16,7 +16,7 @@ unless ENV["S3_BUCKET"].blank?
@file = File.new(fixture_file("5k.png"))
end
it "not raise any error" do
it "does not raise any error" do
@attachment = Dummy.new.avatar
@attachment.assign(@file)
@attachment.save
......@@ -26,7 +26,7 @@ unless ENV["S3_BUCKET"].blank?
@attachment2.save
end
it "allow assignment from another S3 object" do
it "allows assignment from another S3 object" do
@attachment = Dummy.new.avatar
@attachment.assign(@file)
@attachment.save
......@@ -73,7 +73,7 @@ unless ENV["S3_BUCKET"].blank?
@dummy = Dummy.new
end
it "be extended by the S3 module" do
it "is extended by the S3 module" do
assert Dummy.new.avatar.is_a?(Paperclip::Storage::S3)
end
......@@ -93,7 +93,7 @@ unless ENV["S3_BUCKET"].blank?
@dummy.save
end
it "be on S3" do
it "is on S3" do
assert true
end
end
......@@ -117,23 +117,23 @@ unless ENV["S3_BUCKET"].blank?
@dummy.save
end
it "return a replaced version for path" do
it "returns a replaced version for path" do
assert_match /.+\/spaced_file\.png/, @dummy.avatar.path
end
it "return a replaced version for url" do
it "returns a replaced version for url" do
assert_match /.+\/spaced_file\.png/, @dummy.avatar.url
end
it "be accessible" do
it "is accessible" do
assert_success_response @dummy.avatar.url
end
it "be reprocessable" do
it "is reprocessable" do
assert @dummy.avatar.reprocess!
end
it "be destroyable" do
it "is destroyable" do
url = @dummy.avatar.url
@dummy.destroy
assert_not_found_response url
......@@ -172,7 +172,7 @@ unless ENV["S3_BUCKET"].blank?
@dummy.save
end
it "be encrypted on S3" do
it "is encrypted on S3" do
assert @dummy.avatar.s3_object.server_side_encryption == :aes256
end
end
......
......@@ -10,28 +10,28 @@ describe Paperclip::Style do
@style = @attachment.styles[:foo]
end
it "be held as a Style object" do
it "is held as a Style object" do
expect(@style).to be_a Paperclip::Style
end
it "get processors from the attachment definition" do
it "gets processors from the attachment definition" do
assert_equal [:thumbnail], @style.processors
end
it "have the right geometry" do
it "has the right geometry" do
assert_equal "100x100#", @style.geometry
end
it "be whiny if the attachment is" do
it "is whiny if the attachment is" do
assert @style.whiny?
end
it "respond to hash notation" do
it "responds to hash notation" do
assert_equal [:thumbnail], @style[:processors]
assert_equal "100x100#", @style[:geometry]
end
should "return the name of the style in processor options" do
it "returns the name of the style in processor options" do
assert_equal :foo, @style.processor_options[:style]
end
end
......@@ -51,7 +51,7 @@ describe Paperclip::Style do
}
end
it "call procs when they are needed" do
it "calls procs when they are needed" do
assert_equal "300x300#", @attachment.styles[:foo].geometry
assert_equal "300x300#", @attachment.styles[:bar].geometry
assert_equal [:test], @attachment.styles[:foo].processors
......@@ -71,36 +71,36 @@ describe Paperclip::Style do
styles: styles
end
it "have the right number of styles" do
it "has the right number of styles" do
expect(@attachment.styles).to be_a Hash
assert_equal 3, @attachment.styles.size
end
it "have styles as Style objects" do
it "has styles as Style objects" do
[:aslist, :ashash, :aslist].each do |s|
expect(@attachment.styles[s]).to be_a Paperclip::Style
end
end
it "have the right geometries" do
it "has the right geometries" do
[:aslist, :ashash, :aslist].each do |s|
assert_equal @attachment.styles[s].geometry, "100x100"
end
end
it "have the right formats" do
it "has the right formats" do
assert_equal @attachment.styles[:aslist].format, :png
assert_equal @attachment.styles[:ashash].format, :png
assert_nil @attachment.styles[:asstring].format
end
it "retain order" do
it "retains order" do
assert_equal [:aslist, :ashash, :asstring], @attachment.styles.keys
end
end
context "An attachment with :convert_options" do
it "not have called extra_options_for(:thumb/:large) on initialization" do
it "does not have called extra_options_for(:thumb/:large) on initialization" do
@attachment = attachment path: ":basename.:extension",
styles: {thumb: "100x100", large: "400x400"},
convert_options: {all: "-do_stuff", thumb: "-thumbnailize"}
......@@ -108,7 +108,7 @@ describe Paperclip::Style do
@style = @attachment.styles[:thumb]
end
it "call extra_options_for(:thumb/:large) when convert options are requested" do
it "calls extra_options_for(:thumb/:large) when convert options are requested" do
@attachment = attachment path: ":basename.:extension",
styles: {thumb: "100x100", large: "400x400"},
convert_options: {all: "-do_stuff", thumb: "-thumbnailize"}
......@@ -122,7 +122,7 @@ describe Paperclip::Style do
end
context "An attachment with :source_file_options" do
it "not have called extra_source_file_options_for(:thumb/:large) on initialization" do
it "does not have called extra_source_file_options_for(:thumb/:large) on initialization" do
@attachment = attachment path: ":basename.:extension",
styles: {thumb: "100x100", large: "400x400"},
source_file_options: {all: "-density 400", thumb: "-depth 8"}
......@@ -130,7 +130,7 @@ describe Paperclip::Style do
@style = @attachment.styles[:thumb]
end
it "call extra_options_for(:thumb/:large) when convert options are requested" do
it "calls extra_options_for(:thumb/:large) when convert options are requested" do
@attachment = attachment path: ":basename.:extension",
styles: {thumb: "100x100", large: "400x400"},
source_file_options: {all: "-density 400", thumb: "-depth 8"}
......@@ -157,12 +157,12 @@ describe Paperclip::Style do
@style = @attachment.styles[:foo]
end
it "not get processors from the attachment" do
it "does not get processors from the attachment" do
@attachment.expects(:processors).never
assert_not_equal [:thumbnail], @style.processors
end
it "report its own processors" do
it "reports its own processors" do
assert_equal [:test], @style.processors
end
......@@ -181,11 +181,11 @@ describe Paperclip::Style do
processors: [:thumbnail]
end
it "defer processing of procs until they are needed" do
it "defers processing of procs until they are needed" do
expect(@attachment.styles[:foo].instance_variable_get("@processors")).to be_a Proc
end
it "call procs when they are needed" do
it "calls procs when they are needed" do
assert_equal [:test], @attachment.styles[:foo].processors
end
end
......@@ -204,12 +204,12 @@ describe Paperclip::Style do
@file.stubs(:original_filename).returns("file.jpg")
end
it "have empty options for :thumb style" do
it "has empty options for :thumb style" do
assert_equal "", @attachment.styles[:thumb].processor_options[:convert_options]
assert_equal "", @attachment.styles[:thumb].processor_options[:source_file_options]
end
it "have the right options for :large style" do
it "has the right options for :large style" do
assert_equal "-do_stuff", @attachment.styles[:large].processor_options[:convert_options]
assert_equal "-do_extra_stuff", @attachment.styles[:large].processor_options[:source_file_options]
end
......@@ -228,24 +228,24 @@ describe Paperclip::Style do
}
end
it "have the right number of styles" do
it "has the right number of styles" do
expect(@attachment.styles).to be_a Hash
assert_equal 3, @attachment.styles.size
end
it "have styles as Style objects" do
it "has styles as Style objects" do
[:aslist, :ashash, :aslist].each do |s|
expect(@attachment.styles[s]).to be_a Paperclip::Style
end
end
it "have the right geometries" do
it "has the right geometries" do
[:aslist, :ashash, :aslist].each do |s|
assert_equal @attachment.styles[s].geometry, "300x300#"
end
end
it "have the right formats" do
it "has the right formats" do
assert_equal @attachment.styles[:aslist].format, :jpg
assert_equal @attachment.styles[:ashash].format, :png
assert_equal @attachment.styles[:asstring].format, :png
......
require 'spec_helper'
describe Paperclip::TempfileFactory do
it "be able to generate a tempfile with the right name" do
it "is able to generate a tempfile with the right name" do
file = subject.generate("omg.png")
assert File.extname(file.path), "png"
end
it "be able to generate a tempfile with the right name with a tilde at the beginning" do
it "is able to generate a tempfile with the right name with a tilde at the beginning" do
file = subject.generate("~omg.png")
assert File.extname(file.path), "png"
end
it "be able to generate a tempfile with the right name with a tilde at the end" do
it "is able to generate a tempfile with the right name with a tilde at the end" do
file = subject.generate("omg.png~")
assert File.extname(file.path), "png"
end
it "be able to generate a tempfile from a file with a really long name" do
it "is able to generate a tempfile from a file with a really long name" do
filename = "#{"longfilename" * 100}.png"
file = subject.generate(filename)
assert File.extname(file.path), "png"
end
it 'be able to take nothing as a parameter and not error' do
it 'is able to take nothing as a parameter and not error' do
file = subject.generate
assert File.exists?(file.path)
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe Paperclip::UrlGenerator do
it "use the given interpolator" do
it "uses the given interpolator" do
expected = "the expected result"
mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(result: expected)
......@@ -16,7 +16,7 @@ describe Paperclip::UrlGenerator do
assert mock_interpolator.has_interpolated_style_name?(:style_name)
end
it "use the default URL when no file is assigned" do
it "uses the default URL when no file is assigned" do
mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new
default_url = "the default url"
......@@ -29,7 +29,7 @@ describe Paperclip::UrlGenerator do
"expected the interpolator to be passed #{default_url.inspect} but it wasn't"
end
it "execute the default URL lambda when no file is assigned" do
it "executes the default URL lambda when no file is assigned" do
mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new
default_url = lambda {|attachment| "the #{attachment.class.name} default url" }
......@@ -42,7 +42,7 @@ describe Paperclip::UrlGenerator do
%{expected the interpolator to be passed "the MockAttachment default url", but it wasn't}
end
it "execute the method named by the symbol as the default URL when no file is assigned" do
it "executes the method named by the symbol as the default URL when no file is assigned" do
mock_model = MockModel.new
mock_attachment = MockAttachment.new(model: mock_model)
mock_interpolator = MockInterpolator.new
......@@ -56,7 +56,7 @@ describe Paperclip::UrlGenerator do
%{expected the interpolator to be passed #{mock_model.to_s}, but it wasn't}
end
it "URL-escape spaces if asked to" do
it "URL-escapes spaces if asked to" do
expected = "the expected result"
mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(result: expected)
......@@ -68,7 +68,7 @@ describe Paperclip::UrlGenerator do
assert_equal "the%20expected%20result", result
end
it "escape the result of the interpolator using a method on the object, if asked to escape" do
it "escapes the result of the interpolator using a method on the object, if asked to escape" do
expected = Class.new do
def escape
"the escaped result"
......@@ -84,7 +84,7 @@ describe Paperclip::UrlGenerator do
assert_equal "the escaped result", result
end
it "leave spaces unescaped as asked to" do
it "leaves spaces unescaped as asked to" do
expected = "the expected result"
mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(result: expected)
......@@ -96,7 +96,7 @@ describe Paperclip::UrlGenerator do
assert_equal "the expected result", result
end
it "default to leaving spaces unescaped" do
it "defaults to leaving spaces unescaped" do
expected = "the expected result"
mock_attachment = MockAttachment.new
mock_interpolator = MockInterpolator.new(result: expected)
......@@ -108,7 +108,7 @@ describe Paperclip::UrlGenerator do
assert_equal "the expected result", result
end
it "produce URLs without the updated_at value when the object does not respond to updated_at" do
it "produces URLs without the updated_at value when the object does not respond to updated_at" do
expected = "the expected result"
mock_interpolator = MockInterpolator.new(result: expected)
mock_attachment = MockAttachment.new(responds_to_updated_at: false)
......@@ -120,7 +120,7 @@ describe Paperclip::UrlGenerator do
assert_equal expected, result
end
it "produce URLs without the updated_at value when the updated_at value is nil" do
it "produces URLs without the updated_at value when the updated_at value is nil" do
expected = "the expected result"
mock_interpolator = MockInterpolator.new(result: expected)
mock_attachment = MockAttachment.new(responds_to_updated_at: true, updated_at: nil)
......@@ -132,7 +132,7 @@ describe Paperclip::UrlGenerator do
assert_equal expected, result
end
it "produce URLs with the updated_at when it exists" do
it "produces URLs with the updated_at when it exists" do
expected = "the expected result"
updated_at = 1231231234
mock_interpolator = MockInterpolator.new(result: expected)
......@@ -145,7 +145,7 @@ describe Paperclip::UrlGenerator do
assert_equal "#{expected}?#{updated_at}", result
end
it "produce URLs with the updated_at when it exists, separated with a & if a ? follow by = already exists" do
it "produces URLs with the updated_at when it exists, separated with a & if a ? follow by = already exists" do
expected = "the?expected=result"
updated_at = 1231231234
mock_interpolator = MockInterpolator.new(result: expected)
......@@ -158,7 +158,7 @@ describe Paperclip::UrlGenerator do
assert_equal "#{expected}&#{updated_at}", result
end
it "produce URLs without the updated_at when told to do as much" do
it "produces URLs without the updated_at when told to do as much" do
expected = "the expected result"
updated_at = 1231231234
mock_interpolator = MockInterpolator.new(result: expected)
......@@ -171,7 +171,7 @@ describe Paperclip::UrlGenerator do
assert_equal expected, result
end
it "produce the correct URL when the instance has a file name" do
it "produces the correct URL when the instance has a file name" do
expected = "the expected result"
mock_attachment = MockAttachment.new(original_filename: 'exists')
mock_interpolator = MockInterpolator.new
......
......@@ -19,7 +19,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -32,7 +32,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "allow avatar_content_type as nil" do
it "allows avatar_content_type as nil" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -44,7 +44,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not allow avatar_content_type as nil" do
it "does not allow avatar_content_type as nil" do
assert @dummy.errors[:avatar_content_type].present?
end
end
......@@ -57,12 +57,12 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "add error to the base object" do
it "adds error to the base object" do
assert @dummy.errors[:avatar].present?,
"Error not added to base attribute"
end
it "add error to base object as a string" do
it "adds error to base object as a string" do
expect(@dummy.errors[:avatar].first).to be_a String
end
end
......@@ -74,7 +74,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not add error to the base object" do
it "does not add error to the base object" do
assert @dummy.errors[:avatar].blank?,
"Error was added to base attribute"
end
......@@ -88,7 +88,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "allow avatar_content_type as blank" do
it "allows avatar_content_type as blank" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -100,7 +100,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not allow avatar_content_type as blank" do
it "does not allow avatar_content_type as blank" do
assert @dummy.errors[:avatar_content_type].present?
end
end
......@@ -115,7 +115,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -127,7 +127,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -139,7 +139,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -153,7 +153,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct default error message" do
it "sets a correct default error message" do
assert @dummy.errors[:avatar_content_type].present?
expect(@dummy.errors[:avatar_content_type]).to include "is invalid"
end
......@@ -166,7 +166,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct default error message" do
it "sets a correct default error message" do
assert @dummy.errors[:avatar_content_type].present?
expect(@dummy.errors[:avatar_content_type]).to include "is invalid"
end
......@@ -180,7 +180,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct error message" do
it "sets a correct error message" do
expect(@dummy.errors[:avatar_content_type]).to include "should be a PNG image"
end
end
......@@ -192,7 +192,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct error message" do
it "sets a correct error message" do
expect(@dummy.errors[:avatar_content_type]).to include "should have content type image/png"
end
end
......@@ -209,7 +209,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -221,7 +221,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -233,7 +233,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_content_type].blank?
end
end
......@@ -247,7 +247,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct default error message" do
it "sets a correct default error message" do
assert @dummy.errors[:avatar_content_type].present?
expect(@dummy.errors[:avatar_content_type]).to include "is invalid"
end
......@@ -260,7 +260,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct default error message" do
it "sets a correct default error message" do
assert @dummy.errors[:avatar_content_type].present?
expect(@dummy.errors[:avatar_content_type]).to include "is invalid"
end
......@@ -274,7 +274,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct error message" do
it "sets a correct error message" do
expect(@dummy.errors[:avatar_content_type]).to include "should not be a PNG image"
end
end
......@@ -286,7 +286,7 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
@validator.validate(@dummy)
end
it "set a correct error message" do
it "sets a correct error message" do
expect(@dummy.errors[:avatar_content_type]).to include "should not have content type image/png"
end
end
......@@ -299,23 +299,23 @@ describe Paperclip::Validators::AttachmentContentTypeValidator do
Dummy.validates_attachment_content_type :avatar, content_type: "image/jpg"
end
it "add the validator to the class" do
it "adds the validator to the class" do
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_content_type }
end
end
context "given options" do
it "raise argument error if no required argument was given" do
it "raises argument error if no required argument was given" do
assert_raises(ArgumentError) do
build_validator message: "Some message"
end
end
it "not raise argument error if :content_type was given" do
it "does not raise argument error if :content_type was given" do
build_validator content_type: "image/jpg"
end
it "not raise argument error if :not was given" do
it "does not raise argument error if :not was given" do
build_validator not: "image/jpg"
end
end
......
......@@ -19,17 +19,17 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
@validator.validate(@dummy)
end
it "add error to the base object" do
it "adds error to the base object" do
assert @dummy.errors[:avatar].present?,
"Error not added to base attribute"
end
it "add error to base object as a string" do
it "adds error to base object as a string" do
expect(@dummy.errors[:avatar].first).to be_a String
end
end
it "not add error to the base object with a successful validation" do
it "does not add error to the base object with a successful validation" do
build_validator matches: /.*\.png$/, allow_nil: false
@dummy.stubs(avatar_file_name: "image.png")
@validator.validate(@dummy)
......@@ -46,7 +46,7 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_file_name].blank?
end
end
......@@ -58,14 +58,14 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_file_name].blank?
end
end
end
context "with a disallowed type" do
it "set a correct default error message" do
it "sets a correct default error message" do
build_validator matches: /^text\/.*/
@dummy.stubs(avatar_file_name: "image.jpg")
@validator.validate(@dummy)
......@@ -74,7 +74,7 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
expect(@dummy.errors[:avatar_file_name]).to include "is invalid"
end
it "set a correct custom error message" do
it "sets a correct custom error message" do
build_validator matches: /.*\.png$/, message: "should be a PNG image"
@dummy.stubs(avatar_file_name: "image.jpg")
@validator.validate(@dummy)
......@@ -93,7 +93,7 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_file_name].blank?
end
end
......@@ -105,14 +105,14 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
@validator.validate(@dummy)
end
it "not set an error message" do
it "does not set an error message" do
assert @dummy.errors[:avatar_file_name].blank?
end
end
end
context "with a disallowed type" do
it "set a correct default error message" do
it "sets a correct default error message" do
build_validator not: /data.*/
@dummy.stubs(avatar_file_name: "data.txt")
@validator.validate(@dummy)
......@@ -121,7 +121,7 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
expect(@dummy.errors[:avatar_file_name]).to include "is invalid"
end
it "set a correct custom error message" do
it "sets a correct custom error message" do
build_validator not: /.*\.png$/, message: "should not be a PNG image"
@dummy.stubs(avatar_file_name: "image.png")
@validator.validate(@dummy)
......@@ -136,23 +136,23 @@ describe Paperclip::Validators::AttachmentFileNameValidator do
Dummy.validates_attachment_file_name :avatar, matches: /.*\.jpg$/
end
it "add the validator to the class" do
it "adds the validator to the class" do
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_file_name }
end
end
context "given options" do
it "raise argument error if no required argument was given" do
it "raises argument error if no required argument was given" do
assert_raises(ArgumentError) do
build_validator message: "Some message"
end
end
it "not raise argument error if :matches was given" do
it "does not raise argument error if :matches was given" do
build_validator matches: /.*\.jpg$/
end
it "not raise argument error if :not was given" do
it "does not raise argument error if :not was given" do
build_validator not: /.*\.jpg$/
end
end
......
......@@ -23,11 +23,11 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
@validator.validate(@dummy)
end
it "add error on the attachment" do
it "adds error on the attachment" do
assert @dummy.errors[:avatar].present?
end
it "not add an error on the file_name attribute" do
it "does not add an error on the file_name attribute" do
assert @dummy.errors[:avatar_file_name].blank?
end
end
......@@ -39,7 +39,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
@validator.validate(@dummy)
end
it "perform a validation" do
it "performs a validation" do
assert @dummy.errors[:avatar].present?
end
end
......@@ -50,7 +50,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
@validator.validate(@dummy)
end
it "perform a validation" do
it "performs a validation" do
assert @dummy.errors[:avatar].present?
end
end
......@@ -64,11 +64,11 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
@validator.validate(@dummy)
end
it "not add error on the attachment" do
it "does not add error on the attachment" do
assert @dummy.errors[:avatar].blank?
end
it "not add an error on the file_name attribute" do
it "does not add an error on the file_name attribute" do
assert @dummy.errors[:avatar_file_name].blank?
end
end
......@@ -78,7 +78,7 @@ describe Paperclip::Validators::AttachmentPresenceValidator do
Dummy.validates_attachment_presence :avatar
end
it "add the validator to the class" do
it "adds the validator to the class" do
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_presence }
end
end
......
......@@ -14,14 +14,14 @@ describe Paperclip::Validators::AttachmentSizeValidator do
def self.should_allow_attachment_file_size(size)
context "when the attachment size is #{size}" do
it "add error to dummy object" do
it "adds error to dummy object" do
@dummy.stubs(:avatar_file_size).returns(size)
@validator.validate(@dummy)
assert @dummy.errors[:avatar_file_size].blank?,
"Expect an error message on :avatar_file_size, got none."
end
it "not add error to the base dummy object" do
it "does not add error to the base dummy object" do
assert @dummy.errors[:avatar].blank?,
"Error added to base attribute"
end
......@@ -35,22 +35,22 @@ describe Paperclip::Validators::AttachmentSizeValidator do
@validator.validate(@dummy)
end
it "add error to dummy object" do
it "adds error to dummy object" do
assert @dummy.errors[:avatar_file_size].present?,
"Unexpected error message on :avatar_file_size"
end
it "add error to the base dummy object" do
it "adds error to the base dummy object" do
assert @dummy.errors[:avatar].present?,
"Error not added to base attribute"
end
it "add error to base object as a string" do
it "adds error to base object as a string" do
expect(@dummy.errors[:avatar].first).to be_a String
end
if options[:message]
it "return a correct error message" do
it "returns a correct error message" do
expect(@dummy.errors[:avatar_file_size]).to include options[:message]
end
end
......@@ -196,25 +196,25 @@ describe Paperclip::Validators::AttachmentSizeValidator do
Dummy.validates_attachment_size :avatar, in: (5.kilobytes..10.kilobytes)
end
it "add the validator to the class" do
it "adds the validator to the class" do
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :attachment_size }
end
end
context "given options" do
it "raise argument error if no required argument was given" do
it "raises argument error if no required argument was given" do
assert_raises(ArgumentError) do
build_validator message: "Some message"
end
end
(Paperclip::Validators::AttachmentSizeValidator::AVAILABLE_CHECKS).each do |argument|
it "not raise arguemnt error if #{argument} was given" do
it "does not raise arguemnt error if #{argument} was given" do
build_validator argument => 5.kilobytes
end
end
it "not raise argument error if :in was given" do
it "does not raise argument error if :in was given" do
build_validator in: (5.kilobytes..10.kilobytes)
end
end
......
......@@ -12,11 +12,11 @@ describe Paperclip::Validators::MediaTypeSpoofDetectionValidator do
))
end
it "be on the attachment without being explicitly added" do
it "is on the attachment without being explicitly added" do
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :media_type_spoof_detection }
end
it "return default error message for spoofed media type" do
it "returns default error message for spoofed media type" do
build_validator
file = File.new(fixture_file("5k.png"), "rb")
@dummy.avatar.assign(file)
......@@ -28,7 +28,7 @@ describe Paperclip::Validators::MediaTypeSpoofDetectionValidator do
assert_equal "has an extension that does not match its contents", @dummy.errors[:avatar].first
end
it "run when attachment is dirty" do
it "runs when attachment is dirty" do
build_validator
file = File.new(fixture_file("5k.png"), "rb")
@dummy.avatar.assign(file)
......@@ -39,7 +39,7 @@ describe Paperclip::Validators::MediaTypeSpoofDetectionValidator do
assert_received(Paperclip::MediaTypeSpoofDetector, :using){|e| e.once }
end
it "not run when attachment is not dirty" do
it "does not run when attachment is not dirty" do
Paperclip::MediaTypeSpoofDetector.stubs(:using).never
@dummy.valid?
assert_received(Paperclip::MediaTypeSpoofDetector, :using){|e| e.never }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment