cucumber 0.3.91 → 0.3.92

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,21 @@
1
+ == (In Git)
2
+
3
+ This release has some minor improvements to the new Table.diff! functionality. For example,
4
+ if you're using Webrat and you want to compare a feature table with a HTML table containing
5
+ links in one of the columns, you can do:
6
+
7
+ actual = Cucumber::Ast::Table.new(table_at('table').to_a)
8
+ actual.map_column!('Name') { |text| text.strip.match(/>(.*)</)[1] }
9
+ table.diff!(actual)
10
+
11
+ === New features
12
+ * Allow Step Definitions to accept mix of required & optional args (Niels Ganser)
13
+ * table_a.diff!(table_b) now uses column conversions from both tables (Table#map_column!) (Aslak Hellesøy)
14
+
15
+ === Bugfixes
16
+ * Upgrade Sinatra example to work with rack-test 0.3.0 and aslakhellesoy-webrat 0.4.4.1 (Aslak Hellesøy)
17
+ * require 'cucumber/webrat/table_locator' added to Spork environment for Rails (Anders Furseth)
18
+
1
19
  == 0.3.91 2009-07-27
2
20
 
3
21
  === New Features
data/config/hoe.rb CHANGED
@@ -48,7 +48,8 @@ end
48
48
 
49
49
  # Generate all the Rake tasks
50
50
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
51
- $hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ $hoe = Hoe.spec(GEM_NAME) do |p|
52
+ p.version = VERS
52
53
  p.developer(AUTHOR, EMAIL)
53
54
  p.description = DESCRIPTION
54
55
  p.summary = DESCRIPTION
@@ -61,7 +62,7 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
61
62
  #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
63
  p.extra_deps = [
63
64
  ['term-ansicolor', '>= 1.0.3'],
64
- ['treetop', '>= 1.2.6'],
65
+ ['treetop', '>= 1.3.0'],
65
66
  ['diff-lcs', '>= 1.1.2'],
66
67
  ['builder', '>= 2.1.2']
67
68
  ]
@@ -1,6 +1,10 @@
1
1
  # See http://wiki.github.com/aslakhellesoy/cucumber/sinatra
2
2
  # for more details about Sinatra with Cucumber
3
3
 
4
+ gem 'rack-test', '=0.3.0'
5
+ gem 'aslakhellesoy-webrat', '=0.4.4.1'
6
+ gem 'sinatra', '=0.9.4'
7
+
4
8
  # Sinatra
5
9
  app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])
6
10
  require app_file
@@ -8,13 +12,15 @@ require app_file
8
12
  Sinatra::Application.app_file = app_file
9
13
 
10
14
  require 'spec/expectations'
11
-
15
+ require 'rack/test'
12
16
  require 'webrat'
17
+
13
18
  Webrat.configure do |config|
14
19
  config.mode = :rack
15
20
  end
16
21
 
17
22
  class MyWorld
23
+ include Rack::Test::Methods
18
24
  include Webrat::Methods
19
25
  include Webrat::Matchers
20
26
 
@@ -166,7 +166,7 @@ which goes on and on and on for three lines
166
166
  yawn</span></h4><table><tr id="row_26"><th class="val skipped_param" id="row_26_0">state</th></tr><tr id="row_27"><td class="val passed" id="row_27_0">passing</td></tr></table></div></div></div><div class="feature"><h2><span class="val">Feature: Outline Sample</span></h2><p class="narrative"></p><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">I have no steps</span></h3><ol></ol></div><div class="scenario outline"><h3><span class="keyword">Scenario Outline:</span> <span class="val">Test state</span></h3><ol><li class="step skipped" id="features_outline_sample_feature_6"><div><span class="keyword">Given</span> <span class="step val">&lt;state&gt; without a table</span></div></li><li class="step skipped" id="features_outline_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">&lt;other_state&gt; without a table</span></div></li></ol><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Rainbow colours</span></h4><table><tr id="row_9"><th class="val skipped_param" id="row_9_0">state</th><th class="val skipped_param" id="row_9_1">other_state</th></tr><tr id="row_10"><td class="val undefined" id="row_10_0">missing</td><td class="val skipped" id="row_10_1">passing</td></tr><tr id="row_11"><td class="val passed" id="row_11_0">passing</td><td class="val passed" id="row_11_1">passing</td></tr><tr id="row_12"><td class="val failed" id="row_12_0">failing</td><td class="val skipped" id="row_12_1">passing</td></tr><tr><td class="failed" colspan="2"><pre>FAIL (RuntimeError)
