cucumber-rails 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +194 -0
  6. data/History.txt +101 -1
  7. data/LICENSE +22 -0
  8. data/README.md +77 -0
  9. data/Rakefile +3 -19
  10. data/config/cucumber.yml +1 -0
  11. data/cucumber-rails.gemspec +37 -101
  12. data/dev_tasks/cucumber.rake +1 -1
  13. data/dev_tasks/rspec.rake +6 -11
  14. data/features/allow_rescue.feature +63 -0
  15. data/features/capybara_javascript_drivers.feature +87 -0
  16. data/features/database_cleaner.feature +44 -0
  17. data/features/emulate_javascript.feature +34 -0
  18. data/features/inspect_query_string.feature +37 -0
  19. data/features/install_cucumber_rails.feature +16 -0
  20. data/features/mongoid.feature +53 -0
  21. data/features/multiple_databases.feature +74 -0
  22. data/features/named_selectors.feature +33 -0
  23. data/features/no_database.feature +70 -0
  24. data/features/pseduo_class_selectors.feature +24 -0
  25. data/features/rerun_profile.feature +38 -0
  26. data/features/rest_api.feature +47 -0
  27. data/features/routing.feature +18 -0
  28. data/features/select_dates.feature +99 -0
  29. data/features/step_definitions/cucumber_rails_steps.rb +80 -6
  30. data/features/support/env.rb +8 -2
  31. data/features/test_unit.feature +43 -0
  32. data/lib/cucumber/rails/capybara/javascript_emulation.rb +83 -0
  33. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +50 -0
  34. data/lib/cucumber/rails/capybara.rb +6 -0
  35. data/lib/cucumber/rails/hooks/active_record.rb +14 -0
  36. data/lib/cucumber/rails/hooks/allow_rescue.rb +8 -0
  37. data/lib/cucumber/rails/hooks/database_cleaner.rb +13 -0
  38. data/lib/cucumber/rails/hooks/mail.rb +5 -0
  39. data/lib/cucumber/rails/hooks.rb +4 -0
  40. data/lib/cucumber/rails/rspec.rb +4 -6
  41. data/lib/cucumber/rails/world.rb +13 -35
  42. data/lib/cucumber/rails.rb +8 -0
  43. data/lib/cucumber/rails3/action_controller.rb +12 -0
  44. data/lib/cucumber/rails3/active_record.rb +8 -0
  45. data/lib/cucumber/rails3/application.rb +17 -0
  46. data/lib/cucumber/rails3.rb +16 -0
  47. data/lib/cucumber/web/tableish.rb +50 -9
  48. data/lib/generators/cucumber/feature/feature_generator.rb +8 -17
  49. data/lib/generators/cucumber/feature/named_arg.rb +2 -0
  50. data/{templates/feature → lib/generators/cucumber/feature/templates}/feature.erb +10 -12
  51. data/{templates/feature → lib/generators/cucumber/feature/templates}/steps.erb +1 -1
  52. data/lib/generators/cucumber/install/USAGE +15 -0
  53. data/lib/generators/cucumber/install/install_generator.rb +88 -0
  54. data/lib/generators/cucumber/install/templates/config/cucumber.yml.erb +8 -0
  55. data/lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb +192 -0
  56. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_cs.rb.erb +127 -0
  57. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_da.rb.erb +105 -0
  58. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_de.rb.erb +127 -0
  59. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_es.rb.erb +127 -0
  60. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ja.rb.erb +140 -0
  61. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ko.rb.erb +142 -0
  62. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_no.rb.erb +105 -0
  63. data/lib/generators/cucumber/install/templates/step_definitions/web_steps_pt-BR.rb.erb +132 -0
  64. data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +36 -0
  65. data/lib/generators/cucumber/install/templates/support/_rails_prefork.rb.erb +1 -0
  66. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/capybara.rb +0 -4
  67. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/paths.rb +11 -5
  68. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/rails.rb.erb +2 -2
  69. data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/rails_spork.rb.erb +2 -2
  70. data/lib/generators/cucumber/install/templates/support/selectors.rb +39 -0
  71. data/lib/generators/cucumber/install/templates/support/web_steps_warning.txt +19 -0
  72. data/{templates/skeleton → lib/generators/cucumber/install/templates}/tasks/cucumber.rake.erb +18 -0
  73. data/spec/cucumber/web/tableish_spec.rb +83 -6
  74. data/spec/spec_helper.rb +1 -4
  75. metadata +299 -73
  76. data/HACKING.rdoc +0 -34
  77. data/README.rdoc +0 -64
  78. data/VERSION +0 -1
  79. data/features/rails2.feature +0 -56
  80. data/features/rails3.feature +0 -52
  81. data/features/support/matchers/files.rb +0 -17
  82. data/generators/cucumber/USAGE +0 -14
  83. data/generators/cucumber/cucumber_generator.rb +0 -89
  84. data/generators/cucumber/templates/step_definitions/web_steps_ja.rb.erb +0 -136
  85. data/generators/feature/USAGE +0 -12
  86. data/generators/feature/feature_generator.rb +0 -47
  87. data/lib/cucumber/rails/action_controller.rb +0 -65
  88. data/lib/cucumber/rails/active_record.rb +0 -34
  89. data/lib/cucumber/rails/capybara_javascript_emulation.rb +0 -72
  90. data/lib/cucumber/rails/test_unit.rb +0 -9
  91. data/lib/generators/cucumber/feature/feature_base.rb +0 -29
  92. data/lib/generators/cucumber/skeleton/USAGE +0 -21
  93. data/lib/generators/cucumber/skeleton/skeleton_base.rb +0 -202
  94. data/lib/generators/cucumber/skeleton/skeleton_generator.rb +0 -64
  95. data/rvm.yml +0 -22
  96. data/spec/generators/cucumber/skeleton/skeleton_base_spec.rb +0 -84
  97. data/spec/spec.opts +0 -2
  98. data/templates/skeleton/config/cucumber.yml.erb +0 -7
  99. data/templates/skeleton/environments/cucumber.rb.erb +0 -37
  100. data/templates/skeleton/step_definitions/capybara_steps.rb.erb +0 -197
  101. data/templates/skeleton/step_definitions/web_steps_cs.rb.erb +0 -136
  102. data/templates/skeleton/step_definitions/web_steps_da.rb.erb +0 -114
  103. data/templates/skeleton/step_definitions/web_steps_de.rb.erb +0 -136
  104. data/templates/skeleton/step_definitions/web_steps_es.rb.erb +0 -136
  105. data/templates/skeleton/step_definitions/web_steps_no.rb.erb +0 -114
  106. data/templates/skeleton/step_definitions/web_steps_pt-BR.rb.erb +0 -140
  107. data/templates/skeleton/step_definitions/webrat_steps.rb.erb +0 -268
  108. data/templates/skeleton/support/_rails_each_run.rb +0 -34
  109. data/templates/skeleton/support/_rails_prefork.rb.erb +0 -10
  110. data/templates/skeleton/support/webrat.rb +0 -8
  111. /data/{templates/skeleton → lib/generators/cucumber/install/templates}/script/cucumber +0 -0
  112. /data/{templates/skeleton → lib/generators/cucumber/install/templates}/support/edit_warning.txt +0 -0
