Enables RSpec/ExampleWording and fixes all issues
Both avoiding 'should' and repiting 'it' on the tests description improves reading them and also makes all descriptions consistent. Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording
This commit is contained in:
@@ -6,23 +6,23 @@ shared_examples "image validations" do |imageable_factory|
|
||||
let!(:imageable) { image.imageable }
|
||||
let!(:acceptedcontenttypes) { imageable_accepted_content_types }
|
||||
|
||||
it "should be valid" do
|
||||
it "is valid" do
|
||||
expect(image).to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a title" do
|
||||
it "is not valid without a title" do
|
||||
image.title = nil
|
||||
|
||||
expect(image).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without an attachment" do
|
||||
it "is not valid without an attachment" do
|
||||
image.attachment = nil
|
||||
|
||||
expect(image).to_not be_valid
|
||||
end
|
||||
|
||||
it "should be valid for all accepted content types" do
|
||||
it "is valid for all accepted content types" do
|
||||
acceptedcontenttypes.each do |content_type|
|
||||
extension = content_type.split("/").last
|
||||
image.attachment = File.new("spec/fixtures/files/clippy.#{extension}")
|
||||
@@ -31,7 +31,7 @@ shared_examples "image validations" do |imageable_factory|
|
||||
end
|
||||
end
|
||||
|
||||
it "should not be valid for png and gif image content types" do
|
||||
it "is not valid for png and gif image content types" do
|
||||
["gif", "png"].each do |content_type|
|
||||
extension = content_type.split("/").last
|
||||
image.attachment = File.new("spec/fixtures/files/clippy.#{extension}")
|
||||
@@ -40,27 +40,27 @@ shared_examples "image validations" do |imageable_factory|
|
||||
end
|
||||
end
|
||||
|
||||
it "should not be valid for attachments larger than imageable max_file_size definition" do
|
||||
it "is not valid for attachments larger than imageable max_file_size definition" do
|
||||
allow(image).to receive(:attachment_file_size).and_return(Image::MAX_IMAGE_SIZE + 1.byte)
|
||||
|
||||
expect(image).to_not be_valid
|
||||
expect(image.errors[:attachment]).to include "must be in between 0 Bytes and 1 MB"
|
||||
end
|
||||
|
||||
it "should not be valid without a user_id" do
|
||||
it "is not valid without a user_id" do
|
||||
image.user_id = nil
|
||||
|
||||
expect(image).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a imageable_id" do
|
||||
it "is not valid without a imageable_id" do
|
||||
image.save
|
||||
image.imageable_id = nil
|
||||
|
||||
expect(image).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a imageable_type" do
|
||||
it "is not valid without a imageable_type" do
|
||||
image.save
|
||||
image.imageable_type = nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user