167
167
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
168
168
  ./features/step_definitions/sample_steps.rb:16:in `/^failing without a table$/'
169
- features/outline_sample.feature:6:in `Given <state> without a table'</pre></td></tr></table></div><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Only passing</span></h4><table><tr id="row_14"><th class="val skipped_param" id="row_14_0">state</th><th class="val skipped_param" id="row_14_1">other_state</th></tr><tr id="row_15"><td class="val passed" id="row_15_0">passing</td><td class="val passed" id="row_15_1">passing</td></tr></table></div></div></div><div class="feature"><pre class="comment"># Feature comment<br/></pre><span class="tag">@one</span><h2><span class="val">Feature: Sample</span></h2><p class="narrative"></p><div class="scenario"><span class="tag">@two</span><span class="tag">@three</span><h3><span class="keyword">Scenario:</span> <span class="val">Missing</span></h3><ol><li class="step undefined" id="features_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">missing</span></div></li></ol></div><div class="scenario"><pre class="comment"># Scenario comment<br/></pre><span class="tag">@three</span><h3><span class="keyword">Scenario:</span> <span class="val">Passing</span></h3><ol><li class="step passed" id="features_sample_feature_12"><div><span class="keyword">Given</span> <span class="step val">passing</span></div><table><tr id="row_13"><td class="val" id="row_13_0">a</td><td class="val" id="row_13_1">b</td></tr><tr id="row_14"><td class="val" id="row_14_0">c</td><td class="val" id="row_14_1">d</td></tr></table></li></ol></div><div class="scenario"><span class="tag">@four</span><h3><span class="keyword">Scenario:</span> <span class="val">Failing</span></h3><ol><li class="step failed" id="features_sample_feature_18"><div><span class="keyword">Given</span> <span class="step val">failing</span></div><pre class="val">hello</pre><pre class="failed">FAIL (RuntimeError)
169
+ features/outline_sample.feature:6:in `Given <state> without a table'</pre></td></tr></table></div><div class="examples"><h4><span class="keyword">Examples:</span> <span class="val">Only passing</span></h4><table><tr id="row_14"><th class="val skipped_param" id="row_14_0">state</th><th class="val skipped_param" id="row_14_1">other_state</th></tr><tr id="row_15"><td class="val passed" id="row_15_0">passing</td><td class="val passed" id="row_15_1">passing</td></tr></table></div></div></div><div class="feature"><pre class="comment"># Feature comment<br/></pre><span class="tag">@one</span><h2><span class="val">Feature: Sample</span></h2><p class="narrative"></p><div class="scenario"><span class="tag">@two</span> <span class="tag">@three</span><h3><span class="keyword">Scenario:</span> <span class="val">Missing</span></h3><ol><li class="step undefined" id="features_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">missing</span></div></li></ol></div><div class="scenario"><pre class="comment"># Scenario comment<br/></pre><span class="tag">@three</span><h3><span class="keyword">Scenario:</span> <span class="val">Passing</span></h3><ol><li class="step passed" id="features_sample_feature_12"><div><span class="keyword">Given</span> <span class="step val">passing</span></div><table><tr id="row_13"><td class="val" id="row_13_0">a</td><td class="val" id="row_13_1">b</td></tr><tr id="row_14"><td class="val" id="row_14_0">c</td><td class="val" id="row_14_1">d</td></tr></table></li></ol></div><div class="scenario"><span class="tag">@four</span><h3><span class="keyword">Scenario:</span> <span class="val">Failing</span></h3><ol><li class="step failed" id="features_sample_feature_18"><div><span class="keyword">Given</span> <span class="step val">failing</span></div><pre class="val">hello</pre><pre class="failed">FAIL (RuntimeError)
170
170
  ./features/step_definitions/sample_steps.rb:2:in `flunker'
