File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -36,3 +36,22 @@ Feature: Using `file_fixture`
3636 """
3737 When I run `rspec spec/lib/file_spec.rb`
3838 Then the examples should all pass
39+
40+ @rails_post_7
41+ Scenario : Creating a ActiveStorage::Blob from a file fixture
42+ Given a file named "spec/fixtures/files/sample.txt" with:
43+ """
44+ Hello
45+ """
46+ And a file named "spec/lib/fixture_set_blob.rb" with:
47+ """ruby
48+ require "rails_helper"
49+
50+ RSpec.describe "blob" do
51+ it "creates a blob from a sample file" do
52+ expect(ActiveStorage::FixtureSet.blob(filename: "sample.txt")).to include("sample.txt")
53+ end
54+ end
55+ """
56+ When I run `rspec spec/lib/fixture_set_blob.rb`
57+ Then the examples should all pass
Original file line number Diff line number Diff line change 1+ def rails_version
2+ string_version = ENV . fetch ( "RAILS_VERSION" , "~> 7.0.0" )
3+ if string_version == "main" || string_version . nil?
4+ Float ::INFINITY
5+ else
6+ string_version [ /\d [.-]\d / ] . tr ( '-' , '.' )
7+ end
8+ end
9+
10+ Before "@rails_post_7" do |scenario |
11+ if rails_version . to_f < 7.0
12+ warn "Skipping scenario #{ scenario . name } on Rails v#{ rails_version } "
13+ skip_this_scenario
14+ end
15+ end
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments