vcr 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
## In git
|
2
2
|
|
3
|
-
[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.
|
3
|
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.1.1...master)
|
4
|
+
|
5
|
+
## 2.1.1 (April 24, 2012)
|
6
|
+
|
7
|
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.1.0...v2.1.1)
|
8
|
+
|
9
|
+
* Fix `:use_scenario_name` cucumber tag option so that it works properly
|
10
|
+
with multiple scenarios. Thanks to [Brent Snook](https://github.com/brentsnook)
|
11
|
+
for reporting this bug.
|
12
|
+
* Fix `:use_scenario_name` cucumber tag option so that it only uses the
|
13
|
+
first line of the scenario feature name. Cucumber includes all of the
|
14
|
+
pre-amble text in the feature name but that can create a ridiculously
|
15
|
+
long cassette name. Thanks to [Brent Snook](https://github.com/brentsnook)
|
16
|
+
for reporting this bug.
|
17
|
+
|
18
|
+
## 2.1.0 (April 19, 2012)
|
19
|
+
|
20
|
+
[Full Changelog](http://github.com/myronmarston/vcr/compare/v2.0.1...v.2.1.0)
|
4
21
|
|
5
22
|
* Add new `:use_scenario_name` option to the cucumber tags API. This
|
6
23
|
allows you to use a generic tag (such as `@vcr`) and have the
|
@@ -75,6 +75,10 @@ Feature: Usage with Cucumber
|
|
75
75
|
"""
|
76
76
|
Feature: VCR example
|
77
77
|
|
78
|
+
Note: Cucumber treats the pre-amble as part of the feature name. When
|
79
|
+
using the :use_scenario_name option, VCR will only use the first line
|
80
|
+
of the feature name as the directory for the cassette.
|
81
|
+
|
78
82
|
@localhost_request
|
79
83
|
Scenario: tagged scenario
|
80
84
|
When a request is made to "http://localhost:7777/localhost_request_1"
|
@@ -26,18 +26,23 @@ module VCR
|
|
26
26
|
# @param [Array<String>] tag_names the cucumber scenario tags
|
27
27
|
# @param [(optional) Hash] options the cassette options. Specify :use_scenario_name => true to automatically name the cassette according to the scenario name.
|
28
28
|
def tags(*tag_names)
|
29
|
-
|
29
|
+
original_options = tag_names.last.is_a?(::Hash) ? tag_names.pop : {}
|
30
30
|
tag_names.each do |tag_name|
|
31
31
|
tag_name = "@#{tag_name}" unless tag_name =~ /\A@/
|
32
|
-
cassette_name = "cucumber_tags/#{tag_name.gsub(/\A@/, '')}"
|
33
32
|
|
34
33
|
# It would be nice to use an Around hook here, but
|
35
34
|
# cucumber has a bug: background steps do not run
|
36
35
|
# within an around hook.
|
37
36
|
# https://gist.github.com/652968
|
38
37
|
@main_object.Before(tag_name) do |scenario|
|
39
|
-
options =
|
40
|
-
|
38
|
+
options = original_options.dup
|
39
|
+
|
40
|
+
cassette_name = if options.delete(:use_scenario_name)
|
41
|
+
"#{scenario.feature.name.split("\n").first}/#{scenario.name}"
|
42
|
+
else
|
43
|
+
"cucumber_tags/#{tag_name.gsub(/\A@/, '')}"
|
44
|
+
end
|
45
|
+
|
41
46
|
VCR.insert_cassette(cassette_name, options)
|
42
47
|
end
|
43
48
|
|
data/lib/vcr/version.rb
CHANGED
@@ -4,8 +4,12 @@ describe VCR::CucumberTags do
|
|
4
4
|
subject { described_class.new(self) }
|
5
5
|
let(:before_blocks_for_tags) { {} }
|
6
6
|
let(:after_blocks_for_tags) { {} }
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
def scenario(name)
|
9
|
+
stub(:name => name, :feature => stub(:name => "My feature name\nThe preamble text is not included"))
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:current_scenario) { scenario "My scenario name" }
|
9
13
|
|
10
14
|
# define our own Before/After so we can test this in isolation from cucumber's implementation.
|
11
15
|
def Before(tag, &block)
|
@@ -16,12 +20,12 @@ describe VCR::CucumberTags do
|
|
16
20
|
after_blocks_for_tags[tag.sub('@', '')] = block
|
17
21
|
end
|
18
22
|
|
19
|
-
def test_tag(cassette_attribute, tag, expected_value)
|
23
|
+
def test_tag(cassette_attribute, tag, expected_value, scenario=current_scenario)
|
20
24
|
VCR.current_cassette.should be_nil
|
21
25
|
|
22
|
-
before_blocks_for_tags[tag].call(
|
26
|
+
before_blocks_for_tags[tag].call(scenario)
|
23
27
|
VCR.current_cassette.send(cassette_attribute).should eq(expected_value)
|
24
|
-
after_blocks_for_tags[tag].call(
|
28
|
+
after_blocks_for_tags[tag].call(scenario)
|
25
29
|
|
26
30
|
VCR.current_cassette.should be_nil
|
27
31
|
end
|
@@ -73,6 +77,13 @@ describe VCR::CucumberTags do
|
|
73
77
|
original_options[:use_scenario_name].should eq(true)
|
74
78
|
original_options[:record].should eq(:none)
|
75
79
|
end
|
80
|
+
|
81
|
+
it "works properly when multiple scenarios use the tag" do
|
82
|
+
subject.send(tag_method, 'tag1', :use_scenario_name => true)
|
83
|
+
|
84
|
+
test_tag(:name, 'tag1', 'My feature name/Foo', scenario("Foo"))
|
85
|
+
test_tag(:name, 'tag1', 'My feature name/Bar', scenario("Bar"))
|
86
|
+
end
|
76
87
|
end
|
77
88
|
end
|
78
89
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 2.1.
|
9
|
+
- 1
|
10
|
+
version: 2.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Myron Marston
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-25 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|