cucumber-rails 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,11 @@
1
+ == 0.2.3 2010-01-03
2
+
3
+ === New Features
4
+ * The #tableish Proc can return Strings as well as Nokogiri nodes now. (Aslak Hellesøy)
5
+
6
+ === Bugfixes
7
+ * Handle all types of URIs in "I should be on ..." steps. (#5 Andrew D. Smith)
8
+
1
9
  == 0.2.2 2009-12-21
2
10
 
3
11
  === Bugfixes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cucumber-rails}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dennis Bl\303\266te", "Aslak Helles\303\270y", "Rob Holland"]
12
- s.date = %q{2009-12-21}
12
+ s.date = %q{2010-01-03}
13
13
  s.description = %q{Cucumber Generators and Runtime for Rails}
14
14
  s.email = %q{cukes@googlegroups.com}
15
15
  s.extra_rdoc_files = [
@@ -1,5 +1,6 @@
1
1
  <%= embed_file('support/edit_warning.txt') %>
2
2
 
3
+ require 'uri'
3
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
4
5
 
5
6
  module WithinHelpers
@@ -173,10 +174,11 @@ Then /^the "([^\"]*)" checkbox(?: within "([^\"]*)")? should not be checked$/ do
173
174
  end
174
175
 
175
176
  Then /^(?:|I )should be on (.+)$/ do |page_name|
177
+ current_path = URI.parse(current_url).select(:path, :query).compact.join('?')
176
178
  if defined?(Spec::Rails::Matchers)
177
- URI.parse(current_url).path.should == path_to(page_name)
179
+ current_path.should == path_to(page_name)
178
180
  else
179
- assert_equal path_to(page_name), URI.parse(current_url).path
181
+ assert_equal path_to(page_name), current_path
180
182
  end
181
183
  end
182
184
 
@@ -1,5 +1,6 @@
1
1
  <%= embed_file('support/edit_warning.txt') %>
2
2
 
3
+ require 'uri'
3
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
4
5
 
5
6
  # Commonly used webrat steps
@@ -242,10 +243,11 @@ Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
242
243
  end
243
244
 
244
245
  Then /^(?:|I )should be on (.+)$/ do |page_name|
246
+ current_path = URI.parse(current_url).select(:path, :query).compact.join('?')
245
247
  if defined?(Spec::Rails::Matchers)
246
- URI.parse(current_url).path.should == path_to(page_name)
248
+ current_path.should == path_to(page_name)
247
249
  else
248
- assert_equal path_to(page_name), URI.parse(current_url).path
250
+ assert_equal path_to(page_name), current_path
249
251
  end
250
252
  end
251
253
 
@@ -1,13 +1,40 @@
1
- ActionController::Base.class_eval do
2
- cattr_accessor :allow_rescue
3
-
4
- alias_method :rescue_action_without_bypass, :rescue_action
1
+ if Rails.version.to_f >= 3.0
2
+ module ActionController #:nodoc:
3
+ module AllowRescueException
4
+ extend ActiveSupport::Concern
5
+ include ActiveSupport::Rescuable
5
6
 
6
- def rescue_action(exception)
7
- if ActionController::Base.allow_rescue
8
- rescue_action_without_bypass(exception)
9
- else
10
- raise exception
7
+ private
8
+ def process_action(*args)
9
+ if ActionController::Base.allow_rescue
10
+ super
11
+ else
12
+ begin
13
+ super
14
+ rescue Exception => exception
15
+ raise(exception)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ ActionController::Base.class_eval do
23
+ cattr_accessor :allow_rescue
24
+ include ActionController::AllowRescueException
25
+ end
26
+ else
27
+ ActionController::Base.class_eval do
28
+ cattr_accessor :allow_rescue
29
+
30
+ alias_method :rescue_action_without_bypass, :rescue_action
31
+
32
+ def rescue_action(exception)
33
+ if ActionController::Base.allow_rescue
34
+ rescue_action_without_bypass(exception)
35
+ else
36
+ raise exception
37
+ end
11
38
  end
12
39
  end
13
40
  end
@@ -1,14 +1,23 @@
1
1
  if defined?(ActiveRecord::Base)
2
2
  require 'test_help'
3
3
  else
4
- require 'action_controller/test_process'
5
- require 'action_controller/integration'
4
+ # I can't do rescue LoadError because in this files could be loaded
5
+ # from rails gem (ie. load actionpack 2.3.5 if rubygems are not disabled)
6
+ if Rails.version.to_f < 3.0
7
+ require 'action_controller/test_process'
8
+ require 'action_controller/integration'
9
+ else
10
+ require 'action_dispatch/testing/test_process'
11
+ require 'action_dispatch/testing/integration'
12
+ end
6
13
  end
7
14
 
8
15
  require 'cucumber/rails/test_unit'
9
16
  require 'cucumber/rails/action_controller'
10
17
 
11
- if ::Rails.respond_to?(:configuration) && !(::Rails.configuration.cache_classes)
18
+
19
+ if (::Rails.respond_to?(:application) && !(::Rails.application.config.cache_classes)) ||
20
+ (!(::Rails.respond_to?(:application)) && ::Rails.respond_to?(:configuration) && !(::Rails.configuration.cache_classes))
12
21
  warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to break Cucumber's use_transactional_fixtures method. Set config.cache_classes to true if you want to use transactional fixtures. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
13
22
  end
14
23
 
@@ -61,7 +61,11 @@ module Cucumber
61
61
  column_count ||= cells.length
62
62
  (0...column_count).map do |n|
63
63
  cell = cells[n]
64
- cell ? cell.text.strip : ''
64
+ case(cell)
65
+ when String then cell.strip
66
+ when nil then ''
67
+ else cell.text.strip
68
+ end
65
69
  end
66
70
  end
67
71
  end
@@ -123,6 +123,37 @@ module Cucumber
123
123
  %w{aslak},
124
124
  ]
125
125
  end
126
+
127
+ it "should do complex shit" do
128
+ html = <<-HTML
129
+ <form method="post" action="/invoices/10/approve" class="button-to">
130
+ <div>
131
+ <input id="approve_invoice_10" type="submit" value="Approve" />
132
+ <input name="authenticity_token" type="hidden" value="WxKGVy3Y5zcvFEiFe66D/odoc3CicfMdAup4vzQfiZ0=" />
133
+ <span>Hello&nbsp;World<span>
134
+ </div>
135
+ </form>
136
+ <form method="post" action="/invoices/10/delegate" class="button-to">
137
+ <div>
138
+ <input id="delegate_invoice_10" type="submit" value="Delegate" />
139
+ <input name="authenticity_token" type="hidden" value="WxKGVy3Y5zcvFEiFe66D/odoc3CicfMdAup4vzQfiZ0=" />
140
+ <span>Hi There<span>
141
+ </div>
142
+ </form>
143
+ HTML
144
+
145
+ selectors = lambda do |form|
146
+ [
147
+ form.css('div input:nth-child(1)').first.attributes['value'],
148
+ form.css('span').first.text.gsub(/\302\240/, ' ')
149
+ ]
150
+ end
151
+
152
+ _tableish(html, 'form', selectors).should == [
153
+ ['Approve', "Hello World"],
154
+ ['Delegate', 'Hi There']
155
+ ]
156
+ end
126
157
  end
127
158
  end
128
159
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Dennis Bl\xC3\xB6te"
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-12-21 00:00:00 +01:00
14
+ date: 2010-01-03 00:00:00 +01:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency