casecumber 1.0.2.1 → 1.2.1.cb2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/.travis.yml +13 -6
- data/Gemfile +2 -0
- data/History.md +139 -0
- data/LICENSE +1 -1
- data/README.md +19 -4
- data/cucumber.gemspec +16 -29
- data/cucumber.yml +3 -3
- data/examples/i18n/README.textile +1 -16
- data/features/.cucumber/stepdefs.json +612 -0
- data/features/backtraces.feature +36 -0
- data/features/doc_strings.feature +73 -0
- data/features/drb_server_integration.feature +63 -0
- data/features/formatter_step_file_colon_line.feature +46 -0
- data/features/json_formatter.feature +137 -137
- data/features/nested_steps.feature +60 -0
- data/features/rerun_formatter.feature +35 -0
- data/features/run_specific_scenarios.feature +47 -0
- data/features/step_definitions/cucumber-features/cucumber_ruby_mappings.rb +32 -3
- data/features/step_definitions/cucumber_steps.rb +15 -0
- data/features/step_definitions/drb_steps.rb +3 -0
- data/features/support/env.rb +4 -0
- data/features/support/feature_factory.rb +50 -0
- data/gem_tasks/cucumber.rake +15 -8
- data/gem_tasks/yard.rake +18 -0
- data/legacy_features/call_steps_from_stepdefs.feature +1 -1
- data/legacy_features/cucumber_cli.feature +0 -7
- data/legacy_features/default_snippets.feature +3 -2
- data/legacy_features/junit_formatter.feature +60 -10
- data/legacy_features/language_help.feature +17 -15
- data/legacy_features/snippets_when_using_star_keyword.feature +3 -2
- data/legacy_features/step_definitions/cucumber_steps.rb +1 -1
- data/legacy_features/support/env.rb +1 -1
- data/legacy_features/wire_protocol.feature +1 -1
- data/lib/cucumber/ast/background.rb +11 -0
- data/lib/cucumber/ast/doc_string.rb +10 -29
- data/lib/cucumber/ast/feature.rb +6 -2
- data/lib/cucumber/ast/feature_element.rb +7 -3
- data/lib/cucumber/ast/multiline_argument.rb +30 -0
- data/lib/cucumber/ast/outline_table.rb +20 -12
- data/lib/cucumber/ast/step.rb +1 -1
- data/lib/cucumber/ast/step_invocation.rb +2 -15
- data/lib/cucumber/ast/table.rb +67 -38
- data/lib/cucumber/ast/tags.rb +7 -7
- data/lib/cucumber/ast/tree_walker.rb +5 -5
- data/lib/cucumber/cli/configuration.rb +4 -0
- data/lib/cucumber/cli/main.rb +1 -0
- data/lib/cucumber/cli/options.rb +29 -10
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +24 -10
- data/lib/cucumber/formatter/ansicolor.rb +8 -13
- data/lib/cucumber/formatter/console.rb +3 -2
- data/lib/cucumber/formatter/cucumber.css +7 -1
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +6 -2
- data/lib/cucumber/formatter/html.rb +14 -8
- data/lib/cucumber/formatter/interceptor.rb +62 -0
- data/lib/cucumber/formatter/json.rb +0 -12
- data/lib/cucumber/formatter/junit.rb +31 -15
- data/lib/cucumber/formatter/pretty.rb +3 -3
- data/lib/cucumber/formatter/progress.rb +1 -1
- data/lib/cucumber/formatter/rerun.rb +31 -8
- data/lib/cucumber/formatter/usage.rb +1 -1
- data/lib/cucumber/js_support/js_language.rb +1 -1
- data/lib/cucumber/js_support/js_snippets.rb +1 -1
- data/lib/cucumber/language_support/language_methods.rb +0 -4
- data/lib/cucumber/parser/gherkin_builder.rb +13 -14
- data/lib/cucumber/platform.rb +1 -1
- data/lib/cucumber/py_support/py_language.rb +3 -7
- data/lib/cucumber/rb_support/rb_dsl.rb +15 -8
- data/lib/cucumber/rb_support/rb_language.rb +3 -17
- data/lib/cucumber/rb_support/rb_step_definition.rb +17 -5
- data/lib/cucumber/rb_support/rb_transform.rb +5 -2
- data/lib/cucumber/rb_support/rb_world.rb +9 -5
- data/lib/cucumber/rb_support/regexp_argument_matcher.rb +3 -3
- data/lib/cucumber/runtime/results.rb +2 -2
- data/lib/cucumber/runtime/support_code.rb +14 -19
- data/lib/cucumber/runtime.rb +40 -2
- data/lib/cucumber/step_match.rb +3 -4
- data/lib/cucumber/term/ansicolor.rb +118 -0
- data/lib/cucumber/wire_support/wire_protocol/requests.rb +7 -5
- data/lib/cucumber/wire_support/wire_protocol.rb +0 -1
- data/lib/cucumber.rb +2 -1
- data/spec/cucumber/ast/doc_string_spec.rb +2 -2
- data/spec/cucumber/ast/feature_factory.rb +4 -3
- data/spec/cucumber/ast/scenario_outline_spec.rb +1 -2
- data/spec/cucumber/ast/step_spec.rb +1 -1
- data/spec/cucumber/ast/table_spec.rb +61 -27
- data/spec/cucumber/cli/configuration_spec.rb +12 -6
- data/spec/cucumber/cli/main_spec.rb +2 -2
- data/spec/cucumber/cli/options_spec.rb +9 -3
- data/spec/cucumber/constantize_spec.rb +16 -0
- data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
- data/spec/cucumber/formatter/html_spec.rb +4 -3
- data/spec/cucumber/formatter/interceptor_spec.rb +111 -0
- data/spec/cucumber/formatter/junit_spec.rb +36 -20
- data/spec/cucumber/formatter/progress_spec.rb +2 -2
- data/spec/cucumber/rb_support/rb_language_spec.rb +5 -5
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +20 -4
- data/spec/cucumber/rb_support/rb_transform_spec.rb +6 -2
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +7 -3
- data/spec/cucumber/runtime/results_spec.rb +81 -0
- data/spec/cucumber/step_match_spec.rb +8 -4
- data/spec/spec_helper.rb +15 -1
- metadata +68 -128
- data/.gitignore +0 -26
- data/.gitmodules +0 -3
- data/.yardopts +0 -0
- data/Gemfile.lock +0 -115
- data/examples/i18n/de/.gitignore +0 -1
- data/examples/i18n/en/.gitignore +0 -1
- data/examples/i18n/eo/.gitignore +0 -1
- data/examples/i18n/fi/.gitignore +0 -1
- data/examples/i18n/hu/.gitignore +0 -1
- data/examples/i18n/id/.gitignore +0 -1
- data/examples/i18n/ja/.gitignore +0 -1
- data/examples/i18n/ko/.gitignore +0 -1
- data/examples/i18n/lt/.gitignore +0 -1
- data/examples/i18n/pl/.gitignore +0 -1
- data/examples/i18n/sk/.gitignore +0 -1
- data/examples/i18n/tr/.gitignore +0 -1
- data/examples/i18n/zh-TW/.gitignore +0 -1
- data/examples/python/lib/.gitignore +0 -1
- data/examples/ruby2python/lib/.gitignore +0 -1
- data/examples/watir/.gitignore +0 -2
- data/fixtures/self_test/.gitignore +0 -1
- data/lib/cucumber/formatter/pdf.rb +0 -244
- data/lib/cucumber/step_argument.rb +0 -9
@@ -321,12 +321,12 @@ END_OF_MESSAGE
|
|
321
321
|
end
|
322
322
|
|
323
323
|
it "should accept --color option" do
|
324
|
-
Term::ANSIColor.should_receive(:coloring=).with(true)
|
324
|
+
Cucumber::Term::ANSIColor.should_receive(:coloring=).with(true)
|
325
325
|
config.parse!(['--color'])
|
326
326
|
end
|
327
327
|
|
328
328
|
it "should accept --no-color option" do
|
329
|
-
Term::ANSIColor.should_receive(:coloring=).with(false)
|
329
|
+
Cucumber::Term::ANSIColor.should_receive(:coloring=).with(false)
|
330
330
|
config = Configuration.new(StringIO.new)
|
331
331
|
config.parse!(['--no-color'])
|
332
332
|
end
|
@@ -404,14 +404,20 @@ END_OF_MESSAGE
|
|
404
404
|
end
|
405
405
|
|
406
406
|
describe "#tag_expression" do
|
407
|
+
include RSpec::WorkInProgress
|
408
|
+
|
407
409
|
it "returns an empty expression when no tags are specified" do
|
408
|
-
|
409
|
-
|
410
|
+
pending_under :java, 'the java class Gherkin::TagExpression has no isEmpty method' do
|
411
|
+
config.parse!([])
|
412
|
+
config.tag_expression.should be_empty
|
413
|
+
end
|
410
414
|
end
|
411
415
|
|
412
416
|
it "returns an expression when tags are specified" do
|
413
|
-
|
414
|
-
|
417
|
+
pending_under :java, 'the java class Gherkin::TagExpression has no isEmpty method' do
|
418
|
+
config.parse!(['--tags','@foo'])
|
419
|
+
config.tag_expression.should_not be_empty
|
420
|
+
end
|
415
421
|
end
|
416
422
|
end
|
417
423
|
|
@@ -47,7 +47,7 @@ module Cucumber
|
|
47
47
|
|
48
48
|
before(:each) do
|
49
49
|
b = Cucumber::Parser::GherkinBuilder.new
|
50
|
-
@empty_feature = b.feature(Gherkin::Formatter::Model::Feature.new([], [], "Feature", "Foo", "", 99))
|
50
|
+
@empty_feature = b.feature(Gherkin::Formatter::Model::Feature.new([], [], "Feature", "Foo", "", 99, ""))
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should show feature files parsed" do
|
@@ -95,7 +95,7 @@ module Cucumber
|
|
95
95
|
|
96
96
|
context "--drb" do
|
97
97
|
before(:each) do
|
98
|
-
@configuration = mock('Configuration', :drb? => true).as_null_object
|
98
|
+
@configuration = mock('Configuration', :drb? => true, :dotcucumber => false).as_null_object
|
99
99
|
Configuration.stub!(:new).and_return(@configuration)
|
100
100
|
|
101
101
|
@args = ['features']
|
@@ -55,14 +55,20 @@ module Cli
|
|
55
55
|
|
56
56
|
context '--i18n' do
|
57
57
|
context "with LANG specified as 'help'" do
|
58
|
+
include RSpec::WorkInProgress
|
59
|
+
|
58
60
|
it "lists all known langues" do
|
59
|
-
|
60
|
-
|
61
|
+
pending_under :java, "require gherkin >= b5e96f13" do
|
62
|
+
when_parsing '--i18n help' do
|
63
|
+
Kernel.should_receive(:exit)
|
64
|
+
end
|
61
65
|
end
|
62
66
|
end
|
63
67
|
|
64
68
|
it "exits the program" do
|
65
|
-
|
69
|
+
pending_under :java, "require gherkin >= b5e96f13" do
|
70
|
+
when_parsing('--i18n help') { Kernel.should_receive(:exit) }
|
71
|
+
end
|
66
72
|
end
|
67
73
|
end
|
68
74
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
describe Constantize do
|
5
|
+
include Constantize
|
6
|
+
|
7
|
+
it "loads html formatter" do
|
8
|
+
clazz = constantize('Cucumber::Formatter::Html')
|
9
|
+
clazz.name.should == 'Cucumber::Formatter::Html'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "fails to load a made up class" do
|
13
|
+
expect { constantize('My::MadeUp::ClassName') }.to raise_error(LoadError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -193,7 +193,7 @@ module Cucumber
|
|
193
193
|
|
194
194
|
describe "with a step that fails in the scenario" do
|
195
195
|
define_steps do
|
196
|
-
Given(/boo/) { raise 'eek' }
|
196
|
+
Given(/boo/) { raise StandardError, 'eek'.freeze }
|
197
197
|
end
|
198
198
|
|
199
199
|
define_feature(<<-FEATURE)
|
@@ -202,8 +202,9 @@ module Cucumber
|
|
202
202
|
Scenario: Monkey gets a fright
|
203
203
|
Given boo
|
204
204
|
FEATURE
|
205
|
-
|
206
|
-
it { @doc.should have_css_node('.feature .scenario .step.failed', /eek/) }
|
205
|
+
|
206
|
+
it { @doc.should have_css_node('.feature .scenario .step.failed .message', /eek/) }
|
207
|
+
it { @doc.should have_css_node('.feature .scenario .step.failed .message', /StandardError/) }
|
207
208
|
end
|
208
209
|
|
209
210
|
describe "with a step that fails in the backgound" do
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cucumber/formatter/interceptor'
|
3
|
+
|
4
|
+
module Cucumber::Formatter
|
5
|
+
describe Interceptor::Pipe do
|
6
|
+
let(:pipe) do
|
7
|
+
pipe = double('original pipe')
|
8
|
+
pipe.stub(:instance_of?).and_return(true)
|
9
|
+
pipe
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#wrap!' do
|
13
|
+
it 'should raise an ArgumentError if its not passed :stderr/:stdout' do
|
14
|
+
expect {
|
15
|
+
Interceptor::Pipe.wrap(:nonsense)
|
16
|
+
}.to raise_error(ArgumentError)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when passed :stderr' do
|
21
|
+
before :each do
|
22
|
+
@stderr = $stdout
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should wrap $stderr' do
|
26
|
+
wrapped = Interceptor::Pipe.wrap(:stderr)
|
27
|
+
$stderr.should be_instance_of Interceptor::Pipe
|
28
|
+
$stderr.should be wrapped
|
29
|
+
end
|
30
|
+
|
31
|
+
after :each do
|
32
|
+
$stderr = @stderr
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when passed :stdout' do
|
37
|
+
before :each do
|
38
|
+
@stdout = $stdout
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should wrap $stdout' do
|
42
|
+
wrapped = Interceptor::Pipe.wrap(:stdout)
|
43
|
+
$stdout.should be_instance_of Interceptor::Pipe
|
44
|
+
$stdout.should be wrapped
|
45
|
+
end
|
46
|
+
|
47
|
+
after :each do
|
48
|
+
$stdout = @stdout
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#unwrap!' do
|
54
|
+
before :each do
|
55
|
+
@stdout = $stdout
|
56
|
+
@wrapped = Interceptor::Pipe.wrap(:stdout)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should raise an ArgumentError if it wasn\'t passed :stderr/:stdout' do
|
60
|
+
expect {
|
61
|
+
Interceptor::Pipe.unwrap!(:nonsense)
|
62
|
+
}.to raise_error(ArgumentError)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should reset $stdout when #unwrap! is called' do
|
66
|
+
interceptor = Interceptor::Pipe.unwrap! :stdout
|
67
|
+
interceptor.should be_instance_of Interceptor::Pipe
|
68
|
+
$stdout.should_not be interceptor
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should disable the pipe bypass' do
|
72
|
+
buffer = '(::)'
|
73
|
+
Interceptor::Pipe.unwrap! :stdout
|
74
|
+
|
75
|
+
@wrapped.should_receive(:write).with(buffer)
|
76
|
+
@wrapped.buffer.should_not_receive(:<<)
|
77
|
+
@wrapped.write(buffer)
|
78
|
+
end
|
79
|
+
|
80
|
+
after :each do
|
81
|
+
$stdout = @stdout
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#write' do
|
86
|
+
let(:buffer) { 'Some stupid buffer' }
|
87
|
+
let(:pi) { Interceptor::Pipe.new(pipe) }
|
88
|
+
|
89
|
+
it 'should write arguments to the original pipe' do
|
90
|
+
pipe.should_receive(:write).with(buffer).and_return(buffer.size)
|
91
|
+
pi.write(buffer).should == buffer.size
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should add the buffer to its stored output' do
|
95
|
+
pipe.stub(:write)
|
96
|
+
pi.write(buffer)
|
97
|
+
pi.buffer.should_not be_empty
|
98
|
+
pi.buffer.first.should == buffer
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#method_missing' do
|
103
|
+
let(:pi) { Interceptor::Pipe.new(pipe) }
|
104
|
+
|
105
|
+
it 'should pass #tty? to the original pipe' do
|
106
|
+
pipe.should_receive(:tty?).and_return(true)
|
107
|
+
pi.tty?.should be true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -8,28 +8,28 @@ module Cucumber::Formatter
|
|
8
8
|
describe Junit do
|
9
9
|
extend SpecHelperDsl
|
10
10
|
include SpecHelper
|
11
|
-
|
11
|
+
|
12
12
|
class TestDoubleJunitFormatter < Junit
|
13
13
|
attr_reader :written_files
|
14
|
-
|
14
|
+
|
15
15
|
def write_file(feature_filename, data)
|
16
16
|
@written_files ||= {}
|
17
17
|
@written_files[feature_filename] = data
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
before(:each) do
|
22
22
|
File.stub!(:directory?).and_return(true)
|
23
23
|
@formatter = TestDoubleJunitFormatter.new(step_mother, '', {})
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
describe "a feature with no name" do
|
27
27
|
define_feature <<-FEATURE
|
28
28
|
Feature:
|
29
29
|
Scenario: Passing
|
30
30
|
Given a passing scenario
|
31
31
|
FEATURE
|
32
|
-
|
32
|
+
|
33
33
|
it "should raise an exception" do
|
34
34
|
lambda { run_defined_feature }.should raise_error(Junit::UnNamedFeatureError)
|
35
35
|
end
|
@@ -40,7 +40,7 @@ module Cucumber::Formatter
|
|
40
40
|
run_defined_feature
|
41
41
|
@doc = Nokogiri.XML(@formatter.written_files.values.first)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
describe "with a single scenario" do
|
45
45
|
define_feature <<-FEATURE
|
46
46
|
Feature: One passing scenario, one failing scenario
|
@@ -48,8 +48,24 @@ module Cucumber::Formatter
|
|
48
48
|
Scenario: Passing
|
49
49
|
Given a passing scenario
|
50
50
|
FEATURE
|
51
|
-
|
51
|
+
|
52
52
|
it { @doc.to_s.should =~ /One passing scenario, one failing scenario/ }
|
53
|
+
|
54
|
+
it 'should have a root system-out node' do
|
55
|
+
@doc.xpath('//testsuite/system-out').size.should == 1
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should have a root system-err node' do
|
59
|
+
@doc.xpath('//testsuite/system-err').size.should == 1
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should have a system-out node under <testcase/>' do
|
63
|
+
@doc.xpath('//testcase/system-out').size.should == 1
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have a system-err node under <testcase/>' do
|
67
|
+
@doc.xpath('//testcase/system-err').size.should == 1
|
68
|
+
end
|
53
69
|
end
|
54
70
|
|
55
71
|
describe "with a scenario in a subdirectory" do
|
@@ -64,12 +80,12 @@ module Cucumber::Formatter
|
|
64
80
|
@formatter.written_files.keys.first.should == File.join('', 'TEST-features-some-path-spec.xml')
|
65
81
|
end
|
66
82
|
end
|
67
|
-
|
83
|
+
|
68
84
|
describe "with a scenario outline table" do
|
69
85
|
define_steps do
|
70
86
|
Given(/.*/) { }
|
71
87
|
end
|
72
|
-
|
88
|
+
|
73
89
|
define_feature <<-FEATURE
|
74
90
|
Feature: Eat things when hungry
|
75
91
|
|
@@ -78,7 +94,7 @@ module Cucumber::Formatter
|
|
78
94
|
And stuff:
|
79
95
|
| foo |
|
80
96
|
| bar |
|
81
|
-
|
97
|
+
|
82
98
|
Examples: Good
|
83
99
|
| Things |
|
84
100
|
| Cucumber |
|
@@ -87,7 +103,7 @@ module Cucumber::Formatter
|
|
87
103
|
| Things |
|
88
104
|
| Big Mac |
|
89
105
|
FEATURE
|
90
|
-
|
106
|
+
|
91
107
|
it { @doc.to_s.should =~ /Eat things when hungry/ }
|
92
108
|
it { @doc.to_s.should =~ /Cucumber/ }
|
93
109
|
it { @doc.to_s.should =~ /Whisky/ }
|
@@ -96,25 +112,25 @@ module Cucumber::Formatter
|
|
96
112
|
it { @doc.to_s.should_not =~ /Good|Evil/ }
|
97
113
|
it { @doc.to_s.should_not =~ /type="skipped"/}
|
98
114
|
end
|
99
|
-
|
115
|
+
|
100
116
|
describe "with a regular data table scenario" do
|
101
117
|
define_steps do
|
102
|
-
Given(/the following items on a shortlist/) { |table| }
|
118
|
+
Given(/the following items on a shortlist/) { |table| }
|
103
119
|
When(/I go.*/) { }
|
104
|
-
Then(/I should have visited at least/) { |table| }
|
120
|
+
Then(/I should have visited at least/) { |table| }
|
105
121
|
end
|
106
|
-
|
122
|
+
|
107
123
|
define_feature <<-FEATURE
|
108
124
|
Feature: Shortlist
|
109
125
|
|
110
|
-
Scenario: Procure items
|
126
|
+
Scenario: Procure items
|
111
127
|
Given the following items on a shortlist:
|
112
|
-
| item |
|
113
|
-
| milk |
|
128
|
+
| item |
|
129
|
+
| milk |
|
114
130
|
| cookies |
|
115
131
|
When I get some..
|
116
132
|
Then I'll eat 'em
|
117
|
-
|
133
|
+
|
118
134
|
FEATURE
|
119
135
|
# these type of tables shouldn't crash (or generate test cases)
|
120
136
|
it { @doc.to_s.should_not =~ /milk/ }
|
@@ -122,4 +138,4 @@ module Cucumber::Formatter
|
|
122
138
|
end
|
123
139
|
end
|
124
140
|
end
|
125
|
-
end
|
141
|
+
end
|
@@ -6,7 +6,7 @@ module Cucumber
|
|
6
6
|
describe Progress do
|
7
7
|
|
8
8
|
before(:each) do
|
9
|
-
Term::ANSIColor.coloring = false
|
9
|
+
Cucumber::Term::ANSIColor.coloring = false
|
10
10
|
@out = StringIO.new
|
11
11
|
progress = Cucumber::Formatter::Progress.new(mock("step mother"), @out, {})
|
12
12
|
@visitor = Cucumber::Ast::TreeWalker.new(nil, [progress])
|
@@ -14,7 +14,7 @@ module Cucumber
|
|
14
14
|
|
15
15
|
describe "visiting a table cell value without a status" do
|
16
16
|
it "should take the status from the last run step" do
|
17
|
-
@visitor.visit_step_result('', '', nil, :failed, nil, 10, nil)
|
17
|
+
@visitor.visit_step_result('', '', nil, :failed, nil, 10, nil, nil)
|
18
18
|
outline_table = mock()
|
19
19
|
outline_table.should_receive(:accept) do |visitor|
|
20
20
|
visitor.visit_table_cell_value('value', nil)
|
@@ -31,7 +31,7 @@ module Cucumber
|
|
31
31
|
|
32
32
|
it "should recognise a mix of ints, strings and why not a table too" do
|
33
33
|
rb.snippet_text('Given', 'I have 9 "awesome" cukes in 37 "boxes"', Cucumber::Ast::Table).should == unindented(%{
|
34
|
-
Given /^I have (\\d+) "(
|
34
|
+
Given /^I have (\\d+) "(.*?)" cukes in (\\d+) "(.*?)"$/ do |arg1, arg2, arg3, arg4, table|
|
35
35
|
# table is a Cucumber::Ast::Table
|
36
36
|
pending # express the regexp above with the code you wish you had
|
37
37
|
end
|
@@ -40,7 +40,7 @@ module Cucumber
|
|
40
40
|
|
41
41
|
it "should recognise quotes in name and make according regexp" do
|
42
42
|
rb.snippet_text('Given', 'A "first" arg', nil).should == unindented(%{
|
43
|
-
Given /^A "(
|
43
|
+
Given /^A "(.*?)" arg$/ do |arg1|
|
44
44
|
pending # express the regexp above with the code you wish you had
|
45
45
|
end
|
46
46
|
})
|
@@ -48,7 +48,7 @@ module Cucumber
|
|
48
48
|
|
49
49
|
it "should recognise several quoted words in name and make according regexp and args" do
|
50
50
|
rb.snippet_text('Given', 'A "first" and "second" arg', nil).should == unindented(%{
|
51
|
-
Given /^A "(
|
51
|
+
Given /^A "(.*?)" and "(.*?)" arg$/ do |arg1, arg2|
|
52
52
|
pending # express the regexp above with the code you wish you had
|
53
53
|
end
|
54
54
|
})
|
@@ -64,7 +64,7 @@ module Cucumber
|
|
64
64
|
|
65
65
|
it "should be helpful with tables" do
|
66
66
|
rb.snippet_text('Given', 'A "first" arg', Cucumber::Ast::Table).should == unindented(%{
|
67
|
-
Given /^A "(
|
67
|
+
Given /^A "(.*?)" arg$/ do |arg1, table|
|
68
68
|
# table is a Cucumber::Ast::Table
|
69
69
|
pending # express the regexp above with the code you wish you had
|
70
70
|
end
|
@@ -279,4 +279,4 @@ or http://wiki.github.com/cucumber/cucumber/a-whole-new-world.
|
|
279
279
|
|
280
280
|
end
|
281
281
|
end
|
282
|
-
end
|
282
|
+
end
|
@@ -22,7 +22,7 @@ module Cucumber
|
|
22
22
|
|
23
23
|
it "should allow calling of other steps" do
|
24
24
|
dsl.Given /Outside/ do
|
25
|
-
|
25
|
+
step "Inside"
|
26
26
|
end
|
27
27
|
dsl.Given /Inside/ do
|
28
28
|
$inside = true
|
@@ -34,7 +34,7 @@ module Cucumber
|
|
34
34
|
|
35
35
|
it "should allow calling of other steps with inline arg" do
|
36
36
|
dsl.Given /Outside/ do
|
37
|
-
|
37
|
+
step "Inside", Cucumber::Ast::Table.new([['inside']])
|
38
38
|
end
|
39
39
|
dsl.Given /Inside/ do |table|
|
40
40
|
$inside = table.raw[0][0]
|
@@ -44,9 +44,25 @@ module Cucumber
|
|
44
44
|
$inside.should == 'inside'
|
45
45
|
end
|
46
46
|
|
47
|
+
it "should call a method on the world when specified with a symbol" do
|
48
|
+
rb.current_world.should_receive(:with_symbol)
|
49
|
+
dsl.Given /With symbol/, :with_symbol
|
50
|
+
|
51
|
+
support_code.step_match("With symbol").invoke(nil)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should call a method on a specified object" do
|
55
|
+
target = double('target')
|
56
|
+
target.should_receive(:with_symbol)
|
57
|
+
rb.current_world.stub!(:target).and_return(target)
|
58
|
+
dsl.Given /With symbol on block/, :with_symbol, :on => lambda { target }
|
59
|
+
|
60
|
+
support_code.step_match("With symbol on block").invoke(nil)
|
61
|
+
end
|
62
|
+
|
47
63
|
it "should raise Undefined when inside step is not defined" do
|
48
64
|
dsl.Given /Outside/ do
|
49
|
-
|
65
|
+
step 'Inside'
|
50
66
|
end
|
51
67
|
|
52
68
|
lambda do
|
@@ -91,7 +107,7 @@ module Cucumber
|
|
91
107
|
end
|
92
108
|
|
93
109
|
it "should have a JSON representation of the signature" do
|
94
|
-
RbStepDefinition.new(rb, /I CAN HAZ (\d+) CUKES/i, lambda{}).to_hash.should == {'source' => "I CAN HAZ (\\d+) CUKES", 'flags' => 'i'}
|
110
|
+
RbStepDefinition.new(rb, /I CAN HAZ (\d+) CUKES/i, lambda{}, {}).to_hash.should == {'source' => "I CAN HAZ (\\d+) CUKES", 'flags' => 'i'}
|
95
111
|
end
|
96
112
|
end
|
97
113
|
end
|
@@ -8,8 +8,12 @@ module Cucumber
|
|
8
8
|
RbTransform.new(nil, regexp, lambda { |a| })
|
9
9
|
end
|
10
10
|
describe "#to_s" do
|
11
|
-
it "
|
12
|
-
transform(/(a)bc/).to_s.should == "
|
11
|
+
it "converts captures groups to non-capture groups" do
|
12
|
+
transform(/(a|b)bc/).to_s.should == "(?:a|b)bc"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "leaves non capture groups alone" do
|
16
|
+
transform(/(?:a|b)bc/).to_s.should == "(?:a|b)bc"
|
13
17
|
end
|
14
18
|
|
15
19
|
it "strips away anchors" do
|
@@ -4,14 +4,18 @@ require 'cucumber/rb_support/regexp_argument_matcher'
|
|
4
4
|
module Cucumber
|
5
5
|
module RbSupport
|
6
6
|
describe RegexpArgumentMatcher do
|
7
|
+
include RSpec::WorkInProgress
|
8
|
+
|
7
9
|
it "should create 2 arguments" do
|
8
10
|
arguments = RegexpArgumentMatcher.arguments_from(/I (\w+) (\w+)/, "I like fish")
|
9
|
-
arguments.map{|argument| [argument.val, argument.
|
11
|
+
arguments.map{|argument| [argument.val, argument.offset]}.should == [["like", 2], ["fish", 7]]
|
10
12
|
end
|
11
13
|
|
12
14
|
it "should create 2 arguments when first group is optional" do
|
13
|
-
|
14
|
-
|
15
|
+
pending_under :java, "requires cucumber/gherkin >= ac42f51" do
|
16
|
+
arguments = RegexpArgumentMatcher.arguments_from(/should( not)? be flashed '([^']*?)'$/, "I should be flashed 'Login failed.'")
|
17
|
+
arguments.map{|argument| [argument.val, argument.offset]}.should == [[nil, nil], ["Login failed.", 21]]
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
describe Runtime::Results do
|
5
|
+
|
6
|
+
let(:configuration) {double 'Configuration', :strict? => false}
|
7
|
+
let(:passed_scenario) {double 'Scenario', :status => :passed}
|
8
|
+
let(:failed_scenario) {double 'Scenario', :status => :failed}
|
9
|
+
let(:passed_step) {double 'Step', :status => :passed}
|
10
|
+
let(:failed_step) {double 'Step', :status => :failed}
|
11
|
+
let(:pending_step) {double 'Step', :status => :pending}
|
12
|
+
let(:undefined_step) {double 'Step', :status => :undefined}
|
13
|
+
|
14
|
+
subject {described_class.new(configuration)}
|
15
|
+
|
16
|
+
describe '#failure?' do
|
17
|
+
context 'feature is not work in progress' do
|
18
|
+
before do
|
19
|
+
configuration.stub(:wip? => false)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should return true if a scenario failed' do
|
23
|
+
subject.scenario_visited(passed_scenario)
|
24
|
+
subject.scenario_visited(failed_scenario)
|
25
|
+
subject.should be_failure
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return true if a step failed' do
|
29
|
+
subject.step_visited(failed_step)
|
30
|
+
subject.should be_failure
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should return false if there are no scenarios' do
|
34
|
+
subject.should_not be_failure
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return false if all scenarios passed' do
|
38
|
+
subject.scenario_visited(passed_scenario)
|
39
|
+
subject.scenario_visited(passed_scenario)
|
40
|
+
subject.should_not be_failure
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'configuration is strict' do
|
44
|
+
before do
|
45
|
+
configuration.stub(:strict? => true)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should return true if a step is pending' do
|
49
|
+
subject.step_visited(pending_step)
|
50
|
+
subject.should be_failure
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should return true if a step is undefined' do
|
54
|
+
subject.step_visited(undefined_step)
|
55
|
+
subject.should be_failure
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'feature is work in progress' do
|
61
|
+
before do
|
62
|
+
configuration.stub(:wip? => true)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should return true if a scenario passed' do
|
66
|
+
subject.scenario_visited(passed_scenario)
|
67
|
+
subject.should be_failure
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should return false if there are no scenarios' do
|
71
|
+
subject.should_not be_failure
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should return false if all scenarios fail' do
|
75
|
+
subject.scenario_visited(failed_scenario)
|
76
|
+
subject.should_not be_failure
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -5,6 +5,8 @@ require 'cucumber/rb_support/rb_language'
|
|
5
5
|
|
6
6
|
module Cucumber
|
7
7
|
describe StepMatch do
|
8
|
+
include RSpec::WorkInProgress
|
9
|
+
|
8
10
|
WORD = Cucumber::RUBY_1_9 ? '[[:word:]]' : '\w'
|
9
11
|
|
10
12
|
before do
|
@@ -12,7 +14,7 @@ module Cucumber
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def stepdef(regexp)
|
15
|
-
RbSupport::RbStepDefinition.new(@rb_language, regexp, lambda{})
|
17
|
+
RbSupport::RbStepDefinition.new(@rb_language, regexp, lambda{}, {})
|
16
18
|
end
|
17
19
|
|
18
20
|
def step_match(regexp, name)
|
@@ -57,8 +59,10 @@ module Cucumber
|
|
57
59
|
end
|
58
60
|
|
59
61
|
it "should format groups even when first group is optional and not matched" do
|
60
|
-
|
61
|
-
|
62
|
+
pending_under :java, "requires cucumber/gherkin >= ac42f51" do
|
63
|
+
m = step_match(/should( not)? be flashed '([^']*?)'$/, "I should be flashed 'Login failed.'")
|
64
|
+
m.format_args("<span>%s</span>").should == "I should be flashed '<span>Login failed.</span>'"
|
65
|
+
end
|
62
66
|
end
|
63
67
|
|
64
68
|
it "should format embedded groups" do
|
@@ -66,4 +70,4 @@ module Cucumber
|
|
66
70
|
m.format_args("<span>%s</span>").should == "running<span> 5 times</span> <span>10</span> meters"
|
67
71
|
end
|
68
72
|
end
|
69
|
-
end
|
73
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,6 +17,20 @@ $KCODE='u' unless Cucumber::RUBY_1_9
|
|
17
17
|
|
18
18
|
RSpec.configure do |c|
|
19
19
|
c.before do
|
20
|
-
::Term::ANSIColor.coloring = true
|
20
|
+
::Cucumber::Term::ANSIColor.coloring = true
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
module RSpec
|
25
|
+
module WorkInProgress
|
26
|
+
def pending_under platforms, reason, &block
|
27
|
+
if [platforms].flatten.map(&:to_s).include? RUBY_PLATFORM
|
28
|
+
pending "pending under #{platforms.inspect} because: #{reason}", &block
|
29
|
+
else
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|