aslakhellesoy-cucumber 0.2.0.2 → 0.2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,11 +1,15 @@
1
1
  == 0.2.1 (In Git)
2
2
 
3
3
  == Bugfixes
4
+ * HTML Formatter doesn't work correctly with scenario Outlines. (#260 Aslak Hellesøy)
4
5
  * After blocks are run in reverse order of registration. (#113 Aslak Hellesøy)
5
6
  * Snippets are showing 'Ands' (#249 Aslak Hellesøy)
6
7
 
7
8
  === New features
8
- * New usage formatter. This is the foundation for editor autocompletion and navigation between steps and step definitions.
9
+ * Snippets use a regexp and block arguments if the step name has "quoted" arguments. (Aslak Hellesøy)
10
+ * Cucumber::Ast::Feature#to_sexp includes the file name. (Aslak Hellesøy)
11
+ * support/env.rb is not loaded when --dry-run is specified. This is to increase performance. (Aslak Hellesøy)
12
+ * New usage formatter. This is the foundation for editor autocompletion and navigation between steps and step definitions. (#209 Aslak Hellesøy)
9
13
 
10
14
  === Removed features
11
15
  * -S/--step-definitions option introduced in 0.2.0 is removed. Use --format usage [--dry-run] [--no-color].
data/Manifest.txt CHANGED
@@ -158,6 +158,7 @@ examples/self_test/features/sample.feature
158
158
  examples/self_test/features/step_definitions/sample_steps.rb
159
159
  examples/self_test/features/support/env.rb
160
160
  examples/self_test/features/support/tag_count_formatter.rb
161
+ examples/self_test/features/tons_of_cukes.feature
161
162
  examples/sinatra/Rakefile
162
163
  examples/sinatra/app.rb
163
164
  examples/sinatra/features/add.feature
@@ -206,7 +207,6 @@ gem_tasks/features.rake
206
207
  gem_tasks/fix_cr_lf.rake
207
208
  gem_tasks/flog.rake
208
209
  gem_tasks/gemspec.rake
209
- gem_tasks/jar.rake
210
210
  gem_tasks/rspec.rake
211
211
  gem_tasks/yard.rake
212
212
  lib/autotest/cucumber.rb
@@ -0,0 +1,52 @@
1
+ @lots
2
+ Feature: Tons of cukes
3
+ Scenario: Lots and lots
4
+ Given '2' cukes
5
+ Given '2' cukes
6
+ Given '2' cukes
7
+ Given '2' cukes
8
+ Given '2' cukes
9
+ Given '2' cukes
10
+ Given '2' cukes
11
+ Given '2' cukes
12
+ Given '2' cukes
13
+ Given '2' cukes
14
+ Given '2' cukes
15
+ Given '2' cukes
16
+ Given '2' cukes
17
+ Given '2' cukes
18
+ Given '2' cukes
19
+ Given '2' cukes
20
+ Given '2' cukes
21
+ Given '2' cukes
22
+ Given '2' cukes
23
+ Given '2' cukes
24
+ Given '2' cukes
25
+ Given '2' cukes
26
+ Given '2' cukes
27
+ Given '2' cukes
28
+ Given '2' cukes
29
+ Given '2' cukes
30
+ Given '2' cukes
31
+ Given '2' cukes
32
+ Given '2' cukes
33
+ Given '2' cukes
34
+ Given '2' cukes
35
+ Given '2' cukes
36
+ Given '2' cukes
37
+ Given '2' cukes
38
+ Given '2' cukes
39
+ Given '2' cukes
40
+ Given '2' cukes
41
+ Given '2' cukes
42
+ Given '2' cukes
43
+ Given '2' cukes
44
+ Given '2' cukes
45
+ Given '2' cukes
46
+ Given '2' cukes
47
+ Given '2' cukes
48
+ Given '2' cukes
49
+ Given '2' cukes
50
+ Given '2' cukes
51
+ Given '2' cukes
52
+ Given '2' cukes
@@ -166,7 +166,7 @@ Feature: Cucumber command line
166
166
  """
167
167
 
168
168
  Scenario: --dry-run
169
- When I run cucumber --dry-run --no-snippets features/*.feature
169
+ When I run cucumber --dry-run --no-snippets features/*.feature --tags ~@lots
170
170
  Then it should pass with
171
171
  """
172
172
  Feature: Calling undefined step
@@ -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
- | four | one | three | two |
8
- | 1 | 1 | 2 | 1 |
7
+ | four | lots | one | three | two |
8
+ | 1 | 1 | 1 | 2 | 1 |
9
9
 
10
10
  """
11
11
 
@@ -22,6 +22,55 @@ Feature: Cucumber command line
22
22
  And '10' cukes # features/background/failing_background.feature:5
23
23
  Given '10' cukes # features/background/passing_background.feature:4
24
24
  Given '10' cukes # features/background/scenario_outline_passing_background.feature:4
25
+ Given '2' cukes # features/tons_of_cukes.feature:4
26
+ Given '2' cukes # features/tons_of_cukes.feature:5
27
+ Given '2' cukes # features/tons_of_cukes.feature:6
28
+ Given '2' cukes # features/tons_of_cukes.feature:7
29
+ Given '2' cukes # features/tons_of_cukes.feature:8
30
+ Given '2' cukes # features/tons_of_cukes.feature:9
31
+ Given '2' cukes # features/tons_of_cukes.feature:10
32
+ Given '2' cukes # features/tons_of_cukes.feature:11
33
+ Given '2' cukes # features/tons_of_cukes.feature:12
34
+ Given '2' cukes # features/tons_of_cukes.feature:13
35
+ Given '2' cukes # features/tons_of_cukes.feature:14
36
+ Given '2' cukes # features/tons_of_cukes.feature:15
37
+ Given '2' cukes # features/tons_of_cukes.feature:16
38
+ Given '2' cukes # features/tons_of_cukes.feature:17
39
+ Given '2' cukes # features/tons_of_cukes.feature:18
40
+ Given '2' cukes # features/tons_of_cukes.feature:19
41
+ Given '2' cukes # features/tons_of_cukes.feature:20
42
+ Given '2' cukes # features/tons_of_cukes.feature:21
43
+ Given '2' cukes # features/tons_of_cukes.feature:22
44
+ Given '2' cukes # features/tons_of_cukes.feature:23
45
+ Given '2' cukes # features/tons_of_cukes.feature:24
46
+ Given '2' cukes # features/tons_of_cukes.feature:25
47
+ Given '2' cukes # features/tons_of_cukes.feature:26
48
+ Given '2' cukes # features/tons_of_cukes.feature:27
49
+ Given '2' cukes # features/tons_of_cukes.feature:28
50
+ Given '2' cukes # features/tons_of_cukes.feature:29
51
+ Given '2' cukes # features/tons_of_cukes.feature:30
52
+ Given '2' cukes # features/tons_of_cukes.feature:31
53
+ Given '2' cukes # features/tons_of_cukes.feature:32
54
+ Given '2' cukes # features/tons_of_cukes.feature:33
55
+ Given '2' cukes # features/tons_of_cukes.feature:34
56
+ Given '2' cukes # features/tons_of_cukes.feature:35
57
+ Given '2' cukes # features/tons_of_cukes.feature:36
58
+ Given '2' cukes # features/tons_of_cukes.feature:37
59
+ Given '2' cukes # features/tons_of_cukes.feature:38
60
+ Given '2' cukes # features/tons_of_cukes.feature:39
61
+ Given '2' cukes # features/tons_of_cukes.feature:40
62
+ Given '2' cukes # features/tons_of_cukes.feature:41
63
+ Given '2' cukes # features/tons_of_cukes.feature:42
64
+ Given '2' cukes # features/tons_of_cukes.feature:43
65
+ Given '2' cukes # features/tons_of_cukes.feature:44
66
+ Given '2' cukes # features/tons_of_cukes.feature:45
67
+ Given '2' cukes # features/tons_of_cukes.feature:46
68
+ Given '2' cukes # features/tons_of_cukes.feature:47
69
+ Given '2' cukes # features/tons_of_cukes.feature:48
70
+ Given '2' cukes # features/tons_of_cukes.feature:49
71
+ Given '2' cukes # features/tons_of_cukes.feature:50
72
+ Given '2' cukes # features/tons_of_cukes.feature:51
73
+ Given '2' cukes # features/tons_of_cukes.feature:52
25
74
  /^I should have '(.+)' cukes$/ # features/step_definitions/sample_steps.rb:31
26
75
  Then I should have '10' cukes # features/background/failing_background.feature:8
27
76
  Then I should have '10' cukes # features/background/failing_background.feature:11
@@ -1,7 +1,7 @@
1
1
  require 'autotest'
2
2
  require 'tempfile'
3
3
  require 'yaml'
4
- require File.dirname(__FILE__) + '/../cucumber'
4
+ require 'cucumber'
5
5
 
6
6
  module Autotest::CucumberMixin
7
7
  def self.included(receiver)
@@ -48,7 +48,7 @@ module Cucumber
48
48
  end
49
49
 
50
50
  def to_sexp
51
- sexp = [:feature, @name]
51
+ sexp = [:feature, @file, @name]
52
52
  comment = @comment.to_sexp
53
53
  sexp += [comment] if comment
54
54
  tags = @tags.to_sexp
@@ -1,10 +1,16 @@
1
1
  module Cucumber
2
2
  module Ast
3
3
  class Features
4
+ include Enumerable
5
+
4
6
  def initialize
5
7
  @features = []
6
8
  end
7
9
 
10
+ def each(&proc)
11
+ @features.each(&proc)
12
+ end
13
+
8
14
  def add_feature(feature)
9
15
  feature.features = self
10
16
  @features << feature
@@ -78,6 +78,10 @@ module Cucumber
78
78
  @file_colon_line ||= @feature_element.file_colon_line(@line) unless @feature_element.nil?
79
79
  end
80
80
 
81
+ def dom_id
82
+ @dom_id ||= file_colon_line.gsub(/\//, '_').gsub(/\./, '_').gsub(/:/, '_')
83
+ end
84
+
81
85
  private
82
86
 
83
87
  def matched_cells(cells)
@@ -28,7 +28,7 @@ module Cucumber
28
28
  unless @skip_invoke || options[:dry_run] || exception || @step_collection.exception
29
29
  @skip_invoke = true
30
30
  begin
31
- step_mother.current_world.__cucumber_current_step = self
31
+ step_mother.current_world.__cucumber_current_step = self if step_mother.current_world # Nil in Pure Java
32
32
  @step_match.invoke(step_mother.current_world, @multiline_arg)
33
33
  status!(:passed)
34
34
  rescue Pending => e
@@ -102,6 +102,10 @@ module Cucumber
102
102
  @step.file_colon_line
103
103
  end
104
104
 
105
+ def dom_id
106
+ @step.dom_id
107
+ end
108
+
105
109
  def backtrace_line
106
110
  @step.backtrace_line
107
111
  end
@@ -264,6 +264,10 @@ module Cucumber
264
264
  @cells[0].line
265
265
  end
266
266
 
267
+ def dom_id
268
+ "row_#{line}"
269
+ end
270
+
267
271
  def status=(status)
268
272
  each do |cell|
269
273
  cell.status = status
@@ -1,7 +1,7 @@
1
1
  module Cucumber
2
2
  module Cli
3
3
  class YmlLoadError < StandardError; end
4
-
4
+
5
5
  class Configuration
6
6
  FORMATS = %w{pretty profile progress rerun}
7
7
  DEFAULT_FORMAT = 'pretty'
@@ -95,6 +95,7 @@ module Cucumber
95
95
  Term::ANSIColor.coloring = v
96
96
  end
97
97
  opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
98
+ "This also omits the loading of your support/env.rb file if it exists.",
98
99
  "Implies --quiet.") do
99
100
  @options[:dry_run] = true
100
101
  @quiet = true
@@ -236,7 +237,9 @@ module Cucumber
236
237
  end.flatten.uniq
237
238
  sorted_files = files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }.reject{|f| f =~ /^http/}
238
239
  env_files = sorted_files.select {|f| f =~ %r{/support/env.rb} }
239
- env_files + sorted_files.reject {|f| f =~ %r{/support/env.rb} }
240
+ files = env_files + sorted_files.reject {|f| f =~ %r{/support/env.rb} }
241
+ files.reject! {|f| f =~ %r{/support/env.rb} } if @options[:dry_run]
242
+ files
240
243
  end
241
244
 
242
245
  def feature_files
@@ -46,7 +46,18 @@ module Cucumber
46
46
  Kernel.exit(failure ? 1 : 0)
47
47
  end
48
48
 
49
- private
49
+ def load_plain_text_features
50
+ features = Ast::Features.new
51
+ parser = Parser::FeatureParser.new
52
+
53
+ verbose_log("Features:")
54
+ configuration.feature_files.each do |f|
55
+ features.add_feature(parser.parse_file(f))
56
+ verbose_log(" * #{f}")
57
+ end
58
+ verbose_log("\n"*2)
59
+ features
60
+ end
50
61
 
51
62
  def configuration
52
63
  return @configuration if @configuration
@@ -55,6 +66,8 @@ module Cucumber
55
66
  @configuration.parse!(@args)
56
67
  @configuration
57
68
  end
69
+
70
+ private
58
71
 
59
72
  def require_files
60
73
  verbose_log("Ruby files required:")
@@ -70,19 +83,6 @@ module Cucumber
70
83
  verbose_log("\n")
71
84
  end
72
85
 
73
- def load_plain_text_features
74
- features = Ast::Features.new
75
- parser = Parser::FeatureParser.new
76
-
77
- verbose_log("Features:")
78
- configuration.feature_files.each do |f|
79
- features.add_feature(parser.parse_file(f))
80
- verbose_log(" * #{f}")
81
- end
82
- verbose_log("\n"*2)
83
- features
84
- end
85
-
86
86
  def verbose_log(string)
87
87
  @out_stream.puts(string) if configuration.verbose?
88
88
  end
@@ -83,37 +83,73 @@ module Cucumber
83
83
  @builder.h4("#{keyword} #{name}")
84
84
  end
85
85
 
86
- def visit_steps(scenarios)
86
+ def visit_steps(steps)
87
87
  @builder.ol do
88
88
  super
89
89
  end
90
90
  end
91
91
 
92
+ def visit_step(step)
93
+ @step_id = step.dom_id
94
+ @builder.li(:id => @step_id) do
95
+ super
96
+ end
97
+ end
98
+
92
99
  def visit_step_name(keyword, step_match, status, source_indent, background)
93
- step_name = step_match.format_args(lambda{|param| "<span>#{param}</span>"})
94
- @builder.li("#{keyword} #{step_name}", :class => status)
100
+ @step_matches ||= []
101
+ @skip_step = @step_matches.index(step_match)
102
+ @step_matches << step_match
103
+
104
+ unless @skip_step
105
+ step_name = step_match.format_args(lambda{|param| "<span>#{param}</span>"})
106
+ @builder.div(:class => status) do |div|
107
+ div << "#{keyword} #{step_name}"
108
+ end
109
+ end
110
+ end
111
+
112
+ def visit_exception(exception, status)
113
+ @builder.pre(format_exception(e), :class => status)
95
114
  end
96
115
 
97
116
  def visit_multiline_arg(multiline_arg)
117
+ return if @skip_step
98
118
  if Ast::Table === multiline_arg
99
119
  @builder.table do
100
120
  super
101
121
  end
102
122
  else
103
- @builder.p do
104
- super
105
- end
123
+ super
124
+ end
125
+ end
126
+
127
+ def visit_py_string(string, status)
128
+ @builder.pre(:class => status) do |pre|
129
+ pre << string
106
130
  end
107
131
  end
108
132
 
109
133
  def visit_table_row(table_row)
110
- @builder.tr do
134
+ @row_id = table_row.dom_id
135
+ @col_index = 0
136
+ @builder.tr(:id => @row_id) do
111
137
  super
112
138
  end
139
+ if table_row.exception
140
+ @builder.tr do
141
+ @builder.td(:colspan => @col_index.to_s, :class => 'failed') do
142
+ @builder.pre do |pre|
143
+ pre << format_exception(table_row.exception)
144
+ end
145
+ end
146
+ end
147
+ end
113
148
  end
114
149
 
115
150
  def visit_table_cell_value(value, width, status)
116
- @builder.td(value, :class => status)
151
+ @builder.td(value, :class => status, :id => "#{@row_id}_#{@col_index}")
152
+ @col_index += 1
117
153
  end
118
154
 
119
155
  def announce(announcement)
@@ -128,6 +164,9 @@ module Cucumber
128
164
  end
129
165
  end
130
166
 
167
+ def format_exception(exception)
168
+ (["#{exception.message} (#{exception.class})"] + exception.backtrace).join("\n")
169
+ end
131
170
  end
132
171
  end
133
172
  end
@@ -121,16 +121,15 @@ module Cucumber
121
121
 
122
122
  def visit_step_name(keyword, step_match, status, source_indent, background)
123
123
  @step_matches ||= []
124
-
125
124
  non_failed_background_step_outside_background = !@in_background && background && (status != :failed)
126
125
  @skip_step = @step_matches.index(step_match) || non_failed_background_step_outside_background
126
+ @step_matches << step_match
127
127
 
128
128
  unless(@skip_step)
129
129
  source_indent = nil unless @options[:source]
130
130
  formatted_step_name = format_step(keyword, step_match, status, source_indent)
131
131
  @io.puts(" " + formatted_step_name)
132
132
  end
133
- @step_matches << step_match
134
133
  end
135
134
 
136
135
  def visit_multiline_arg(multiline_arg)
@@ -3,6 +3,50 @@ require 'cucumber/core_ext/string'
3
3
  require 'cucumber/core_ext/proc'
4
4
 
5
5
  module Cucumber
6
+ module StepDefinitionMethods
7
+ def step_match(name_to_match, name_to_report)
8
+ if(match = name_to_match.match(regexp))
9
+ StepMatch.new(self, name_to_match, name_to_report, match.captures)
10
+ else
11
+ nil
12
+ end
13
+ end
14
+
15
+ # Formats the matched arguments of the associated Step. This method
16
+ # is usually called from visitors, which render output.
17
+ #
18
+ # The +format+ can either be a String or a Proc.
19
+ #
20
+ # If it is a String it should be a format string according to
21
+ # <tt>Kernel#sprinf</tt>, for example:
22
+ #
23
+ # '<span class="param">%s</span></tt>'
24
+ #
25
+ # If it is a Proc, it should take one argument and return the formatted
26
+ # argument, for example:
27
+ #
28
+ # lambda { |param| "[#{param}]" }
29
+ #
30
+ def format_args(step_name, format)
31
+ step_name.gzub(regexp, format)
32
+ end
33
+
34
+ def match(step_name)
35
+ case step_name
36
+ when String then regexp.match(step_name)
37
+ when Regexp then regexp == step_name
38
+ end
39
+ end
40
+
41
+ def backtrace_line
42
+ "#{file_colon_line}:in `#{regexp.inspect}'"
43
+ end
44
+
45
+ def text_length
46
+ regexp.inspect.jlength
47
+ end
48
+ end
49
+
6
50
  # A Step Definition holds a Regexp and a Proc, and is created
7
51
  # by calling <tt>Given</tt>, <tt>When</tt> or <tt>Then</tt>
8
52
  # in the <tt>step_definitions</tt> ruby files - for example:
@@ -14,7 +58,22 @@ module Cucumber
14
58
  class StepDefinition
15
59
  def self.snippet_text(step_keyword, step_name)
16
60
  escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
17
- "#{step_keyword} /^#{escaped}$/ do\n pending\nend"
61
+ param_pattern = /"([^\"]*)"/
62
+
63
+ match = escaped.match(param_pattern)
64
+ if match
65
+ n = 0
66
+ block_args = match.captures.map do |a|
67
+ n += 1
68
+ "arg#{n}"
69
+ end
70
+ block_arg_string = " |#{block_args.join(", ")}|"
71
+ else
72
+ block_arg_string = ""
73
+ end
74
+
75
+ escaped = escaped.gsub(param_pattern, '"([^\\"]*)"')
76
+ "#{step_keyword} /^#{escaped}$/ do#{block_arg_string}\n pending\nend"
18
77
  end
19
78
 
20
79
  class MissingProc < StandardError
@@ -23,7 +82,7 @@ module Cucumber
23
82
  end
24
83
  end
25
84
 
26
- attr_reader :regexp
85
+ include StepDefinitionMethods
27
86
 
28
87
  def initialize(pattern, &proc)
29
88
  raise MissingProc if proc.nil?
@@ -34,66 +93,22 @@ module Cucumber
34
93
  @regexp, @proc = pattern, proc
35
94
  end
36
95
 
37
- def step_match(name_to_match, name_to_report)
38
- if(match = name_to_match.match(@regexp))
39
- StepMatch.new(self, name_to_match, name_to_report, match.captures)
40
- else
41
- nil
42
- end
96
+ def regexp
97
+ @regexp
43
98
  end
44
99
 
45
- def invoke(world, args, step_name)
100
+ def invoke(world, args)
46
101
  args = args.map{|arg| Ast::PyString === arg ? arg.to_s : arg}
47
102
  begin
48
- world.cucumber_instance_exec(true, @regexp.inspect, *args, &@proc)
103
+ world.cucumber_instance_exec(true, regexp.inspect, *args, &@proc)
49
104
  rescue Cucumber::ArityMismatchError => e
50
105
  e.backtrace.unshift(self.backtrace_line)
51
106
  raise e
52
107
  end
53
108
  end
54
109
 
55
- #:stopdoc:
56
-
57
- def match(step_name)
58
- case step_name
59
- when String then @regexp.match(step_name)
60
- when Regexp then @regexp == step_name
61
- end
62
- end
63
-
64
- # Formats the matched arguments of the associated Step. This method
65
- # is usually called from visitors, which render output.
66
- #
67
- # The +format+ can either be a String or a Proc.
68
- #
69
- # If it is a String it should be a format string according to
70
- # <tt>Kernel#sprinf</tt>, for example:
71
- #
72
- # '<span class="param">%s</span></tt>'
73
- #
74
- # If it is a Proc, it should take one argument and return the formatted
75
- # argument, for example:
76
- #
77
- # lambda { |param| "[#{param}]" }
78
- #
79
- def format_args(step_name, format)
80
- step_name.gzub(@regexp, format)
81
- end
82
-
83
- def matched_args(step_name)
84
- step_name.match(@regexp).captures
85
- end
86
-
87
- def backtrace_line
88
- "#{file_colon_line}:in `#{@regexp.inspect}'"
89
- end
90
-
91
110
  def file_colon_line
92
111
  @proc.file_colon_line
93
112
  end
94
-
95
- def text_length
96
- @regexp.inspect.jlength
97
- end
98
113
  end
99
114
  end
@@ -10,7 +10,7 @@ module Cucumber
10
10
  def invoke(world, multiline_arg)
11
11
  all_args = @args.dup
12
12
  all_args << multiline_arg if multiline_arg
13
- @step_definition.invoke(world, all_args, @step_name)
13
+ @step_definition.invoke(world, all_args)
14
14
  end
15
15
 
16
16
  def format_args(format = lambda{|a| a})
@@ -3,7 +3,7 @@ module Cucumber #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
5
  TINY = 0
6
- PATCH = 2 # Set to nil for official release
6
+ PATCH = 3 # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
@@ -10,7 +10,7 @@ When /^I delete the (\d+)(?:st|nd|rd|th) <%= singular_name %>$/ do |pos|
10
10
  end
11
11
 
12
12
  Then /^I should see the following <%= plural_name %>:$/ do |<%= plural_name %>|
13
- <%= plural_name %>.raw[1..-1].each_with_index do |row, i|
13
+ <%= plural_name %>.rows.each_with_index do |row, i|
14
14
  row.each_with_index do |cell, j|
15
15
  response.should have_selector("table > tr:nth-child(#{i+2}) > td:nth-child(#{j+1})") { |td|
16
16
  td.inner_text.should == cell
@@ -9,7 +9,8 @@ module Cucumber
9
9
  it "should convert to sexp" do
10
10
  feature = create_feature(Object.new)
11
11
  feature.to_sexp.should ==
12
- [:feature,
12
+ [:feature,
13
+ "features/pretty_printing.feature",
13
14
  "Pretty printing",
14
15
  [:comment, "# My feature comment\n"],
15
16
  [:tag, "one"],
@@ -18,7 +18,7 @@ module Cli
18
18
  it "should require files in support paths first" do
19
19
  File.stub!(:directory?).and_return(true)
20
20
  Dir.stub!(:[]).and_return(["/features/step_definitions/foo.rb","/features/support/bar.rb"])
21
-
21
+
22
22
  config = Configuration.new(StringIO.new)
23
23
  config.parse!(%w{--require /features})
24
24
 
@@ -31,7 +31,7 @@ module Cli
31
31
  it "should require env.rb files first" do
32
32
  File.stub!(:directory?).and_return(true)
33
33
  Dir.stub!(:[]).and_return(["/features/support/a_file.rb","/features/support/env.rb"])
34
-
34
+
35
35
  config = Configuration.new(StringIO.new)
36
36
  config.parse!(%w{--require /features})
37
37
 
@@ -40,7 +40,19 @@ module Cli
40
40
  "/features/support/a_file.rb"
41
41
  ]
42
42
  end
43
-
43
+
44
+ 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"])
47
+
48
+ config = Configuration.new(StringIO.new)
49
+ config.parse!(%w{--require /features --dry-run})
50
+
51
+ config.files_to_require.should == [
52
+ "/features/support/a_file.rb"
53
+ ]
54
+ end
55
+
44
56
  it "should expand args from YAML file" do
45
57
  given_cucumber_yml_defined_as({'bongo' => '--require from/yml'})
46
58
 
@@ -33,7 +33,7 @@ with blurb
33
33
  parse(%{# My comment
34
34
  Feature: hi
35
35
  }).to_sexp.should ==
36
- [:feature, "Feature: hi\n",
36
+ [:feature, nil, "Feature: hi\n",
37
37
  [:comment, "# My comment\n"]]
38
38
  end
39
39
 
@@ -45,7 +45,7 @@ Feature: hi
45
45
  # When bar
46
46
  Then baz
47
47
  }).to_sexp.should ==
48
- [:feature, "Feature: Hi",
48
+ [:feature, nil, "Feature: Hi",
49
49
  [:scenario, 2, "Scenario:", "Hello",
50
50
  [:step, 3, "Given", "foo"],
51
51
  [:comment, "# When bar\n"],
@@ -59,18 +59,18 @@ Feature: hi
59
59
  # World
60
60
  Feature: hi
61
61
  }).to_sexp.should ==
62
- [:feature, "Feature: hi\n",
62
+ [:feature, nil, "Feature: hi\n",
63
63
  [:comment, "# Hello\n# World\n"]]
64
64
  end
65
65
 
66
66
  it "should parse a file with no comments" do
67
67
  parse("Feature: hi\n").to_sexp.should ==
68
- [:feature, "Feature: hi\n"]
68
+ [:feature, nil, "Feature: hi\n"]
69
69
  end
70
70
 
71
71
  it "should parse a file with only a multiline comment with newlines" do
72
72
  parse("# Hello\n\n# World\n").to_sexp.should ==
73
- [:feature, "",
73
+ [:feature, nil, "",
74
74
  [:comment, "# Hello\n\n# World\n"]]
75
75
  end
76
76
  end
@@ -78,7 +78,7 @@ Feature: hi
78
78
  describe "Tags" do
79
79
  it "should parse a file with tags on a feature" do
80
80
  parse("# My comment\n@hello @world Feature: hi\n").to_sexp.should ==
81
- [:feature, "Feature: hi\n",
81
+ [:feature, nil, "Feature: hi\n",
82
82
  [:comment, "# My comment\n"],
83
83
  [:tag, "hello"],
84
84
  [:tag, "world"]]
@@ -96,7 +96,7 @@ Feature: hi
96
96
  @st3
97
97
  @st4 @ST5 @#^%&ST6**!
98
98
  Scenario: Second}).to_sexp.should ==
99
- [:feature, "Feature: hi",
99
+ [:feature, nil, "Feature: hi",
100
100
  [:comment, "# FC\n "],
101
101
  [:tag, "ft"],
102
102
  [:scenario, 6, 'Scenario:', 'First',
@@ -111,7 +111,7 @@ Feature: hi
111
111
  describe "Background" do
112
112
  it "should have steps" do
113
113
  parse("Feature: Hi\nBackground:\nGiven I am a step\n").to_sexp.should ==
114
- [:feature, "Feature: Hi",
114
+ [:feature, nil, "Feature: Hi",
115
115
  [:background, 2, "Background:",
116
116
  [:step, 3, "Given", "I am a step"]]]
117
117
  end
@@ -120,7 +120,7 @@ Feature: hi
120
120
  describe "Scenarios" do
121
121
  it "can be empty" do
122
122
  parse("Feature: Hi\n\nScenario: Hello\n").to_sexp.should ==
123
- [:feature, "Feature: Hi",
123
+ [:feature, nil, "Feature: Hi",
124
124
  [:scenario, 3, "Scenario:", "Hello"]]
125
125
  end
126
126
 
@@ -134,7 +134,7 @@ Scenario: bar
134
134
 
135
135
  it "should have steps" do
136
136
  parse("Feature: Hi\nScenario: Hello\nGiven I am a step\n").to_sexp.should ==
137
- [:feature, "Feature: Hi",
137
+ [:feature, nil, "Feature: Hi",
138
138
  [:scenario, 2, "Scenario:", "Hello",
139
139
  [:step_invocation, 3, "Given", "I am a step"]]]
140
140
  end
@@ -145,7 +145,7 @@ Scenario: Hello
145
145
  Given I have a table
146
146
  |a|b|
147
147
  }).to_sexp.should ==
148
- [:feature, "Feature: Hi",
148
+ [:feature, nil, "Feature: Hi",
149
149
  [:scenario, 2, "Scenario:", "Hello",
150
150
  [:step_invocation, 3, "Given", "I have a table",
151
151
  [:table,
@@ -166,7 +166,7 @@ Given I have a string
166
166
  """
167
167
 
168
168
  }).to_sexp.should ==
169
- [:feature, "Feature: Hi",
169
+ [:feature, nil, "Feature: Hi",
170
170
  [:scenario, 2, "Scenario:", "Hello",
171
171
  [:step_invocation, 3, "Given", "I have a string",
172
172
  [:py_string, "hello\nworld"]]]]
@@ -182,7 +182,7 @@ Examples:
182
182
  |what|
183
183
  |green|
184
184
  }).to_sexp.should ==
