Skip to content

Commit

Permalink
Fixes issue with ActiveStorage::FixtureSet.blob erroring because Acti…
Browse files Browse the repository at this point in the history
…veStorage::FixtureSet.file_fixture_path is not set.
  • Loading branch information
jaywhy committed Apr 20, 2023
1 parent 1873102 commit 192bcdd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions features/file_fixture.feature
Expand Up @@ -36,3 +36,21 @@ Feature: Using `file_fixture`
"""
When I run `rspec spec/lib/file_spec.rb`
Then the examples should all pass

Scenario: Creating a ActiveStorage::Blob from a file fixture
Given a file named "spec/fixtures/files/sample.txt" with:
"""
Hello
"""
And a file named "spec/lib/fixture_set_blob.rb" with:
"""ruby
require "rails_helper"
RSpec.describe "blob" do
it "creates a blob from a sample file" do
expect(ActiveStorage::FixtureSet.blob(filename: "sample.txt")).to include("sample.txt")
end
end
"""
When I run `rspec spec/lib/fixture_set_blob.rb`
Then the examples should all pass
3 changes: 3 additions & 0 deletions lib/rspec/rails/file_fixture_support.rb
Expand Up @@ -9,6 +9,9 @@ module FileFixtureSupport

included do
self.file_fixture_path = RSpec.configuration.file_fixture_path
if defined? ActiveStorage::FixtureSet
ActiveStorage::FixtureSet.file_fixture_path = RSpec.configuration.file_fixture_path
end
end
end
end
Expand Down

0 comments on commit 192bcdd

Please sign in to comment.