Skip to content

Commit 192bcdd

Browse files
committed
Fixes issue with ActiveStorage::FixtureSet.blob erroring because ActiveStorage::FixtureSet.file_fixture_path is not set.
1 parent 1873102 commit 192bcdd

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

features/file_fixture.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@ Feature: Using `file_fixture`
3636
"""
3737
When I run `rspec spec/lib/file_spec.rb`
3838
Then the examples should all pass
39+
40+
Scenario: Creating a ActiveStorage::Blob from a file fixture
41+
Given a file named "spec/fixtures/files/sample.txt" with:
42+
"""
43+
Hello
44+
"""
45+
And a file named "spec/lib/fixture_set_blob.rb" with:
46+
"""ruby
47+
require "rails_helper"
48+
49+
RSpec.describe "blob" do
50+
it "creates a blob from a sample file" do
51+
expect(ActiveStorage::FixtureSet.blob(filename: "sample.txt")).to include("sample.txt")
52+
end
53+
end
54+
"""
55+
When I run `rspec spec/lib/fixture_set_blob.rb`
56+
Then the examples should all pass

lib/rspec/rails/file_fixture_support.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ module FileFixtureSupport
99

1010
included do
1111
self.file_fixture_path = RSpec.configuration.file_fixture_path
12+
if defined? ActiveStorage::FixtureSet
13+
ActiveStorage::FixtureSet.file_fixture_path = RSpec.configuration.file_fixture_path
14+
end
1215
end
1316
end
1417
end

0 commit comments

Comments
 (0)