171
171
  ./features/step_definitions/sample_steps.rb:9:in `/^failing$/'
172
172
  features/sample.feature:18:in `Given failing'</pre></li></ol></div></div><div class="feature"><h2><span class="val">Feature: search examples</span></h2><p class="narrative"></p><div class="background"><h3><span class="keyword">Background:</span> <span class="val">Hantu Pisang background match</span></h3><ol><li class="step passed" id="features_search_sample_feature_4"><div><span class="keyword">Given</span> <span class="step val">passing without a table</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">should match Hantu Pisang</span></h3><ol><li class="step passed" id="features_search_sample_feature_7"><div><span class="keyword">Given</span> <span class="step val">passing without a table</span></div></li></ol></div><div class="scenario"><h3><span class="keyword">Scenario:</span> <span class="val">Ignore me</span></h3><ol><li class="step failed" id="features_search_sample_feature_10"><div><span class="keyword">Given</span> <span class="step val">failing without a table</span></div><pre class="failed">FAIL (RuntimeError)
@@ -44,6 +44,15 @@ module Cucumber
44
44
  "#{@file}:#{line}"
45
45
  end
46
46
 
47
+ def short_name
48
+ first_line = name.split(/\n/)[0]
49
+ if first_line =~ /#{language.keywords('feature', true)}:(.*)/
50
+ $1.strip
51
+ else
52
+ first_line
53
+ end
54
+ end
55
+
47
56
  def to_sexp
48
57
  sexp = [:feature, @file, @name]
49
58
  comment = @comment.to_sexp
@@ -9,6 +9,10 @@ module Cucumber
9
9
  @features = []
10
10
  end
11
11
 
12
+ def [](index)
13
+ @features[index]
14
+ end
15
+
12
16
  def each(&proc)
13
17
  @features.each(&proc)
14
18
  end
@@ -190,7 +190,7 @@ module Cucumber
190
190
  #
191
191
  # Since all tables that are passed to StepDefinitions always have String
192
192
  # objects in their cells, you may want to use #map_column! before calling
193
- # #diff!
193
+ # #diff!. You can use #map_column! on either of the tables.
194
194
  #
195
195
  # An exception is raised if there are missing rows or columns, or
196
196
  # surplus rows. An error is <em>not</em> raised for surplus columns.
@@ -212,6 +212,7 @@ module Cucumber
212
212
  options = {:missing_row => true, :surplus_row => true, :missing_col => true, :surplus_col => false}.merge(options)
213
213
 
214
214
  other_table = ensure_table(other_table)
215
+ other_table.convert_columns!
215
216
  ensure_green!
216
217
 
217
218
  original_width = cell_matrix[0].length
@@ -137,6 +137,12 @@ module Cucumber
137
137
  def trap_interrupt
138
138
  trap('INT') do
139
139
  $cucumber_interrupted = true
140
+ STDERR.puts "Interrupted. Waiting for current step to finish."
141
+ STDERR.puts "Will suicide in 5 seconds if current step doesn't finish gracefully."
142
+ Thread.new do
143
+ sleep(5)
144
+ exit!(1)
145
+ end
140
146
  end
141
147
  end
142
148
  end
@@ -10,10 +10,12 @@ class Object
10
10
  cucumber_run_with_backtrace_filtering(pseudo_method) do
11
11
  if check_arity && !cucumber_compatible_arity?(args, block)
12
12
  instance_exec do
13
- s1 = cucumber_arity(block) == 1 ? "" : "s"
13
+ ari = cucumber_arity(block)
14
+ ari = ari < 0 ? (ari.abs-1).to_s+"+" : ari
15
+ s1 = ari == 1 ? "" : "s"
14
16
  s2 = args.length == 1 ? "" : "s"
15
17
  raise Cucumber::ArityMismatchError.new(
16
- "Your block takes #{cucumber_arity(block)} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
18
+ "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
17
19
  )
18
20
  end
19
21
  else
@@ -28,9 +30,10 @@ class Object
28
30
  end
29
31
 
30
32
  def cucumber_compatible_arity?(args, block)
31
- a = cucumber_arity(block)
32
- return true if (a == -1) && Cucumber::RUBY_1_9
33
- a == args.length
33
+ ari = cucumber_arity(block)
34
+ len = args.length
35
+ return true if ari == len or ari < 0 && len >= ari.abs-1
36
+ false
34
37
  end
35
38
 
36
39
  def cucumber_run_with_backtrace_filtering(pseudo_method)
@@ -168,13 +168,13 @@
168
168
  feature: Feature
169
169
  background: Background
170
170
  scenario: Scenario
