Use the file_fixture helper in tests
This way we don't have to write `"spec/fixtures/files"` every time. Note this method isn't included in factories. We could include it like so: ``` FactoryBot::SyntaxRunner.class_eval do include ActiveSupport::Testing::FileFixtures self.file_fixture_path = RSpec.configuration.file_fixture_path end ``` However, I'm not sure about the possible side effects, and since we only use attachments in a few factories, there isn't much gain in applying the monkey-patch.
This commit is contained in:
@@ -21,7 +21,7 @@ shared_examples "image validations" do |imageable_factory|
|
||||
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}")
|
||||
image.attachment = File.new(file_fixture("clippy.#{extension}"))
|
||||
|
||||
expect(image).to be_valid
|
||||
end
|
||||
@@ -30,7 +30,7 @@ shared_examples "image validations" do |imageable_factory|
|
||||
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}")
|
||||
image.attachment = File.new(file_fixture("clippy.#{extension}"))
|
||||
|
||||
expect(image).not_to be_valid
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user