cucumber 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/.travis.yml +3 -2
- data/DEVELOPERS.md +48 -0
- data/History.md +22 -3
- data/README.md +13 -31
- data/Rakefile +1 -0
- data/cucumber.gemspec +18 -17
- data/cucumber.yml +3 -2
- data/examples/i18n/cs/Rakefile +6 -0
- data/examples/i18n/cs/features/addition.feature +17 -0
- data/examples/i18n/cs/features/division.feature +11 -0
- data/examples/i18n/cs/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/cs/lib/calculator.rb +14 -0
- data/examples/i18n/hi/Rakefile +6 -0
- data/examples/i18n/hi/features/addition.feature +16 -0
- data/examples/i18n/hi/features/division.feature +10 -0
- data/examples/i18n/hi/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/hi/lib/calculator.rb +15 -0
- data/examples/python/README.textile +2 -1
- data/examples/ruby2python/README.textile +2 -1
- data/features/.cucumber/stepdefs.json +1688 -445
- data/features/assertions.feature +69 -0
- data/features/formatter_callbacks.feature +189 -0
- data/features/html_formatter.feature +19 -0
- data/features/json_formatter.feature +8 -4
- data/features/nested_steps_with_second_arg.feature +73 -0
- data/features/step_definitions.feature +65 -0
- data/features/step_definitions/cucumber_steps.rb +18 -3
- data/fixtures/self_test/features/support/env.rb +1 -1
- data/gem_tasks/cucumber.rake +5 -3
- data/gem_tasks/downloads.rb +3 -3
- data/gem_tasks/stats +4 -2
- data/gem_tasks/yard.rake +31 -13
- data/legacy_features/default_snippets.feature +3 -3
- data/legacy_features/language_help.feature +4 -0
- data/legacy_features/report_called_undefined_steps.feature +1 -1
- data/legacy_features/snippet.feature +3 -3
- data/legacy_features/snippets_when_using_star_keyword.feature +1 -1
- data/legacy_features/step_definitions/cucumber_steps.rb +4 -3
- data/legacy_features/support/env.rb +1 -1
- data/legacy_features/support/fake_wire_server.rb +9 -9
- data/lib/autotest/cucumber_mixin.rb +14 -14
- data/lib/autotest/discover.rb +2 -0
- data/lib/cucumber.rb +2 -2
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +11 -7
- data/lib/cucumber/ast/comment.rb +2 -2
- data/lib/cucumber/ast/doc_string.rb +1 -1
- data/lib/cucumber/ast/examples.rb +1 -1
- data/lib/cucumber/ast/feature.rb +2 -2
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/multiline_argument.rb +2 -2
- data/lib/cucumber/ast/names.rb +2 -2
- data/lib/cucumber/ast/outline_table.rb +4 -5
- data/lib/cucumber/ast/scenario.rb +14 -14
- data/lib/cucumber/ast/scenario_outline.rb +4 -4
- data/lib/cucumber/ast/step.rb +3 -3
- data/lib/cucumber/ast/step_collection.rb +5 -5
- data/lib/cucumber/ast/step_invocation.rb +8 -8
- data/lib/cucumber/ast/table.rb +40 -27
- data/lib/cucumber/ast/tree_walker.rb +9 -8
- data/lib/cucumber/ast/visitor.rb +1 -1
- data/lib/cucumber/cli/configuration.rb +10 -10
- data/lib/cucumber/cli/drb_client.rb +1 -1
- data/lib/cucumber/cli/main.rb +3 -3
- data/lib/cucumber/cli/options.rb +3 -2
- data/lib/cucumber/cli/profile_loader.rb +1 -1
- data/lib/cucumber/configuration.rb +12 -12
- data/lib/cucumber/constantize.rb +11 -2
- data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +1 -1
- data/lib/cucumber/core_ext/instance_exec.rb +4 -4
- data/lib/cucumber/core_ext/proc.rb +3 -3
- data/lib/cucumber/errors.rb +1 -1
- data/lib/cucumber/feature_file.rb +1 -1
- data/lib/cucumber/formatter/ansicolor.rb +36 -23
- data/lib/cucumber/formatter/console.rb +45 -25
- data/lib/cucumber/formatter/debug.rb +7 -7
- data/lib/cucumber/formatter/duration.rb +1 -1
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +7 -0
- data/lib/cucumber/formatter/gpretty.rb +1 -1
- data/lib/cucumber/formatter/html.rb +52 -53
- data/lib/cucumber/formatter/interceptor.rb +2 -2
- data/lib/cucumber/formatter/json.rb +1 -1
- data/lib/cucumber/formatter/json_pretty.rb +2 -1
- data/lib/cucumber/formatter/junit.rb +1 -1
- data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +12 -12
- data/lib/cucumber/formatter/progress.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +5 -5
- data/lib/cucumber/formatter/stepdefs.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +6 -6
- data/lib/cucumber/formatter/summary.rb +6 -6
- data/lib/cucumber/formatter/unicode.rb +18 -18
- data/lib/cucumber/formatter/usage.rb +7 -7
- data/lib/cucumber/js_support/js_dsl.js +1 -1
- data/lib/cucumber/language_support.rb +1 -1
- data/lib/cucumber/parser/gherkin_builder.rb +33 -33
- data/lib/cucumber/platform.rb +3 -2
- data/lib/cucumber/py_support/py_dsl.py +2 -2
- data/lib/cucumber/py_support/py_language.py +2 -2
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +4 -3
- data/lib/cucumber/rb_support/rb_dsl.rb +10 -10
- data/lib/cucumber/rb_support/rb_language.rb +27 -19
- data/lib/cucumber/rb_support/rb_step_definition.rb +39 -11
- data/lib/cucumber/rb_support/rb_transform.rb +3 -3
- data/lib/cucumber/rb_support/rb_world.rb +15 -15
- data/lib/cucumber/rb_support/regexp_argument_matcher.rb +1 -1
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
- data/lib/cucumber/rspec/doubles.rb +1 -1
- data/lib/cucumber/runtime.rb +11 -10
- data/lib/cucumber/runtime/features_loader.rb +6 -6
- data/lib/cucumber/runtime/for_programming_languages.rb +8 -15
- data/lib/cucumber/runtime/results.rb +6 -6
- data/lib/cucumber/runtime/support_code.rb +37 -28
- data/lib/cucumber/runtime/user_interface.rb +4 -4
- data/lib/cucumber/step_definition_light.rb +4 -4
- data/lib/cucumber/step_definitions.rb +2 -3
- data/lib/cucumber/step_match.rb +6 -6
- data/lib/cucumber/step_mother.rb +1 -1
- data/lib/cucumber/term/ansicolor.rb +22 -22
- data/lib/cucumber/wire_support/configuration.rb +11 -14
- data/lib/cucumber/wire_support/connection.rb +10 -9
- data/lib/cucumber/wire_support/request_handler.rb +3 -3
- data/lib/cucumber/wire_support/wire_exception.rb +3 -3
- data/lib/cucumber/wire_support/wire_language.rb +11 -11
- data/lib/cucumber/wire_support/wire_packet.rb +7 -5
- data/lib/cucumber/wire_support/wire_protocol.rb +6 -6
- data/lib/cucumber/wire_support/wire_protocol/requests.rb +20 -20
- data/lib/cucumber/wire_support/wire_step_definition.rb +4 -4
- data/spec/cucumber/ast/background_spec.rb +4 -4
- data/spec/cucumber/ast/doc_string_spec.rb +8 -8
- data/spec/cucumber/ast/feature_factory.rb +4 -4
- data/spec/cucumber/ast/feature_spec.rb +18 -18
- data/spec/cucumber/ast/outline_table_spec.rb +3 -3
- data/spec/cucumber/ast/step_spec.rb +4 -4
- data/spec/cucumber/ast/table_spec.rb +50 -29
- data/spec/cucumber/ast/tree_walker_spec.rb +12 -4
- data/spec/cucumber/broadcaster_spec.rb +1 -1
- data/spec/cucumber/cli/configuration_spec.rb +10 -4
- data/spec/cucumber/cli/drb_client_spec.rb +1 -1
- data/spec/cucumber/cli/main_spec.rb +28 -7
- data/spec/cucumber/cli/options_spec.rb +3 -3
- data/spec/cucumber/configuration_spec.rb +4 -4
- data/spec/cucumber/constantize_spec.rb +2 -0
- data/spec/cucumber/core_ext/proc_spec.rb +7 -7
- data/spec/cucumber/formatter/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/duration_spec.rb +2 -2
- data/spec/cucumber/formatter/html_spec.rb +31 -31
- data/spec/cucumber/formatter/interceptor_spec.rb +10 -0
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +7 -7
- data/spec/cucumber/rake/forked_spec.rb +15 -2
- data/spec/cucumber/rake/rcov_spec.rb +2 -2
- data/spec/cucumber/rb_support/rb_language_spec.rb +34 -17
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +45 -35
- data/spec/cucumber/rb_support/rb_transform_spec.rb +3 -3
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +31 -0
- data/spec/cucumber/runtime/results_spec.rb +5 -5
- data/spec/cucumber/runtime/support_code_spec.rb +13 -2
- data/spec/cucumber/runtime_spec.rb +7 -7
- data/spec/cucumber/step_match_spec.rb +2 -2
- data/spec/cucumber/wire_support/configuration_spec.rb +16 -6
- data/spec/cucumber/wire_support/connection_spec.rb +25 -11
- data/spec/cucumber/wire_support/wire_exception_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_language_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_packet_spec.rb +4 -4
- data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +98 -128
- data/legacy_features/html_formatter.feature +0 -8
- data/legacy_features/html_formatter/a.html +0 -561
@@ -68,6 +68,16 @@ module Cucumber::Formatter
|
|
68
68
|
$stdout.should_not be interceptor
|
69
69
|
end
|
70
70
|
|
71
|
+
it 'should noop if $stdout or $stderr has been overwritten' do
|
72
|
+
$stdout = StringIO.new
|
73
|
+
pipe = Interceptor::Pipe.unwrap! :stdout
|
74
|
+
pipe.should == $stdout
|
75
|
+
|
76
|
+
$stderr = StringIO.new
|
77
|
+
pipe = Interceptor::Pipe.unwrap! :stderr
|
78
|
+
pipe.should == $stderr
|
79
|
+
end
|
80
|
+
|
71
81
|
it 'should disable the pipe bypass' do
|
72
82
|
buffer = '(::)'
|
73
83
|
Interceptor::Pipe.unwrap! :stdout
|
@@ -11,7 +11,7 @@ module Cucumber
|
|
11
11
|
progress = Cucumber::Formatter::Progress.new(mock("step mother"), @out, {})
|
12
12
|
@visitor = Cucumber::Ast::TreeWalker.new(nil, [progress])
|
13
13
|
end
|
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
17
|
@visitor.visit_step_result('', '', nil, :failed, nil, 10, nil, nil)
|
@@ -3,12 +3,12 @@ module Cucumber
|
|
3
3
|
|
4
4
|
module SpecHelperDsl
|
5
5
|
attr_reader :feature_content, :step_defs, :feature_filename
|
6
|
-
|
6
|
+
|
7
7
|
def define_feature(string, feature_file = 'spec.feature')
|
8
8
|
@feature_content = string
|
9
9
|
@feature_filename = feature_file
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def define_steps(&block)
|
13
13
|
@step_defs = block
|
14
14
|
end
|
@@ -20,11 +20,11 @@ module Cucumber
|
|
20
20
|
features = load_features(self.class.feature_content || raise("No feature content defined!"))
|
21
21
|
run(features)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def step_mother
|
25
25
|
@step_mother ||= Runtime.new
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def load_features(content)
|
29
29
|
feature_file = FeatureFile.new(self.class.feature_filename, content)
|
30
30
|
features = Ast::Features.new
|
@@ -33,20 +33,20 @@ module Cucumber
|
|
33
33
|
features.add_feature(feature) if feature
|
34
34
|
features
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def run(features)
|
38
38
|
configuration = Cucumber::Configuration.default
|
39
39
|
tree_walker = Cucumber::Ast::TreeWalker.new(step_mother, [@formatter], configuration)
|
40
40
|
tree_walker.visit_features(features)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def define_steps
|
44
44
|
return unless step_defs = self.class.step_defs
|
45
45
|
rb = step_mother.load_programming_language('rb')
|
46
46
|
dsl = Object.new
|
47
47
|
dsl.extend RbSupport::RbDsl
|
48
48
|
dsl.instance_exec &step_defs
|
49
|
-
end
|
49
|
+
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -24,9 +24,22 @@ module Cucumber
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "uses bundle exec to find cucumber and libraries" do
|
27
|
+
bundle_cmd = Gem.default_exec_format % 'bundle'
|
28
|
+
|
29
|
+
subject.cmd.should == [Cucumber::RUBY_BINARY,
|
30
|
+
'-S',
|
31
|
+
bundle_cmd,
|
32
|
+
'exec',
|
33
|
+
'cucumber',
|
34
|
+
'--cuke-option'] + feature_files
|
35
|
+
end
|
36
|
+
|
37
|
+
it "obeys program suffix for bundler" do
|
38
|
+
Gem::ConfigMap.stub(:[]).with(:ruby_install_name).and_return('XrubyY')
|
39
|
+
|
27
40
|
subject.cmd.should == [Cucumber::RUBY_BINARY,
|
28
41
|
'-S',
|
29
|
-
'
|
42
|
+
'XbundleY',
|
30
43
|
'exec',
|
31
44
|
'cucumber',
|
32
45
|
'--cuke-option'] + feature_files
|
@@ -59,4 +72,4 @@ module Cucumber
|
|
59
72
|
end
|
60
73
|
|
61
74
|
end
|
62
|
-
end
|
75
|
+
end
|
@@ -10,7 +10,7 @@ module Cucumber
|
|
10
10
|
let(:support_code) do
|
11
11
|
Cucumber::Runtime::SupportCode.new(user_interface, {})
|
12
12
|
end
|
13
|
-
let(:dsl) do
|
13
|
+
let(:dsl) do
|
14
14
|
rb
|
15
15
|
Object.new.extend(RbSupport::RbDsl)
|
16
16
|
end
|
@@ -18,12 +18,20 @@ module Cucumber
|
|
18
18
|
def unindented(s)
|
19
19
|
s.split("\n")[1..-2].join("\n").indent(-10)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
describe "snippets" do
|
23
|
-
|
23
|
+
|
24
|
+
it "should wrap snippet patterns in parentheses" do
|
25
|
+
rb.snippet_text('Given', 'A "string" with 4 spaces', nil).should == unindented(%{
|
26
|
+
Given(/^A "(.*?)" with (\\d+) spaces$/) do |arg1, arg2|
|
27
|
+
pending # express the regexp above with the code you wish you had
|
28
|
+
end
|
29
|
+
})
|
30
|
+
end
|
31
|
+
|
24
32
|
it "should recognise numbers in name and make according regexp" do
|
25
33
|
rb.snippet_text('Given', 'Cloud 9 yeah', nil).should == unindented(%{
|
26
|
-
Given
|
34
|
+
Given(/^Cloud (\\d+) yeah$/) do |arg1|
|
27
35
|
pending # express the regexp above with the code you wish you had
|
28
36
|
end
|
29
37
|
})
|
@@ -31,7 +39,7 @@ module Cucumber
|
|
31
39
|
|
32
40
|
it "should recognise a mix of ints, strings and why not a table too" do
|
33
41
|
rb.snippet_text('Given', 'I have 9 "awesome" cukes in 37 "boxes"', Cucumber::Ast::Table).should == unindented(%{
|
34
|
-
Given
|
42
|
+
Given(/^I have (\\d+) "(.*?)" cukes in (\\d+) "(.*?)"$/) do |arg1, arg2, arg3, arg4, table|
|
35
43
|
# table is a Cucumber::Ast::Table
|
36
44
|
pending # express the regexp above with the code you wish you had
|
37
45
|
end
|
@@ -40,7 +48,7 @@ module Cucumber
|
|
40
48
|
|
41
49
|
it "should recognise quotes in name and make according regexp" do
|
42
50
|
rb.snippet_text('Given', 'A "first" arg', nil).should == unindented(%{
|
43
|
-
Given
|
51
|
+
Given(/^A "(.*?)" arg$/) do |arg1|
|
44
52
|
pending # express the regexp above with the code you wish you had
|
45
53
|
end
|
46
54
|
})
|
@@ -48,15 +56,15 @@ module Cucumber
|
|
48
56
|
|
49
57
|
it "should recognise several quoted words in name and make according regexp and args" do
|
50
58
|
rb.snippet_text('Given', 'A "first" and "second" arg', nil).should == unindented(%{
|
51
|
-
Given
|
59
|
+
Given(/^A "(.*?)" and "(.*?)" arg$/) do |arg1, arg2|
|
52
60
|
pending # express the regexp above with the code you wish you had
|
53
61
|
end
|
54
62
|
})
|
55
63
|
end
|
56
|
-
|
64
|
+
|
57
65
|
it "should not use quote group when there are no quotes" do
|
58
66
|
rb.snippet_text('Given', 'A first arg', nil).should == unindented(%{
|
59
|
-
Given
|
67
|
+
Given(/^A first arg$/) do
|
60
68
|
pending # express the regexp above with the code you wish you had
|
61
69
|
end
|
62
70
|
})
|
@@ -64,38 +72,38 @@ module Cucumber
|
|
64
72
|
|
65
73
|
it "should be helpful with tables" do
|
66
74
|
rb.snippet_text('Given', 'A "first" arg', Cucumber::Ast::Table).should == unindented(%{
|
67
|
-
Given
|
75
|
+
Given(/^A "(.*?)" arg$/) do |arg1, table|
|
68
76
|
# table is a Cucumber::Ast::Table
|
69
77
|
pending # express the regexp above with the code you wish you had
|
70
78
|
end
|
71
79
|
})
|
72
80
|
end
|
73
|
-
|
81
|
+
|
74
82
|
end
|
75
|
-
|
83
|
+
|
76
84
|
describe "#load_code_file" do
|
77
85
|
after do
|
78
86
|
FileUtils.rm_rf('tmp.rb')
|
79
87
|
end
|
80
|
-
|
88
|
+
|
81
89
|
def a_file_called(name)
|
82
90
|
File.open('tmp.rb', 'w') do |f|
|
83
91
|
f.puts yield
|
84
92
|
end
|
85
93
|
end
|
86
|
-
|
94
|
+
|
87
95
|
it "re-loads the file when called multiple times" do
|
88
96
|
a_file_called('tmp.rb') do
|
89
97
|
"$foo = 1"
|
90
98
|
end
|
91
|
-
|
99
|
+
|
92
100
|
rb.load_code_file('tmp.rb')
|
93
101
|
$foo.should == 1
|
94
|
-
|
102
|
+
|
95
103
|
a_file_called('tmp.rb') do
|
96
104
|
"$foo = 2"
|
97
105
|
end
|
98
|
-
|
106
|
+
|
99
107
|
rb.load_code_file('tmp.rb')
|
100
108
|
$foo.should == 2
|
101
109
|
end
|
@@ -189,6 +197,15 @@ or http://wiki.github.com/cucumber/cucumber/a-whole-new-world.
|
|
189
197
|
rb.execute_transforms(['abc']).should == [42]
|
190
198
|
rb.execute_transforms(['abbc']).should == [42]
|
191
199
|
end
|
200
|
+
|
201
|
+
it "transforms times" do
|
202
|
+
require 'time'
|
203
|
+
dsl.Transform(/^(\d\d-\d\d-\d\d\d\d)$/) do |arg|
|
204
|
+
Time.parse(arg)
|
205
|
+
end
|
206
|
+
rb.execute_transforms(['10-0E-1971']).should == ['10-0E-1971']
|
207
|
+
rb.execute_transforms(['10-03-1971']).should == [Time.parse('10-03-1971')]
|
208
|
+
end
|
192
209
|
end
|
193
210
|
|
194
211
|
describe "with capture groups" do
|
@@ -7,19 +7,22 @@ module Cucumber
|
|
7
7
|
module RbSupport
|
8
8
|
describe RbStepDefinition do
|
9
9
|
let(:user_interface) { double('user interface') }
|
10
|
-
let(:support_code)
|
11
|
-
let(:rb)
|
12
|
-
let(:dsl) do
|
10
|
+
let(:support_code) { Cucumber::Runtime::SupportCode.new(user_interface) }
|
11
|
+
let(:rb) { support_code.load_programming_language('rb') }
|
12
|
+
let(:dsl) do
|
13
13
|
rb
|
14
14
|
Object.new.extend(Cucumber::RbSupport::RbDsl)
|
15
15
|
end
|
16
|
-
|
17
|
-
before do
|
18
|
-
rb.before(mock('scenario').as_null_object)
|
19
16
|
|
17
|
+
before do
|
18
|
+
rb.before(mock('scenario').as_null_object)
|
20
19
|
$inside = nil
|
21
20
|
end
|
22
|
-
|
21
|
+
|
22
|
+
def run_step(text)
|
23
|
+
support_code.step_match(text).invoke(nil)
|
24
|
+
end
|
25
|
+
|
23
26
|
it "should allow calling of other steps" do
|
24
27
|
dsl.Given /Outside/ do
|
25
28
|
step "Inside"
|
@@ -28,7 +31,7 @@ module Cucumber
|
|
28
31
|
$inside = true
|
29
32
|
end
|
30
33
|
|
31
|
-
|
34
|
+
run_step "Outside"
|
32
35
|
$inside.should == true
|
33
36
|
end
|
34
37
|
|
@@ -40,24 +43,35 @@ module Cucumber
|
|
40
43
|
$inside = table.raw[0][0]
|
41
44
|
end
|
42
45
|
|
43
|
-
|
46
|
+
run_step "Outside"
|
44
47
|
$inside.should == 'inside'
|
45
48
|
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
context "mapping to world methods" do
|
51
|
+
it "should call a method on the world when specified with a symbol" do
|
52
|
+
rb.current_world.should_receive(:with_symbol)
|
53
|
+
dsl.Given /With symbol/, :with_symbol
|
50
54
|
|
51
|
-
|
52
|
-
|
55
|
+
run_step "With symbol"
|
56
|
+
end
|
53
57
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
dsl.Given /With symbol on block/, :with_symbol, :on => lambda { target }
|
58
|
+
it "should call a method on a specified object" do
|
59
|
+
target = double('target')
|
60
|
+
rb.current_world.stub(:target => target)
|
61
|
+
dsl.Given /With symbol on block/, :with_symbol, :on => lambda { target }
|
59
62
|
|
60
|
-
|
63
|
+
target.should_receive(:with_symbol)
|
64
|
+
run_step "With symbol on block"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should call a method on a specified world attribute" do
|
68
|
+
target = double('target')
|
69
|
+
rb.current_world.stub(:target => target)
|
70
|
+
dsl.Given /With symbol on symbol/, :with_symbol, :on => :target
|
71
|
+
|
72
|
+
target.should_receive(:with_symbol)
|
73
|
+
run_step "With symbol on symbol"
|
74
|
+
end
|
61
75
|
end
|
62
76
|
|
63
77
|
it "should raise Undefined when inside step is not defined" do
|
@@ -65,9 +79,8 @@ module Cucumber
|
|
65
79
|
step 'Inside'
|
66
80
|
end
|
67
81
|
|
68
|
-
lambda
|
69
|
-
|
70
|
-
end.should raise_error(Cucumber::Undefined, 'Undefined step: "Inside"')
|
82
|
+
lambda { run_step "Outside" }.
|
83
|
+
should raise_error(Cucumber::Undefined, 'Undefined step: "Inside"')
|
71
84
|
end
|
72
85
|
|
73
86
|
it "should allow forced pending" do
|
@@ -75,18 +88,16 @@ module Cucumber
|
|
75
88
|
pending("Do me!")
|
76
89
|
end
|
77
90
|
|
78
|
-
lambda
|
79
|
-
|
80
|
-
end.should raise_error(Cucumber::Pending, "Do me!")
|
91
|
+
lambda { run_step "Outside" }.
|
92
|
+
should raise_error(Cucumber::Pending, "Do me!")
|
81
93
|
end
|
82
94
|
|
83
95
|
it "should raise ArityMismatchError when the number of capture groups differs from the number of step arguments" do
|
84
96
|
dsl.Given /No group: \w+/ do |arg|
|
85
97
|
end
|
86
98
|
|
87
|
-
lambda
|
88
|
-
|
89
|
-
end.should raise_error(Cucumber::ArityMismatchError)
|
99
|
+
lambda { run_step "No group: arg" }.
|
100
|
+
should raise_error(Cucumber::ArityMismatchError)
|
90
101
|
end
|
91
102
|
|
92
103
|
it "should allow puts" do
|
@@ -94,16 +105,15 @@ module Cucumber
|
|
94
105
|
dsl.Given /Loud/ do
|
95
106
|
puts 'wasup'
|
96
107
|
end
|
97
|
-
|
98
|
-
support_code.step_match("Loud").invoke(nil)
|
108
|
+
run_step "Loud"
|
99
109
|
end
|
100
|
-
|
110
|
+
|
101
111
|
it "should recognize $arg style captures" do
|
112
|
+
arg_value = "wow!"
|
102
113
|
dsl.Given "capture this: $arg" do |arg|
|
103
|
-
arg.should ==
|
114
|
+
arg.should == arg_value
|
104
115
|
end
|
105
|
-
|
106
|
-
support_code.step_match('capture this: this').invoke(nil)
|
116
|
+
run_step "capture this: wow!"
|
107
117
|
end
|
108
118
|
|
109
119
|
it "should have a JSON representation of the signature" do
|
@@ -11,15 +11,15 @@ module Cucumber
|
|
11
11
|
it "converts captures groups to non-capture groups" do
|
12
12
|
transform(/(a|b)bc/).to_s.should == "(?:a|b)bc"
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "leaves non capture groups alone" do
|
16
16
|
transform(/(?:a|b)bc/).to_s.should == "(?:a|b)bc"
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "strips away anchors" do
|
20
20
|
transform(/^xyz$/).to_s.should == "xyz"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
describe Runtime::ForProgrammingLanguages do
|
5
|
+
|
6
|
+
let(:user_interface) { double('user interface') }
|
7
|
+
subject { Runtime::SupportCode.new(user_interface,{}) }
|
8
|
+
let(:runtime_facade) { Runtime::ForProgrammingLanguages.new(subject, user_interface) }
|
9
|
+
|
10
|
+
it 'should produce Ast::DocString by #doc_string with default content-type' do
|
11
|
+
str = runtime_facade.doc_string('DOC')
|
12
|
+
str.should be_kind_of(Ast::DocString)
|
13
|
+
str.content_type.should eq('')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should produce Ast::DocString by #doc_string with ruby content-type' do
|
17
|
+
str = runtime_facade.doc_string('DOC','ruby')
|
18
|
+
str.should be_kind_of(Ast::DocString)
|
19
|
+
str.content_type.should eq('ruby')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should produce Ast::Table by #table' do
|
23
|
+
runtime_facade.table(%{
|
24
|
+
| account | description | amount |
|
25
|
+
| INT-100 | Taxi | 114 |
|
26
|
+
| CUC-101 | Peeler | 22 |
|
27
|
+
}).should be_kind_of(Ast::Table)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -24,16 +24,16 @@ module Cucumber
|
|
24
24
|
subject.scenario_visited(failed_scenario)
|
25
25
|
subject.should be_failure
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it 'should return true if a step failed' do
|
29
29
|
subject.step_visited(failed_step)
|
30
30
|
subject.should be_failure
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it 'should return false if there are no scenarios' do
|
34
34
|
subject.should_not be_failure
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it 'should return false if all scenarios passed' do
|
38
38
|
subject.scenario_visited(passed_scenario)
|
39
39
|
subject.scenario_visited(passed_scenario)
|
@@ -49,7 +49,7 @@ module Cucumber
|
|
49
49
|
subject.step_visited(pending_step)
|
50
50
|
subject.should be_failure
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it 'should return true if a step is undefined' do
|
54
54
|
subject.step_visited(undefined_step)
|
55
55
|
subject.should be_failure
|
@@ -70,7 +70,7 @@ module Cucumber
|
|
70
70
|
it 'should return false if there are no scenarios' do
|
71
71
|
subject.should_not be_failure
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it 'should return false if all scenarios fail' do
|
75
75
|
subject.scenario_visited(failed_scenario)
|
76
76
|
subject.should_not be_failure
|