171
- scenario_outline: All y'all
171
+ scenario_outline: All y\'all
172
172
  examples: Examples
173
- given: Given y'all
174
- when: When y'all
175
- then: Then y'all
176
- and: And y'all
177
- but: But y'all
173
+ given: Given y\'all
174
+ when: When y\'all
175
+ then: Then y\'all
176
+ and: And y\'all
177
+ but: But y\'all
178
178
  space_after_keyword: true
179
179
  "es":
180
180
  name: Spanish
@@ -86,7 +86,7 @@ module Cucumber
86
86
 
87
87
  include StepDefinitionMethods
88
88
 
89
- attr_reader :regexp, :proc
89
+ attr_reader :proc
90
90
 
91
91
  def initialize(pattern, &proc)
92
92
  raise MissingProc if proc.nil?
@@ -2,7 +2,7 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 91
5
+ TINY = 92
6
6
  PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
@@ -7,6 +7,7 @@ Spork.prefork do
7
7
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
8
8
 
9
9
  require 'webrat'
10
+ require 'cucumber/webrat/table_locator' # Lets you do table.diff!(table_at('#my_table').to_a)
10
11
 
11
12
  Webrat.configure do |config|
12
13
  config.mode = :rails
@@ -227,7 +227,7 @@ module Cucumber
227
227
  }
228
228
  end
229
229
 
230
- it "should allow column mapping before diffing" do
230
+ it "should allow column mapping of target before diffing" do
231
231
  t1 = Table.new([
232
232
  ['name', 'male'],
233
233
  ['aslak', 'true']
@@ -244,6 +244,25 @@ module Cucumber
244
244
  }
245
245
  end
246
246
 
247
+ it "should allow column mapping of argument before diffing" do
248
+ t1 = Table.new([
249
+ ['name', 'male'],
250
+ ['aslak', true]
251
+ ])
252
+ t1.map_column!('male') {
253
+ 'true'
254
+ }
255
+ t2 = Table.new([
256
+ ['name', 'male'],
257
+ ['aslak', 'true']
258
+ ])
259
+ t2.diff!(t1)
260
+ t1.to_s(:indent => 12, :color => false).should == %{
261
+ | name | male |
262
+ | aslak | true |
263
+ }
264
+ end
265
+
247
266
  it "should allow header mapping before diffing" do
248
267
  t1 = Table.new([
249
268
  ['Name', 'Male'],
@@ -36,7 +36,7 @@ describe Proc do
36
36
  end
37
37
 
38
38
  if Cucumber::RUBY_1_9
39
- it "should allow varargs" do
39
+ it "should allow varargs (expecting 0+)" do
40
40
  lambda {
41
41
  Object.new.cucumber_instance_exec(true, 'foo', 1) do |*args|
42
42
  end
@@ -44,11 +44,25 @@ describe Proc do
44
44
  end
45
45
  else
46
46
  # Ruby 1.8
47
- it "should not allow varargs because Ruby 1.8 reports same arity as with no args, so we can't really tell the difference." do
47
+ it "should not allow varargs 0+ because Ruby 1.8 reports same arity as with no args, so we can't really tell the difference." do
48
48
  lambda {
49
49
  Object.new.cucumber_instance_exec(true, 'foo', 1) do |*args|
50
50
  end
51
51
  }.should raise_error(Cucumber::ArityMismatchError, "Your block takes 0 arguments, but the Regexp matched 1 argument.")
52
52
  end
53
53
  end
54
+
55
+ it "should allow varargs (expecting 1+)" do
56
+ lambda {
57
+ Object.new.cucumber_instance_exec(true, 'foo', 1) do |arg,*args|
58
+ end
59
+ }.should_not raise_error(Cucumber::ArityMismatchError)
60
+ end
61
+
62
+ it "should raise ArityMismatchError for too few required args when using varargs (expecting 1+)" do
63
+ lambda {
64
+ Object.new.cucumber_instance_exec(true, nil) do |arg,*args|
65
+ end
66
+ }.should raise_error(Cucumber::ArityMismatchError, "Your block takes 1+ arguments, but the Regexp matched 0 arguments.")
67
+ end
54
68
  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.91
4
+ version: 0.3.92
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-07-27 00:00:00 +02:00
12
+ date: 2009-07-29 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.6
33
+ version: 1.3.0
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: diff-lcs