aslakhellesoy-cucumber 0.3.95 → 0.3.96
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +21 -0
- data/Manifest.txt +9 -3
- data/examples/sinatra/features/support/env.rb +1 -3
- data/features/cucumber_cli.feature +1 -0
- data/features/drb_server_integration.feature +56 -3
- data/features/junit_formatter.feature +23 -12
- data/features/step_definitions/cucumber_steps.rb +13 -2
- data/features/support/env.rb +19 -3
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/step.rb +1 -1
- data/lib/cucumber/ast/step_invocation.rb +3 -2
- data/lib/cucumber/cli/configuration.rb +9 -25
- data/lib/cucumber/cli/drb_client.rb +7 -3
- data/lib/cucumber/cli/language_help_formatter.rb +4 -4
- data/lib/cucumber/cli/main.rb +26 -46
- data/lib/cucumber/cli/options.rb +3 -0
- data/lib/cucumber/constantize.rb +28 -0
- data/lib/cucumber/feature_file.rb +3 -3
- data/lib/cucumber/formatter/junit.rb +13 -9
- data/lib/cucumber/formatter/pretty.rb +2 -2
- data/lib/cucumber/language_support/hook_methods.rb +9 -0
- data/lib/cucumber/language_support/language_methods.rb +47 -0
- data/lib/cucumber/language_support/step_definition_methods.rb +44 -0
- data/lib/cucumber/parser/natural_language.rb +72 -0
- data/lib/cucumber/rb_support/rb_dsl.rb +73 -0
- data/lib/cucumber/rb_support/rb_hook.rb +19 -0
- data/lib/cucumber/rb_support/rb_language.rb +129 -0
- data/lib/cucumber/rb_support/rb_step_definition.rb +56 -0
- data/lib/cucumber/step_match.rb +2 -2
- data/lib/cucumber/step_mother.rb +87 -206
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/webrat/element_locator.rb +7 -7
- data/lib/cucumber/world.rb +28 -8
- data/rails_generators/cucumber/templates/cucumber_environment.rb +2 -2
- data/rails_generators/cucumber/templates/spork_env.rb +0 -2
- data/rails_generators/cucumber/templates/webrat_steps.rb +17 -0
- data/spec/cucumber/ast/background_spec.rb +8 -5
- data/spec/cucumber/ast/feature_factory.rb +4 -5
- data/spec/cucumber/ast/feature_spec.rb +7 -1
- data/spec/cucumber/ast/scenario_outline_spec.rb +10 -6
- data/spec/cucumber/ast/scenario_spec.rb +8 -3
- data/spec/cucumber/ast/step_collection_spec.rb +2 -2
- data/spec/cucumber/cli/configuration_spec.rb +15 -0
- data/spec/cucumber/cli/drb_client_spec.rb +35 -1
- data/spec/cucumber/cli/main_spec.rb +5 -4
- data/spec/cucumber/cli/options_spec.rb +6 -0
- data/spec/cucumber/parser/feature_parser_spec.rb +6 -5
- data/spec/cucumber/parser/table_parser_spec.rb +1 -1
- data/spec/cucumber/step_definition_spec.rb +26 -25
- data/spec/cucumber/step_mother_spec.rb +46 -41
- data/spec/cucumber/world/pending_spec.rb +4 -5
- metadata +11 -5
- data/lib/cucumber/cli/rb_step_def_loader.rb +0 -14
- data/lib/cucumber/parser/i18n/language.rb +0 -87
- data/lib/cucumber/step_definition.rb +0 -122
@@ -13,6 +13,7 @@ module Cli
|
|
13
13
|
|
14
14
|
def given_the_following_files(*files)
|
15
15
|
File.stub!(:directory?).and_return(true)
|
16
|
+
File.stub!(:file?).and_return(true)
|
16
17
|
Dir.stub!(:[]).and_return(files)
|
17
18
|
end
|
18
19
|
|
@@ -114,6 +115,20 @@ module Cli
|
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
118
|
+
describe "#drb_port" do
|
119
|
+
it "is nil when not configured" do
|
120
|
+
config.parse!([])
|
121
|
+
config.drb_port.should be_nil
|
122
|
+
end
|
123
|
+
|
124
|
+
it "is numeric when configured" do
|
125
|
+
config.parse!(%w{features --port 1000})
|
126
|
+
config.drb_port.should == 1000
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
end
|
131
|
+
|
117
132
|
it "uses the default profile when no profile is defined" do
|
118
133
|
given_cucumber_yml_defined_as({'default' => '--require some_file'})
|
119
134
|
|
@@ -23,7 +23,7 @@ module Cucumber
|
|
23
23
|
DRbClient.run(@args, @error_stream, @out_stream)
|
24
24
|
end
|
25
25
|
|
26
|
-
it "runs the
|
26
|
+
it "runs the features on the DRb server" do
|
27
27
|
@drb_object.should_receive(:run).with(@args, @error_stream, @out_stream)
|
28
28
|
DRbClient.run(@args, @error_stream, @out_stream)
|
29
29
|
end
|
@@ -38,6 +38,40 @@ module Cucumber
|
|
38
38
|
DRbClient.run(@args, @error_stream, @out_stream).should == 'foo'
|
39
39
|
end
|
40
40
|
|
41
|
+
context "with $CUCUMBER_DRB set" do
|
42
|
+
before do
|
43
|
+
@original_env = ENV['CUCUMBER_DRB']
|
44
|
+
ENV['CUCUMBER_DRB'] = '90000'
|
45
|
+
end
|
46
|
+
after do
|
47
|
+
ENV['CUCUMBER_DRB'] = @original_env
|
48
|
+
end
|
49
|
+
it "connects to specified DRb server" do
|
50
|
+
DRbObject.should_receive(:new_with_uri).with("druby://127.0.0.1:90000")
|
51
|
+
DRbClient.run(@args, @error_stream, @out_stream)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with provided drb_port" do
|
56
|
+
before do
|
57
|
+
@args = @args + ['--port', '8000']
|
58
|
+
end
|
59
|
+
it "connects to specified drb port" do
|
60
|
+
DRbObject.should_receive(:new_with_uri).with("druby://127.0.0.1:8000")
|
61
|
+
DRbClient.run(@args, @error_stream, @out_stream, 8000)
|
62
|
+
end
|
63
|
+
it "prefers configuration to environment" do
|
64
|
+
original = ENV['CUCUMBER_DRB'] = original
|
65
|
+
begin
|
66
|
+
ENV['CUCUMBER_DRB'] = "4000"
|
67
|
+
DRbObject.should_receive(:new_with_uri).with("druby://127.0.0.1:8000")
|
68
|
+
DRbClient.run(@args, @error_stream, @out_stream, 8000)
|
69
|
+
ensure
|
70
|
+
ENV['CUCUMBER_DRB'] = original
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
41
75
|
end
|
42
76
|
end
|
43
77
|
end
|
@@ -29,7 +29,7 @@ module Cucumber
|
|
29
29
|
|
30
30
|
FeatureFile.stub!(:new).and_return(mock("feature file", :parse => @empty_feature))
|
31
31
|
|
32
|
-
@cli.execute!(
|
32
|
+
@cli.execute!(StepMother.new)
|
33
33
|
|
34
34
|
@out.string.should include('example.feature')
|
35
35
|
end
|
@@ -80,7 +80,7 @@ module Cucumber
|
|
80
80
|
Object.should_receive(:const_get).with('ZooModule').and_return(mock_module)
|
81
81
|
mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => f))
|
82
82
|
|
83
|
-
cli.execute!(
|
83
|
+
cli.execute!(StepMother.new)
|
84
84
|
end
|
85
85
|
|
86
86
|
end
|
@@ -93,7 +93,7 @@ module Cucumber
|
|
93
93
|
configuration.stub!(:parse!).and_raise(exception_klass.new("error message"))
|
94
94
|
|
95
95
|
main = Main.new('', out = StringIO.new, error = StringIO.new)
|
96
|
-
main.execute!(
|
96
|
+
main.execute!(StepMother.new).should be_true
|
97
97
|
error.string.should == "error message\n"
|
98
98
|
end
|
99
99
|
end
|
@@ -111,7 +111,8 @@ module Cucumber
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "delegates the execution to the DRB client passing the args and streams" do
|
114
|
-
|
114
|
+
@configuration.stub :drb_port => 1450
|
115
|
+
DRbClient.should_receive(:run).with(@args, @err, @out, 1450).and_return(true)
|
115
116
|
@cli.execute!(@step_mother)
|
116
117
|
end
|
117
118
|
|
@@ -68,6 +68,12 @@ module Cli
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
context "--port PORT" do
|
72
|
+
it "sets the drb_port to the provided option" do
|
73
|
+
after_parsing('--port 4500') { options[:drb_port].should == '4500' }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
71
77
|
context '-f FORMAT or --format FORMAT' do
|
72
78
|
it "defaults the output for the formatter to the output stream (STDOUT)" do
|
73
79
|
after_parsing('-f pretty') { options[:formats].should == [['pretty', output_stream]] }
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
require 'cucumber/parser/
|
2
|
+
require 'cucumber/parser/natural_language'
|
3
3
|
|
4
4
|
module Cucumber
|
5
5
|
module Parser
|
6
6
|
describe Feature do
|
7
7
|
before do
|
8
|
-
@
|
8
|
+
@step_mother = StepMother.new
|
9
|
+
@parser = NaturalLanguage.get(@step_mother, 'en').parser
|
9
10
|
end
|
10
11
|
|
11
12
|
def parse(text)
|
@@ -13,11 +14,11 @@ module Cucumber
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def parse_file(file)
|
16
|
-
FeatureFile.new(File.dirname(__FILE__) + "/../treetop_parser/" + file).parse
|
17
|
+
FeatureFile.new(File.dirname(__FILE__) + "/../treetop_parser/" + file).parse(@step_mother, {})
|
17
18
|
end
|
18
19
|
|
19
20
|
def parse_example_file(file)
|
20
|
-
FeatureFile.new(File.dirname(__FILE__) + "/../../../examples/" + file).parse
|
21
|
+
FeatureFile.new(File.dirname(__FILE__) + "/../../../examples/" + file).parse(@step_mother, {})
|
21
22
|
end
|
22
23
|
|
23
24
|
describe "Comments" do
|
@@ -354,7 +355,7 @@ Given I am a step
|
|
354
355
|
it "should filter outline tables" do
|
355
356
|
ff = FeatureFile.new(
|
356
357
|
File.dirname(__FILE__) + '/../../../examples/self_test/features/outline_sample.feature:12')
|
357
|
-
f = ff.parse({:lang => 'en'})
|
358
|
+
f = ff.parse(@step_mother, {:lang => 'en'})
|
358
359
|
f.to_sexp.should ==
|
359
360
|
[:feature,
|
360
361
|
"./spec/cucumber/parser/../../../examples/self_test/features/outline_sample.feature",
|
@@ -2,72 +2,73 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
|
3
3
|
require 'cucumber/ast'
|
4
4
|
require 'cucumber/step_mother'
|
5
|
-
require 'cucumber/
|
5
|
+
require 'cucumber/rb_support/rb_language'
|
6
6
|
|
7
7
|
module Cucumber
|
8
|
-
describe
|
9
|
-
before do
|
10
|
-
|
11
|
-
@
|
8
|
+
describe RbStepDefinition do
|
9
|
+
before do
|
10
|
+
@step_mother = StepMother.new
|
11
|
+
@step_mother.load_natural_language('en')
|
12
|
+
@rb = @step_mother.load_programming_language('rb')
|
13
|
+
@dsl = Object.new
|
14
|
+
@dsl.extend RbSupport::RbDsl
|
15
|
+
@step_mother.begin_scenario
|
16
|
+
|
12
17
|
$inside = nil
|
13
18
|
end
|
14
19
|
|
15
20
|
it "should allow calling of other steps" do
|
16
|
-
Given /Outside/ do
|
21
|
+
@dsl.Given /Outside/ do
|
17
22
|
Given "Inside"
|
18
23
|
end
|
19
|
-
Given /Inside/ do
|
24
|
+
@dsl.Given /Inside/ do
|
20
25
|
$inside = true
|
21
26
|
end
|
22
27
|
|
23
|
-
step_match("Outside").invoke(
|
28
|
+
@step_mother.step_match("Outside").invoke(nil)
|
24
29
|
$inside.should == true
|
25
30
|
end
|
26
31
|
|
27
32
|
it "should allow calling of other steps with inline arg" do
|
28
|
-
Given /Outside/ do
|
33
|
+
@dsl.Given /Outside/ do
|
29
34
|
Given "Inside", Ast::Table.new([['inside']])
|
30
35
|
end
|
31
|
-
Given /Inside/ do |table|
|
36
|
+
@dsl.Given /Inside/ do |table|
|
32
37
|
$inside = table.raw[0][0]
|
33
38
|
end
|
34
39
|
|
35
|
-
step_match("Outside").invoke(
|
40
|
+
@step_mother.step_match("Outside").invoke(nil)
|
36
41
|
$inside.should == 'inside'
|
37
42
|
end
|
38
43
|
|
39
44
|
it "should raise Undefined when inside step is not defined" do
|
40
|
-
Given /Outside/ do
|
45
|
+
@dsl.Given /Outside/ do
|
41
46
|
Given 'Inside'
|
42
47
|
end
|
43
48
|
|
44
|
-
step = mock('Step')
|
45
|
-
step.should_receive(:exception=)
|
46
49
|
lambda do
|
47
|
-
@
|
48
|
-
step_match('Outside').invoke(@world, nil)
|
50
|
+
@step_mother.step_match('Outside').invoke(nil)
|
49
51
|
end.should raise_error(Undefined, 'Undefined step: "Inside"')
|
50
52
|
end
|
51
53
|
|
52
54
|
it "should allow forced pending" do
|
53
|
-
Given /Outside/ do
|
55
|
+
@dsl.Given /Outside/ do
|
54
56
|
pending("Do me!")
|
55
57
|
end
|
56
58
|
|
57
59
|
lambda do
|
58
|
-
step_match("Outside").invoke(
|
60
|
+
@step_mother.step_match("Outside").invoke(nil)
|
59
61
|
end.should raise_error(Pending, "Do me!")
|
60
62
|
end
|
61
63
|
|
62
64
|
it "should allow announce" do
|
63
65
|
v = mock('visitor')
|
64
66
|
v.should_receive(:announce).with('wasup')
|
65
|
-
|
66
|
-
|
67
|
-
Given /Loud/ do
|
67
|
+
@step_mother.visitor = v
|
68
|
+
@dsl.Given /Loud/ do
|
68
69
|
announce 'wasup'
|
69
70
|
end
|
70
|
-
step_match("Loud").invoke(
|
71
|
+
@step_mother.step_match("Loud").invoke(nil)
|
71
72
|
end
|
72
73
|
|
73
74
|
def unindented(s)
|
@@ -75,7 +76,7 @@ module Cucumber
|
|
75
76
|
end
|
76
77
|
|
77
78
|
it "should recognise quotes in name and make according regexp" do
|
78
|
-
|
79
|
+
@rb.snippet_text('Given', 'A "first" arg').should == unindented(%{
|
79
80
|
Given /^A "([^\\"]*)" arg$/ do |arg1|
|
80
81
|
pending
|
81
82
|
end
|
@@ -83,7 +84,7 @@ module Cucumber
|
|
83
84
|
end
|
84
85
|
|
85
86
|
it "should recognise several quoted words in name and make according regexp and args" do
|
86
|
-
|
87
|
+
@rb.snippet_text('Given', 'A "first" and "second" arg').should == unindented(%{
|
87
88
|
Given /^A "([^\\"]*)" and "([^\\"]*)" arg$/ do |arg1, arg2|
|
88
89
|
pending
|
89
90
|
end
|
@@ -91,7 +92,7 @@ module Cucumber
|
|
91
92
|
end
|
92
93
|
|
93
94
|
it "should not use quote group when there are no quotes" do
|
94
|
-
|
95
|
+
@rb.snippet_text('Given', 'A first arg').should == unindented(%{
|
95
96
|
Given /^A first arg$/ do
|
96
97
|
pending
|
97
98
|
end
|
@@ -1,34 +1,40 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
-
require 'cucumber
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rb_support/rb_language'
|
4
5
|
|
5
6
|
module Cucumber
|
6
7
|
describe StepMother do
|
7
8
|
before do
|
8
|
-
@
|
9
|
-
@
|
9
|
+
@dsl = Object.new
|
10
|
+
@dsl.extend(RbSupport::RbDsl)
|
11
|
+
|
12
|
+
@step_mother = StepMother.new
|
13
|
+
@step_mother.load_natural_language('en')
|
14
|
+
@rb = @step_mother.load_programming_language('rb')
|
15
|
+
|
10
16
|
@visitor = mock('Visitor')
|
11
17
|
end
|
12
18
|
|
13
19
|
it "should format step names" do
|
14
|
-
@
|
20
|
+
@dsl.Given(/it (.*) in (.*)/) do |what, month|
|
15
21
|
end
|
16
|
-
@
|
22
|
+
@dsl.Given(/nope something else/) do |what, month|
|
17
23
|
end
|
18
24
|
format = @step_mother.step_match("it snows in april").format_args("[%s]")
|
19
25
|
format.should == "it [snows] in [april]"
|
20
26
|
end
|
21
27
|
|
22
28
|
it "should raise Ambiguous error with guess hint when multiple step definitions match" do
|
23
|
-
@
|
24
|
-
@
|
29
|
+
@dsl.Given(/Three (.*) mice/) {|disability|}
|
30
|
+
@dsl.Given(/Three blind (.*)/) {|animal|}
|
25
31
|
|
26
32
|
lambda do
|
27
33
|
@step_mother.step_match("Three blind mice")
|
28
34
|
end.should raise_error(Ambiguous, %{Ambiguous match of "Three blind mice":
|
29
35
|
|
30
|
-
spec/cucumber/step_mother_spec.rb:
|
31
|
-
spec/cucumber/step_mother_spec.rb:
|
36
|
+
spec/cucumber/step_mother_spec.rb:29:in `/Three (.*) mice/'
|
37
|
+
spec/cucumber/step_mother_spec.rb:30:in `/Three blind (.*)/'
|
32
38
|
|
33
39
|
You can run again with --guess to make Cucumber be more smart about it
|
34
40
|
})
|
@@ -36,23 +42,23 @@ You can run again with --guess to make Cucumber be more smart about it
|
|
36
42
|
|
37
43
|
it "should not show --guess hint when --guess is used" do
|
38
44
|
@step_mother.options = {:guess => true}
|
39
|
-
@
|
40
|
-
@
|
45
|
+
@dsl.Given(/Three (.*) mice/) {|disability|}
|
46
|
+
@dsl.Given(/Three cute (.*)/) {|animal|}
|
41
47
|
|
42
48
|
lambda do
|
43
49
|
@step_mother.step_match("Three cute mice")
|
44
50
|
end.should raise_error(Ambiguous, %{Ambiguous match of "Three cute mice":
|
45
51
|
|
46
|
-
spec/cucumber/step_mother_spec.rb:
|
47
|
-
spec/cucumber/step_mother_spec.rb:
|
52
|
+
spec/cucumber/step_mother_spec.rb:45:in `/Three (.*) mice/'
|
53
|
+
spec/cucumber/step_mother_spec.rb:46:in `/Three cute (.*)/'
|
48
54
|
|
49
55
|
})
|
50
56
|
end
|
51
57
|
|
52
58
|
it "should not raise Ambiguous error when multiple step definitions match, but --guess is enabled" do
|
53
59
|
@step_mother.options = {:guess => true}
|
54
|
-
@
|
55
|
-
@
|
60
|
+
@dsl.Given(/Three (.*) mice/) {|disability|}
|
61
|
+
@dsl.Given(/Three (.*)/) {|animal|}
|
56
62
|
|
57
63
|
lambda do
|
58
64
|
@step_mother.step_match("Three blind mice")
|
@@ -61,23 +67,23 @@ spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
|
|
61
67
|
|
62
68
|
it "should pick right step definition when --guess is enabled and equal number of capture groups" do
|
63
69
|
@step_mother.options = {:guess => true}
|
64
|
-
right = @
|
65
|
-
wrong = @
|
70
|
+
right = @dsl.Given(/Three (.*) mice/) {|disability|}
|
71
|
+
wrong = @dsl.Given(/Three (.*)/) {|animal|}
|
66
72
|
@step_mother.step_match("Three blind mice").step_definition.should == right
|
67
73
|
end
|
68
74
|
|
69
75
|
it "should pick right step definition when --guess is enabled and unequal number of capture groups" do
|
70
76
|
@step_mother.options = {:guess => true}
|
71
|
-
right = @
|
72
|
-
wrong = @
|
77
|
+
right = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
|
78
|
+
wrong = @dsl.Given(/Three (.*)/) {|animal|}
|
73
79
|
@step_mother.step_match("Three blind mice ran far").step_definition.should == right
|
74
80
|
end
|
75
81
|
|
76
82
|
it "should pick most specific step definition when --guess is enabled and unequal number of capture groups" do
|
77
83
|
@step_mother.options = {:guess => true}
|
78
|
-
general = @
|
79
|
-
specific = @
|
80
|
-
more_specific = @
|
84
|
+
general = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
|
85
|
+
specific = @dsl.Given(/Three blind mice ran far/) {}
|
86
|
+
more_specific = @dsl.Given(/^Three blind mice ran far$/) {}
|
81
87
|
@step_mother.step_match("Three blind mice ran far").step_definition.should == more_specific
|
82
88
|
end
|
83
89
|
|
@@ -88,28 +94,28 @@ spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
|
|
88
94
|
end
|
89
95
|
|
90
96
|
it "should raise Redundant error when same regexp is registered twice" do
|
91
|
-
@
|
97
|
+
@dsl.Given(/Three (.*) mice/) {|disability|}
|
92
98
|
lambda do
|
93
|
-
@
|
99
|
+
@dsl.Given(/Three (.*) mice/) {|disability|}
|
94
100
|
end.should raise_error(Redundant)
|
95
101
|
end
|
96
102
|
|
97
103
|
# http://railsforum.com/viewtopic.php?pid=93881
|
98
104
|
it "should not raise Redundant unless it's really redundant" do
|
99
|
-
@
|
100
|
-
@
|
105
|
+
@dsl.Given(/^(.*) (.*) user named '(.*)'$/) {|a,b,c|}
|
106
|
+
@dsl.Given(/^there is no (.*) user named '(.*)'$/) {|a,b|}
|
101
107
|
end
|
102
108
|
|
103
109
|
it "should raise an error if the world is nil" do
|
104
|
-
@
|
110
|
+
@dsl.World do
|
105
111
|
end
|
106
112
|
|
107
113
|
begin
|
108
114
|
@step_mother.before_and_after(nil) {}
|
109
115
|
raise "Should fail"
|
110
|
-
rescue NilWorld => e
|
116
|
+
rescue RbSupport::NilWorld => e
|
111
117
|
e.message.should == "World procs should never return nil"
|
112
|
-
e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:
|
118
|
+
e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:110:in `World'"]
|
113
119
|
end
|
114
120
|
end
|
115
121
|
|
@@ -123,25 +129,24 @@ spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
|
|
123
129
|
end
|
124
130
|
|
125
131
|
it "should implicitly extend world with modules" do
|
126
|
-
@
|
127
|
-
|
128
|
-
|
129
|
-
class << w
|
132
|
+
@dsl.World(ModuleOne, ModuleTwo)
|
133
|
+
@step_mother.begin_scenario
|
134
|
+
class << @rb.current_world
|
130
135
|
included_modules.index(ModuleOne).should_not == nil
|
131
136
|
included_modules.index(ModuleTwo).should_not == nil
|
132
137
|
end
|
133
|
-
|
138
|
+
@rb.current_world.class.should == Object
|
134
139
|
end
|
135
140
|
|
136
141
|
it "should raise error when we try to register more than one World proc" do
|
137
|
-
@
|
142
|
+
@dsl.World { Hash.new }
|
138
143
|
lambda do
|
139
|
-
@
|
140
|
-
end.should raise_error(MultipleWorld, %{You can only pass a proc to #World once, but it's happening
|
144
|
+
@dsl.World { Array.new }
|
145
|
+
end.should raise_error(RbSupport::MultipleWorld, %{You can only pass a proc to #World once, but it's happening
|
141
146
|
in 2 places:
|
142
147
|
|
143
|
-
spec/cucumber/step_mother_spec.rb:
|
144
|
-
spec/cucumber/step_mother_spec.rb:
|
148
|
+
spec/cucumber/step_mother_spec.rb:142:in `World'
|
149
|
+
spec/cucumber/step_mother_spec.rb:144:in `World'
|
145
150
|
|
146
151
|
Use Ruby modules instead to extend your worlds. See the Cucumber::StepMother#World RDoc
|
147
152
|
or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
|
@@ -150,8 +155,8 @@ or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
|
|
150
155
|
end
|
151
156
|
|
152
157
|
it "should find before hooks" do
|
153
|
-
fish = @
|
154
|
-
meat = @
|
158
|
+
fish = @dsl.Before('@fish'){}
|
159
|
+
meat = @dsl.Before('@meat'){}
|
155
160
|
|
156
161
|
scenario = mock('Scenario')
|
157
162
|
scenario.should_receive(:accept_hook?).with(fish).and_return(true)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/rb_support/rb_language'
|
2
3
|
|
3
4
|
module Cucumber
|
4
|
-
module StepMother
|
5
5
|
describe 'Pending' do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
|
9
|
-
|
10
|
-
@world =
|
8
|
+
l = RbSupport::RbLanguage.new(StepMother.new)
|
9
|
+
l.begin_scenario
|
10
|
+
@world = l.current_world
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should raise a Pending if no block is supplied' do
|
@@ -43,5 +43,4 @@ module Cucumber
|
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
46
|
-
end
|
47
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aslakhellesoy-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.96
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Aslak Helles\xC3\xB8y"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-16 00:00:00 -07:00
|
13
13
|
default_executable: cucumber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -388,7 +388,7 @@ files:
|
|
388
388
|
- lib/cucumber/cli/main.rb
|
389
389
|
- lib/cucumber/cli/options.rb
|
390
390
|
- lib/cucumber/cli/profile_loader.rb
|
391
|
-
- lib/cucumber/
|
391
|
+
- lib/cucumber/constantize.rb
|
392
392
|
- lib/cucumber/core_ext/exception.rb
|
393
393
|
- lib/cucumber/core_ext/instance_exec.rb
|
394
394
|
- lib/cucumber/core_ext/proc.rb
|
@@ -413,12 +413,15 @@ files:
|
|
413
413
|
- lib/cucumber/formatter/unicode.rb
|
414
414
|
- lib/cucumber/formatter/usage.rb
|
415
415
|
- lib/cucumber/formatters/unicode.rb
|
416
|
+
- lib/cucumber/language_support/hook_methods.rb
|
417
|
+
- lib/cucumber/language_support/language_methods.rb
|
418
|
+
- lib/cucumber/language_support/step_definition_methods.rb
|
416
419
|
- lib/cucumber/languages.yml
|
417
420
|
- lib/cucumber/parser.rb
|
418
421
|
- lib/cucumber/parser/feature.rb
|
419
422
|
- lib/cucumber/parser/feature.tt
|
420
423
|
- lib/cucumber/parser/i18n.tt
|
421
|
-
- lib/cucumber/parser/
|
424
|
+
- lib/cucumber/parser/natural_language.rb
|
422
425
|
- lib/cucumber/parser/table.rb
|
423
426
|
- lib/cucumber/parser/table.tt
|
424
427
|
- lib/cucumber/parser/treetop_ext.rb
|
@@ -426,8 +429,11 @@ files:
|
|
426
429
|
- lib/cucumber/rails/rspec.rb
|
427
430
|
- lib/cucumber/rails/world.rb
|
428
431
|
- lib/cucumber/rake/task.rb
|
432
|
+
- lib/cucumber/rb_support/rb_dsl.rb
|
433
|
+
- lib/cucumber/rb_support/rb_hook.rb
|
434
|
+
- lib/cucumber/rb_support/rb_language.rb
|
435
|
+
- lib/cucumber/rb_support/rb_step_definition.rb
|
429
436
|
- lib/cucumber/rspec_neuter.rb
|
430
|
-
- lib/cucumber/step_definition.rb
|
431
437
|
- lib/cucumber/step_match.rb
|
432
438
|
- lib/cucumber/step_mother.rb
|
433
439
|
- lib/cucumber/version.rb
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Parser
|
3
|
-
module I18n
|
4
|
-
class Language
|
5
|
-
KEYWORD_KEYS = %w{name native encoding feature background scenario scenario_outline examples given when then but}
|
6
|
-
|
7
|
-
class << self
|
8
|
-
LANGUAGES = Hash.new{|h,k| h[k] = Language.new(k)}
|
9
|
-
|
10
|
-
def [](key)
|
11
|
-
LANGUAGES[key]
|
12
|
-
end
|
13
|
-
|
14
|
-
def alias_step_definitions(keywords) #:nodoc:
|
15
|
-
all_keywords = %w{given when then and but}.map{|keyword| keywords[keyword].split('|')}.flatten
|
16
|
-
alias_steps(all_keywords)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Sets up additional method aliases for Given, When and Then.
|
20
|
-
# This does *not* affect how feature files are parsed. If you
|
21
|
-
# want to create aliases in the parser, you have to do this in
|
22
|
-
# languages.yml. For example:
|
23
|
-
#
|
24
|
-
# and: And|With
|
25
|
-
def alias_steps(keywords)
|
26
|
-
keywords.each do |adverb|
|
27
|
-
StepMother.alias_adverb(adverb)
|
28
|
-
World.alias_adverb(adverb)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
alias_step_definitions(Cucumber::LANGUAGES['en'])
|
34
|
-
|
35
|
-
def initialize(lang)
|
36
|
-
@keywords = Cucumber::LANGUAGES[lang]
|
37
|
-
raise "Language not supported: #{lang.inspect}" if @keywords.nil?
|
38
|
-
@keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
|
39
|
-
end
|
40
|
-
|
41
|
-
def parser
|
42
|
-
return @parser if @parser
|
43
|
-
i18n_tt = File.expand_path(File.dirname(__FILE__) + '/../i18n.tt')
|
44
|
-
template = File.open(i18n_tt, Cucumber.file_mode('r')).read
|
45
|
-
erb = ERB.new(template)
|
46
|
-
grammar = erb.result(binding)
|
47
|
-
Treetop.load_from_string(grammar)
|
48
|
-
self.class.alias_step_definitions(@keywords)
|
49
|
-
@parser = Parser::I18n.const_get("#{@keywords['grammar_name']}Parser").new
|
50
|
-
def @parser.inspect
|
51
|
-
"#<#{self.class.name}>"
|
52
|
-
end
|
53
|
-
@parser
|
54
|
-
end
|
55
|
-
|
56
|
-
def parse(source, path, filter)
|
57
|
-
feature = parser.parse_or_fail(source, path, filter)
|
58
|
-
feature.language = self if feature
|
59
|
-
feature
|
60
|
-
end
|
61
|
-
|
62
|
-
def keywords(key, raw=false)
|
63
|
-
return @keywords[key] if raw
|
64
|
-
return nil unless @keywords[key]
|
65
|
-
values = @keywords[key].split('|')
|
66
|
-
values.map{|value| "'#{value}'"}.join(" / ")
|
67
|
-
end
|
68
|
-
|
69
|
-
def incomplete?
|
70
|
-
KEYWORD_KEYS.detect{|key| @keywords[key].nil?}
|
71
|
-
end
|
72
|
-
|
73
|
-
def scenario_keyword
|
74
|
-
@keywords['scenario'].split('|')[0] + ':'
|
75
|
-
end
|
76
|
-
|
77
|
-
def but_keywords
|
78
|
-
@keywords['but'].split('|')
|
79
|
-
end
|
80
|
-
|
81
|
-
def and_keywords
|
82
|
-
@keywords['and'].split('|')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|