cucumber 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +26 -1
- data/Manifest.txt +20 -1
- data/config/hoe.rb +5 -4
- data/examples/i18n/hu/Rakefile +6 -0
- data/examples/i18n/hu/features/addition.feature +16 -0
- data/examples/i18n/hu/features/division.feature +9 -0
- data/examples/i18n/hu/features/step_definitons/calculator_steps.rb +25 -0
- data/examples/i18n/hu/lib/calculator.rb +14 -0
- data/examples/i18n/lv/Rakefile +6 -0
- data/examples/i18n/lv/features/addition.feature +16 -0
- data/examples/i18n/lv/features/division.feature +9 -0
- data/examples/i18n/lv/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/lv/lib/calculator.rb +14 -0
- data/examples/self_test/features/background/failing_background.feature +1 -0
- data/examples/self_test/features/multiline_name.feature +27 -0
- data/examples/self_test/features/search_sample.feature +22 -0
- data/examples/self_test/features/step_definitions/sample_steps.rb +3 -2
- data/examples/tickets/Rakefile +3 -3
- data/examples/tickets/features/236.feature +9 -9
- data/examples/tickets/features/272/hooks.feature +26 -0
- data/examples/tickets/features/272/hooks_steps.rb +53 -0
- data/examples/tickets/features/301/filter_background_tagged_hooks.feature +6 -0
- data/examples/tickets/features/301/filter_background_tagged_hooks_steps.rb +12 -0
- data/examples/tickets/features/306/only_background.feature +4 -0
- data/features/background.feature +2 -1
- data/features/cucumber_cli.feature +88 -12
- data/features/cucumber_cli_outlines.feature +32 -0
- data/features/custom_formatter.feature +2 -2
- data/features/multiline_names.feature +43 -0
- data/features/report_called_undefined_steps.feature +1 -1
- data/features/usage.feature +13 -4
- data/lib/cucumber/ast/background.rb +10 -13
- data/lib/cucumber/ast/feature.rb +5 -0
- data/lib/cucumber/ast/feature_element.rb +23 -12
- data/lib/cucumber/ast/outline_table.rb +10 -0
- data/lib/cucumber/ast/py_string.rb +5 -1
- data/lib/cucumber/ast/scenario.rb +17 -6
- data/lib/cucumber/ast/scenario_outline.rb +1 -6
- data/lib/cucumber/ast/step.rb +6 -3
- data/lib/cucumber/ast/step_collection.rb +9 -1
- data/lib/cucumber/ast/table.rb +8 -0
- data/lib/cucumber/ast/visitor.rb +2 -2
- data/lib/cucumber/cli/configuration.rb +15 -14
- data/lib/cucumber/formatter/console.rb +1 -1
- data/lib/cucumber/formatter/html.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +7 -8
- data/lib/cucumber/languages.yml +30 -0
- data/lib/cucumber/parser/feature.rb +214 -14
- data/lib/cucumber/parser/feature.tt +44 -14
- data/lib/cucumber/parser/treetop_ext.rb +3 -3
- data/lib/cucumber/rails/world.rb +6 -0
- data/lib/cucumber/step_mother.rb +2 -1
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/world.rb +2 -2
- data/rails_generators/cucumber/templates/paths.rb +11 -13
- data/rails_generators/feature/feature_generator.rb +1 -1
- data/spec/cucumber/ast/feature_element_spec.rb +40 -0
- data/spec/cucumber/ast/py_string_spec.rb +4 -0
- data/spec/cucumber/ast/table_spec.rb +20 -4
- data/spec/cucumber/ast/visitor_spec.rb +27 -0
- data/spec/cucumber/cli/configuration_spec.rb +4 -13
- data/spec/cucumber/cli/main_spec.rb +55 -153
- data/spec/cucumber/parser/feature_parser_spec.rb +79 -0
- data/spec/cucumber/step_mother_spec.rb +12 -5
- metadata +22 -13
- data/spec/cucumber/formatters/profile_formatter_spec.rb +0 -198
@@ -25,8 +25,8 @@ module Cucumber
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def build(filter)
|
28
|
-
if(filter.nil? || feature_elements.accept?(filter))
|
29
|
-
background = bg.respond_to?(:build) ? bg.build : nil
|
28
|
+
if(filter.nil? || feature_elements.accept?(filter) || (!bg.empty? && filter.accept?(bg)))
|
29
|
+
background = bg.respond_to?(:build) ? bg.build : nil
|
30
30
|
Ast::Feature.new(
|
31
31
|
background,
|
32
32
|
comment.build,
|
@@ -76,13 +76,23 @@ module Cucumber
|
|
76
76
|
end
|
77
77
|
|
78
78
|
rule background
|
79
|
-
comment white background_keyword space* name:
|
79
|
+
comment white background_keyword space* name:lines_to_keyword? (eol+ / eof) steps {
|
80
|
+
|
81
|
+
def matches_name?(regexp_to_match)
|
82
|
+
name.build =~ regexp_to_match
|
83
|
+
end
|
84
|
+
|
85
|
+
def has_tags?(tag_names)
|
86
|
+
feature_tags = self.parent.tags
|
87
|
+
feature_tags.has_tags?(tag_names)
|
88
|
+
end
|
89
|
+
|
80
90
|
def build
|
81
91
|
Ast::Background.new(
|
82
92
|
comment.build,
|
83
93
|
background_keyword.line,
|
84
94
|
background_keyword.text_value,
|
85
|
-
name.
|
95
|
+
name.build,
|
86
96
|
steps.build
|
87
97
|
)
|
88
98
|
end
|
@@ -106,7 +116,7 @@ module Cucumber
|
|
106
116
|
end
|
107
117
|
|
108
118
|
rule scenario
|
109
|
-
comment tags white scenario_keyword space* name:
|
119
|
+
comment tags white scenario_keyword space* name:lines_to_keyword white steps white {
|
110
120
|
def at_line?(line)
|
111
121
|
scenario_keyword.line == line ||
|
112
122
|
steps.at_line?(line) ||
|
@@ -118,8 +128,8 @@ module Cucumber
|
|
118
128
|
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
119
129
|
end
|
120
130
|
|
121
|
-
def matches_name?(
|
122
|
-
name.
|
131
|
+
def matches_name?(regexp_to_match)
|
132
|
+
name.build =~ regexp_to_match
|
123
133
|
end
|
124
134
|
|
125
135
|
def build(background, filter)
|
@@ -129,7 +139,7 @@ module Cucumber
|
|
129
139
|
tags.build,
|
130
140
|
scenario_keyword.line,
|
131
141
|
scenario_keyword.text_value,
|
132
|
-
name.
|
142
|
+
name.build,
|
133
143
|
steps.build
|
134
144
|
)
|
135
145
|
end
|
@@ -137,7 +147,7 @@ module Cucumber
|
|
137
147
|
end
|
138
148
|
|
139
149
|
rule scenario_outline
|
140
|
-
comment tags white scenario_outline_keyword space* name:
|
150
|
+
comment tags white scenario_outline_keyword space* name:lines_to_keyword white steps examples_sections white {
|
141
151
|
def at_line?(line)
|
142
152
|
outline_at_line?(line) ||
|
143
153
|
examples_sections.at_line?(line) ||
|
@@ -154,8 +164,8 @@ module Cucumber
|
|
154
164
|
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
155
165
|
end
|
156
166
|
|
157
|
-
def matches_name?(
|
158
|
-
name.
|
167
|
+
def matches_name?(regexp_to_match)
|
168
|
+
name.build =~ regexp_to_match
|
159
169
|
end
|
160
170
|
|
161
171
|
def build(background, filter)
|
@@ -165,7 +175,7 @@ module Cucumber
|
|
165
175
|
tags.build,
|
166
176
|
scenario_outline_keyword.line,
|
167
177
|
scenario_outline_keyword.text_value,
|
168
|
-
name.
|
178
|
+
name.build,
|
169
179
|
steps.build,
|
170
180
|
examples_sections.build(filter, self)
|
171
181
|
)
|
@@ -219,7 +229,7 @@ module Cucumber
|
|
219
229
|
end
|
220
230
|
|
221
231
|
rule examples
|
222
|
-
space* examples_keyword space* name:
|
232
|
+
space* examples_keyword space* name:lines_to_keyword? eol table white {
|
223
233
|
def at_line?(line)
|
224
234
|
examples_keyword.line == line ||
|
225
235
|
table.at_line?(line)
|
@@ -233,8 +243,12 @@ module Cucumber
|
|
233
243
|
true
|
234
244
|
end
|
235
245
|
|
246
|
+
def matches_name?(regexp_to_match)
|
247
|
+
name.build =~ regexp_to_match
|
248
|
+
end
|
249
|
+
|
236
250
|
def build(filter, scenario_outline)
|
237
|
-
[examples_keyword.line, examples_keyword.text_value, name.
|
251
|
+
[examples_keyword.line, examples_keyword.text_value, name.build, table.raw(filter, scenario_outline)]
|
238
252
|
end
|
239
253
|
}
|
240
254
|
end
|
@@ -247,6 +261,22 @@ module Cucumber
|
|
247
261
|
(!eol .)*
|
248
262
|
end
|
249
263
|
|
264
|
+
rule line_to_keyword
|
265
|
+
white text:(!step_keyword !scenario_keyword !scenario_outline_keyword !table !tag !comment_line !eol .)+ {
|
266
|
+
def build
|
267
|
+
text.text_value.strip
|
268
|
+
end
|
269
|
+
}
|
270
|
+
end
|
271
|
+
|
272
|
+
rule lines_to_keyword
|
273
|
+
(line_to_keyword)* {
|
274
|
+
def build
|
275
|
+
elements.map{|s| s.build}.join("\n")
|
276
|
+
end
|
277
|
+
}
|
278
|
+
end
|
279
|
+
|
250
280
|
rule py_string
|
251
281
|
open_py_string s:(!close_py_string .)* close_py_string {
|
252
282
|
def at_line?(line)
|
@@ -17,7 +17,7 @@ module Cucumber
|
|
17
17
|
@lines = lines
|
18
18
|
@include_tags = options[:include_tags] || []
|
19
19
|
@exclude_tags = options[:exclude_tags] || []
|
20
|
-
@
|
20
|
+
@name_regexps = options[:name_regexps] || []
|
21
21
|
end
|
22
22
|
|
23
23
|
def accept?(syntax_node)
|
@@ -48,7 +48,7 @@ module Cucumber
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def matches_names?(syntax_node)
|
51
|
-
@
|
51
|
+
@name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.matches_name?(name_regexp)}
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -111,4 +111,4 @@ module Treetop
|
|
111
111
|
include Cucumber::Parser::TreetopExt
|
112
112
|
end
|
113
113
|
end
|
114
|
-
end
|
114
|
+
end
|
data/lib/cucumber/rails/world.rb
CHANGED
@@ -9,6 +9,7 @@ else
|
|
9
9
|
end
|
10
10
|
require 'test/unit/testresult'
|
11
11
|
|
12
|
+
|
12
13
|
# So that Test::Unit doesn't launch at the end - makes it think it has already been run.
|
13
14
|
Test::Unit.run = true if Test::Unit.respond_to?(:run=)
|
14
15
|
|
@@ -30,6 +31,11 @@ module Cucumber #:nodoc:
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def self.use_transactional_fixtures
|
34
|
+
|
35
|
+
unless ::Rails.configuration.cache_classes
|
36
|
+
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/test.rb). This setting is known to break Cucumber's use_transactional_fixtures method. Set config.cache_classes to true if you want to use transactional fixtures. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
|
37
|
+
end
|
38
|
+
|
33
39
|
World.use_transactional_fixtures = true
|
34
40
|
if defined?(ActiveRecord::Base)
|
35
41
|
$__cucumber_toplevel.Before do
|
data/lib/cucumber/step_mother.rb
CHANGED
@@ -57,7 +57,8 @@ module Cucumber
|
|
57
57
|
message << "in 2 places:\n\n"
|
58
58
|
message << first_proc.backtrace_line('World') << "\n"
|
59
59
|
message << second_proc.backtrace_line('World') << "\n\n"
|
60
|
-
message << "Use Ruby modules instead to extend your worlds. See the #World RDoc
|
60
|
+
message << "Use Ruby modules instead to extend your worlds. See the Cucumber::StepMother#World RDoc\n"
|
61
|
+
message << "or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.\n\n"
|
61
62
|
super(message)
|
62
63
|
end
|
63
64
|
end
|
data/lib/cucumber/version.rb
CHANGED
data/lib/cucumber/world.rb
CHANGED
@@ -16,7 +16,7 @@ module Cucumber
|
|
16
16
|
step_match.invoke(self, multiline_argument)
|
17
17
|
rescue Exception => e
|
18
18
|
e.nested! if Undefined === e
|
19
|
-
@__cucumber_current_step.exception = e
|
19
|
+
@__cucumber_current_step.exception = e if @__cucumber_current_step
|
20
20
|
raise e
|
21
21
|
end
|
22
22
|
end
|
@@ -50,4 +50,4 @@ module Cucumber
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
@@ -1,27 +1,25 @@
|
|
1
1
|
module NavigationHelpers
|
2
|
-
# Maps a
|
2
|
+
# Maps a name to a path. Used by the
|
3
3
|
#
|
4
|
-
#
|
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:
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
8
5
|
#
|
9
|
-
#
|
10
|
-
# post = Post.find_by_name(name)
|
11
|
-
# visit post_comments_path(post)
|
12
|
-
# end
|
6
|
+
# step definition in webrat_steps.rb
|
13
7
|
#
|
14
8
|
def path_to(page_name)
|
15
9
|
case page_name
|
16
10
|
|
17
11
|
when /the homepage/
|
18
|
-
|
19
|
-
|
20
|
-
# Add more page name => path mappings here
|
12
|
+
'/'
|
21
13
|
|
14
|
+
# Add more mappings here.
|
15
|
+
# Here is a more fancy example:
|
16
|
+
#
|
17
|
+
# when /^(.*)'s profile page$/i
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
19
|
+
|
22
20
|
else
|
23
21
|
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
24
|
-
"Now, go and add a mapping in
|
22
|
+
"Now, go and add a mapping in #{__FILE__}"
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -6,7 +6,7 @@ class FeatureGenerator < Rails::Generator::NamedBase
|
|
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
8
|
|
9
|
-
m.gsub_file 'features/support/paths.rb', /
|
9
|
+
m.gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
|
10
10
|
"#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
require 'cucumber/ast'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
describe FeatureElement do
|
7
|
+
include FeatureElement
|
8
|
+
|
9
|
+
describe "with multiline names" do
|
10
|
+
it "should select the longest line as the text length" do
|
11
|
+
@keyword = "key"
|
12
|
+
@name = "short\nvery longer\ntiny"
|
13
|
+
text_length.should == 11 + Ast::Step::INDENT - 1
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should add keyword to first lines length" do
|
17
|
+
@keyword = "key"
|
18
|
+
@name = "short\nvery longer\ntiny"
|
19
|
+
|
20
|
+
first_line_length.should == (@keyword.jlength) + (first_line_name_length = 5)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "with empty name" do
|
25
|
+
it "should only return the length of the keyword" do
|
26
|
+
@name = ""
|
27
|
+
@keyword = "key"
|
28
|
+
|
29
|
+
text_length.should == 3
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should support checking if its name matches a list of regexps" do
|
34
|
+
@name = 'test'
|
35
|
+
matches_scenario_names?([/es/]).should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -21,6 +21,10 @@ module Cucumber
|
|
21
21
|
@table.columns[1].map{|cell| cell.value}.should == %w{four 55555}
|
22
22
|
end
|
23
23
|
|
24
|
+
it "should have headers" do
|
25
|
+
@table.headers.should == %w{one four seven}
|
26
|
+
end
|
27
|
+
|
24
28
|
it "should have same cell objects in rows and columns" do
|
25
29
|
# 666666
|
26
30
|
@table.cells_rows[1].__send__(:[], 2).should equal(@table.columns[2].__send__(:[], 1))
|
@@ -57,7 +61,7 @@ module Cucumber
|
|
57
61
|
}.should raise_error('The column named "two" does not exist')
|
58
62
|
end
|
59
63
|
|
60
|
-
describe "
|
64
|
+
describe "#transpose" do
|
61
65
|
before(:each) do
|
62
66
|
@table = Table.new([
|
63
67
|
%w{one 1111},
|
@@ -70,7 +74,7 @@ module Cucumber
|
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
73
|
-
describe "
|
77
|
+
describe "#rows_hash" do
|
74
78
|
|
75
79
|
it "should return a hash of the rows" do
|
76
80
|
table = Table.new([
|
@@ -105,10 +109,10 @@ module Cucumber
|
|
105
109
|
describe "replacing arguments" do
|
106
110
|
|
107
111
|
before(:each) do
|
108
|
-
@table =
|
112
|
+
@table = Table.new([
|
109
113
|
%w{qty book},
|
110
114
|
%w{<qty> <book>}
|
111
|
-
|
115
|
+
])
|
112
116
|
end
|
113
117
|
|
114
118
|
it "should return a new table with arguments replaced with values" do
|
@@ -118,6 +122,18 @@ module Cucumber
|
|
118
122
|
table_with_replaced_args.hashes[0]['qty'].should == '5'
|
119
123
|
end
|
120
124
|
|
125
|
+
it "should recognise when entire cell is delimited" do
|
126
|
+
@table.should have_text('<book>')
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should recognise when just a subset of a cell is delimited" do
|
130
|
+
table = Table.new([
|
131
|
+
%w{qty book},
|
132
|
+
['<qty>', "This is <who>'s book"]
|
133
|
+
])
|
134
|
+
table.should have_text('<who>')
|
135
|
+
end
|
136
|
+
|
121
137
|
it "should replace nil values with nil" do
|
122
138
|
table_with_replaced_args = @table.arguments_replaced({'<book>' => nil})
|
123
139
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
require 'cucumber/ast'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Ast
|
7
|
+
describe Visitor do
|
8
|
+
|
9
|
+
it "should support checking scenario name matches regexps" do
|
10
|
+
visitor = Visitor.new(mock("step mother"))
|
11
|
+
scenario = Scenario.new(background=nil,
|
12
|
+
comment=Comment.new(""),
|
13
|
+
tags=Tags.new(0, []),
|
14
|
+
line=99,
|
15
|
+
keyword="",
|
16
|
+
name="test name",
|
17
|
+
steps=[])
|
18
|
+
|
19
|
+
visitor.options = {:name_regexps => [/name/]}
|
20
|
+
|
21
|
+
visitor.matches_scenario_names?(scenario).should be_true
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -234,15 +234,6 @@ END_OF_MESSAGE
|
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
237
|
-
xit "should strip gems when --backtrace is absent" do
|
238
|
-
config = Main.new(['--'])
|
239
|
-
begin
|
240
|
-
"x".should == "y"
|
241
|
-
rescue => e
|
242
|
-
e.backtrace[0].should == "#{__FILE__}:#{__LINE__ - 2}"
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
237
|
after do
|
247
238
|
Exception.cucumber_full_backtrace = false
|
248
239
|
end
|
@@ -264,12 +255,12 @@ END_OF_MESSAGE
|
|
264
255
|
|
265
256
|
end
|
266
257
|
|
267
|
-
it "should accept multiple --
|
258
|
+
it "should accept multiple --name options" do
|
268
259
|
config = Configuration.new
|
269
|
-
config.parse!(['--
|
260
|
+
config.parse!(['--name', "User logs in", '--name', "User signs up"])
|
270
261
|
|
271
|
-
config.options[:
|
272
|
-
config.options[:
|
262
|
+
config.options[:name_regexps].should include(/User logs in/)
|
263
|
+
config.options[:name_regexps].should include(/User signs up/)
|
273
264
|
end
|
274
265
|
|
275
266
|
it "should search for all features in the specified directory" do
|
@@ -7,189 +7,91 @@ rescue ::LoadError
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module Cucumber
|
10
|
-
module Cli
|
11
|
-
|
12
|
-
before(:each) do
|
13
|
-
@out = StringIO.new
|
14
|
-
Kernel.stub!(:exit).and_return(nil)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "verbose mode" do
|
18
|
-
|
10
|
+
module Cli
|
11
|
+
describe Main do
|
19
12
|
before(:each) do
|
20
|
-
@
|
21
|
-
|
13
|
+
@out = StringIO.new
|
14
|
+
Kernel.stub!(:exit).and_return(nil)
|
22
15
|
end
|
23
16
|
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
describe "verbose mode" do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@empty_feature = Ast::Feature.new(nil, Ast::Comment.new(''), Ast::Tags.new(2, []), "Feature", [])
|
21
|
+
Dir.stub!(:[])
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should show ruby files required" do
|
25
|
+
@cli = Main.new(%w{--verbose --require example.rb}, @out)
|
26
|
+
@cli.stub!(:require)
|
27
27
|
|
28
|
-
|
28
|
+
@cli.execute!(Object.new.extend(StepMother))
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
@out.string.should include('example.rb')
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
it "should show feature files parsed" do
|
34
|
+
@cli = Main.new(%w{--verbose example.feature}, @out)
|
35
|
+
@cli.stub!(:require)
|
36
36
|
|
37
|
-
|
37
|
+
Parser::FeatureParser.stub!(:new).and_return(mock("feature parser", :parse_file => @empty_feature))
|
38
38
|
|
39
|
-
|
39
|
+
@cli.execute!(Object.new.extend(StepMother))
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
@out.string.should include('example.feature')
|
42
|
+
end
|
43
43
|
|
44
|
-
|
44
|
+
end
|
45
45
|
|
46
|
-
|
46
|
+
describe "diffing" do
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
@step_mother = mock('StepMother', :null_object => true)
|
48
|
+
before :each do
|
49
|
+
@configuration = mock('Configuration', :null_object => true)
|
50
|
+
Configuration.should_receive(:new).and_return(@configuration)
|
53
51
|
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
it "uses Spec Differ::Default when diff is enabled" do
|
58
|
-
@configuration.should_receive(:diff_enabled?).and_return(true)
|
52
|
+
@step_mother = mock('StepMother', :null_object => true)
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
@cli.execute!(@step_mother)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "does not use Spec Differ::Default when diff is disabled" do
|
66
|
-
@configuration.should_receive(:diff_enabled?).and_return(false)
|
67
|
-
|
68
|
-
::Spec::Expectations::Differs::Default.should_not_receive(:new)
|
69
|
-
|
70
|
-
@cli.execute!(@step_mother)
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "--format with class" do
|
76
|
-
|
77
|
-
describe "in module" do
|
78
|
-
|
79
|
-
it "should resolve each module until it gets Formatter class" do
|
80
|
-
cli = Main.new(%w{--format ZooModule::MonkeyFormatterClass}, nil)
|
81
|
-
mock_module = mock('module')
|
82
|
-
Object.stub!(:const_defined?).and_return(true)
|
83
|
-
mock_module.stub!(:const_defined?).and_return(true)
|
84
|
-
|
85
|
-
f = stub('formatter', :null_object => true)
|
86
|
-
|
87
|
-
Object.should_receive(:const_get).with('ZooModule').and_return(mock_module)
|
88
|
-
mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => f))
|
89
|
-
|
90
|
-
cli.execute!(Object.new.extend(StepMother))
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "exists and valid constructor" do
|
96
|
-
|
97
|
-
before(:each) do
|
98
|
-
@mock_formatter_class = mock('formatter class')
|
99
|
-
Object.stub!(:const_get).and_return(@mock_formatter_class)
|
100
|
-
Object.stub!(:const_defined?).with('magical').and_return(true)
|
54
|
+
@cli = Main.new(nil, @out)
|
101
55
|
end
|
56
|
+
|
57
|
+
it "uses Spec Differ::Default when diff is enabled" do
|
58
|
+
@configuration.should_receive(:diff_enabled?).and_return(true)
|
102
59
|
|
103
|
-
|
104
|
-
cli = Main.new
|
105
|
-
mock_formatter = mock('magical formatter')
|
106
|
-
cli.parse_options!(%w{--format magical})
|
107
|
-
|
108
|
-
@mock_formatter_class.should_receive(:new)
|
109
|
-
|
110
|
-
cli.execute!(stub('step mother'), mock_executor, stub('features'))
|
111
|
-
end
|
112
|
-
|
113
|
-
xit "should register the formatter with broadcaster" do
|
114
|
-
cli = Main.new
|
115
|
-
broadcaster = Broadcaster.new
|
116
|
-
mock_formatter = mock('magical formatter')
|
117
|
-
Broadcaster.stub!(:new).and_return(broadcaster, stub("output broadcaster", :register => nil))
|
118
|
-
@mock_formatter_class.stub!(:new).and_return(mock_formatter)
|
119
|
-
cli.parse_options!(%w{--format magical})
|
120
|
-
|
121
|
-
broadcaster.should_receive(:register).with(mock_formatter)
|
60
|
+
::Spec::Expectations::Differs::Default.should_receive(:new)
|
122
61
|
|
123
|
-
cli.execute!(
|
62
|
+
@cli.execute!(@step_mother)
|
124
63
|
end
|
125
64
|
|
126
|
-
|
127
|
-
|
128
|
-
describe "exists but invalid constructor" do
|
129
|
-
|
130
|
-
before(:each) do
|
131
|
-
@out = StringIO.new
|
132
|
-
@error = StringIO.new
|
133
|
-
@cli = Main.new(@out, @error)
|
134
|
-
|
135
|
-
mock_formatter_class = stub('formatter class')
|
136
|
-
mock_formatter_class.stub!(:new).and_raise("No such method")
|
137
|
-
Object.stub!(:const_get).and_return(mock_formatter_class)
|
138
|
-
Object.stub!(:const_defined?).with('exists_but_evil').and_return(true)
|
139
|
-
|
140
|
-
@cli.parse_options!(%w{--format exists_but_evil})
|
141
|
-
end
|
65
|
+
it "does not use Spec Differ::Default when diff is disabled" do
|
66
|
+
@configuration.should_receive(:diff_enabled?).and_return(false)
|
142
67
|
|
143
|
-
|
144
|
-
Kernel.stub!(:exit)
|
145
|
-
|
146
|
-
@cli.execute!(stub('step mother'))
|
147
|
-
|
148
|
-
@error.string.should include("No such method")
|
149
|
-
end
|
68
|
+
::Spec::Expectations::Differs::Default.should_not_receive(:new)
|
150
69
|
|
151
|
-
|
152
|
-
Kernel.should_receive(:exit)
|
153
|
-
|
154
|
-
@cli.execute!(stub('step mother'), mock_executor, stub('features'))
|
70
|
+
@cli.execute!(@step_mother)
|
155
71
|
end
|
156
|
-
|
72
|
+
|
157
73
|
end
|
158
|
-
|
159
|
-
describe "non-existent" do
|
160
74
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@cli = Main.new(%w{--format invalid}, @out, @error)
|
165
|
-
end
|
75
|
+
describe "--format with class" do
|
76
|
+
|
77
|
+
describe "in module" do
|
166
78
|
|
167
|
-
|
168
|
-
|
79
|
+
it "should resolve each module until it gets Formatter class" do
|
80
|
+
cli = Main.new(%w{--format ZooModule::MonkeyFormatterClass}, nil)
|
81
|
+
mock_module = mock('module')
|
82
|
+
Object.stub!(:const_defined?).and_return(true)
|
83
|
+
mock_module.stub!(:const_defined?).and_return(true)
|
169
84
|
|
170
|
-
|
171
|
-
|
172
|
-
@error.string.should include("Invalid format: invalid\n")
|
173
|
-
end
|
174
|
-
|
175
|
-
xit "should display --help" do
|
176
|
-
Kernel.stub!(:exit)
|
85
|
+
f = stub('formatter', :null_object => true)
|
177
86
|
|
178
|
-
|
179
|
-
|
180
|
-
@out.string.should include("Usage: cucumber")
|
181
|
-
end
|
87
|
+
Object.should_receive(:const_get).with('ZooModule').and_return(mock_module)
|
88
|
+
mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => f))
|
182
89
|
|
183
|
-
|
184
|
-
|
90
|
+
cli.execute!(Object.new.extend(StepMother))
|
91
|
+
end
|
185
92
|
|
186
|
-
|
187
|
-
end
|
188
|
-
|
93
|
+
end
|
189
94
|
end
|
190
|
-
|
191
95
|
end
|
192
|
-
|
193
96
|
end
|
194
97
|
end
|
195
|
-
end
|