Skip to content

Commit

Permalink
Merge pull request #9 from grepsedawk/flip-to-side-b
Browse files Browse the repository at this point in the history
Fix multi-casette test runs
  • Loading branch information
kalinon authored Feb 25, 2022
2 parents 4ad23ad + 191d0de commit c7eb4ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions spec/vcr_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ describe VCR do
end
end

it "switches cassette_dir when new cassette is loaded" do
load_cassette("cassette-one") do
VCR.cassette_dir.should eq "spec/fixtures/vcr/cassette-one"
end

load_cassette("cassette-two") do
VCR.cassette_dir.should eq "spec/fixtures/vcr/cassette-two"
end

load_cassette("cassette-three")
VCR.cassette_dir.should eq "spec/fixtures/vcr/cassette-three"
end

describe "#filter_sensitive_data!" do
headers = HTTP::Headers.new
headers["Authorization"] = "Bearer 123"
Expand Down
3 changes: 1 addition & 2 deletions src/vcr.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module VCR

@@in_order = false
@@sequence = 0
@@cassette_dir : String? = nil

Habitat.create do
setting cassette_library_dir : String = "spec/fixtures/vcr"
Expand All @@ -21,7 +20,7 @@ module VCR
end

def cassette_dir
@@cassette_dir ||= File.join(VCR.settings.cassette_library_dir, cassette_name.not_nil!)
File.join(VCR.settings.cassette_library_dir, cassette_name.not_nil!)
end

# The current sequence, calling this will increment the value
Expand Down

0 comments on commit c7eb4ee

Please sign in to comment.