@@ -0,0 +1,132 @@
1
+ # encoding: utf-8
2
+ <%= embed_file('support/web_steps_warning.txt') %>
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
6
+
7
+ # Single-line step scoper
8
+ Quando /^(.*) dentro de ([^:]+)$/ do |step, parent|
9
+ with_scope(parent) { Quando step }
10
+ end
11
+
12
+ # Multi-line step scoper
13
+ Quando /^(.*) dentro de ([^:]+):$/ do |step, parent, table_or_string|
14
+ with_scope(parent) { Quando "#{step}:", table_or_string }
15
+ end
16
+
17
+ Dado /^que eu estou na (.+)$/ do |page_name|
18
+ Given %{I am on #{page_name}}
19
+ end
20
+
21
+ Quando /^eu vou para (.+)$/ do |page_name|
22
+ When %{I go to #{page_name}}
23
+ end
24
+
25
+ Quando /^eu aperto "([^"]*)"$/ do |button|
26
+ When %{I press "#{button}"}
27
+ end
28
+
29
+ Quando /^eu clico "([^"]*)"$/ do |link|
30
+ When %{I follow "#{link}"}
31
+ end
32
+
33
+ Quando /^eu preencho "([^"]*)" com "([^"]*)"$/ do |field, value|
34
+ When %{I fill in "#{field}" with "#{value}"}
35
+ end
36
+
37
+ Quando /^eu preencho "([^"]*)" para "([^"]*)"$/ do |value, field|
38
+ When %{I fill in "#{value}" for "#{field}"}
39
+ end
40
+
41
+ Quando /^eu preencho o seguinte:$/ do |fields|
42
+ When %{I fill in the following:}, fields
43
+ end
44
+
45
+ Quando /^eu seleciono "([^"]*)" de "([^"]*)"$/ do |value, field|
46
+ When %{I select "#{value}" from "#{field}"}
47
+ end
48
+
49
+ Quando /^eu seleciono "([^"]*)" como a data e a hora$/ do |time|
50
+ When %{I select "#{time}" as the date and time}
51
+ end
52
+
53
+ Quando /^eu seleciono "([^"]*)" como a data e a hora "([^"]*)"$/ do |datetime, datetime_label|
54
+ When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
55
+ end
56
+
57
+ Quando /^eu seleciono "([^"]*)" como a hora$/ do |time|
58
+ When %{I select "#{time}" as the time}
59
+ end
60
+
61
+ Quando /^eu seleciono "([^"]*)" como a hora "([^"]*)"$/ do |time, time_label|
62
+ When %{I select "#{time}" as the "#{time_label}" time}
63
+ end
64
+
65
+ Quando /^eu seleciono "([^"]*)" como a data$/ do |date|
66
+ When %{I select "#{date}" as the date}
67
+ end
68
+
69
+ Quando /^eu seleciono "([^"]*)" como a data "([^"]*)"$/ do |date, date_label|
70
+ When %{I select "#{date}" as the "#{date_label}" date}
71
+ end
72
+
73
+ Quando /^eu seleciono "([^"]*)" como "([^"]*)"$/ do |date, date_label|
74
+ When %{I select "#{date}" as the "#{date_label}" date}
75
+ end
76
+
77
+ Quando /^eu marco "([^"]*)"$/ do |field|
78
+ When %{I check "#{field}"}
79
+ end
80
+
81
+ Quando /^eu desmarco "([^"]*)"$/ do |field|
82
+ When %{I uncheck "#{field}"}
83
+ end
84
+
85
+ Quando /^eu escolho "([^"]*)"$/ do |field|
86
+ When %{I choose "#{field}"}
87
+ end
88
+
89
+ Quando /^eu anexo o arquivo em "([^"]*)" a "([^"]*)"$/ do |path, field|
90
+ When %{I attach the file "#{path}" to "#{field}"}
91
+ end
92
+
93
+ Então /^eu devo ver "([^"]*)"$/ do |text|
94
+ Then %{I should see "#{text}"}
95
+ end
96
+
97
+ Então /^eu devo ver \/([^\/]*)\/$/ do |regexp|
98
+ Then %{I should see /#{regexp}/}
99
+ end
100
+
101
+ Então /^eu não devo ver "([^"]*)"$/ do |text|
102
+ Then %{I should not see "#{text}"}
103
+ end
104
+
105
+ Então /^eu não devo ver \/([^\/]*)\/$/ do |regexp|
106
+ Then %{I should not see /#{regexp}/}
107
+ end
108
+
109
+ Então /^o campo "([^"]*)" deve conter "([^"]*)"$/ do |field, value|
110
+ Then %{the "#{field}" field should contain "#{value}"}
111
+ end
112
+
113
+ Então /^o campo "([^"]*)" não deve conter "([^"]*)"$/ do |field, value|
114
+ Then %{the "#{field}" field should not contain "#{value}"}
115
+ end
116
+
117
+ Então /^o checkbox "([^"]*)" deve estar marcado$/ do |label|
118
+ Then %{the "#{label}" checkbox should be checked}
119
+ end
120
+
121
+ Então /^o checkbox "([^"]*)" não deve estar marcado$/ do |label|
122
+ Then %{the "#{label}" checkbox should not be checked}
123
+ end
124
+
125
+ Então /^eu devo estar na (.+)$/ do |page_name|
126
+ Then %{I should be on #{page_name}}
127
+ end
128
+
129
+ Então /^mostre-me a página$/ do
130
+ Then %{show me the page}
131
+ end
132
+
@@ -0,0 +1,36 @@
1
+ # By default, any exception happening in your Rails application will bubble up
2
+ # to Cucumber so that your scenario will fail. This is a different from how
3
+ # your application behaves in the production environment, where an error page will
4
+ # be rendered instead.
5
+ #
6
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
7
+ # exceptions and display an error page (just like when the app is running in production).
8
+ # Typical scenarios where you want to do this is when you test your error pages.
9
+ # There are two ways to allow Rails to rescue exceptions:
10
+ #
11
+ # 1) Tag your scenario (or feature) with @allow-rescue
12
+ #
13
+ # 2) Set the value below to true. Beware that doing this globally is not
14
+ # recommended as it will mask a lot of errors for you!
15
+ #
16
+ ActionController::Base.allow_rescue = false
17
+
18
+ # Remove/comment out the lines below if your app doesn't have a database.
19
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
20
+ begin
21
+ DatabaseCleaner.strategy = :transaction
22
+ rescue NameError
23
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
24
+ end
25
+
26
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
27
+ # See the DatabaseCleaner documentation for details. Example:
28
+ #
29
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
30
+ # DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
31
+ # end
32
+ #
33
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
34
+ # DatabaseCleaner.strategy = :transaction
35
+ # end
36
+ #
@@ -0,0 +1 @@
1
+ require 'cucumber/rails'
@@ -1,7 +1,3 @@
1
- require 'capybara/rails'
2
- require 'capybara/cucumber'
3
- require 'capybara/session'
4
- require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
5
1
  # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
6
2
  # order to ease the transition to Capybara we set the default here. If you'd
7
3
  # prefer to use XPath just remove this line and adjust any selectors in your
@@ -7,10 +7,10 @@ module NavigationHelpers
7
7
  #
8
8
  def path_to(page_name)
9
9
  case page_name
10
-
11
- when /the home\s?page/
10
+
11
+ when /^the home\s?page$/
12
12
  '/'
13
-
13
+
14
14
  # Add more mappings here.
15
15
  # Here is an example that pulls values out of the Regexp:
16
16
  #
@@ -18,8 +18,14 @@ module NavigationHelpers
18
18
  # user_profile_path(User.find_by_login($1))
19
19
 
20
20
  else
21
- raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
22
- "Now, go and add a mapping in #{__FILE__}"
21
+ begin
22
+ page_name =~ /^the (.*) page$/
23
+ path_components = $1.split(/\s+/)
24
+ self.send(path_components.push('path').join('_').to_sym)
25
+ rescue NoMethodError, ArgumentError
26
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
27
+ "Now, go and add a mapping in #{__FILE__}"
28
+ end
23
29
  end
24
30
  end
25
31
  end
@@ -1,4 +1,4 @@
1
1
  <%= embed_file('support/edit_warning.txt') %>
2
2
  <%= embed_template('support/_rails_prefork.rb.erb') %>
3
- <%= embed_file("support/#{driver}.rb") %>
4
- <%= embed_file('support/_rails_each_run.rb') %>
3
+ <%= embed_file("support/capybara.rb") %>
4
+ <%= embed_template('support/_rails_each_run.rb.erb') %>
@@ -5,9 +5,9 @@ require 'spork'
5
5
  Spork.prefork do
6
6
  <%= embed_template('support/_rails_prefork.rb.erb', ' ') %>
7
7
 
8
- <%= embed_file("support/#{driver}.rb", ' ') %>
8
+ <%= embed_file("support/capybara.rb", ' ') %>
9
9
  end
10
10
 
11
11
  Spork.each_run do
12
- <%= embed_file('support/_rails_each_run.rb', ' ') %>
12
+ <%= embed_template('support/_rails_each_run.rb.erb', ' ') %>
13
13
  end
@@ -0,0 +1,39 @@
1
+ module HtmlSelectorsHelpers
2
+ # Maps a name to a selector. Used primarily by the
3
+ #
4
+ # When /^(.+) within (.+)$/ do |step, scope|
5
+ #
6
+ # step definitions in web_steps.rb
7
+ #
8
+ def selector_for(locator)
9
+ case locator
10
+
11
+ when "the page"
12
+ "html > body"
13
+
14
+ # Add more mappings here.
15
+ # Here is an example that pulls values out of the Regexp:
16
+ #
17
+ # when /^the (notice|error|info) flash$/
18
+ # ".flash.#{$1}"
19
+
20
+ # You can also return an array to use a different selector
21
+ # type, like:
22
+ #
23
+ # when /the header/
24
+ # [:xpath, "//header"]
25
+
26
+ # This allows you to provide a quoted selector as the scope
27
+ # for "within" steps as was previously the default for the
28
+ # web steps:
29
+ when /^"(.+)"$/
30
+ $1
31
+
32
+ else
33
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
34
+ "Now, go and add a mapping in #{__FILE__}"
35
+ end
36
+ end
37
+ end
38
+
39
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,19 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file was generated by Cucumber-Rails and is only here to get you a head start
4
+ # These step definitions are thin wrappers around the Capybara/Webrat API that lets you
5
+ # visit pages, interact with widgets and make assertions about page content.
6
+ #
7
+ # If you use these step definitions as basis for your features you will quickly end up
8
+ # with features that are:
9
+ #
10
+ # * Hard to maintain
11
+ # * Verbose to read
12
+ #
13
+ # A much better approach is to write your own higher level step definitions, following
14
+ # the advice in the following blog posts:
15
+ #
16
+ # * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
17
+ # * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
18
+ # * http://elabs.se/blog/15-you-re-cuking-it-wrong
19
+ #
@@ -21,8 +21,20 @@ begin
21
21
  t.profile = 'wip'
22
22
  end
23
23
 
24
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
25
+ t.binary = vendored_cucumber_bin
26
+ t.fork = true # You may get faster startup if you set this to false
27
+ t.profile = 'rerun'
28
+ end
29
+
24
30
  desc 'Run all features'
25
31
  task :all => [:ok, :wip]
32
+
33
+ task :statsetup do
34
+ require 'rails/code_statistics'
35
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
36
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
37
+ end
26
38
  end
27
39
  desc 'Alias for cucumber:ok'
28
40
  task :cucumber => 'cucumber:ok'
@@ -32,6 +44,12 @@ begin
32
44
  task :features => :cucumber do
33
45
  STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
34
46
  end
47
+
48
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
49
+ task 'db:test:prepare' do
50
+ end
51
+
52
+ task :stats => 'cucumber:statsetup'
35
53
  rescue LoadError
36
54
  desc 'cucumber rake task not available (cucumber not installed)'
37
55
  task :cucumber do
@@ -9,8 +9,55 @@ module Cucumber
9
9
  module Web
10
10
  describe Tableish do
11
11
  include Tableish
12
-
12
+
13
13
  unless RUBY_PLATFORM =~ /java/
14
+ it "should convert a table" do
15
+ html = <<-HTML
16
+ <div class="admin-table">
17
+ <table>
18
+ <thead>
19
+ <tr>
20
+ <th>Name</th>
21
+ <th><span>Edit</span></th>
22
+ <th><span>Delete</span></th>
23
+ </tr>
24
+ </thead>
25
+ <tbody>
26
+ <tr>
27
+ <td><strong>Guybrush Threepwood</strong></td>
28
+ <td><a href="/users/1/edit">Edit</a></td>
29
+ <td>
30
+ <form method="post" action="/users/1" class="button-to">
31
+ <div>
32
+ <input type="hidden" name="_method" value="delete" />
33
+ <input value="Delete" type="submit" />
34
+ </div>
35
+ </form>
36
+ </td>
37
+ </tr>
38
+ </tbody>
39
+ </table>
40
+ </div>
41
+ HTML
42
+
43
+ header = _tableish(html, '.admin-table table thead tr', 'th')
44
+
45
+ column_selector = lambda do |tr|
46
+ tds = tr.search('td')
47
+ [
48
+ tds[0].text,
49
+ tds[1].text,
50
+ tds[2].css('input:nth-child(2)').first.attributes['value']
51
+ ]
52
+ end
53
+ body = _tableish(html, '.admin-table table tbody tr', column_selector)
54
+
55
+ (header + body).should == [
56
+ ['Name', 'Edit', 'Delete'],
57
+ ['Guybrush Threepwood', 'Edit', 'Delete']
58
+ ]
59
+ end
60
+
14
61
  it "should convert a table" do
15
62
  html = <<-HTML
16
63
  <table id="tools">
@@ -58,9 +105,9 @@ module Cucumber
58
105
  HTML
59
106
 
60
107
  _tableish(html, 'table#tools tr', 'td,th').should == [
61
- %w{tool dude},
62
- %w{webrat bryan},
63
- %w{cucumber aslak}
108
+ ['tool', 'dude',],
109
+ ['webrat', 'bryan'],
110
+ ['cucumber', 'aslak']
64
111
  ]
65
112
  end
66
113
 
@@ -88,6 +135,36 @@ module Cucumber
88
135
  ]
