cucumber 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,15 @@
1
+ == 0.3.3 2009-05-10
2
+
3
+ Minor bugfix release, made specially for EuRuKo!
4
+
5
+ === Bugfixes
6
+ * Summaries are no longer printed in an empty () if there are no scenarios/steps (Aslak Hellesøy)
7
+ * Background, Scenario Outline, Before Hook interaction (#309 Aslak Hellesøy)
8
+ * Multiline String snippets no longer give misleading info. It's a String, not a PyString that's sent to step def.
9
+
10
+ === Removed/changed features
11
+ * New aliases: --no-source/-s, --name/-n (#317 Lonnon Foster)
12
+
1
13
  == 0.3.2 2009-05-05
2
14
 
3
15
  This release has some minor bug fixes and new features.
@@ -158,11 +158,13 @@ examples/selenium/features/search.feature
158
158
  examples/selenium/features/step_definitons/search_steps.rb
159
159
  examples/selenium/features/support/env.rb
160
160
  examples/selenium_webrat/Rakefile
161
+ examples/selenium_webrat/config.ru
161
162
  examples/selenium_webrat/features/search.feature
162
163
  examples/selenium_webrat/features/step_definitons/search_steps.rb
163
164
  examples/selenium_webrat/features/support/env.rb
164
165
  examples/self_test/README.textile
165
166
  examples/self_test/Rakefile
167
+ examples/self_test/features/background/background_tagged_before_on_outline.feature
166
168
  examples/self_test/features/background/background_with_name.feature
167
169
  examples/self_test/features/background/failing_background.feature
168
170
  examples/self_test/features/background/failing_background_after_success.feature
@@ -233,6 +235,7 @@ features/cucumber_cli.feature
233
235
  features/cucumber_cli_diff_disabled.feature
234
236
  features/cucumber_cli_outlines.feature
235
237
  features/custom_formatter.feature
238
+ features/exclude_files.feature
236
239
  features/multiline_names.feature
237
240
  features/rake_task.feature
238
241
  features/report_called_undefined_steps.feature
data/Rakefile CHANGED
@@ -5,4 +5,5 @@ require 'config/hoe' # setup Hoe + all gem configuration
5
5
  Dir['gem_tasks/**/*.rake'].each { |rake| load rake }
6
6
 
7
7
  # Hoe gives us :default => :test, but we don't have Test::Unit tests.
8
- Rake::Task[:default].clear_prerequisites rescue nil # For some super weird reason this fails for some...
8
+ Rake::Task[:default].clear_prerequisites rescue nil # For some super weird reason this fails for some...
9
+ task :default => [:spec, :features]
File without changes
@@ -6,4 +6,4 @@ Feature: Search
6
6
  Scenario: Find what I'm looking for
7
7
  Given I am on the Google search page
8
8
  When I search for "rspec"
9
- Then I should see a link to http://rspec.info/
9
+ Then I should see a link to RSpec-1.2.4: Home
@@ -4,10 +4,10 @@ end
4
4
 
5
5
  When /I search for "(.*)"/ do |query|
6
6
  fill_in('q', :with => query)
7
- click_button('btnG')
7
+ click_button 'Google Search'
8
8
  selenium.wait_for_page_to_load
9
9
  end
10
10
 
11
11
  Then /I should see a link to (.*)/ do |expected_url|
12
- click_link(expected_url)
12
+ click_link expected_url
13
13
  end
@@ -17,6 +17,7 @@ require 'spec/expectations'
17
17
 
18
18
  # Webrat
19
19
  require 'webrat'
20
+
20
21
  Webrat.configure do |config|
21
22
  config.mode = :selenium
22
23
  end
@@ -31,11 +32,14 @@ end
31
32
 
32
33
  # START HACK
33
34
  # Disable Rails-specific code
34
- module Webrat
35
- def self.start_app_server
35
+ class Webrat::Selenium::ApplicationServer
36
+ def self.boot
37
+
38
+ STDOUT.puts "Starting app server"
36
39
  end
37
40
 
38
- def self.stop_app_server
41
+ def self.stop_at_exit
42
+ STDOUT.puts "Stopping app server"
39
43
  end
40
44
  end
41
45
  # END HACK
@@ -0,0 +1,12 @@
1
+ @background_tagged_before_on_outline
2
+ Feature: Background tagged Before on Outline
3
+
4
+ Background:
5
+ Given passing without a table
6
+
7
+ Scenario Outline: passing background
8
+ Then I should have '<count>' cukes
9
+
10
+ Examples:
11
+ | count |
12
+ | 888 |
@@ -1,7 +1,7 @@
1
1
  Feature: search examples
2
2
 
3
- Background: Hantu Pisang background match
4
- Given passing without a table
3
+ Background: Hantu Pisang background match
4
+ Given passing without a table
5
5
 
6
6
  Scenario: should match Hantu Pisang
7
7
  Given passing without a table
@@ -12,21 +12,21 @@ Feature: search examples
12
12
  Scenario Outline: Ignore me
13
13
  Given <state> without a table
14
14
  Examples:
15
- |state|
16
- |failing|
15
+ | state |
16
+ | failing |
17
17
 
18
18
  Scenario Outline: Hantu Pisang match
19
19
  Given <state> without a table
20
20
  Examples:
21
- |state|
22
- |passing|
21
+ | state |
22
+ | passing |
23
23
 
24
24
  Scenario Outline: no match in name but in examples
25
25
  Given <state> without a table
26
26
  Examples: Hantu Pisang
27
- |state|
28
- |passing|
27
+ | state |
28
+ | passing |
29
29
 
30
30
  Examples: Ignore me
31
- |state|
32
- |failing|
31
+ | state |
32
+ | failing |
@@ -1 +1,17 @@
1
- require 'spec/expectations'
1
+ require 'spec/expectations'
2
+
3
+ Before('@not_used') do
4
+ raise "Should never run"
5
+ end
6
+
7
+ After('@not_used') do
8
+ raise "Should never run"
9
+ end
10
+
11
+ Before('@background_tagged_before_on_outline') do
12
+ @cukes = '888'
13
+ end
14
+
15
+ After('@background_tagged_before_on_outline') do
16
+ @cukes.should == '888'
17
+ end
@@ -10,7 +10,7 @@ Cucumber::Rake::Task.new(:html) do |t|
10
10
  end
11
11
 
12
12
  Cucumber::Rake::Task.new(:progress) do |t|
13
- t.cucumber_opts = "--tags ~@intentional_failure --format progress -i -n"
13
+ t.cucumber_opts = "--tags ~@intentional_failure --format progress -i -s"
14
14
  end
15
15
 
16
16
  task :default => [:pretty, :html, :progress]
@@ -68,6 +68,28 @@ Feature: backgrounds
68
68
 
69
69
  """
70
70
 
71
+ Scenario: run a feature with scenario outlines that has a background that passes
72
+ When I run cucumber -q features/background/background_tagged_before_on_outline.feature --require features
73
+ Then it should pass with
74
+ """
75
+ @background_tagged_before_on_outline
76
+ Feature: Background tagged Before on Outline
77
+
78
+ Background:
79
+ Given passing without a table
80
+
81
+ Scenario Outline: passing background
82
+ Then I should have '<count>' cukes
83
+
84
+ Examples:
85
+ | count |
86
+ | 888 |
87
+
88
+ 1 scenario (1 passed)
89
+ 2 steps (2 passed)
90
+
91
+ """
92
+
71
93
  Scenario: run a feature with a background that fails
72
94
  When I run cucumber -q features/background/failing_background.feature --require features
73
95
  Then it should fail with
@@ -2,6 +2,8 @@ Feature: Cucumber command line
2
2
  In order to write better software
3
3
  Developers should be able to execute requirements as tests
4
4
 
5
+
6
+
5
7
  Scenario: Run single scenario with missing step definition
6
8
  When I run cucumber -q features/sample.feature:5
7
9
  Then it should pass with
@@ -367,7 +369,7 @@ Feature: Cucumber command line
367
369
 
368
370
  """
369
371
 
370
- Scenario: Run a single background which matches a name using --name
372
+ Scenario: Run a single background which matches a name using --name (Useful if there is an error in it)
371
373
  When I run cucumber --name 'Hantu Pisang background' -q features/
372
374
  Then it should pass with
373
375
  """
@@ -376,7 +378,7 @@ Feature: Cucumber command line
376
378
  Background: Hantu Pisang background match
377
379
  Given passing without a table
378
380
 
379
- 0 scenarios ()
381
+ 0 scenarios
380
382
  1 step (1 passed)
381
383
 
382
384
  """
@@ -486,3 +488,33 @@ Feature: Cucumber command line
486
488
 
487
489
  """
488
490
 
491
+ Scenario: Run feature elements which match a name using -n
492
+ When I run cucumber -n Pisang -q features/
493
+ Then it should pass with
494
+ """
495
+ Feature: search examples
496
+
497
+ Background: Hantu Pisang background match
498
+ Given passing without a table
499
+
500
+ Scenario: should match Hantu Pisang
501
+ Given passing without a table
502
+
503
+ Scenario Outline: Hantu Pisang match
504
+ Given <state> without a table
505
+
506
+ Examples:
507
+ | state |
508
+ | passing |
509
+
510
+ Scenario Outline: no match in name but in examples
511
+ Given <state> without a table
512
+
513
+ Examples: Hantu Pisang
514
+ | state |
515
+ | passing |
516
+
517
+ 3 scenarios (3 passed)
518
+ 6 steps (6 passed)
519
+
520
+ """
@@ -4,8 +4,8 @@ Feature: Custom Formatter
4
4
  When I run cucumber --format Tag::Count features
5
5
  Then it should fail with
6
6
  """
7
- | after_file | four | lots | one | three | two |
8
- | 1 | 1 | 1 | 1 | 2 | 1 |
7
+ | after_file | background_tagged_before_on_outline | four | lots | one | three | two |
8
+ | 1 | 1 | 1 | 1 | 1 | 2 | 1 |
9
9
 
10
10
  """
11
11
 
@@ -0,0 +1,20 @@
1
+ Feature: Exclude ruby and feature files from runs
2
+ Developers should be able to easily exclude files from cucumber runs
3
+ This is a nice feature to have in conjunction with profiles, so you can exclude
4
+ certain environment files from certain runs.
5
+
6
+ Scenario: exclude ruby files
7
+ Given a standard Cucumber project directory structure
8
+ And a file named "features/support/dont_require_me.rb"
9
+ And a file named "features/step_definitions/fooz.rb"
10
+ And a file named "features/step_definitions/foof.rb"
11
+ And a file named "features/step_definitions/foot.rb"
12
+ And a file named "features/support/require_me.rb"
13
+
14
+ When I run cucumber features -q --verbose --exclude features/support/dont --exclude foo[zf]
15
+
16
+ Then "features/support/require_me.rb" should be required
17
+ And "features/step_definitions/foot.rb" should be required
18
+ And "features/support/dont_require_me.rb" should not be required
19
+ And "features/step_definitions/foof.rb" should not be required
20
+ And "features/step_definitions/fooz.rb" should not be required
@@ -4,16 +4,15 @@ Feature: Snippets
4
4
  I want snippet suggestions for undefined step definitions
5
5
 
6
6
  Scenario: Snippet for undefined step with a pystring
7
- When I run cucumber features/undefined_multiline_args.feature:3 -n
7
+ When I run cucumber features/undefined_multiline_args.feature:3 -s
8
8
  Then the output should contain
9
9
  """
10
10
  Given /^a pystring$/ do |string|
11
- # string is a Cucumber::Ast::PyString
12
11
  pending
13
12
  end
14
13
  """
15
14
  Scenario: Snippet for undefined step with a step table
16
- When I run cucumber features/undefined_multiline_args.feature:9 -n
15
+ When I run cucumber features/undefined_multiline_args.feature:9 -s
17
16
  Then the output should contain
18
17
  """
19
18
  Given /^a table$/ do |table|
@@ -67,3 +67,12 @@ Then /^"(.*)" should exist$/ do |file|
67
67
  File.exists?(file).should be_true
68
68
  FileUtils.rm(file)
69
69
  end
70
+
71
+ Then /^"([^\"]*)" should not be required$/ do |file_name|
72
+ last_stdout.should_not include("* #{file_name}")
73
+ end
74
+
75
+ Then /^"([^\"]*)" should be required$/ do |file_name|
76
+ last_stdout.should include("* #{file_name}")
77
+ end
78
+
@@ -8,6 +8,7 @@ Feature: Cucumber command line
8
8
  Then it should pass with
9
9
  """
10
10
  /^passing without a table$/ # features/step_definitions/sample_steps.rb:12
11
+ Given passing without a table # features/background/background_tagged_before_on_outline.feature:5
11
12
  Given passing without a table # features/background/failing_background_after_success.feature:4
12
13
  Given passing without a table # features/multiline_name.feature:6
13
14
  Given passing without a table # features/multiline_name.feature:11
@@ -83,6 +84,7 @@ Feature: Cucumber command line
83
84
  Given '2' cukes # features/tons_of_cukes.feature:51
84
85
  Given '2' cukes # features/tons_of_cukes.feature:52
85
86
  /^I should have '(.+)' cukes$/ # features/step_definitions/sample_steps.rb:31
87
+ Then I should have '<count>' cukes # features/background/background_tagged_before_on_outline.feature:8
86
88
  Then I should have '10' cukes # features/background/background_with_name.feature:7
87
89
  Then I should have '10' cukes # features/background/failing_background.feature:9
88
90
  Then I should have '10' cukes # features/background/failing_background.feature:12
@@ -32,7 +32,12 @@ module Cucumber
32
32
  end
33
33
 
34
34
  def accept_hook?(hook)
35
- false
35
+ if hook_context != self
36
+ hook_context.accept_hook?(hook)
37
+ else
38
+ # We have no scenarios
39
+ false
40
+ end
36
41
  end
37
42
 
38
43
  def failed?
@@ -23,6 +23,8 @@ module Cucumber
23
23
  examples_table = OutlineTable.new(examples_matrix, self)
24
24
  Examples.new(examples_line, examples_keyword, examples_name, examples_table)
25
25
  end
26
+
27
+ @background.feature_elements << self if @background
26
28
  end
27
29
 
28
30
  def accept(visitor)
@@ -5,32 +5,32 @@ module Cucumber
5
5
  class Configuration
6
6
  FORMATS = %w{pretty profile progress rerun}
7
7
  DEFAULT_FORMAT = 'pretty'
8
-
8
+
9
9
  attr_reader :paths
10
10
  attr_reader :options
11
-
11
+
12
12
  def initialize(out_stream = STDOUT, error_stream = STDERR)
13
13
  @out_stream = out_stream
14
14
  @error_stream = error_stream
15
-
15
+
16
16
  @paths = []
17
17
  @options = default_options
18
18
  @active_format = DEFAULT_FORMAT
19
19
  end
20
-
20
+
21
21
  def parse!(args)
22
22
  @args = args
23
23
  return parse_args_from_profile('default') if @args.empty?
24
24
  @args.extend(::OptionParser::Arguable)
25
-
25
+
26
26
  @args.options do |opts|
27
27
  opts.banner = ["Usage: cucumber [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+", "",
28
28
  "Examples:",
29
29
  "cucumber examples/i18n/en/features",
30
30
  "cucumber --language it examples/i18n/it/features/somma.feature:6:98:113",
31
- "cucumber -n -i http://rubyurl.com/eeCl", "", "",
31
+ "cucumber -s -i http://rubyurl.com/eeCl", "", "",
32
32
  ].join("\n")
33
- opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
33
+ opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
34
34
  "Require files before executing the features. If this",
35
35
  "option is not specified, all *.rb files that are",
36
36
  "siblings or below the features will be loaded auto-",
@@ -42,7 +42,7 @@ module Cucumber
42
42
  @options[:require] ||= []
43
43
  @options[:require] << v
44
44
  end
45
- opts.on("-l LANG", "--language LANG",
45
+ opts.on("-l LANG", "--language LANG",
46
46
  "Specify language for features (Default: #{@options[:lang]})",
47
47
  %{Run with "--language help" to see all languages},
48
48
  %{Run with "--language LANG help" to list keywords for LANG}) do |v|
@@ -54,38 +54,38 @@ module Cucumber
54
54
  @options[:lang] = v
55
55
  end
56
56
  end
57
- opts.on("-f FORMAT", "--format FORMAT",
57
+ opts.on("-f FORMAT", "--format FORMAT",
58
58
  "How to format features (Default: #{DEFAULT_FORMAT})",
59
59
  "Available formats: #{FORMATS.join(", ")}",
60
60
  "You can also provide your own formatter classes as long",
61
61
  "as they have been previously required using --require or",
62
62
  "if they are in the folder structure such that cucumber",
63
- "will require them automatically.",
63
+ "will require them automatically.",
64
64
  "This option can be specified multiple times.") do |v|
65
65
  @options[:formats][v] = @out_stream
66
66
  @active_format = v
67
67
  end
68
- opts.on("-o", "--out FILE",
68
+ opts.on("-o", "--out FILE",
69
69
  "Write output to a file instead of STDOUT. This option",
70
70
  "applies to the previously specified --format, or the",
71
71
  "default format if no format is specified.") do |v|
72
72
  @options[:formats][@active_format] = v
73
73
  end
74
- opts.on("-t TAGS", "--tags TAGS",
74
+ opts.on("-t TAGS", "--tags TAGS",
75
75
  "Only execute the features or scenarios with the specified tags.",
76
76
  "TAGS must be comma-separated without spaces. Prefix tags with ~ to",
77
77
  "exclude features or scenarios having that tag. Tags can be specified",
78
78
  "with or without the @ prefix.") do |v|
79
79
  @options[:include_tags], @options[:exclude_tags] = *parse_tags(v)
80
80
  end
81
- opts.on("-n NAME", "--name NAME",
81
+ opts.on("-n NAME", "--name NAME",
82
82
  "Only execute the feature elements which match part of the given name.",
83
83
  "If this option is given more than once, it will match against all the",
84
84
  "given names.") do |v|
85
85
  @options[:name_regexps] << /#{v}/
86
86
  end
87
- opts.on("-e", "--exclude PATTERN", "Don't run feature files matching PATTERN") do |v|
88
- @options[:excludes] << v
87
+ opts.on("-e", "--exclude PATTERN", "Don't run feature files or require ruby files matching PATTERN") do |v|
88
+ @options[:excludes] << Regexp.new(v)
89
89
  end
90
90
  opts.on("-p", "--profile PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
91
91
  parse_args_from_profile(v)
@@ -101,7 +101,7 @@ module Cucumber
101
101
  @options[:dry_run] = true
102
102
  @quiet = true
103
103
  end
104
- opts.on("-a", "--autoformat DIRECTORY",
104
+ opts.on("-a", "--autoformat DIRECTORY",
105
105
  "Reformats (pretty prints) feature files and write them to DIRECTORY.",
106
106
  "Be careful if you choose to overwrite the originals.",
107
107
  "Implies --dry-run --formatter pretty.") do |directory|
@@ -110,11 +110,11 @@ module Cucumber
110
110
  @options[:dry_run] = true
111
111
  @quiet = true
112
112
  end
113
- opts.on("-m", "--no-multiline",
113
+ opts.on("-m", "--no-multiline",
114
114
  "Don't print multiline strings and tables under steps.") do
115
115
  @options[:no_multiline] = true
116
116
  end
117
- opts.on("-n", "--no-source",
117
+ opts.on("-s", "--no-source",
118
118
  "Don't print the file and line of the step definition with the steps.") do
119
119
  @options[:source] = false
120
120
  end
@@ -157,19 +157,19 @@ module Cucumber
157
157
  # Whatever is left after option parsing is the FILE arguments
158
158
  @paths += args
159
159
  end
160
-
160
+
161
161
  def verbose?
162
162
  @options[:verbose]
163
163
  end
164
-
164
+
165
165
  def strict?
166
166
  @options[:strict]
167
167
  end
168
-
168
+
169
169
  def guess?
170
170
  @options[:guess]
171
171
  end
172
-
172
+
173
173
  def diff_enabled?
174
174
  @options[:diff_enabled]
175
175
  end
@@ -203,7 +203,7 @@ module Cucumber
203
203
  out.close
204
204
  end
205
205
  end
206
-
206
+
207
207
  begin
208
208
  formatter_class = formatter_class(format)
209
209
  formatter_class.new(step_mother, out, @options)
@@ -211,12 +211,12 @@ module Cucumber
211
211
  exit_with_error("Error creating formatter: #{format}", e)
212
212
  end
213
213
  end
214
-
214
+
215
215
  broadcaster = Broadcaster.new(formatters)
216
216
  broadcaster.options = @options
217
217
  return broadcaster
218
218
  end
219
-
219
+
220
220
  def formatter_class(format)
221
221
  case format
222
222
  when 'html' then Formatter::Html
@@ -229,7 +229,7 @@ module Cucumber
229
229
  constantize(format)
230
230
  end
231
231
  end
232
-
232
+
233
233
  def files_to_require
234
234
  requires = @options[:require] || feature_dirs
235
235
  files = requires.map do |path|
@@ -239,32 +239,32 @@ module Cucumber
239
239
  sorted_files = files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }.reject{|f| f =~ /^http/}
240
240
  env_files = sorted_files.select {|f| f =~ %r{/support/env.rb} }
241
241
  files = env_files + sorted_files.reject {|f| f =~ %r{/support/env.rb} }
242
+ remove_excluded_files_from(files)
242
243
  files.reject! {|f| f =~ %r{/support/env.rb} } if @options[:dry_run]
243
244
  files
244
245
  end
245
-
246
+
247
+
246
248
  def feature_files
247
249
  potential_feature_files = @paths.map do |path|
248
250
  path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
249
251
  path = path.chomp('/')
250
252
  File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
251
253
  end.flatten.uniq
252
-
253
- @options[:excludes].each do |exclude|
254
- potential_feature_files.reject! do |path|
255
- path =~ /#{Regexp.escape(exclude)}/
256
- end
257
- end
258
-
254
+ remove_excluded_files_from(potential_feature_files)
259
255
  potential_feature_files
260
256
  end
261
257
 
262
258
  protected
263
-
259
+
260
+ def remove_excluded_files_from(files)
261
+ files.reject! {|path| @options[:excludes].detect {|pattern| path =~ pattern } }
262
+ end
263
+
264
264
  def feature_dirs
265
265
  @paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
266
266
  end
267
-
267
+
268
268
  def constantize(camel_cased_word)
269
269
  names = camel_cased_word.split('::')
270
270
  names.shift if names.empty? || names.first.empty?
@@ -275,7 +275,7 @@ module Cucumber
275
275
  end
276
276
  constant
277
277
  end
278
-
278
+
279
279
  def parse_args_from_profile(profile)
280
280
  unless cucumber_yml.has_key?(profile)
281
281
  return(exit_with_error <<-END_OF_ERROR)
@@ -299,7 +299,7 @@ Defined profiles in cucumber.yml:
299
299
  rescue YmlLoadError => e
300
300
  exit_with_error(e.message)
301
301
  end
302
-
302
+
303
303
  def cucumber_yml
304
304
  return @cucumber_yml if @cucumber_yml
305
305
  unless File.exist?('cucumber.yml')
@@ -319,7 +319,7 @@ Defined profiles in cucumber.yml:
319
319
 
320
320
  return @cucumber_yml
321
321
  end
322
-
322
+
323
323
  def list_keywords_and_exit(lang)
324
324
  unless Cucumber::LANGUAGES[lang]
325
325
  exit_with_error("No language with key #{lang}")
@@ -327,12 +327,12 @@ Defined profiles in cucumber.yml:
327
327
  LanguageHelpFormatter.list_keywords(@out_stream, lang)
328
328
  Kernel.exit
329
329
  end
330
-
330
+
331
331
  def list_languages
332
332
  LanguageHelpFormatter.list_languages(@out_stream)
333
333
  Kernel.exit
334
334
  end
335
-
335
+
336
336
  def default_options
337
337
  {
338
338
  :strict => false,
@@ -347,7 +347,7 @@ Defined profiles in cucumber.yml:
347
347
  :diff_enabled => true
348
348
  }
349
349
  end
350
-
350
+
351
351
  def exit_with_error(error_message, e=nil)
352
352
  @error_stream.puts(error_message)
353
353
  if e
@@ -357,6 +357,6 @@ Defined profiles in cucumber.yml:
357
357
  Kernel.exit 1
358
358
  end
359
359
  end
360
-
360
+
361
361
  end
362
362
  end
@@ -97,8 +97,12 @@ module Cucumber
97
97
  counts = [:failed, :skipped, :undefined, :pending, :passed].map do |status|
98
98
  elements = yield status
99
99
  elements.any? ? format_string("#{elements.length} #{status.to_s}", status) : nil
100
+ end.compact
101
+ if counts.any?
102
+ @io.puts(" (#{counts.join(', ')})")
103
+ else
104
+ @io.puts
100
105
  end
101
- @io.puts(" (#{counts.compact.join(', ')})")
102
106
  end
103
107
 
104
108
  def dump_count(count, what, state=nil)
@@ -70,9 +70,12 @@ module Cucumber
70
70
  end
71
71
  block_args << multiline_arg_class.default_arg_name unless multiline_arg_class.nil?
72
72
  block_arg_string = block_args.empty? ? "" : " |#{block_args.join(", ")}|"
73
- multiline_class_string = multiline_arg_class ? "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n " : ""
73
+ multiline_class_comment = ""
74
+ if(multiline_arg_class == Ast::Table)
75
+ multiline_class_comment = "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n "
76
+ end
74
77
 
75
- "#{step_keyword} /^#{escaped}$/ do#{block_arg_string}\n #{multiline_class_string}pending\nend"
78
+ "#{step_keyword} /^#{escaped}$/ do#{block_arg_string}\n #{multiline_class_comment}pending\nend"
76
79
  end
77
80
 
78
81
  class MissingProc < StandardError
@@ -2,7 +2,7 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 2
5
+ TINY = 3
6
6
  PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
@@ -40,8 +40,8 @@ end
40
40
  # <%%= f.label :alternative %><br />
41
41
  # <%%= f.datetime_select :alternative %>
42
42
  # The following steps would fill out the form:
43
- # When I select "November 23, 2004 11:20" as the "Preferred" data and time
44
- # And I select "November 25, 2004 10:30" as the "Alternative" data and time
43
+ # When I select "November 23, 2004 11:20" as the "Preferred" date and time
44
+ # And I select "November 25, 2004 10:30" as the "Alternative" date and time
45
45
  When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
46
46
  select_datetime(datetime, :from => datetime_label)
47
47
  end
@@ -107,19 +107,19 @@ Then /^I should not see "([^\"]*)"$/ do |text|
107
107
  end
108
108
 
109
109
  Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
110
- <% if framework == :rspec -%>
111
- field_labeled(field).value.should =~ /#{value}/
112
- <% else -%>
113
- assert_match(/#{value}/, field_labeled(field).value)
114
- <% end -%>
110
+ <% if framework == :rspec -%>
111
+ field_labeled(field).value.should =~ /#{value}/
112
+ <% else -%>
113
+ assert_match(/#{value}/, field_labeled(field).value)
114
+ <% end -%>
115
115
  end
116
116
 
117
117
  Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
118
- <% if framework == :rspec -%>
119
- field_labeled(field).value.should_not =~ /#{value}/
120
- <% else -%>
121
- assert_no_match(/#{value}/, field_labeled(field).value)
122
- <% end -%>
118
+ <% if framework == :rspec -%>
119
+ field_labeled(field).value.should_not =~ /#{value}/
120
+ <% else -%>
121
+ assert_no_match(/#{value}/, field_labeled(field).value)
122
+ <% end -%>
123
123
  end
124
124
 
125
125
  Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
@@ -4,20 +4,24 @@ require 'yaml'
4
4
  module Cucumber
5
5
  module Cli
6
6
  describe Configuration do
7
-
7
+
8
8
  def given_cucumber_yml_defined_as(hash_or_string)
9
9
  File.stub!(:exist?).and_return(true)
10
10
  cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string
11
11
  IO.stub!(:read).with('cucumber.yml').and_return(cucumber_yml)
12
12
  end
13
-
13
+
14
+ def given_the_following_files(*files)
15
+ File.stub!(:directory?).and_return(true)
16
+ Dir.stub!(:[]).and_return(files)
17
+ end
18
+
14
19
  before(:each) do
15
20
  Kernel.stub!(:exit).and_return(nil)
16
21
  end
17
22
 
18
23
  it "should require files in support paths first" do
19
- File.stub!(:directory?).and_return(true)
20
- Dir.stub!(:[]).and_return(["/features/step_definitions/foo.rb","/features/support/bar.rb"])
24
+ given_the_following_files("/features/step_definitions/foo.rb","/features/support/bar.rb")
21
25
 
22
26
  config = Configuration.new(StringIO.new)
23
27
  config.parse!(%w{--require /features})
@@ -29,8 +33,7 @@ module Cli
29
33
  end
30
34
 
31
35
  it "should require env.rb files first" do
32
- File.stub!(:directory?).and_return(true)
33
- Dir.stub!(:[]).and_return(["/features/support/a_file.rb","/features/support/env.rb"])
36
+ given_the_following_files("/features/support/a_file.rb","/features/support/env.rb")
34
37
 
35
38
  config = Configuration.new(StringIO.new)
36
39
  config.parse!(%w{--require /features})
@@ -42,8 +45,7 @@ module Cli
42
45
  end
43
46
 
44
47
  it "should not require env.rb files when --dry-run" do
45
- File.stub!(:directory?).and_return(true)
46
- Dir.stub!(:[]).and_return(["/features/support/a_file.rb","/features/support/env.rb"])
48
+ given_the_following_files("/features/support/a_file.rb","/features/support/env.rb")
47
49
 
48
50
  config = Configuration.new(StringIO.new)
49
51
  config.parse!(%w{--require /features --dry-run})
@@ -53,6 +55,37 @@ module Cli
53
55
  ]
54
56
  end
55
57
 
58
+ describe "--exclude" do
59
+
60
+ it "excludes a ruby file from requiring when the name matches exactly" do
61
+ given_the_following_files("/features/support/a_file.rb","/features/support/env.rb")
62
+
63
+ config = Configuration.new(StringIO.new)
64
+ config.parse!(%w{--require /features --exclude a_file.rb})
65
+
66
+ config.files_to_require.should == [
67
+ "/features/support/env.rb"
68
+ ]
69
+ end
70
+
71
+ it "excludes all ruby files that match the provided patterns from requiring" do
72
+ given_the_following_files("/features/support/foof.rb","/features/support/bar.rb",
73
+ "/features/support/food.rb","/features/blah.rb",
74
+ "/features/support/fooz.rb")
75
+
76
+ config = Configuration.new(StringIO.new)
77
+ config.parse!(%w{--require /features --exclude foo[df] --exclude blah})
78
+
79
+ config.files_to_require.should == [
80
+ "/features/support/bar.rb",
81
+ "/features/support/fooz.rb"
82
+ ]
83
+ end
84
+
85
+
86
+ end
87
+
88
+
56
89
  it "should expand args from YAML file" do
57
90
  given_cucumber_yml_defined_as({'bongo' => '--require from/yml'})
58
91
 
@@ -121,7 +154,7 @@ END_OF_MESSAGE
121
154
 
122
155
  ['', 'sfsadfs', "--- \n- an\n- array\n", "---dddfd"].each do |bad_input|
123
156
  given_cucumber_yml_defined_as(bad_input)
124
-
157
+
125
158
  config = Configuration.new(StringIO.new, error = StringIO.new)
126
159
  config.parse!([])
127
160
 
@@ -194,13 +227,13 @@ END_OF_MESSAGE
194
227
  config.options[:formats].should have_key('pretty')
195
228
  config.options[:formats].should have_key('progress')
196
229
  end
197
-
230
+
198
231
  it "should associate --out to previous --format" do
199
232
  config = Configuration.new(StringIO.new)
200
233
  config.parse!(%w{--format progress --out file1 --format profile --out file2})
201
234
  config.options[:formats].should == {"profile"=>"file2", "progress"=>"file1"}
202
235
  end
203
-
236
+
204
237
  it "should accept --color option" do
205
238
  Term::ANSIColor.should_receive(:coloring=).with(true)
206
239
  config = Configuration.new(StringIO.new)
@@ -212,19 +245,19 @@ END_OF_MESSAGE
212
245
  config = Configuration.new(StringIO.new)
213
246
  config.parse!(['--no-color'])
214
247
  end
215
-
248
+
216
249
  it "should parse tags" do
217
250
  config = Configuration.new(nil)
218
251
  includes, excludes = config.parse_tags("one,~two,@three,~@four")
219
252
  includes.should == ['one', 'three']
220
253
  excludes.should == ['two', 'four']
221
254
  end
222
-
255
+
223
256
  describe "--backtrace" do
224
257
  before do
225
258
  Exception.cucumber_full_backtrace = false
226
259
  end
227
-
260
+
228
261
  it "should show full backtrace when --backtrace is present" do
229
262
  config = Main.new(['--backtrace'])
230
263
  begin
@@ -238,41 +271,50 @@ END_OF_MESSAGE
238
271
  Exception.cucumber_full_backtrace = false
239
272
  end
240
273
  end
241
-
274
+
242
275
  describe "diff output" do
243
276
 
244
277
  it "is enabled by default" do
245
278
  config = Configuration.new
246
279
  config.diff_enabled?.should be_true
247
280
  end
248
-
281
+
249
282
  it "is disabled when the --no-diff option is supplied" do
250
283
  config = Configuration.new
251
284
  config.parse!(%w{--no-diff})
252
285
 
253
286
  config.diff_enabled?.should be_false
254
287
  end
255
-
288
+
256
289
  end
257
290
 
258
291
  it "should accept multiple --name options" do
259
292
  config = Configuration.new
260
293
  config.parse!(['--name', "User logs in", '--name', "User signs up"])
261
-
294
+
262
295
  config.options[:name_regexps].should include(/User logs in/)
263
296
  config.options[:name_regexps].should include(/User signs up/)
264
297
  end
265
-
298
+
299
+ it "should accept multiple -n options" do
300
+ config = Configuration.new
301
+ config.parse!(['-n', "User logs in", '-n', "User signs up"])
302
+
303
+ config.options[:name_regexps].should include(/User logs in/)
304
+ config.options[:name_regexps].should include(/User signs up/)
305
+ end
306
+
266
307
  it "should search for all features in the specified directory" do
267
308
  File.stub!(:directory?).and_return(true)
268
- Dir.should_receive(:[]).with("feature_directory/**/*.feature").any_number_of_times.and_return(["cucumber.feature"])
269
-
309
+ Dir.should_receive(:[]).with("feature_directory/**/*.feature").
310
+ any_number_of_times.and_return(["cucumber.feature"])
311
+
270
312
  config = Configuration.new(StringIO)
271
313
  config.parse!(%w{feature_directory/})
272
-
314
+
273
315
  config.feature_files.should == ["cucumber.feature"]
274
316
  end
275
-
317
+
276
318
  end
277
319
  end
278
320
  end
@@ -313,7 +313,7 @@ Given I am a step
313
313
  }).to_sexp.should ==
314
314
  [:feature, nil, "Feature: Hi",
315
315
  [:scenario, 2, "Scenario:", "When I have when in scenario",
316
- [:step, 3, "Given", "I am a step"]]]
316
+ [:step_invocation, 3, "Given", "I am a step"]]]
317
317
  end
318
318
  end
319
319
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
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-05-03 00:00:00 -07:00
12
+ date: 2009-05-10 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -235,11 +235,13 @@ files:
235
235
  - examples/selenium/features/step_definitons/search_steps.rb
236
236
  - examples/selenium/features/support/env.rb
237
237
  - examples/selenium_webrat/Rakefile
238
+ - examples/selenium_webrat/config.ru
238
239
  - examples/selenium_webrat/features/search.feature
239
240
  - examples/selenium_webrat/features/step_definitons/search_steps.rb
240
241
  - examples/selenium_webrat/features/support/env.rb
241
242
  - examples/self_test/README.textile
242
243
  - examples/self_test/Rakefile
244
+ - examples/self_test/features/background/background_tagged_before_on_outline.feature
243
245
  - examples/self_test/features/background/background_with_name.feature
244
246
  - examples/self_test/features/background/failing_background.feature
245
247
  - examples/self_test/features/background/failing_background_after_success.feature
@@ -310,6 +312,7 @@ files:
310
312
  - features/cucumber_cli_diff_disabled.feature
311
313
  - features/cucumber_cli_outlines.feature
312
314
  - features/custom_formatter.feature
315
+ - features/exclude_files.feature
313
316
  - features/multiline_names.feature
314
317
  - features/rake_task.feature
315
318
  - features/report_called_undefined_steps.feature