aslakhellesoy-cucumber 0.2.3.1 → 0.2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +23 -2
- data/Manifest.txt +47 -47
- data/examples/i18n/ru/features/support/world.rb +4 -3
- data/examples/sinatra/features/support/env.rb +2 -6
- data/examples/test_unit/features/step_definitions/test_unit_steps.rb +1 -4
- data/lib/cucumber/ast/py_string.rb +1 -6
- data/lib/cucumber/ast/step.rb +3 -5
- data/lib/cucumber/ast/step_invocation.rb +1 -2
- data/lib/cucumber/ast/table.rb +0 -13
- data/lib/cucumber/ast/visitor.rb +12 -6
- data/lib/cucumber/formatter/html.rb +16 -6
- data/lib/cucumber/formatter/pretty.rb +9 -3
- data/lib/cucumber/languages.yml +4 -4
- data/lib/cucumber/step_mother.rb +85 -18
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/templates/paths.rb +13 -4
- data/{specs → spec}/cucumber/ast/background_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/feature_factory.rb +0 -0
- data/{specs → spec}/cucumber/ast/feature_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/py_string_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/scenario_outline_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/scenario_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/step_collection_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/step_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/table_spec.rb +0 -0
- data/{specs → spec}/cucumber/ast/tags_spec.rb +0 -0
- data/{specs → spec}/cucumber/broadcaster_spec.rb +0 -0
- data/{specs → spec}/cucumber/cli/configuration_spec.rb +0 -0
- data/{specs → spec}/cucumber/cli/main_spec.rb +0 -0
- data/{specs → spec}/cucumber/core_ext/proc_spec.rb +1 -1
- data/{specs → spec}/cucumber/core_ext/string_spec.rb +0 -0
- data/{specs → spec}/cucumber/formatter/ansicolor_spec.rb +0 -0
- data/{specs → spec}/cucumber/formatter/color_io_spec.rb +0 -0
- data/{specs → spec}/cucumber/formatter/html/cucumber.css +0 -0
- data/{specs → spec}/cucumber/formatter/html/cucumber.js +0 -0
- data/{specs → spec}/cucumber/formatter/html/index.html +0 -0
- data/{specs → spec}/cucumber/formatter/html/jquery-1.3.min.js +0 -0
- data/{specs → spec}/cucumber/formatter/html/jquery.uitableedit.js +0 -0
- data/{specs → spec}/cucumber/formatters/profile_formatter_spec.rb +0 -0
- data/{specs → spec}/cucumber/parser/feature_parser_spec.rb +0 -0
- data/{specs → spec}/cucumber/parser/table_parser_spec.rb +0 -0
- data/{specs → spec}/cucumber/rails/stubs/mini_rails.rb +0 -0
- data/{specs → spec}/cucumber/rails/stubs/test_help.rb +0 -0
- data/{specs → spec}/cucumber/rails/world_spec.rb +0 -0
- data/{specs → spec}/cucumber/sell_cucumbers.feature +0 -0
- data/{specs → spec}/cucumber/step_definition_spec.rb +0 -0
- data/{specs → spec}/cucumber/step_mother_spec.rb +41 -6
- data/{specs → spec}/cucumber/treetop_parser/empty_feature.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/empty_scenario.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/empty_scenario_outline.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/fit_scenario.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/given_scenario.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/invalid_scenario_outlines.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/multiline_steps.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/multiple_tables.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/scenario_outline.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/spaces.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/test_dos.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/with_comments.feature +0 -0
- data/{specs → spec}/cucumber/treetop_parser/with_tags.feature +0 -0
- data/{specs → spec}/cucumber/world/pending_spec.rb +0 -0
- data/{specs → spec}/spec.opts +0 -0
- data/{specs → spec}/spec_helper.rb +0 -0
- metadata +49 -49
data/History.txt
CHANGED
@@ -1,12 +1,33 @@
|
|
1
|
-
== 0.
|
1
|
+
== 0.3.0 (In Git)
|
2
|
+
|
3
|
+
This release has some minor changes to the APIs, but big enough that a new major release is in order.
|
4
|
+
The biggest change is the new semantics of the #World method. Previously you would call this method
|
5
|
+
several times, passing a Proc and extending the world object of the previous one with a Ruby module.
|
6
|
+
The problem was that there was no nice way to ensure the order in which these procs were called, which
|
7
|
+
led to some unexpected situations. In this release you can only register a single World proc. If you
|
8
|
+
want to extend a world with certain modules, you simply call the #World method with the module(s)
|
9
|
+
you wish to extend the World with. The Sinatra example illustrates how to do this.
|
10
|
+
|
11
|
+
The Visitor API (which is used for formatters) has also changed slightly. However, we have tried to
|
12
|
+
do this in a backwards compatible way, so if you have custom formatters for Cucumber 0.2 they should
|
13
|
+
still work.
|
2
14
|
|
3
15
|
=== New features
|
16
|
+
* Only a single World proc can be registered. World extension now happens by calling #World with ruby modules.
|
17
|
+
* Portuguese uses Funcionalidade in stead of Característica and accented words are aliased with unaccented ones (Alexandre da Silva and Felipe Coury).
|
4
18
|
* The usage formatter also prints unused step definitions (Aslak Hellesøy)
|
5
19
|
* Better exception if a World proc returns nil. (Aslak Hellesøy)
|
6
20
|
* Allow Step Definitions to use |*varargs|, but only on Ruby 1.9. (Aslak Hellesøy)
|
7
|
-
* Snippets for steps that use Step Tables or
|
21
|
+
* Snippets for steps that use Step Tables or PyStrings include block param and object type hint comment (#247 Joseph Wilk)
|
8
22
|
* Support description string for Backgrounds (#271 Joseph Wilk)
|
9
23
|
|
24
|
+
=== Removed/changed features
|
25
|
+
* The visitor API has changed slightly:
|
26
|
+
** #visit_step_name, #visit_multiline_arg and #visit_exception are no longer official API methods.
|
27
|
+
** #visit_step_result replaces those 3 methods.
|
28
|
+
** Table and PyString no longer hold status information. Each visitor subclass should store state in @state if needed.
|
29
|
+
** #visit_py_string no longer takes a status argument.
|
30
|
+
|
10
31
|
== 0.2.3 2009-03-30
|
11
32
|
|
12
33
|
This release sports 4 updated languages, slightly better help with snippets if you "quote" arguments
|
data/Manifest.txt
CHANGED
@@ -286,50 +286,50 @@ rails_generators/feature/USAGE
|
|
286
286
|
rails_generators/feature/feature_generator.rb
|
287
287
|
rails_generators/feature/templates/feature.erb
|
288
288
|
rails_generators/feature/templates/steps.erb
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
289
|
+
spec/cucumber/ast/background_spec.rb
|
290
|
+
spec/cucumber/ast/feature_factory.rb
|
291
|
+
spec/cucumber/ast/feature_spec.rb
|
292
|
+
spec/cucumber/ast/py_string_spec.rb
|
293
|
+
spec/cucumber/ast/scenario_outline_spec.rb
|
294
|
+
spec/cucumber/ast/scenario_spec.rb
|
295
|
+
spec/cucumber/ast/step_collection_spec.rb
|
296
|
+
spec/cucumber/ast/step_spec.rb
|
297
|
+
spec/cucumber/ast/table_spec.rb
|
298
|
+
spec/cucumber/ast/tags_spec.rb
|
299
|
+
spec/cucumber/broadcaster_spec.rb
|
300
|
+
spec/cucumber/cli/configuration_spec.rb
|
301
|
+
spec/cucumber/cli/main_spec.rb
|
302
|
+
spec/cucumber/core_ext/proc_spec.rb
|
303
|
+
spec/cucumber/core_ext/string_spec.rb
|
304
|
+
spec/cucumber/formatter/ansicolor_spec.rb
|
305
|
+
spec/cucumber/formatter/color_io_spec.rb
|
306
|
+
spec/cucumber/formatter/html/cucumber.css
|
307
|
+
spec/cucumber/formatter/html/cucumber.js
|
308
|
+
spec/cucumber/formatter/html/index.html
|
309
|
+
spec/cucumber/formatter/html/jquery-1.3.min.js
|
310
|
+
spec/cucumber/formatter/html/jquery.uitableedit.js
|
311
|
+
spec/cucumber/formatters/profile_formatter_spec.rb
|
312
|
+
spec/cucumber/parser/feature_parser_spec.rb
|
313
|
+
spec/cucumber/parser/table_parser_spec.rb
|
314
|
+
spec/cucumber/rails/stubs/mini_rails.rb
|
315
|
+
spec/cucumber/rails/stubs/test_help.rb
|
316
|
+
spec/cucumber/rails/world_spec.rb
|
317
|
+
spec/cucumber/sell_cucumbers.feature
|
318
|
+
spec/cucumber/step_definition_spec.rb
|
319
|
+
spec/cucumber/step_mother_spec.rb
|
320
|
+
spec/cucumber/treetop_parser/empty_feature.feature
|
321
|
+
spec/cucumber/treetop_parser/empty_scenario.feature
|
322
|
+
spec/cucumber/treetop_parser/empty_scenario_outline.feature
|
323
|
+
spec/cucumber/treetop_parser/fit_scenario.feature
|
324
|
+
spec/cucumber/treetop_parser/given_scenario.feature
|
325
|
+
spec/cucumber/treetop_parser/invalid_scenario_outlines.feature
|
326
|
+
spec/cucumber/treetop_parser/multiline_steps.feature
|
327
|
+
spec/cucumber/treetop_parser/multiple_tables.feature
|
328
|
+
spec/cucumber/treetop_parser/scenario_outline.feature
|
329
|
+
spec/cucumber/treetop_parser/spaces.feature
|
330
|
+
spec/cucumber/treetop_parser/test_dos.feature
|
331
|
+
spec/cucumber/treetop_parser/with_comments.feature
|
332
|
+
spec/cucumber/treetop_parser/with_tags.feature
|
333
|
+
spec/cucumber/world/pending_spec.rb
|
334
|
+
spec/spec.opts
|
335
|
+
spec/spec_helper.rb
|
@@ -16,9 +16,5 @@ Webrat.configure do |config|
|
|
16
16
|
config.mode = :sinatra
|
17
17
|
end
|
18
18
|
|
19
|
-
World
|
20
|
-
|
21
|
-
session.extend(Webrat::Matchers)
|
22
|
-
session.extend(Webrat::HaveTagMatcher)
|
23
|
-
session
|
24
|
-
end
|
19
|
+
World{Webrat::SinatraSession.new}
|
20
|
+
World(Webrat::Matchers, Webrat::HaveTagMatcher)
|
@@ -25,11 +25,6 @@ module Cucumber
|
|
25
25
|
def initialize(start_line, end_line, string, quotes_indent)
|
26
26
|
@start_line, @end_line = start_line, end_line
|
27
27
|
@string, @quotes_indent = string.gsub(/\\"/, '"'), quotes_indent
|
28
|
-
@status = :passed
|
29
|
-
end
|
30
|
-
|
31
|
-
def status=(status)
|
32
|
-
@status = status
|
33
28
|
end
|
34
29
|
|
35
30
|
def to_s
|
@@ -41,7 +36,7 @@ module Cucumber
|
|
41
36
|
end
|
42
37
|
|
43
38
|
def accept(visitor)
|
44
|
-
visitor.visit_py_string(to_s
|
39
|
+
visitor.visit_py_string(to_s)
|
45
40
|
end
|
46
41
|
|
47
42
|
def arguments_replaced(arguments) #:nodoc:
|
data/lib/cucumber/ast/step.rb
CHANGED
@@ -33,13 +33,11 @@ module Cucumber
|
|
33
33
|
def accept(visitor)
|
34
34
|
# The only time a Step is visited is when it is in a ScenarioOutline.
|
35
35
|
# Otherwise it's always StepInvocation that gest visited instead.
|
36
|
-
|
36
|
+
visit_step_result(visitor, first_match(visitor), @multiline_arg, :skipped, nil, nil)
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
visitor.
|
41
|
-
visitor.visit_multiline_arg(@multiline_arg) if @multiline_arg
|
42
|
-
visitor.visit_exception(exception, status) if exception
|
39
|
+
def visit_step_result(visitor, step_match, multiline_arg, status, exception, background)
|
40
|
+
visitor.visit_step_result(@keyword, step_match, @multiline_arg, status, exception, source_indent, background)
|
43
41
|
end
|
44
42
|
|
45
43
|
def first_match(visitor)
|
@@ -20,7 +20,7 @@ module Cucumber
|
|
20
20
|
|
21
21
|
def accept(visitor)
|
22
22
|
invoke(visitor.step_mother, visitor.options)
|
23
|
-
@step.
|
23
|
+
@step.visit_step_result(visitor, @step_match, @multiline_arg, @status, @exception, @background)
|
24
24
|
end
|
25
25
|
|
26
26
|
def invoke(step_mother, options)
|
@@ -68,7 +68,6 @@ module Cucumber
|
|
68
68
|
|
69
69
|
def status!(status)
|
70
70
|
@status = status
|
71
|
-
@multiline_arg.status = status if @multiline_arg
|
72
71
|
@matched_cells.each do |cell|
|
73
72
|
cell.status = status
|
74
73
|
end
|
data/lib/cucumber/ast/table.rb
CHANGED
@@ -116,12 +116,6 @@ module Cucumber
|
|
116
116
|
nil
|
117
117
|
end
|
118
118
|
|
119
|
-
def status=(status)
|
120
|
-
cells_rows.each do |row|
|
121
|
-
row.status = status
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
119
|
# For testing only
|
126
120
|
def to_sexp #:nodoc:
|
127
121
|
[:table, *cells_rows.map{|row| row.to_sexp}]
|
@@ -293,12 +287,6 @@ module Cucumber
|
|
293
287
|
"row_#{line}"
|
294
288
|
end
|
295
289
|
|
296
|
-
def status=(status)
|
297
|
-
each do |cell|
|
298
|
-
cell.status = status
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
290
|
private
|
303
291
|
|
304
292
|
def index
|
@@ -320,7 +308,6 @@ module Cucumber
|
|
320
308
|
|
321
309
|
def initialize(value, table, row, col, line)
|
322
310
|
@value, @table, @row, @col, @line = value, table, row, col, line
|
323
|
-
@status = :passed
|
324
311
|
end
|
325
312
|
|
326
313
|
def accept(visitor)
|
data/lib/cucumber/ast/visitor.rb
CHANGED
@@ -93,14 +93,23 @@ module Cucumber
|
|
93
93
|
step.accept(self)
|
94
94
|
end
|
95
95
|
|
96
|
-
def
|
96
|
+
def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
|
97
|
+
visit_step_name(keyword, step_match, status, source_indent, background)
|
98
|
+
visit_multiline_arg(multiline_arg) if multiline_arg
|
99
|
+
visit_exception(exception, status) if exception
|
97
100
|
end
|
98
101
|
|
99
|
-
def
|
102
|
+
def visit_step_name(keyword, step_match, status, source_indent, background) #:nodoc:
|
103
|
+
end
|
104
|
+
|
105
|
+
def visit_multiline_arg(multiline_arg) #:nodoc:
|
100
106
|
multiline_arg.accept(self)
|
101
107
|
end
|
102
108
|
|
103
|
-
def
|
109
|
+
def visit_exception(exception, status) #:nodoc:
|
110
|
+
end
|
111
|
+
|
112
|
+
def visit_py_string(string)
|
104
113
|
end
|
105
114
|
|
106
115
|
def visit_table_row(table_row)
|
@@ -114,9 +123,6 @@ module Cucumber
|
|
114
123
|
def visit_table_cell_value(value, width, status)
|
115
124
|
end
|
116
125
|
|
117
|
-
def visit_exception(exception, status)
|
118
|
-
end
|
119
|
-
|
120
126
|
def announce(announcement)
|
121
127
|
end
|
122
128
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'erb'
|
1
2
|
begin
|
2
3
|
require 'builder'
|
3
4
|
rescue LoadError
|
@@ -8,6 +9,8 @@ end
|
|
8
9
|
module Cucumber
|
9
10
|
module Formatter
|
10
11
|
class Html < Ast::Visitor
|
12
|
+
include ERB::Util # for the #h method
|
13
|
+
|
11
14
|
def initialize(step_mother, io, options)
|
12
15
|
super(step_mother)
|
13
16
|
@builder = Builder::XmlMarkup.new(:target => io, :indent => 2)
|
@@ -93,7 +96,12 @@ module Cucumber
|
|
93
96
|
|
94
97
|
def visit_step(step)
|
95
98
|
@step_id = step.dom_id
|
96
|
-
|
99
|
+
super
|
100
|
+
end
|
101
|
+
|
102
|
+
def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
|
103
|
+
@status = status
|
104
|
+
@builder.li(:id => @step_id, :class => status) do
|
97
105
|
super
|
98
106
|
end
|
99
107
|
end
|
@@ -105,8 +113,8 @@ module Cucumber
|
|
105
113
|
|
106
114
|
unless @skip_step
|
107
115
|
step_name = step_match.format_args(lambda{|param| "<span>#{param}</span>"})
|
108
|
-
@builder.div
|
109
|
-
div << "#{keyword} #{step_name}"
|
116
|
+
@builder.div do |div|
|
117
|
+
div << h("#{keyword} #{step_name}")
|
110
118
|
end
|
111
119
|
end
|
112
120
|
end
|
@@ -126,8 +134,8 @@ module Cucumber
|
|
126
134
|
end
|
127
135
|
end
|
128
136
|
|
129
|
-
def visit_py_string(string
|
130
|
-
@builder.pre(:class => status) do |pre|
|
137
|
+
def visit_py_string(string)
|
138
|
+
@builder.pre(:class => @status) do |pre|
|
131
139
|
pre << string
|
132
140
|
end
|
133
141
|
end
|
@@ -152,7 +160,9 @@ module Cucumber
|
|
152
160
|
|
153
161
|
def visit_table_cell_value(value, width, status)
|
154
162
|
cell_type = @outline_row == 0 ? :th : :td
|
155
|
-
|
163
|
+
attributes = {:id => "#{@row_id}_#{@col_index}"}
|
164
|
+
attributes[:class] = status if status
|
165
|
+
@builder.__send__(cell_type, value, attributes)
|
156
166
|
@col_index += 1
|
157
167
|
end
|
158
168
|
|
@@ -119,6 +119,11 @@ module Cucumber
|
|
119
119
|
super
|
120
120
|
end
|
121
121
|
|
122
|
+
def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
|
123
|
+
@status = status
|
124
|
+
super
|
125
|
+
end
|
126
|
+
|
122
127
|
def visit_step_name(keyword, step_match, status, source_indent, background)
|
123
128
|
@step_matches ||= []
|
124
129
|
non_failed_background_step_outside_background = !@in_background && background && (status != :failed)
|
@@ -150,14 +155,15 @@ module Cucumber
|
|
150
155
|
print_exception(table_row.exception, :failed, @indent) if table_row.exception
|
151
156
|
end
|
152
157
|
|
153
|
-
def visit_py_string(string
|
154
|
-
s = "
|
158
|
+
def visit_py_string(string)
|
159
|
+
s = %{"""\n#{string}\n"""}.indent(@indent)
|
155
160
|
s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
|
156
|
-
@io.puts(format_string(s, status))
|
161
|
+
@io.puts(format_string(s, @status))
|
157
162
|
@io.flush
|
158
163
|
end
|
159
164
|
|
160
165
|
def visit_table_cell_value(value, width, status)
|
166
|
+
status ||= @status || :passed
|
161
167
|
@io.print(' ' + format_string((value.to_s || '').ljust(width), status) + " #{@delim}")
|
162
168
|
@io.flush
|
163
169
|
end
|
data/lib/cucumber/languages.yml
CHANGED
@@ -311,13 +311,13 @@
|
|
311
311
|
native: português
|
312
312
|
encoding: UTF-8
|
313
313
|
background: Contexto
|
314
|
-
feature:
|
315
|
-
scenario: Cenário
|
316
|
-
scenario_outline: Esquema do Cenário
|
314
|
+
feature: Funcionalidade
|
315
|
+
scenario: Cenário|Cenario
|
316
|
+
scenario_outline: Esquema do Cenário|Esquema do Cenario
|
317
317
|
examples: Exemplos
|
318
318
|
given: Dado
|
319
319
|
when: Quando
|
320
|
-
then: Então
|
320
|
+
then: Então|Entao
|
321
321
|
and: E
|
322
322
|
but: Mas
|
323
323
|
space_after_keyword: true
|
data/lib/cucumber/step_mother.rb
CHANGED
@@ -51,6 +51,17 @@ module Cucumber
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
class MultipleWorld < StandardError
|
55
|
+
def initialize(first_proc, second_proc)
|
56
|
+
message = "You can only pass a proc to #World once, but it's happening\n"
|
57
|
+
message << "in 2 places:\n\n"
|
58
|
+
message << first_proc.backtrace_line('World') << "\n"
|
59
|
+
message << second_proc.backtrace_line('World') << "\n\n"
|
60
|
+
message << "Use Ruby modules instead to extend your worlds. See the #World RDoc.\n\n"
|
61
|
+
super(message)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
54
65
|
# This is the main interface for registering step definitions, which is done
|
55
66
|
# from <tt>*_steps.rb</tt> files. This module is included right at the top-level
|
56
67
|
# so #register_step_definition (and more interestingly - its aliases) are
|
@@ -111,10 +122,46 @@ module Cucumber
|
|
111
122
|
(@after_procs ||= []).unshift(proc)
|
112
123
|
end
|
113
124
|
|
114
|
-
# Registers
|
115
|
-
#
|
116
|
-
|
117
|
-
|
125
|
+
# Registers any number of +world_modules+ (Ruby Modules) and/or a Proc.
|
126
|
+
# The +proc+ will be executed once before each scenario to create an
|
127
|
+
# Object that the scenario's steps will run within. Any +world_modules+
|
128
|
+
# will be mixed into this Object (via Object#extend).
|
129
|
+
#
|
130
|
+
# This method is typically called from one or more Ruby scripts under
|
131
|
+
# <tt>features/support</tt>. You can call this method as many times as you
|
132
|
+
# like (to register more modules), but if you try to register more than
|
133
|
+
# one Proc you will get an error.
|
134
|
+
#
|
135
|
+
# Cucumber will not yield anything to the +proc+ (like it used to do before v0.3).
|
136
|
+
#
|
137
|
+
# In earlier versions of Cucumber (before 0.3) you could not register
|
138
|
+
# any +world_modules+. Instead you would register several Proc objects (by
|
139
|
+
# calling the method several times). The result of each +proc+ would be yielded
|
140
|
+
# to the next +proc+. Example:
|
141
|
+
#
|
142
|
+
# World do |world| # NOT SUPPORTED FROM 0.3
|
143
|
+
# MyClass.new
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# World do |world| # NOT SUPPORTED FROM 0.3
|
147
|
+
# world.extend(MyModule)
|
148
|
+
# end
|
149
|
+
#
|
150
|
+
# From Cucumber 0.3 the recommended way to do this is:
|
151
|
+
#
|
152
|
+
# World do
|
153
|
+
# MyClass.new
|
154
|
+
# end
|
155
|
+
#
|
156
|
+
# World(MyModule)
|
157
|
+
#
|
158
|
+
def World(*world_modules, &proc)
|
159
|
+
if(proc)
|
160
|
+
raise MultipleWorld.new(@world_proc, proc) if @world_proc
|
161
|
+
@world_proc = proc
|
162
|
+
end
|
163
|
+
@world_modules ||= []
|
164
|
+
@world_modules += world_modules
|
118
165
|
end
|
119
166
|
|
120
167
|
def current_world
|
@@ -174,26 +221,46 @@ module Cucumber
|
|
174
221
|
|
175
222
|
# Creates a new world instance
|
176
223
|
def new_world!
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
224
|
+
create_world!
|
225
|
+
extend_world
|
226
|
+
connect_world
|
227
|
+
@current_world
|
228
|
+
end
|
229
|
+
|
230
|
+
def create_world!
|
231
|
+
if(@world_proc)
|
232
|
+
@current_world = @world_proc.call
|
233
|
+
check_nil(@current_world, @world_proc)
|
234
|
+
else
|
235
|
+
@current_world = Object.new
|
189
236
|
end
|
237
|
+
end
|
190
238
|
|
239
|
+
def extend_world
|
191
240
|
@current_world.extend(World)
|
241
|
+
@current_world.extend(::Spec::Matchers) if defined?(::Spec::Matchers)
|
242
|
+
(@world_modules || []).each do |mod|
|
243
|
+
@current_world.extend(mod)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def connect_world
|
192
248
|
@current_world.__cucumber_step_mother = self
|
193
249
|
@current_world.__cucumber_visitor = @visitor
|
250
|
+
end
|
194
251
|
|
195
|
-
|
196
|
-
|
252
|
+
def check_nil(o, proc)
|
253
|
+
if o.nil?
|
254
|
+
begin
|
255
|
+
raise NilWorld.new
|
256
|
+
rescue NilWorld => e
|
257
|
+
e.backtrace.clear
|
258
|
+
e.backtrace.push(proc.backtrace_line("World"))
|
259
|
+
raise e
|
260
|
+
end
|
261
|
+
else
|
262
|
+
o
|
263
|
+
end
|
197
264
|
end
|
198
265
|
|
199
266
|
def nil_world!
|
data/lib/cucumber/version.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
module NavigationHelpers
|
2
|
+
# Maps a static name to a static route.
|
3
|
+
#
|
4
|
+
# This method is *not* designed to map from a dynamic name to a
|
5
|
+
# dynamic route like <tt>post_comments_path(post)</tt>. For dynamic
|
6
|
+
# routes like this you should *not* rely on #path_to, but write
|
7
|
+
# your own step definitions instead. Example:
|
8
|
+
#
|
9
|
+
# Given /I am on the comments page for the "(.+)" post/ |name|
|
10
|
+
# post = Post.find_by_name(name)
|
11
|
+
# visit post_comments_path(post)
|
12
|
+
# end
|
13
|
+
#
|
2
14
|
def path_to(page_name)
|
3
15
|
case page_name
|
4
16
|
|
@@ -14,7 +26,4 @@ module NavigationHelpers
|
|
14
26
|
end
|
15
27
|
end
|
16
28
|
|
17
|
-
World
|
18
|
-
world.extend NavigationHelpers
|
19
|
-
world
|
20
|
-
end
|
29
|
+
World(NavigationHelpers)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,7 +4,7 @@ require 'cucumber/core_ext/instance_exec'
|
|
4
4
|
describe Proc do
|
5
5
|
it "should remove extraneous path info for file" do
|
6
6
|
proc = lambda {|a,b|}
|
7
|
-
proc.file_colon_line.should =~ /^
|
7
|
+
proc.file_colon_line.should =~ /^spec\/cucumber\/core_ext\/proc_spec\.rb:6/
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should raise ArityMismatchError for too many args (expecting 0)" do
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -27,8 +27,8 @@ module Cucumber
|
|
27
27
|
@step_mother.step_match("Three blind mice")
|
28
28
|
end.should raise_error(Ambiguous, %{Ambiguous match of "Three blind mice":
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
spec/cucumber/step_mother_spec.rb:23:in `/Three (.*) mice/'
|
31
|
+
spec/cucumber/step_mother_spec.rb:24:in `/Three blind (.*)/'
|
32
32
|
|
33
33
|
You can run again with --guess to make Cucumber be more smart about it
|
34
34
|
})
|
@@ -43,8 +43,8 @@ You can run again with --guess to make Cucumber be more smart about it
|
|
43
43
|
@step_mother.step_match("Three cute mice")
|
44
44
|
end.should raise_error(Ambiguous, %{Ambiguous match of "Three cute mice":
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
spec/cucumber/step_mother_spec.rb:39:in `/Three (.*) mice/'
|
47
|
+
spec/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
|
48
48
|
|
49
49
|
})
|
50
50
|
end
|
@@ -93,10 +93,45 @@ specs/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
|
|
93
93
|
begin
|
94
94
|
@step_mother.before_and_after(nil)
|
95
95
|
raise "Should fail"
|
96
|
-
rescue => e
|
96
|
+
rescue NilWorld => e
|
97
97
|
e.message.should == "World procs should never return nil"
|
98
|
-
e.backtrace.should == ["
|
98
|
+
e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:90:in `World'"]
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
module ModuleOne
|
103
|
+
end
|
104
|
+
|
105
|
+
module ModuleTwo
|
106
|
+
end
|
107
|
+
|
108
|
+
class ClassOne
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should implicitly extend world with modules" do
|
112
|
+
@step_mother.World(ModuleOne, ModuleTwo)
|
113
|
+
|
114
|
+
w = @step_mother.__send__(:new_world!)
|
115
|
+
class << w
|
116
|
+
included_modules.index(ModuleOne).should_not == nil
|
117
|
+
included_modules.index(ModuleTwo).should_not == nil
|
118
|
+
end
|
119
|
+
w.class.should == Object
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should raise error when we try to register more than one World proc" do
|
123
|
+
@step_mother.World { Hash.new }
|
124
|
+
lambda do
|
125
|
+
@step_mother.World { Array.new }
|
126
|
+
end.should raise_error(MultipleWorld, %{You can only pass a proc to #World once, but it's happening
|
127
|
+
in 2 places:
|
128
|
+
|
129
|
+
spec/cucumber/step_mother_spec.rb:123:in `World'
|
130
|
+
spec/cucumber/step_mother_spec.rb:125:in `World'
|
131
|
+
|
132
|
+
Use Ruby modules instead to extend your worlds. See the #World RDoc.
|
133
|
+
|
134
|
+
})
|
135
|
+
end
|
101
136
|
end
|
102
137
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/{specs → spec}/spec.opts
RENAMED
File without changes
|
File without changes
|
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.2.3.
|
4
|
+
version: 0.2.3.2
|
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-04-
|
12
|
+
date: 2009-04-06 00:00:00 -07:00
|
13
13
|
default_executable: cucumber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -373,53 +373,53 @@ files:
|
|
373
373
|
- rails_generators/feature/feature_generator.rb
|
374
374
|
- rails_generators/feature/templates/feature.erb
|
375
375
|
- rails_generators/feature/templates/steps.erb
|
376
|
-
-
|
377
|
-
-
|
378
|
-
-
|
379
|
-
-
|
380
|
-
-
|
381
|
-
-
|
382
|
-
-
|
383
|
-
-
|
384
|
-
-
|
385
|
-
-
|
386
|
-
-
|
387
|
-
-
|
388
|
-
-
|
389
|
-
-
|
390
|
-
-
|
391
|
-
-
|
392
|
-
-
|
393
|
-
-
|
394
|
-
-
|
395
|
-
-
|
396
|
-
-
|
397
|
-
-
|
398
|
-
-
|
399
|
-
-
|
400
|
-
-
|
401
|
-
-
|
402
|
-
-
|
403
|
-
-
|
404
|
-
-
|
405
|
-
-
|
406
|
-
-
|
407
|
-
-
|
408
|
-
-
|
409
|
-
-
|
410
|
-
-
|
411
|
-
-
|
412
|
-
-
|
413
|
-
-
|
414
|
-
-
|
415
|
-
-
|
416
|
-
-
|
417
|
-
-
|
418
|
-
-
|
419
|
-
-
|
420
|
-
-
|
421
|
-
-
|
422
|
-
-
|
376
|
+
- spec/cucumber/ast/background_spec.rb
|
377
|
+
- spec/cucumber/ast/feature_factory.rb
|
378
|
+
- spec/cucumber/ast/feature_spec.rb
|
379
|
+
- spec/cucumber/ast/py_string_spec.rb
|
380
|
+
- spec/cucumber/ast/scenario_outline_spec.rb
|
381
|
+
- spec/cucumber/ast/scenario_spec.rb
|
382
|
+
- spec/cucumber/ast/step_collection_spec.rb
|
383
|
+
- spec/cucumber/ast/step_spec.rb
|
384
|
+
- spec/cucumber/ast/table_spec.rb
|
385
|
+
- spec/cucumber/ast/tags_spec.rb
|
386
|
+
- spec/cucumber/broadcaster_spec.rb
|
387
|
+
- spec/cucumber/cli/configuration_spec.rb
|
388
|
+
- spec/cucumber/cli/main_spec.rb
|
389
|
+
- spec/cucumber/core_ext/proc_spec.rb
|
390
|
+
- spec/cucumber/core_ext/string_spec.rb
|
391
|
+
- spec/cucumber/formatter/ansicolor_spec.rb
|
392
|
+
- spec/cucumber/formatter/color_io_spec.rb
|
393
|
+
- spec/cucumber/formatter/html/cucumber.css
|
394
|
+
- spec/cucumber/formatter/html/cucumber.js
|
395
|
+
- spec/cucumber/formatter/html/index.html
|
396
|
+
- spec/cucumber/formatter/html/jquery-1.3.min.js
|
397
|
+
- spec/cucumber/formatter/html/jquery.uitableedit.js
|
398
|
+
- spec/cucumber/formatters/profile_formatter_spec.rb
|
399
|
+
- spec/cucumber/parser/feature_parser_spec.rb
|
400
|
+
- spec/cucumber/parser/table_parser_spec.rb
|
401
|
+
- spec/cucumber/rails/stubs/mini_rails.rb
|
402
|
+
- spec/cucumber/rails/stubs/test_help.rb
|
403
|
+
- spec/cucumber/rails/world_spec.rb
|
404
|
+
- spec/cucumber/sell_cucumbers.feature
|
405
|
+
- spec/cucumber/step_definition_spec.rb
|
406
|
+
- spec/cucumber/step_mother_spec.rb
|
407
|
+
- spec/cucumber/treetop_parser/empty_feature.feature
|
408
|
+
- spec/cucumber/treetop_parser/empty_scenario.feature
|
409
|
+
- spec/cucumber/treetop_parser/empty_scenario_outline.feature
|
410
|
+
- spec/cucumber/treetop_parser/fit_scenario.feature
|
411
|
+
- spec/cucumber/treetop_parser/given_scenario.feature
|
412
|
+
- spec/cucumber/treetop_parser/invalid_scenario_outlines.feature
|
413
|
+
- spec/cucumber/treetop_parser/multiline_steps.feature
|
414
|
+
- spec/cucumber/treetop_parser/multiple_tables.feature
|
415
|
+
- spec/cucumber/treetop_parser/scenario_outline.feature
|
416
|
+
- spec/cucumber/treetop_parser/spaces.feature
|
417
|
+
- spec/cucumber/treetop_parser/test_dos.feature
|
418
|
+
- spec/cucumber/treetop_parser/with_comments.feature
|
419
|
+
- spec/cucumber/treetop_parser/with_tags.feature
|
420
|
+
- spec/cucumber/world/pending_spec.rb
|
421
|
+
- spec/spec.opts
|
422
|
+
- spec/spec_helper.rb
|
423
423
|
has_rdoc: true
|
424
424
|
homepage: http://cukes.info
|
425
425
|
post_install_message:
|