89
136
  end
90
137
 
138
+ it "should handle colspan and rowspan" do
139
+ html = <<-HTML
140
+ <table id="tools">
141
+ <tr>
142
+ <td rowspan="4">a</td>
143
+ <td>b</td>
144
+ <td>c</td>
145
+ <td>d</td>
146
+ </tr>
147
+ <tr>
148
+ <td colspan="3">e</td>
149
+ </tr>
150
+ <tr>
151
+ <td rowspan="2" colspan="2">f</td>
152
+ <td>g</td>
153
+ </tr>
154
+ <tr>
155
+ <td>h</td>
156
+ </tr>
157
+ </table>
158
+ HTML
159
+
160
+ _tableish(html, 'table#tools tr', 'td,th').should == [
161
+ ['a', 'b', 'c', 'd'],
162
+ ['', 'e', '', '' ],
163
+ ['', 'f', '', 'g' ],
164
+ ['', '', '', 'h' ],
165
+ ]
166
+ end
167
+
91
168
  it "should convert a dl" do
92
169
  html = <<-HTML
93
170
  <dl id="tools">
@@ -144,7 +221,7 @@ module Cucumber
144
221
  </form>
145
222
  HTML
146
223
 
147
- selectors = lambda do |form|
224
+ selectors = lambda do |form|
148
225
  [
149
226
  form.css('div input:nth-child(1)').first.attributes['value'],
150
227
  form.css('span').first.text.gsub(/\302\240/, ' ')
@@ -159,4 +236,4 @@ module Cucumber
159
236
  end
160
237
  end
161
238
  end
162
- end
239
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,3 @@
1
1
  require 'rubygems'
2
2
  gem 'rspec'
3
- require 'spec'
4
- require 'spec/autorun'
5
-
6
- $:.unshift(File.dirname(__FILE__) + '/../lib')
3
+ require 'rspec/autorun'