185
- [:feature, "Feature: Hi",
185
+ [:feature, nil, "Feature: Hi",
186
186
  [:scenario_outline, "Scenario Outline:", "Hello",
187
187
  [:step, 3, "Given", "a <what> cucumber"],
188
188
  [:examples, "Examples:", "",
@@ -203,7 +203,7 @@ Examples:
203
203
  |a|b|
204
204
  |c|d|
205
205
  }).to_sexp.should ==
206
- [:feature, "Feature: Hi",
206
+ [:feature, nil, "Feature: Hi",
207
207
  [:scenario_outline, "Scenario Outline:", "Hello",
208
208
  [:step, 4, "Given", "I have a table",
209
209
  [:table,
@@ -233,7 +233,7 @@ Examples:
233
233
  |5|6|
234
234
 
235
235
  ").to_sexp.should ==
236
- [:feature, "Feature: Hi",
236
+ [:feature, nil, "Feature: Hi",
237
237
  [:scenario_outline, "Scenario Outline:", "Hello",
238
238
  [:step, 5, "Given", "I have a table",
239
239
  [:table,
@@ -69,5 +69,25 @@ module Cucumber
69
69
  end
70
70
  step_match("Loud").invoke(world, nil)
71
71
  end
72
+
73
+ def unindented(s)
74
+ s.split("\n")[1..-2].join("\n").indent(-8)
75
+ end
76
+
77
+ it "should recognise quotes in name and make according regexp" do
78
+ StepDefinition.snippet_text('Given', 'A "first" arg').should == unindented(%{
79
+ Given /^A "([^\\"]*)" arg$/ do |arg1|
80
+ pending
81
+ end
82
+ })
83
+ end
84
+
85
+ it "should not use quote group when there are no quotes" do
86
+ StepDefinition.snippet_text('Given', 'A first arg').should == unindented(%{
87
+ Given /^A first arg$/ do
88
+ pending
89
+ end
90
+ })
91
+ end
72
92
  end
73
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aslakhellesoy-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.2
4
+ version: 0.2.0.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-03-21 00:00:00 -07:00
12
+ date: 2009-03-24 00:00:00 -07:00
13
13
  default_executable: cucumber
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -245,6 +245,7 @@ files:
245
245
  - examples/self_test/features/step_definitions/sample_steps.rb
246
246
  - examples/self_test/features/support/env.rb
247
247
  - examples/self_test/features/support/tag_count_formatter.rb
248
+ - examples/self_test/features/tons_of_cukes.feature
248
249
  - examples/sinatra/Rakefile
249
250
  - examples/sinatra/app.rb
250
251
  - examples/sinatra/features/add.feature
@@ -293,7 +294,6 @@ files:
293
294
  - gem_tasks/fix_cr_lf.rake
294
295
  - gem_tasks/flog.rake
295
296
  - gem_tasks/gemspec.rake
296
- - gem_tasks/jar.rake
297
297
  - gem_tasks/rspec.rake
298
298
  - gem_tasks/yard.rake
299
299
  - lib/autotest/cucumber.rb
data/gem_tasks/jar.rake DELETED
@@ -1,67 +0,0 @@
1
- # http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar
2
-
3
- USE_JRUBY_VERSION = '1.1.6'
4
- USE_JBEHAVE_VERSION = '2.1'
5
- USE_JUNIT_VERSION = '4.5'
6
- USE_HAMCREST_VERSION = '1.1'
7
- CUCUMBER_VERSIONED = "cucumber-#{Cucumber::VERSION::STRING}"
8
-
9
- task :jar => [
10
- :clean,
11
- 'jar:download_jruby',
12
- 'jar:install_gems',
13
- 'jar:bundle_gems',
14
- 'jar:download_jars_deps',
15
- 'jar:unpack_jar_deps',
16
- 'jar:bundle_jars',
17
- 'jar:fix_gem_binaries',
18
- 'jar:test_jar'
19
- ]
20
-
21
- namespace :jar do
22
- task :download_jruby do
23
- sh "wget http://dist.codehaus.org/jruby/#{USE_JRUBY_VERSION}/jruby-complete-#{USE_JRUBY_VERSION}.jar -O #{CUCUMBER_VERSIONED}.jar"
24
- end
25
-
26
- task :install_gems => :gem do
27
- mkdir 'pkg/jar_gems'
28
- sh "java -jar #{CUCUMBER_VERSIONED}.jar -S gem install -i ./pkg/jar_gems pkg/#{CUCUMBER_VERSIONED}.gem --no-ri --no-rdoc"
29
- end
30
-
31
- task :bundle_gems do
32
- sh "jar uf #{CUCUMBER_VERSIONED}.jar -C pkg/jar_gems ."
33
- end
34
-
35
- task :download_jars_deps do
36
- mkdir 'pkg/jar_deps'
37
- sh "wget http://repository.codehaus.org/org/jbehave/jbehave-core/#{USE_JBEHAVE_VERSION}/jbehave-core-#{USE_JBEHAVE_VERSION}.jar -O pkg/jar_deps/jbehave-core-#{USE_JBEHAVE_VERSION}.jar"
38
- sh "wget http://mirrors.ibiblio.org/pub/mirrors/maven2/junit/junit/#{USE_JUNIT_VERSION}/junit-#{USE_JUNIT_VERSION}.jar -O pkg/jar_deps/junit-#{USE_JUNIT_VERSION}.jar"
39
- sh "wget http://hamcrest.googlecode.com/files/hamcrest-all-#{USE_HAMCREST_VERSION}.jar -O pkg/jar_deps/hamcrest-all-#{USE_HAMCREST_VERSION}.jar"
40
- end
41
-
42
- task :unpack_jar_deps do
43
- Dir.chdir 'pkg/jar_deps' do
44
- Dir['*.jar'].each do |jar|
45
- sh "jar xvf #{jar}"
46
- rm_rf jar
47
- rm_rf 'META-INF'
48
- end
49
- end
50
- end
51
-
52
- task :bundle_jars do
53
- sh "jar uf #{CUCUMBER_VERSIONED}.jar -C pkg/jar_deps ."
54
- end
55
-
56
- task :fix_gem_binaries do
57
- mkdir_p 'pkg/gem_binaries/META-INF/jruby.home'
58
- Dir.chdir 'pkg/gem_binaries/META-INF/jruby.home' do
59
- sh "jar xvf ../../../../#{CUCUMBER_VERSIONED}.jar bin"
60
- end
61
- sh "jar uf #{CUCUMBER_VERSIONED}.jar -C pkg/gem_binaries ."
62
- end
63
-
64
- task :test_jar do
65
- sh "java -cp examples/jbehave/target/classes -jar #{CUCUMBER_VERSIONED}.jar -S cucumber examples/jbehave/features"
66
- end
67
- end