aslakhellesoy-cucumber 0.1.99.23 → 0.1.100.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -6
- data/Manifest.txt +8 -2
- data/examples/i18n/et/features/jagamine.feature +9 -0
- data/examples/jbehave/README.textile +4 -1
- data/examples/jbehave/features/trading.feature +4 -0
- data/examples/jbehave/pom.xml +5 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +6 -1
- data/examples/selenium/features/step_definitons/search_steps.rb +13 -0
- data/examples/selenium/features/support/env.rb +19 -0
- data/examples/selenium_webrat/Rakefile +6 -0
- data/examples/selenium_webrat/features/search.feature +9 -0
- data/examples/selenium_webrat/features/step_definitons/search_steps.rb +13 -0
- data/examples/selenium_webrat/features/support/env.rb +41 -0
- data/examples/self_test/features/background/failing_background.feature +1 -0
- data/examples/self_test/features/step_definitions/sample_steps.rb +1 -1
- data/examples/self_test/features/support/tag_count_formatter.rb +1 -1
- data/features/background.feature +9 -11
- data/features/cucumber_cli.feature +24 -1
- data/features/cucumber_cli_outlines.feature +10 -19
- data/features/report_called_undefined_steps.feature +2 -0
- data/gem_tasks/rspec.rake +2 -0
- data/lib/cucumber.rb +7 -15
- data/lib/cucumber/ast.rb +3 -3
- data/lib/cucumber/ast/background.rb +28 -66
- data/lib/cucumber/ast/examples.rb +15 -3
- data/lib/cucumber/ast/feature.rb +20 -24
- data/lib/cucumber/ast/feature_element.rb +46 -0
- data/lib/cucumber/ast/features.rb +2 -21
- data/lib/cucumber/ast/outline_table.rb +46 -14
- data/lib/cucumber/ast/py_string.rb +8 -3
- data/lib/cucumber/ast/scenario.rb +34 -73
- data/lib/cucumber/ast/scenario_outline.rb +40 -42
- data/lib/cucumber/ast/step.rb +53 -89
- data/lib/cucumber/ast/step_collection.rb +66 -0
- data/lib/cucumber/ast/step_invocation.rb +106 -0
- data/lib/cucumber/ast/table.rb +38 -19
- data/lib/cucumber/ast/tags.rb +4 -11
- data/lib/cucumber/ast/visitor.rb +31 -19
- data/lib/cucumber/broadcaster.rb +1 -1
- data/lib/cucumber/cli/configuration.rb +24 -16
- data/lib/cucumber/cli/language_help_formatter.rb +4 -4
- data/lib/cucumber/cli/main.rb +5 -4
- data/lib/cucumber/core_ext/proc.rb +2 -2
- data/lib/cucumber/formatter/ansicolor.rb +0 -1
- data/lib/cucumber/formatter/console.rb +18 -34
- data/lib/cucumber/formatter/html.rb +13 -10
- data/lib/cucumber/formatter/pretty.rb +48 -36
- data/lib/cucumber/formatter/profile.rb +6 -6
- data/lib/cucumber/formatter/progress.rb +12 -20
- data/lib/cucumber/formatter/rerun.rb +5 -5
- data/lib/cucumber/jbehave.rb +21 -26
- data/lib/cucumber/parser/feature.rb +26 -29
- data/lib/cucumber/parser/feature.tt +17 -12
- data/lib/cucumber/parser/treetop_ext.rb +13 -13
- data/lib/cucumber/platform.rb +0 -1
- data/lib/cucumber/rails/world.rb +2 -2
- data/lib/cucumber/rake/task.rb +0 -1
- data/lib/cucumber/step_definition.rb +21 -12
- data/lib/cucumber/step_match.rb +49 -0
- data/lib/cucumber/step_mother.rb +98 -80
- data/lib/cucumber/version.rb +2 -2
- data/lib/cucumber/world.rb +42 -0
- data/rails_generators/cucumber/templates/paths.rb +1 -1
- data/rails_generators/cucumber/templates/webrat_steps.rb +17 -17
- data/rails_generators/feature/feature_generator.rb +4 -0
- data/rails_generators/feature/templates/steps.erb +0 -4
- data/spec/cucumber/ast/background_spec.rb +32 -41
- data/spec/cucumber/ast/feature_factory.rb +10 -1
- data/spec/cucumber/ast/feature_spec.rb +7 -30
- data/spec/cucumber/ast/scenario_outline_spec.rb +3 -0
- data/spec/cucumber/ast/scenario_spec.rb +8 -25
- data/spec/cucumber/ast/step_collection_spec.rb +8 -0
- data/spec/cucumber/ast/step_spec.rb +37 -29
- data/spec/cucumber/ast/tags_spec.rb +2 -18
- data/spec/cucumber/cli/configuration_spec.rb +7 -0
- data/spec/cucumber/cli/main_spec.rb +1 -1
- data/spec/cucumber/parser/feature_parser_spec.rb +6 -5
- data/spec/cucumber/step_definition_spec.rb +5 -5
- data/spec/cucumber/step_mother_spec.rb +6 -6
- data/spec/cucumber/world/pending_spec.rb +1 -1
- metadata +17 -5
- data/lib/cucumber/ast/filter.rb +0 -22
- data/lib/cucumber/ast/steps.rb +0 -13
data/lib/cucumber/step_mother.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cucumber/step_definition'
|
2
|
+
require 'cucumber/world'
|
2
3
|
require 'cucumber/core_ext/instance_exec'
|
3
4
|
|
4
5
|
module Cucumber
|
@@ -9,18 +10,25 @@ module Cucumber
|
|
9
10
|
super %{Undefined step: "#{step_name}"}
|
10
11
|
@step_name = step_name
|
11
12
|
end
|
12
|
-
|
13
|
+
|
14
|
+
def nested!
|
15
|
+
@nested = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def nested?
|
19
|
+
@nested
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
23
|
+
# Raised when a StepDefinition's block invokes World#pending
|
15
24
|
class Pending < StandardError
|
16
|
-
Cucumber::EXCEPTION_STATUS[self] = :pending
|
17
25
|
end
|
18
26
|
|
19
27
|
# Raised when a step matches 2 or more StepDefinition
|
20
28
|
class Ambiguous < StandardError
|
21
29
|
def initialize(step_name, step_definitions)
|
22
30
|
message = "Ambiguous match of \"#{step_name}\":\n\n"
|
23
|
-
message << step_definitions.map{|sd| sd.
|
31
|
+
message << step_definitions.map{|sd| sd.backtrace_line}.join("\n")
|
24
32
|
message << "\n\n"
|
25
33
|
super(message)
|
26
34
|
end
|
@@ -30,8 +38,8 @@ module Cucumber
|
|
30
38
|
class Redundant < StandardError
|
31
39
|
def initialize(step_def_1, step_def_2)
|
32
40
|
message = "Multiple step definitions have the same Regexp:\n\n"
|
33
|
-
message << step_def_1.
|
34
|
-
message << step_def_2.
|
41
|
+
message << step_def_1.backtrace_line << "\n"
|
42
|
+
message << step_def_2.backtrace_line << "\n\n"
|
35
43
|
super(message)
|
36
44
|
end
|
37
45
|
end
|
@@ -41,9 +49,31 @@ module Cucumber
|
|
41
49
|
# so #register_step_definition (and more interestingly - its aliases) are
|
42
50
|
# available from the top-level.
|
43
51
|
module StepMother
|
44
|
-
|
45
|
-
|
52
|
+
class << self
|
53
|
+
def alias_adverb(adverb)
|
54
|
+
alias_method adverb, :register_step_definition
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
attr_writer :snippet_generator, :options
|
59
|
+
|
60
|
+
def step_visited(step)
|
61
|
+
steps << step unless steps.index(step)
|
62
|
+
end
|
46
63
|
|
64
|
+
def steps(status = nil)
|
65
|
+
@steps ||= []
|
66
|
+
if(status)
|
67
|
+
@steps.select{|step| step.status == status}
|
68
|
+
else
|
69
|
+
@steps
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def scenarios
|
74
|
+
@scenarios ||= []
|
75
|
+
end
|
76
|
+
|
47
77
|
# Registers a new StepDefinition. This method is aliased
|
48
78
|
# to <tt>Given</tt>, <tt>When</tt> and <tt>Then</tt>.
|
49
79
|
#
|
@@ -63,20 +93,6 @@ module Cucumber
|
|
63
93
|
step_definition
|
64
94
|
end
|
65
95
|
|
66
|
-
def world(scenario, prior_world = nil, &proc)
|
67
|
-
world = prior_world || new_world
|
68
|
-
begin
|
69
|
-
(@before_procs ||= []).each do |proc|
|
70
|
-
world.cucumber_instance_exec(false, 'Before', scenario, &proc)
|
71
|
-
end
|
72
|
-
yield world
|
73
|
-
ensure
|
74
|
-
(@after_procs ||= []).each do |proc|
|
75
|
-
world.cucumber_instance_exec(false, 'After', scenario, &proc)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
96
|
# Registers a Before proc. You can call this method as many times as you
|
81
97
|
# want (typically from ruby scripts under <tt>support</tt>).
|
82
98
|
def Before(&proc)
|
@@ -93,37 +109,25 @@ module Cucumber
|
|
93
109
|
(@world_procs ||= []) << proc
|
94
110
|
end
|
95
111
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
(@world_procs ||= []).each do |proc|
|
100
|
-
world = proc.call(world)
|
101
|
-
end
|
102
|
-
|
103
|
-
world.extend(WorldMethods)
|
104
|
-
world.__cucumber_step_mother = self
|
112
|
+
def current_world
|
113
|
+
@current_world
|
114
|
+
end
|
105
115
|
|
106
|
-
|
107
|
-
|
116
|
+
def step_match(step_name, formatted_step_name=nil)
|
117
|
+
matches = step_definitions.map { |d| d.step_match(step_name, formatted_step_name) }.compact
|
118
|
+
raise Undefined.new(step_name) if matches.empty?
|
119
|
+
matches = best_matches(step_name, matches) if matches.size > 1 && options[:guess]
|
120
|
+
raise Ambiguous.new(step_name, matches) if matches.size > 1
|
121
|
+
matches[0]
|
108
122
|
end
|
109
123
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
raise Ambiguous.new(step_name, found) if found.size > 1
|
118
|
-
found[0]
|
119
|
-
end
|
120
|
-
|
121
|
-
def best_matches(step_name, step_definitions)
|
122
|
-
top_group_score = step_definitions.map {|s| s.match(step_name).captures.length }.sort.last
|
123
|
-
top_groups = step_definitions.select {|s| s.match(step_name).captures.length == top_group_score }
|
124
|
-
if top_groups.size > 1
|
125
|
-
shortest_capture_length = top_groups.map {|s| s.match(step_name).captures.inject(0) {|sum, c| sum + c.length } }.sort.first
|
126
|
-
top_groups.select {|s| s.match(step_name).captures.inject(0) {|sum, c| sum + c.length } == shortest_capture_length }
|
124
|
+
def best_matches(step_name, step_matches)
|
125
|
+
max_arg_length = step_matches.map {|step_match| step_match.args.length }.max
|
126
|
+
top_groups = step_matches.select {|step_match| step_match.args.length == max_arg_length }
|
127
|
+
|
128
|
+
if top_groups.length > 1
|
129
|
+
shortest_capture_length = top_groups.map {|step_match| step_match.args.inject(0) {|sum, c| sum + c.length } }.min
|
130
|
+
top_groups.select {|step_match| step_match.args.inject(0) {|sum, c| sum + c.length } == shortest_capture_length }
|
127
131
|
else
|
128
132
|
top_groups
|
129
133
|
end
|
@@ -144,6 +148,19 @@ module Cucumber
|
|
144
148
|
end
|
145
149
|
end
|
146
150
|
|
151
|
+
def before_and_after(scenario, skip=false)
|
152
|
+
unless current_world || skip
|
153
|
+
new_world!
|
154
|
+
execute_before(scenario)
|
155
|
+
end
|
156
|
+
if block_given?
|
157
|
+
yield
|
158
|
+
execute_after(scenario) unless skip
|
159
|
+
nil_world!
|
160
|
+
scenario_visited(scenario)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
147
164
|
private
|
148
165
|
|
149
166
|
def max_step_definition_length
|
@@ -154,41 +171,42 @@ module Cucumber
|
|
154
171
|
@options || {}
|
155
172
|
end
|
156
173
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
begin
|
163
|
-
# TODO: Very similar to code in Step. Refactor. Get back StepInvocation?
|
164
|
-
# Make more similar to JBehave?
|
165
|
-
step_definition = @__cucumber_step_mother.step_definition(name)
|
166
|
-
matched_args = step_definition.matched_args(name)
|
167
|
-
args = (matched_args + multiline_arguments)
|
168
|
-
step_definition.execute(name, self, *args)
|
169
|
-
rescue Exception => e
|
170
|
-
@__cucumber_current_step.exception = e
|
171
|
-
raise e
|
172
|
-
end
|
174
|
+
# Creates a new world instance
|
175
|
+
def new_world!
|
176
|
+
@current_world = Object.new
|
177
|
+
(@world_procs ||= []).each do |proc|
|
178
|
+
@current_world = proc.call(@current_world)
|
173
179
|
end
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
180
|
+
|
181
|
+
@current_world.extend(World)
|
182
|
+
@current_world.__cucumber_step_mother = self
|
183
|
+
|
184
|
+
@current_world.extend(::Spec::Matchers) if defined?(::Spec::Matchers)
|
185
|
+
@current_world
|
186
|
+
end
|
187
|
+
|
188
|
+
def nil_world!
|
189
|
+
@current_world = nil
|
190
|
+
end
|
191
|
+
|
192
|
+
def execute_before(scenario)
|
193
|
+
(@before_procs ||= []).each do |proc|
|
194
|
+
@current_world.cucumber_instance_exec(false, 'Before', scenario, &proc)
|
178
195
|
end
|
196
|
+
end
|
179
197
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
yield
|
184
|
-
rescue Exception => e
|
185
|
-
raise Pending.new(message)
|
186
|
-
end
|
187
|
-
raise Pending.new("Expected pending '#{message}' to fail. No Error was raised. No longer pending?")
|
188
|
-
else
|
189
|
-
raise Pending.new(message)
|
190
|
-
end
|
198
|
+
def execute_after(scenario)
|
199
|
+
(@after_procs ||= []).each do |proc|
|
200
|
+
@current_world.cucumber_instance_exec(false, 'After', scenario, &proc)
|
191
201
|
end
|
192
202
|
end
|
203
|
+
|
204
|
+
def scenario_visited(scenario)
|
205
|
+
scenarios << scenario unless scenarios.index(scenario)
|
206
|
+
end
|
207
|
+
|
208
|
+
def options
|
209
|
+
@options || {}
|
210
|
+
end
|
193
211
|
end
|
194
212
|
end
|
data/lib/cucumber/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Cucumber
|
2
|
+
# All steps are run in the context of an object that extends this module
|
3
|
+
module World
|
4
|
+
class << self
|
5
|
+
def alias_adverb(adverb)
|
6
|
+
alias_method adverb, :__cucumber_invoke
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_writer :__cucumber_step_mother, :__cucumber_current_step
|
11
|
+
|
12
|
+
# Call a step from within a step definition
|
13
|
+
def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
|
14
|
+
begin
|
15
|
+
step_match = @__cucumber_step_mother.step_match(name)
|
16
|
+
step_match.invoke(self, multiline_argument)
|
17
|
+
rescue Exception => e
|
18
|
+
e.nested! if Undefined === e
|
19
|
+
@__cucumber_current_step.exception = e
|
20
|
+
raise e
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def table(text, file=nil, line_offset=0)
|
25
|
+
@table_parser ||= Parser::TableParser.new
|
26
|
+
@table_parser.parse_or_fail(text.strip, file, line_offset)
|
27
|
+
end
|
28
|
+
|
29
|
+
def pending(message = "TODO")
|
30
|
+
if block_given?
|
31
|
+
begin
|
32
|
+
yield
|
33
|
+
rescue Exception => e
|
34
|
+
raise Pending.new(message)
|
35
|
+
end
|
36
|
+
raise Pending.new("Expected pending '#{message}' to fail. No Error was raised. No longer pending?")
|
37
|
+
else
|
38
|
+
raise Pending.new(message)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -11,25 +11,25 @@ When /^I go to (.+)$/ do |page_name|
|
|
11
11
|
visit path_to(page_name)
|
12
12
|
end
|
13
13
|
|
14
|
-
When /^I press "(
|
14
|
+
When /^I press "([^\"]*)"$/ do |button|
|
15
15
|
click_button(button)
|
16
16
|
end
|
17
17
|
|
18
|
-
When /^I follow "(
|
18
|
+
When /^I follow "([^\"]*)"$/ do |link|
|
19
19
|
click_link(link)
|
20
20
|
end
|
21
21
|
|
22
|
-
When /^I fill in "(
|
22
|
+
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
23
23
|
fill_in(field, :with => value)
|
24
24
|
end
|
25
25
|
|
26
|
-
When /^I select "(
|
26
|
+
When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
27
27
|
select(value, :from => field)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
31
31
|
# When I select "December 25, 2008 10:00" as the date and time
|
32
|
-
When /^I select "(
|
32
|
+
When /^I select "([^\"]*)" as the date and time$/ do |time|
|
33
33
|
select_datetime(time)
|
34
34
|
end
|
35
35
|
|
@@ -42,7 +42,7 @@ end
|
|
42
42
|
# The following steps would fill out the form:
|
43
43
|
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
|
44
44
|
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
|
45
|
-
When /^I select "(
|
45
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
46
46
|
select_datetime(datetime, :from => datetime_label)
|
47
47
|
end
|
48
48
|
|
@@ -50,47 +50,47 @@ end
|
|
50
50
|
# When I select "2:20PM" as the time
|
51
51
|
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
52
52
|
# will convert the 2:20PM to 14:20 and then select it.
|
53
|
-
When /^I select "(
|
53
|
+
When /^I select "([^\"]*)" as the time$/ do |time|
|
54
54
|
select_time(time)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Use this step when using multiple time_select helpers on a page or you want to
|
58
58
|
# specify the name of the time on the form. For example:
|
59
59
|
# When I select "7:30AM" as the "Gym" time
|
60
|
-
When /^I select "(
|
60
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
61
61
|
select_time(time, :from => time_label)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Use this step in conjunction with Rail's date_select helper. For example:
|
65
65
|
# When I select "February 20, 1981" as the date
|
66
|
-
When /^I select "(
|
66
|
+
When /^I select "([^\"]*)" as the date$/ do |date|
|
67
67
|
select_date(date)
|
68
68
|
end
|
69
69
|
|
70
70
|
# Use this step when using multiple date_select helpers on one page or
|
71
71
|
# you want to specify the name of the date on the form. For example:
|
72
72
|
# When I select "April 26, 1982" as the "Date of Birth" date
|
73
|
-
When /^I select "(
|
73
|
+
When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
74
74
|
select_date(date, :from => date_label)
|
75
75
|
end
|
76
76
|
|
77
|
-
When /^I check "(
|
77
|
+
When /^I check "([^\"]*)"$/ do |field|
|
78
78
|
check(field)
|
79
79
|
end
|
80
80
|
|
81
|
-
When /^I uncheck "(
|
81
|
+
When /^I uncheck "([^\"]*)"$/ do |field|
|
82
82
|
uncheck(field)
|
83
83
|
end
|
84
84
|
|
85
|
-
When /^I choose "(
|
85
|
+
When /^I choose "([^\"]*)"$/ do |field|
|
86
86
|
choose(field)
|
87
87
|
end
|
88
88
|
|
89
|
-
When /^I attach the file at "(
|
89
|
+
When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
90
90
|
attach_file(field, path)
|
91
91
|
end
|
92
92
|
|
93
|
-
Then /^I should see "(
|
93
|
+
Then /^I should see "([^\"]*)"$/ do |text|
|
94
94
|
<% if framework == :rspec -%>
|
95
95
|
response.should contain(text)
|
96
96
|
<% else -%>
|
@@ -98,7 +98,7 @@ Then /^I should see "(.*)"$/ do |text|
|
|
98
98
|
<% end -%>
|
99
99
|
end
|
100
100
|
|
101
|
-
Then /^I should not see "(
|
101
|
+
Then /^I should not see "([^\"]*)"$/ do |text|
|
102
102
|
<% if framework == :rspec -%>
|
103
103
|
response.should_not contain(text)
|
104
104
|
<% else -%>
|
@@ -106,7 +106,7 @@ Then /^I should not see "(.*)"$/ do |text|
|
|
106
106
|
<% end -%>
|
107
107
|
end
|
108
108
|
|
109
|
-
Then /^the "(
|
109
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
110
110
|
<% if framework == :rspec -%>
|
111
111
|
field_labeled(label).should be_checked
|
112
112
|
<% else -%>
|
@@ -5,6 +5,10 @@ class FeatureGenerator < Rails::Generator::NamedBase
|
|
5
5
|
m.directory 'features/step_definitions'
|
6
6
|
m.template 'feature.erb', "features/manage_#{plural_name}.feature"
|
7
7
|
m.template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
|
8
|
+
|
9
|
+
m.gsub_file 'features/support/paths.rb', /root_path/mi do |match|
|
10
|
+
"#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
@@ -5,53 +5,44 @@ module Cucumber
|
|
5
5
|
module Ast
|
6
6
|
describe Background do
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
before do
|
9
|
+
@step_mother = Object.new
|
10
|
+
@step_mother.extend(StepMother)
|
11
|
+
$x = $y = nil
|
12
|
+
@step_mother.Before do
|
13
|
+
$x = 2
|
14
|
+
end
|
15
|
+
@step_mother.Given /y is (\d+)/ do |n|
|
16
|
+
$y = $x * n.to_i
|
17
|
+
end
|
18
|
+
@visitor = Visitor.new(@step_mother)
|
19
|
+
@visitor.options = {}
|
20
|
+
|
21
|
+
@feature = mock('feature', :visit? => true).as_null_object
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should execute Before blocks before background steps" do
|
10
25
|
background = Background.new(
|
11
|
-
comment=Comment.new(
|
12
|
-
line=
|
26
|
+
comment=Comment.new(''),
|
27
|
+
line=2,
|
13
28
|
keyword="",
|
14
29
|
steps=[
|
15
|
-
|
30
|
+
Step.new(7, "Given", "y is 5")
|
16
31
|
])
|
17
|
-
visitor = mock('visitor', :null_object => true)
|
18
32
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@background = Background.new(
|
29
|
-
comment=Comment.new(""),
|
30
|
-
line=99,
|
31
|
-
keyword="",
|
32
|
-
steps=[
|
33
|
-
@mock_step
|
34
|
-
])
|
35
|
-
|
36
|
-
@visitor = mock('visitor', :null_object => true)
|
37
|
-
@background.accept(@visitor)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should execute the steps" do
|
41
|
-
@mock_step.should_receive(:execute_as_new).and_return(mock('executed step', :null_object => true))
|
42
|
-
|
43
|
-
@background.accept(@visitor)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should visit the background if there was a exception when executing a step" do
|
47
|
-
mock_executed_step = mock('executed step', :null_object => true, :exception => Exception.new)
|
48
|
-
@mock_step.stub!(:execute_as_new).and_return(mock_executed_step)
|
49
|
-
|
50
|
-
@visitor.should_receive(:visit_background).with(@background)
|
33
|
+
scenario = Scenario.new(
|
34
|
+
background,
|
35
|
+
comment=Comment.new(""),
|
36
|
+
tags=Tags.new(98,[]),
|
37
|
+
line=99,
|
38
|
+
keyword="",
|
39
|
+
name="",
|
40
|
+
steps=[])
|
41
|
+
background.feature = @feature
|
51
42
|
|
52
|
-
|
53
|
-
|
54
|
-
|
43
|
+
@visitor.visit_background(background)
|
44
|
+
$x.should == 2
|
45
|
+
$y.should == 10
|
55
46
|
end
|
56
47
|
end
|
57
48
|
end
|