Skip to content

Commit

Permalink
Merge 45e6de4 into bb7c426
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Oct 20, 2014
2 parents bb7c426 + 45e6de4 commit 3f9842f
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/minitest-vcr/spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.configure!
run_before = lambda do |example|
if metadata[:vcr]
options = metadata[:vcr].is_a?(Hash) ? metadata[:vcr] : {}
VCR.insert_cassette StringHelpers.vcr_path(example, spec_name), options
VCR.insert_cassette StringHelpers.vcr_path(example), options
end
end

Expand All @@ -24,8 +24,8 @@ def self.configure!

module StringHelpers

def self.vcr_path(example, spec_name)
description_stack(example).push(spec_name).join("/")
def self.vcr_path(example)
description_stack(example).push(extract_example_description(example)).join("/")
end

protected
Expand All @@ -42,5 +42,16 @@ def self.description_stack(example)
return stack
end

# Minitest::Spec takes the example description and writes
# a test_NNNN_ in front of it, and doesn't actually keep
# the original anywhere. Okay, we'll take it out.
def self.extract_example_description(example)
if (example.name =~ /\Atest_\d{4}_(.*)\z/)
return $1
else
return example.name
end
end

end
end # MinitestVcr

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions test/minitest-vcr/nested_describe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,18 @@
end

end


describe "top level describe", :vcr do
describe "an inner describe" do
it "a test inside inner describe" do
conn = Faraday.new
@response = conn.get "http://example.com"

VCR.current_cassette.name.must_equal "top level describe/an inner describe/a test inside inner describe"
end
end

it "makes a request succesfully" do
end
end

0 comments on commit 3f9842f

Please sign in to comment.