dchelimsky-rspec-rails 1.1.99.5 → 1.1.99.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  === Version 1.1.99.4 (in git)
2
2
 
3
- IMPORTANT: See Upgrade.txt for information about upgrading to rspec-rails-1.1.99.4
3
+ IMPORTANT: See Upgrade.markdown for information about upgrading to rspec-rails-1.1.99.4
4
4
 
5
5
  IMPORTANT: This release includes the following backwards-compatibility-breaking changes.
6
6
 
@@ -16,6 +16,11 @@ IMPORTANT: This release includes the following backwards-compatibility-breaking
16
16
 
17
17
  * see Upgrade.txt for more information
18
18
 
19
+ * deprecations
20
+
21
+ * controller.use_rails_error_handling! is deprecated
22
+ * use rescue_action_in_public! (from rails) instead
23
+
19
24
  * enhancements
20
25
 
21
26
  * Adding status codes to redirect_to matcher (Damian Janowski). Closes #570.
@@ -28,6 +33,7 @@ IMPORTANT: This release includes the following backwards-compatibility-breaking
28
33
  * redirect_to and render_template matchers can accept controller or response (Joe Ferris). Closes #686.
29
34
  * generated specs use declarative docstrings
30
35
  * rspec_scaffold generator generates layout and stylesheet (per Rails-2.3)
36
+ * add bypass_rescue for controller specs
31
37
 
32
38
  * bug fixes
33
39
 
data/Manifest.txt CHANGED
@@ -4,7 +4,7 @@ Manifest.txt
4
4
  README.txt
5
5
  Rakefile
6
6
  TODO.txt
7
- Upgrade.txt
7
+ Upgrade.markdown
8
8
  features/step_definitions/people.rb
9
9
  features/support/env.rb
10
10
  features/transactions/transactions_should_rollback.feature
@@ -51,6 +51,7 @@ lib/spec/rails/example/routing_helpers.rb
51
51
  lib/spec/rails/example/view_example_group.rb
52
52
  lib/spec/rails/extensions.rb
53
53
  lib/spec/rails/extensions/action_controller/rescue.rb
54
+ lib/spec/rails/extensions/action_controller/test_case.rb
54
55
  lib/spec/rails/extensions/action_controller/test_response.rb
55
56
  lib/spec/rails/extensions/action_view/base.rb
56
57
  lib/spec/rails/extensions/active_record/base.rb
@@ -135,13 +136,13 @@ spec/spec/rails/example/configuration_spec.rb
135
136
  spec/spec/rails/example/controller_example_group_spec.rb
136
137
  spec/spec/rails/example/controller_isolation_spec.rb
137
138
  spec/spec/rails/example/cookies_proxy_spec.rb
139
+ spec/spec/rails/example/error_handling_spec.rb
138
140
  spec/spec/rails/example/example_group_factory_spec.rb
139
141
  spec/spec/rails/example/helper_example_group_spec.rb
140
142
  spec/spec/rails/example/model_example_group_spec.rb
141
143
  spec/spec/rails/example/shared_behaviour_spec.rb
142
144
  spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb
143
145
  spec/spec/rails/example/view_example_group_spec.rb
144
- spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
145
146
  spec/spec/rails/extensions/action_view_base_spec.rb
146
147
  spec/spec/rails/extensions/active_record_spec.rb
147
148
  spec/spec/rails/interop/testcase_spec.rb
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Hoe.new('rspec-rails', Spec::Rails::VERSION::STRING) do |p|
20
20
  p.description = "Behaviour Driven Development for Ruby on Rails."
21
21
  p.rubyforge_name = 'rspec'
22
22
  p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
23
- p.extra_deps = [["dchelimsky-rspec","1.1.99.5"],["rack",">=0.4.0"]]
23
+ p.extra_deps = [["dchelimsky-rspec","1.1.99.6"],["rack",">=0.4.0"]]
24
24
  p.extra_dev_deps = [["cucumber",">= 0.1.13"]]
25
25
  p.remote_rdoc_dir = "rspec-rails/#{Spec::Rails::VERSION::STRING}"
26
26
  end
data/Upgrade.markdown ADDED
@@ -0,0 +1,51 @@
1
+ # Upgrade to rspec-rails-1.1.99.x
2
+
3
+ ## Supported Rails Versions
4
+
5
+ This release supports the following versions of rails:
6
+
7
+ * 2.0.5
8
+ * 2.1.2
9
+ * 2.2.2
10
+ * 2.3.0
11
+
12
+ ## update generated files
13
+
14
+ Be sure to run "script/generate rspec" and allow the following files to be overwritten:
15
+
16
+ * lib/tasks/rspec.rake
17
+ * script/spec_server
18
+
19
+ ## controller.use\_rails\_error\_handling! is deprecated
20
+
21
+ Use rescue\_action\_in\_public! instead. It comes directly from rails and does
22
+ exactly the same thing
23
+
24
+ ## route_for
25
+
26
+ After a change to edge rails broke our monkey-patched #route_for method, I
27
+ decided to just delegate to rails' #assert_generates method. For most cases,
28
+ this will not present a problem, but for some it might. You'll know if you
29
+ upgrade and see any newly failing, route-related examples. Here are the things
30
+ that you might need to change.
31
+
32
+ * Make sure IDs are strings
33
+
34
+ If you had :id => 1 before, you need to change that to :id => "1"
35
+
36
+ #old
37
+ route_for(:controller => 'things', :action => 'show', :id => 1).should == "/things/1"
38
+
39
+ #new
40
+ route_for(:controller => 'things', :action => 'show', :id => "1").should == "/things/1"
41
+
42
+ * Convert paths for non-get methods to hashes
43
+
44
+ If you had an example with a route that requires post, put, or delete, you'll
45
+ need to declare that explicitly.
46
+
47
+ #old
48
+ route_for(:controller => 'things', :action => 'create').should == "/things"
49
+
50
+ #new
51
+ route_for(:controller => 'things', :action => 'create').should == {:path => "/things", :method => :post}
@@ -3,21 +3,22 @@ module Spec
3
3
  module Example
4
4
  # Controller Examples live in $RAILS_ROOT/spec/controllers/.
5
5
  #
6
- # Controller Examples use Spec::Rails::Example::ControllerExampleGroup, which supports running specs for
7
- # Controllers in two modes, which represent the tension between the more granular
8
- # testing common in TDD and the more high level testing built into
9
- # rails. BDD sits somewhere in between: we want to a balance between
10
- # specs that are close enough to the code to enable quick fault
11
- # isolation and far enough away from the code to enable refactoring
12
- # with minimal changes to the existing specs.
6
+ # Controller Examples use Spec::Rails::Example::ControllerExampleGroup,
7
+ # which supports running specs for Controllers in two modes, which
8
+ # represent the tension between the more granular testing common in TDD
9
+ # and the more high level testing built into rails. BDD sits somewhere
10
+ # in between: we want to a balance between specs that are close enough
11
+ # to the code to enable quick fault isolation and far enough away from
12
+ # the code to enable refactoring with minimal changes to the existing
13
+ # specs.
13
14
  #
14
15
  # == Isolation mode (default)
15
16
  #
16
- # No dependencies on views because none are ever rendered. The
17
- # benefit of this mode is that can spec the controller completely
18
- # independent of the view, allowing that responsibility to be
19
- # handled later, or by somebody else. Combined w/ separate view
20
- # specs, this also provides better fault isolation.
17
+ # No dependencies on views because none are ever rendered. The benefit
18
+ # of this mode is that can spec the controller completely independent of
19
+ # the view, allowing that responsibility to be handled later, or by
20
+ # somebody else. Combined w/ separate view specs, this also provides
21
+ # better fault isolation.
21
22
  #
22
23
  # == Integration mode
23
24
  #
@@ -28,13 +29,12 @@ module Spec
28
29
  # integrate_views
29
30
  # ...
30
31
  #
31
- # In this mode, controller specs are run in the same way that
32
- # rails functional tests run - one set of tests for both the
33
- # controllers and the views. The benefit of this approach is that
34
- # you get wider coverage from each spec. Experienced rails
35
- # developers may find this an easier approach to begin with, however
36
- # we encourage you to explore using the isolation mode and revel
37
- # in its benefits.
32
+ # In this mode, controller specs are run in the same way that rails
33
+ # functional tests run - one set of tests for both the controllers and
34
+ # the views. The benefit of this approach is that you get wider coverage
35
+ # from each spec. Experienced rails developers may find this an easier
36
+ # approach to begin with, however we encourage you to explore using the
37
+ # isolation mode and revel in its benefits.
38
38
  #
39
39
  # == Expecting Errors
40
40
  #
@@ -44,14 +44,15 @@ module Spec
44
44
  class ControllerExampleGroup < FunctionalExampleGroup
45
45
  class << self
46
46
 
47
- # Use this to instruct RSpec to render views in your controller examples (Integration Mode).
47
+ # Use integrate_views to instruct RSpec to render views in
48
+ # your controller examples in Integration mode.
48
49
  #
49
50
  # describe ThingController do
50
51
  # integrate_views
51
52
  # ...
52
53
  #
53
- # See Spec::Rails::Example::ControllerExampleGroup for more information about
54
- # Integration and Isolation modes.
54
+ # See Spec::Rails::Example::ControllerExampleGroup for more
55
+ # information about Integration and Isolation modes.
55
56
  def integrate_views(integrate_views = true)
56
57
  @integrate_views = integrate_views
57
58
  end
@@ -66,14 +67,18 @@ module Spec
66
67
  super
67
68
  end
68
69
 
69
- def set_description(*args)
70
+ def set_description(*args) # :nodoc:
70
71
  super
71
72
  if described_class && described_class.ancestors.include?(ActionController::Base)
72
73
  tests described_class
73
74
  end
74
75
  end
75
76
 
76
- # You MUST provide a controller_name within the context of
77
+ # When you don't pass a controller to describe, like this:
78
+ #
79
+ # describe ThingsController do
80
+ #
81
+ # ... then you must provide a controller_name within the context of
77
82
  # your controller specs:
78
83
  #
79
84
  # describe "ThingController" do
@@ -94,19 +99,20 @@ module Spec
94
99
  end
95
100
 
96
101
  unless @controller.class.ancestors.include?(ActionController::Base)
97
- Spec::Expectations.fail_with <<-EOE
98
- You have to declare the controller name in controller specs. For example:
99
- describe "The ExampleController" do
100
- controller_name "example" #invokes the ExampleController
101
- end
102
- EOE
103
- end
104
- (class << @controller; self; end).class_eval do
105
- def controller_path #:nodoc:
106
- self.class.name.underscore.gsub('_controller', '')
107
- end
108
- include ControllerInstanceMethods
102
+ Spec::Expectations.fail_with <<-MESSAGE
103
+ Controller specs need to know what controller is being specified. You can
104
+ indicate this by passing the controller to describe():
105
+
106
+ describe MyController do
107
+
108
+ or by declaring the controller's name
109
+
110
+ describe "a MyController" do
111
+ controller_name :my #invokes the MyController
112
+ end
113
+ MESSAGE
109
114
  end
115
+ @controller.extend ControllerInstanceMethods
110
116
  @controller.integrate_views! if @integrate_views
111
117
  @controller.session = session
112
118
  end
@@ -118,12 +124,28 @@ module Spec
118
124
  @integrate_views = self.class.integrate_views?
119
125
  end
120
126
 
127
+ # Bypasses any error rescues defined with rescue_from. Useful
128
+ # in cases in which you want to specify errors coming out of
129
+ # actions that might be caught by a rescue_from clause that is
130
+ # specified separately.
131
+ #
132
+ # Note that this will override the effect of rescue_action_in_public
133
+ def bypass_rescue
134
+ if ::Rails::VERSION::STRING >= '2.2'
135
+ def controller.rescue_action(exception)
136
+ raise exception
137
+ end
138
+ else
139
+ def controller.rescue_action_with_handler(exception)
140
+ raise exception
141
+ end
142
+ end
143
+ end
144
+
121
145
  protected
122
146
 
123
147
  def _assigns_hash_proxy
124
- @_assigns_hash_proxy ||= AssignsHashProxy.new self do
125
- @response.template
126
- end
148
+ @_assigns_hash_proxy ||= AssignsHashProxy.new(self) {@response.template}
127
149
  end
128
150
 
129
151
  private
@@ -146,24 +168,33 @@ module Spec
146
168
  end
147
169
 
148
170
  def render(*args)
149
- if @_rendered
150
- opts = args[0]
151
- (@_rendered[:template] ||= opts[:file]) if opts[:file]
152
- (@_rendered[:partials][opts[:partial]] += 1) if opts[:partial]
153
- else
154
- super
155
- end
171
+ @_rendered ? record_render(args[0]) : super
172
+ end
173
+
174
+ private
175
+
176
+ def record_render(opts)
177
+ (@_rendered[:template] ||= opts[:file]) if opts[:file]
178
+ (@_rendered[:partials][opts[:partial]] += 1) if opts[:partial]
179
+ end
180
+
181
+ # Returned by _pick_template when running controller examples in isolation mode.
182
+ class PickedTemplate
183
+ # Do nothing when running controller examples in isolation mode.
184
+ def render_template(*ignore_args); end
185
+ # Do nothing when running controller examples in isolation mode.
186
+ def render_partial(*ignore_args); end
156
187
  end
157
188
  end
158
-
159
- module ControllerInstanceMethods #:nodoc:
189
+
190
+ module ControllerInstanceMethods # :nodoc:
160
191
  include Spec::Rails::Example::RenderObserver
161
192
 
162
193
  # === render(options = nil, extra_options={}, &block)
163
194
  #
164
195
  # This gets added to the controller's singleton meta class,
165
196
  # allowing Controller Examples to run in two modes, freely switching
166
- # from context to context.
197
+ # from example group to example group.
167
198
  def render(options=nil, extra_options={}, &block)
168
199
  unless block_given?
169
200
  unless integrate_views?
@@ -193,31 +224,24 @@ module Spec
193
224
  @integrate_views = true
194
225
  end
195
226
 
196
- private
227
+ private
197
228
 
198
229
  def integrate_views?
199
230
  @integrate_views
200
231
  end
201
232
 
202
233
  def matching_message_expectation_exists(options)
203
- render_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
234
+ render_proxy.__send__(:__mock_proxy).__send__(:find_matching_expectation, :render, options)
204
235
  end
205
236
 
206
237
  def matching_stub_exists(options)
207
- render_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
238
+ render_proxy.__send__(:__mock_proxy).__send__(:find_matching_method_stub, :render, options)
208
239
  end
209
240
 
210
241
  end
211
242
 
212
243
  Spec::Example::ExampleGroupFactory.register(:controller, self)
213
- end
214
-
215
- # Returned by _pick_template when running controller examples in isolation mode.
216
- class PickedTemplate
217
- # Do nothing when running controller examples in isolation mode.
218
- def render_template(*ignore_args); end
219
- # Do nothing when running controller examples in isolation mode.
220
- def render_partial(*ignore_args); end
244
+
221
245
  end
222
246
  end
223
247
  end
@@ -155,11 +155,10 @@ module Spec
155
155
 
156
156
  Spec::Example::ExampleGroupFactory.register(:helper, self)
157
157
 
158
- protected
158
+ protected
159
+
159
160
  def _assigns_hash_proxy
160
- @_assigns_hash_proxy ||= AssignsHashProxy.new self do
161
- helper
162
- end
161
+ @_assigns_hash_proxy ||= AssignsHashProxy.new(self) {helper}
163
162
  end
164
163
 
165
164
  end
@@ -56,14 +56,14 @@ module Spec
56
56
  end
57
57
 
58
58
  before {ensure_that_flash_and_session_work_properly}
59
- after {ensure_that_base_view_path_is_not_set_across_example_groups}
59
+ after {ensure_that_base_view_path_is_not_set_across_example_groups}
60
60
 
61
61
  def ensure_that_flash_and_session_work_properly #:nodoc:
62
- @controller.send :initialize_template_class, @response
63
- @controller.send :assign_shortcuts, @request, @response
64
- @controller.send :initialize_current_url
62
+ @controller.class.__send__ :public, :flash
63
+ @controller.__send__ :initialize_template_class, @response
64
+ @controller.__send__ :assign_shortcuts, @request, @response
65
+ @controller.__send__ :initialize_current_url
65
66
  @session = @controller.session
66
- @controller.class.send :public, :flash
67
67
  end
68
68
 
69
69
  def ensure_that_base_view_path_is_not_set_across_example_groups #:nodoc:
@@ -134,7 +134,7 @@ module Spec
134
134
  defaults = { :layout => false }
135
135
  options = defaults.merge options
136
136
 
137
- @controller.send(:params).reverse_merge! @request.parameters
137
+ @controller.__send__(:params).reverse_merge! @request.parameters
138
138
 
139
139
  @controller.class.instance_eval %{
140
140
  def controller_path
@@ -146,9 +146,9 @@ module Spec
146
146
  end
147
147
  }
148
148
 
149
- @controller.send :forget_variables_added_to_assigns
150
- @controller.send :render, options
151
- @controller.send :process_cleanup
149
+ @controller.__send__ :forget_variables_added_to_assigns
150
+ @controller.__send__ :render, options
151
+ @controller.__send__ :process_cleanup
152
152
  end
153
153
 
154
154
  # This provides the template. Use this to set mock
@@ -168,11 +168,9 @@ module Spec
168
168
 
169
169
  Spec::Example::ExampleGroupFactory.register(:view, self)
170
170
 
171
- protected
171
+ protected
172
172
  def _assigns_hash_proxy
173
- @_assigns_hash_proxy ||= AssignsHashProxy.new self do
174
- @response.template
175
- end
173
+ @_assigns_hash_proxy ||= AssignsHashProxy.new(self) {@response.template}
176
174
  end
177
175
  end
178
176
 
@@ -1,25 +1,42 @@
1
1
  module ActionController
2
2
  module Rescue
3
3
  def use_rails_error_handling!
4
- @use_rails_error_handling = true
5
- end
4
+ Kernel.warn <<-WARNING
5
+ DEPRECATION NOTICE: controller.use_rails_error_handling! is
6
+ deprecated and will be removed from a future version of
7
+ rspec-rails.
6
8
 
9
+ Use rescue_action_in_public!, which is defined directly in
10
+ rails' testing framework, instead.
11
+ WARNING
12
+ if Rails::VERSION::STRING =~ /^2\.0/
13
+ @use_rails_error_handling = true
14
+ else
15
+ # anything but 0.0.0.0 - borrowed from rails own rescue_action_in_public!
16
+ request.remote_addr = '208.77.188.166'
17
+ end
18
+ end
19
+
7
20
  def use_rails_error_handling?
8
21
  @use_rails_error_handling ||= false
9
22
  end
10
23
 
11
24
  protected
12
25
 
13
- def rescue_action_with_fast_errors(exception)
14
- unless respond_to?(:rescue_with_handler) and rescue_with_handler(exception)
15
- if use_rails_error_handling?
16
- rescue_action_without_fast_errors exception
26
+ if Rails::VERSION::STRING =~ /^2\.0/
27
+ def rescue_action_in_public?
28
+ request.respond_to?(:rescue_action_in_public?) and request.rescue_action_in_public?
29
+ end
30
+
31
+ def rescue_action_with_handler_with_fast_errors(exception)
32
+ if (use_rails_error_handling? || rescue_action_in_public?) & !handler_for_rescue(exception)
33
+ rescue_action_in_public(exception)
17
34
  else
18
- raise exception
35
+ rescue_action_with_handler_without_fast_errors(exception)
19
36
  end
20
37
  end
38
+ alias_method_chain :rescue_action_with_handler, :fast_errors
21
39
  end
22
- alias_method_chain :rescue_action, :fast_errors
23
40
 
24
41
  end
25
42
  end
@@ -0,0 +1,14 @@
1
+ module ActionController
2
+ class TestCase
3
+ if Rails::VERSION::STRING =~ /2\.0/
4
+ # Introduced in Rails 2.1, but we need it for 2.0
5
+ def rescue_action_in_public!
6
+ # See rescue.rb in this same directory
7
+ def request.rescue_action_in_public?
8
+ true
9
+ end
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -9,9 +9,10 @@ module ActionController #:nodoc:
9
9
  if ::Rails::VERSION::STRING < "2.3"
10
10
  def [](name)
11
11
  Kernel.warn <<-WARNING
12
- [](name) as an alias for capture(name) (TestResponse extension in rspec-rails)
13
- is deprecated and will be removed in the rspec-rails release that follows the
14
- rails-2.3.0 release.
12
+ DEPRECATION NOTICE: [](name) as an alias for capture(name) (TestResponse
13
+ extension in rspec-rails) is deprecated and will not be defined by rspec-rails
14
+ when working with rails >= 2.3.0. It will also be removed entirely from
15
+ a future version of rspec-rails.
15
16
  WARNING
16
17
  capture(name)
17
18
  end
@@ -3,8 +3,7 @@ module ActionView #:nodoc:
3
3
  include Spec::Rails::Example::RenderObserver
4
4
  cattr_accessor :base_view_path
5
5
 
6
- alias_method :orig_render_partial, :render_partial
7
- def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
6
+ def render_partial_with_base_view_path_handling(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
8
7
  if partial_path.is_a?(String)
9
8
  unless partial_path.include?("/")
10
9
  unless self.class.base_view_path.nil?
@@ -13,21 +12,22 @@ module ActionView #:nodoc:
13
12
  end
14
13
  end
15
14
  begin
16
- orig_render_partial(partial_path, local_assigns, deprecated_local_assigns)
15
+ render_partial_without_base_view_path_handling(partial_path, local_assigns, deprecated_local_assigns)
17
16
  rescue ArgumentError # edge rails > 2.1 changed render_partial to accept only one arg
18
- orig_render_partial(partial_path)
17
+ render_partial_without_base_view_path_handling(partial_path)
19
18
  end
20
19
  end
20
+ alias_method_chain :render_partial, :base_view_path_handling
21
21
 
22
- alias_method :orig_render, :render
23
- def render(options = {}, old_local_assigns = {}, &block)
24
- if render_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
22
+ def render_with_mock_proxy(options = {}, old_local_assigns = {}, &block)
23
+ if render_proxy.__send__(:__mock_proxy).__send__(:find_matching_expectation, :render, options)
25
24
  render_proxy.render(options)
26
25
  else
27
- unless render_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
28
- orig_render(options, old_local_assigns, &block)
26
+ unless render_proxy.__send__(:__mock_proxy).__send__(:find_matching_method_stub, :render, options)
27
+ render_without_mock_proxy(options, old_local_assigns, &block)
29
28
  end
30
29
  end
31
30
  end
31
+ alias_method_chain :render, :mock_proxy
32
32
  end
33
33
  end
@@ -1,29 +1,45 @@
1
1
  if defined?(ActiveRecord::Base)
2
- module ActiveRecord #:nodoc:
3
- class Base
4
- class << self
5
- # Extension for <tt>should have</tt> on AR Model classes
6
- #
7
- # ModelClass.should have(:no).records
8
- # ModelClass.should have(1).record
9
- # ModelClass.should have(n).records
10
- def records
11
- find(:all)
12
- end
13
- alias :record :records
14
- end
2
+ module Spec
3
+ module Rails
4
+ module Extensions
5
+ module ActiveRecord
6
+ module ClassMethods
7
+ # :call-seq:
8
+ # ModelClass.should have(:no).records
9
+ # ModelClass.should have(1).record
10
+ # ModelClass.should have(n).records
11
+ #
12
+ # Extension to enhance <tt>should have</tt> on AR Model classes
13
+ def records
14
+ find(:all)
15
+ end
16
+ alias :record :records
17
+ end
15
18
 
16
- # Extension for <tt>should have</tt> on AR Model instances
17
- #
18
- # model.should have(:no).errors_on(:attribute)
19
- # model.should have(1).error_on(:attribute)
20
- # model.should have(n).errors_on(:attribute)
21
- def errors_on(attribute)
22
- self.valid?
23
- [self.errors.on(attribute)].flatten.compact
19
+ module InstanceMethods
20
+ # :call-seq:
21
+ # model.should have(:no).errors_on(:attribute)
22
+ # model.should have(1).error_on(:attribute)
23
+ # model.should have(n).errors_on(:attribute)
24
+ #
25
+ # Extension to enhance <tt>should have</tt> on AR Model instances.
26
+ # Calls model.valid? in order to prepare the object's errors
27
+ # object.
28
+ def errors_on(attribute)
29
+ self.valid?
30
+ [self.errors.on(attribute)].flatten.compact
31
+ end
32
+ alias :error_on :errors_on
33
+ end
34
+ end
24
35
  end
25
- alias :error_on :errors_on
26
-
36
+ end
37
+ end
38
+
39
+ module ActiveRecord #:nodoc:
40
+ class Base
41
+ extend Spec::Rails::Extensions::ActiveRecord::ClassMethods
42
+ include Spec::Rails::Extensions::ActiveRecord::InstanceMethods
27
43
  end
28
44
  end
29
45
  end
@@ -3,19 +3,21 @@ require 'spec/matchers/have'
3
3
  module Spec #:nodoc:
4
4
  module Matchers #:nodoc:
5
5
  class Have #:nodoc:
6
- alias_method :__original_failure_message, :failure_message
7
- def failure_message
6
+
7
+ def failure_message_with_errors_on_extensions
8
8
  return "expected #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}, got #{@given}" if @collection_name == :errors_on
9
9
  return "expected #{relativities[@relativity]}#{@expected} error on :#{@args[0]}, got #{@given}" if @collection_name == :error_on
10
- return __original_failure_message
10
+ return failure_message_without_errors_on_extensions
11
11
  end
12
+ alias_method_chain :failure_message, :errors_on_extensions
12
13
 
13
- alias_method :__original_description, :description
14
- def description
14
+ def description_with_errors_on_extensions
15
15
  return "should have #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}" if @collection_name == :errors_on
16
16
  return "should have #{relativities[@relativity]}#{@expected} error on :#{@args[0]}" if @collection_name == :error_on
17
- return __original_description
17
+ return description_without_errors_on_extensions
18
18
  end
19
+ alias_method_chain :description, :errors_on_extensions
20
+
19
21
  end
20
22
  end
21
23
  end
@@ -6,5 +6,6 @@ require 'spec/rails/extensions/spec/matchers/have'
6
6
  require 'spec/rails/extensions/active_support/test_case'
7
7
  require 'spec/rails/extensions/active_record/base'
8
8
  require 'spec/rails/extensions/action_controller/rescue'
9
+ require 'spec/rails/extensions/action_controller/test_case'
9
10
  require 'spec/rails/extensions/action_controller/test_response'
10
11
  require 'spec/rails/extensions/action_view/base'
@@ -6,7 +6,7 @@ module Spec
6
6
 
7
7
  def initialize
8
8
  @matcher = Spec::Matchers::Be.new :be_valid
9
- @matcher.send :handling_predicate!
9
+ @matcher.__send__ :handling_predicate!
10
10
  end
11
11
 
12
12
  def matches?(actual)
@@ -24,7 +24,7 @@ module Spec # :nodoc:
24
24
  end
25
25
  @block = block if block
26
26
  begin
27
- @spec_scope.send(@assertion, *@args, &@block)
27
+ @spec_scope.__send__(@assertion, *@args, &@block)
28
28
  rescue ::Test::Unit::AssertionFailedError => @error
29
29
  end
30
30
 
@@ -17,7 +17,7 @@ module Spec
17
17
  :errors => stub("errors", :count => 0)
18
18
  })
19
19
  m = mock("#{model_class.name}_#{id}", options_and_stubs)
20
- m.send(:__mock_proxy).instance_eval <<-CODE
20
+ m.__send__(:__mock_proxy).instance_eval <<-CODE
21
21
  def @target.as_new_record
22
22
  self.stub!(:id).and_return nil
23
23
  self.stub!(:to_param).and_return nil
@@ -14,8 +14,8 @@ require 'spec/rails'
14
14
 
15
15
  Test::Unit.run = true
16
16
 
17
- ActionController::Integration::Session.send(:include, Spec::Matchers)
18
- ActionController::Integration::Session.send(:include, Spec::Rails::Matchers)
17
+ ActionController::Integration::Session.__send__ :include, Spec::Matchers
18
+ ActionController::Integration::Session.__send__ :include, Spec::Rails::Matchers
19
19
 
20
20
  class RailsStory < ActionController::IntegrationTest
21
21
  if defined?(ActiveRecord::Base)
@@ -43,7 +43,7 @@ class ActiveRecordSafetyListener
43
43
  if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
44
44
  ActiveRecord::Base.connection.increment_open_transactions
45
45
  else
46
- ActiveRecord::Base.send :increment_open_transactions
46
+ ActiveRecord::Base.__send__ :increment_open_transactions
47
47
  end
48
48
  end
49
49
  ActiveRecord::Base.connection.begin_db_transaction
@@ -55,7 +55,7 @@ class ActiveRecordSafetyListener
55
55
  if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
56
56
  ActiveRecord::Base.connection.decrement_open_transactions
57
57
  else
58
- ActiveRecord::Base.send :decrement_open_transactions
58
+ ActiveRecord::Base.__send__ :decrement_open_transactions
59
59
  end
60
60
  end
61
61
  end
@@ -5,7 +5,7 @@ module Spec
5
5
  MAJOR = 1
6
6
  MINOR = 1
7
7
  TINY = 99
8
- MINESCULE = 5
8
+ MINESCULE = 6
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY, MINESCULE].compact.join('.')
11
11
 
data/rspec-rails.gemspec CHANGED
@@ -2,38 +2,38 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rspec-rails}
5
- s.version = "1.1.99.5"
5
+ s.version = "1.1.99.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["RSpec Development Team"]
9
- s.date = %q{2009-02-12}
9
+ s.date = %q{2009-02-15}
10
10
  s.description = %q{Behaviour Driven Development for Ruby on Rails.}
11
11
  s.email = ["rspec-devel@rubyforge.org"]
12
- s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "TODO.txt", "Upgrade.txt", "generators/rspec/templates/previous_failures.txt"]
13
- s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "TODO.txt", "Upgrade.txt", "features/step_definitions/people.rb", "features/support/env.rb", "features/transactions/transactions_should_rollback.feature", "generators/rspec/CHANGES", "generators/rspec/rspec_generator.rb", "generators/rspec/templates/previous_failures.txt", "generators/rspec/templates/rcov.opts", "generators/rspec/templates/rspec.rake", "generators/rspec/templates/script/autospec", "generators/rspec/templates/script/spec", "generators/rspec/templates/script/spec_server", "generators/rspec/templates/spec.opts", "generators/rspec/templates/spec_helper.rb", "generators/rspec_controller/USAGE", "generators/rspec_controller/rspec_controller_generator.rb", "generators/rspec_controller/templates/controller_spec.rb", "generators/rspec_controller/templates/helper_spec.rb", "generators/rspec_controller/templates/view_spec.rb", "generators/rspec_default_values.rb", "generators/rspec_model/USAGE", "generators/rspec_model/rspec_model_generator.rb", "generators/rspec_model/templates/model_spec.rb", "generators/rspec_scaffold/rspec_scaffold_generator.rb", "generators/rspec_scaffold/templates/controller_spec.rb", "generators/rspec_scaffold/templates/edit_erb_spec.rb", "generators/rspec_scaffold/templates/helper_spec.rb", "generators/rspec_scaffold/templates/index_erb_spec.rb", "generators/rspec_scaffold/templates/new_erb_spec.rb", "generators/rspec_scaffold/templates/routing_spec.rb", "generators/rspec_scaffold/templates/show_erb_spec.rb", "init.rb", "lib/autotest/discover.rb", "lib/autotest/rails_rspec.rb", "lib/spec/rails.rb", "lib/spec/rails/example.rb", "lib/spec/rails/example/assigns_hash_proxy.rb", "lib/spec/rails/example/controller_example_group.rb", "lib/spec/rails/example/cookies_proxy.rb", "lib/spec/rails/example/functional_example_group.rb", "lib/spec/rails/example/helper_example_group.rb", "lib/spec/rails/example/model_example_group.rb", "lib/spec/rails/example/render_observer.rb", "lib/spec/rails/example/routing_helpers.rb", "lib/spec/rails/example/view_example_group.rb", "lib/spec/rails/extensions.rb", "lib/spec/rails/extensions/action_controller/rescue.rb", "lib/spec/rails/extensions/action_controller/test_response.rb", "lib/spec/rails/extensions/action_view/base.rb", "lib/spec/rails/extensions/active_record/base.rb", "lib/spec/rails/extensions/active_support/test_case.rb", "lib/spec/rails/extensions/spec/matchers/have.rb", "lib/spec/rails/extensions/spec/runner/configuration.rb", "lib/spec/rails/interop/testcase.rb", "lib/spec/rails/matchers.rb", "lib/spec/rails/matchers/ar_be_valid.rb", "lib/spec/rails/matchers/assert_select.rb", "lib/spec/rails/matchers/change.rb", "lib/spec/rails/matchers/have_text.rb", "lib/spec/rails/matchers/include_text.rb", "lib/spec/rails/matchers/redirect_to.rb", "lib/spec/rails/matchers/render_template.rb", "lib/spec/rails/mocks.rb", "lib/spec/rails/spec_server.rb", "lib/spec/rails/story_adapter.rb", "lib/spec/rails/version.rb", "rspec-rails.gemspec", "spec/autotest/mappings_spec.rb", "spec/rails_suite.rb", "spec/resources/controllers/action_view_base_spec_controller.rb", "spec/resources/controllers/application.rb", "spec/resources/controllers/controller_spec_controller.rb", "spec/resources/controllers/redirect_spec_controller.rb", "spec/resources/controllers/render_spec_controller.rb", "spec/resources/controllers/rjs_spec_controller.rb", "spec/resources/helpers/addition_helper.rb", "spec/resources/helpers/explicit_helper.rb", "spec/resources/helpers/more_explicit_helper.rb", "spec/resources/helpers/plugin_application_helper.rb", "spec/resources/helpers/view_spec_helper.rb", "spec/resources/models/animal.rb", "spec/resources/models/person.rb", "spec/resources/models/thing.rb", "spec/resources/views/controller_spec/_partial.rhtml", "spec/resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml", "spec/resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml", "spec/resources/views/controller_spec/action_setting_the_assigns_hash.rhtml", "spec/resources/views/controller_spec/action_with_errors_in_template.rhtml", "spec/resources/views/controller_spec/action_with_template.rhtml", "spec/resources/views/layouts/application.rhtml", "spec/resources/views/layouts/simple.rhtml", "spec/resources/views/objects/_object.html.erb", "spec/resources/views/render_spec/_a_partial.rhtml", "spec/resources/views/render_spec/action_with_alternate_layout.rhtml", "spec/resources/views/render_spec/some_action.html.erb", "spec/resources/views/render_spec/some_action.js.rjs", "spec/resources/views/render_spec/some_action.rjs", "spec/resources/views/rjs_spec/_replacement_partial.rhtml", "spec/resources/views/rjs_spec/hide_div.rjs", "spec/resources/views/rjs_spec/hide_page_element.rjs", "spec/resources/views/rjs_spec/insert_html.rjs", "spec/resources/views/rjs_spec/replace.rjs", "spec/resources/views/rjs_spec/replace_html.rjs", "spec/resources/views/rjs_spec/replace_html_with_partial.rjs", "spec/resources/views/rjs_spec/visual_effect.rjs", "spec/resources/views/rjs_spec/visual_toggle_effect.rjs", "spec/resources/views/tag_spec/no_tags.rhtml", "spec/resources/views/tag_spec/single_div_with_no_attributes.rhtml", "spec/resources/views/tag_spec/single_div_with_one_attribute.rhtml", "spec/resources/views/view_spec/_partial.rhtml", "spec/resources/views/view_spec/_partial_used_twice.rhtml", "spec/resources/views/view_spec/_partial_with_local_variable.rhtml", "spec/resources/views/view_spec/_partial_with_sub_partial.rhtml", "spec/resources/views/view_spec/_spacer.rhtml", "spec/resources/views/view_spec/accessor.rhtml", "spec/resources/views/view_spec/block_helper.rhtml", "spec/resources/views/view_spec/entry_form.rhtml", "spec/resources/views/view_spec/explicit_helper.rhtml", "spec/resources/views/view_spec/foo/show.rhtml", "spec/resources/views/view_spec/implicit_helper.rhtml", "spec/resources/views/view_spec/multiple_helpers.rhtml", "spec/resources/views/view_spec/path_params.html.erb", "spec/resources/views/view_spec/should_not_receive.rhtml", "spec/resources/views/view_spec/template_with_partial.rhtml", "spec/resources/views/view_spec/template_with_partial_using_collection.rhtml", "spec/resources/views/view_spec/template_with_partial_with_array.rhtml", "spec/spec/rails/example/assigns_hash_proxy_spec.rb", "spec/spec/rails/example/configuration_spec.rb", "spec/spec/rails/example/controller_example_group_spec.rb", "spec/spec/rails/example/controller_isolation_spec.rb", "spec/spec/rails/example/cookies_proxy_spec.rb", "spec/spec/rails/example/example_group_factory_spec.rb", "spec/spec/rails/example/helper_example_group_spec.rb", "spec/spec/rails/example/model_example_group_spec.rb", "spec/spec/rails/example/shared_behaviour_spec.rb", "spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb", "spec/spec/rails/example/view_example_group_spec.rb", "spec/spec/rails/extensions/action_controller_rescue_action_spec.rb", "spec/spec/rails/extensions/action_view_base_spec.rb", "spec/spec/rails/extensions/active_record_spec.rb", "spec/spec/rails/interop/testcase_spec.rb", "spec/spec/rails/matchers/ar_be_valid_spec.rb", "spec/spec/rails/matchers/assert_select_spec.rb", "spec/spec/rails/matchers/errors_on_spec.rb", "spec/spec/rails/matchers/have_text_spec.rb", "spec/spec/rails/matchers/include_text_spec.rb", "spec/spec/rails/matchers/redirect_to_spec.rb", "spec/spec/rails/matchers/render_template_spec.rb", "spec/spec/rails/matchers/should_change_spec.rb", "spec/spec/rails/mocks/ar_classes.rb", "spec/spec/rails/mocks/mock_model_spec.rb", "spec/spec/rails/mocks/stub_model_spec.rb", "spec/spec/rails/sample_modified_fixture.rb", "spec/spec/rails/sample_spec.rb", "spec/spec/rails/spec_server_spec.rb", "spec/spec/rails/spec_spec.rb", "spec/spec_helper.rb"]
12
+ s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "TODO.txt", "generators/rspec/templates/previous_failures.txt"]
13
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "TODO.txt", "Upgrade.markdown", "features/step_definitions/people.rb", "features/support/env.rb", "features/transactions/transactions_should_rollback.feature", "generators/rspec/CHANGES", "generators/rspec/rspec_generator.rb", "generators/rspec/templates/previous_failures.txt", "generators/rspec/templates/rcov.opts", "generators/rspec/templates/rspec.rake", "generators/rspec/templates/script/autospec", "generators/rspec/templates/script/spec", "generators/rspec/templates/script/spec_server", "generators/rspec/templates/spec.opts", "generators/rspec/templates/spec_helper.rb", "generators/rspec_controller/USAGE", "generators/rspec_controller/rspec_controller_generator.rb", "generators/rspec_controller/templates/controller_spec.rb", "generators/rspec_controller/templates/helper_spec.rb", "generators/rspec_controller/templates/view_spec.rb", "generators/rspec_default_values.rb", "generators/rspec_model/USAGE", "generators/rspec_model/rspec_model_generator.rb", "generators/rspec_model/templates/model_spec.rb", "generators/rspec_scaffold/rspec_scaffold_generator.rb", "generators/rspec_scaffold/templates/controller_spec.rb", "generators/rspec_scaffold/templates/edit_erb_spec.rb", "generators/rspec_scaffold/templates/helper_spec.rb", "generators/rspec_scaffold/templates/index_erb_spec.rb", "generators/rspec_scaffold/templates/new_erb_spec.rb", "generators/rspec_scaffold/templates/routing_spec.rb", "generators/rspec_scaffold/templates/show_erb_spec.rb", "init.rb", "lib/autotest/discover.rb", "lib/autotest/rails_rspec.rb", "lib/spec/rails.rb", "lib/spec/rails/example.rb", "lib/spec/rails/example/assigns_hash_proxy.rb", "lib/spec/rails/example/controller_example_group.rb", "lib/spec/rails/example/cookies_proxy.rb", "lib/spec/rails/example/functional_example_group.rb", "lib/spec/rails/example/helper_example_group.rb", "lib/spec/rails/example/model_example_group.rb", "lib/spec/rails/example/render_observer.rb", "lib/spec/rails/example/routing_helpers.rb", "lib/spec/rails/example/view_example_group.rb", "lib/spec/rails/extensions.rb", "lib/spec/rails/extensions/action_controller/rescue.rb", "lib/spec/rails/extensions/action_controller/test_case.rb", "lib/spec/rails/extensions/action_controller/test_response.rb", "lib/spec/rails/extensions/action_view/base.rb", "lib/spec/rails/extensions/active_record/base.rb", "lib/spec/rails/extensions/active_support/test_case.rb", "lib/spec/rails/extensions/spec/matchers/have.rb", "lib/spec/rails/extensions/spec/runner/configuration.rb", "lib/spec/rails/interop/testcase.rb", "lib/spec/rails/matchers.rb", "lib/spec/rails/matchers/ar_be_valid.rb", "lib/spec/rails/matchers/assert_select.rb", "lib/spec/rails/matchers/change.rb", "lib/spec/rails/matchers/have_text.rb", "lib/spec/rails/matchers/include_text.rb", "lib/spec/rails/matchers/redirect_to.rb", "lib/spec/rails/matchers/render_template.rb", "lib/spec/rails/mocks.rb", "lib/spec/rails/spec_server.rb", "lib/spec/rails/story_adapter.rb", "lib/spec/rails/version.rb", "rspec-rails.gemspec", "spec/autotest/mappings_spec.rb", "spec/rails_suite.rb", "spec/resources/controllers/action_view_base_spec_controller.rb", "spec/resources/controllers/application.rb", "spec/resources/controllers/controller_spec_controller.rb", "spec/resources/controllers/redirect_spec_controller.rb", "spec/resources/controllers/render_spec_controller.rb", "spec/resources/controllers/rjs_spec_controller.rb", "spec/resources/helpers/addition_helper.rb", "spec/resources/helpers/explicit_helper.rb", "spec/resources/helpers/more_explicit_helper.rb", "spec/resources/helpers/plugin_application_helper.rb", "spec/resources/helpers/view_spec_helper.rb", "spec/resources/models/animal.rb", "spec/resources/models/person.rb", "spec/resources/models/thing.rb", "spec/resources/views/controller_spec/_partial.rhtml", "spec/resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml", "spec/resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml", "spec/resources/views/controller_spec/action_setting_the_assigns_hash.rhtml", "spec/resources/views/controller_spec/action_with_errors_in_template.rhtml", "spec/resources/views/controller_spec/action_with_template.rhtml", "spec/resources/views/layouts/application.rhtml", "spec/resources/views/layouts/simple.rhtml", "spec/resources/views/objects/_object.html.erb", "spec/resources/views/render_spec/_a_partial.rhtml", "spec/resources/views/render_spec/action_with_alternate_layout.rhtml", "spec/resources/views/render_spec/some_action.html.erb", "spec/resources/views/render_spec/some_action.js.rjs", "spec/resources/views/render_spec/some_action.rjs", "spec/resources/views/rjs_spec/_replacement_partial.rhtml", "spec/resources/views/rjs_spec/hide_div.rjs", "spec/resources/views/rjs_spec/hide_page_element.rjs", "spec/resources/views/rjs_spec/insert_html.rjs", "spec/resources/views/rjs_spec/replace.rjs", "spec/resources/views/rjs_spec/replace_html.rjs", "spec/resources/views/rjs_spec/replace_html_with_partial.rjs", "spec/resources/views/rjs_spec/visual_effect.rjs", "spec/resources/views/rjs_spec/visual_toggle_effect.rjs", "spec/resources/views/tag_spec/no_tags.rhtml", "spec/resources/views/tag_spec/single_div_with_no_attributes.rhtml", "spec/resources/views/tag_spec/single_div_with_one_attribute.rhtml", "spec/resources/views/view_spec/_partial.rhtml", "spec/resources/views/view_spec/_partial_used_twice.rhtml", "spec/resources/views/view_spec/_partial_with_local_variable.rhtml", "spec/resources/views/view_spec/_partial_with_sub_partial.rhtml", "spec/resources/views/view_spec/_spacer.rhtml", "spec/resources/views/view_spec/accessor.rhtml", "spec/resources/views/view_spec/block_helper.rhtml", "spec/resources/views/view_spec/entry_form.rhtml", "spec/resources/views/view_spec/explicit_helper.rhtml", "spec/resources/views/view_spec/foo/show.rhtml", "spec/resources/views/view_spec/implicit_helper.rhtml", "spec/resources/views/view_spec/multiple_helpers.rhtml", "spec/resources/views/view_spec/path_params.html.erb", "spec/resources/views/view_spec/should_not_receive.rhtml", "spec/resources/views/view_spec/template_with_partial.rhtml", "spec/resources/views/view_spec/template_with_partial_using_collection.rhtml", "spec/resources/views/view_spec/template_with_partial_with_array.rhtml", "spec/spec/rails/example/assigns_hash_proxy_spec.rb", "spec/spec/rails/example/configuration_spec.rb", "spec/spec/rails/example/controller_example_group_spec.rb", "spec/spec/rails/example/controller_isolation_spec.rb", "spec/spec/rails/example/cookies_proxy_spec.rb", "spec/spec/rails/example/error_handling_spec.rb", "spec/spec/rails/example/example_group_factory_spec.rb", "spec/spec/rails/example/helper_example_group_spec.rb", "spec/spec/rails/example/model_example_group_spec.rb", "spec/spec/rails/example/shared_behaviour_spec.rb", "spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb", "spec/spec/rails/example/view_example_group_spec.rb", "spec/spec/rails/extensions/action_view_base_spec.rb", "spec/spec/rails/extensions/active_record_spec.rb", "spec/spec/rails/interop/testcase_spec.rb", "spec/spec/rails/matchers/ar_be_valid_spec.rb", "spec/spec/rails/matchers/assert_select_spec.rb", "spec/spec/rails/matchers/errors_on_spec.rb", "spec/spec/rails/matchers/have_text_spec.rb", "spec/spec/rails/matchers/include_text_spec.rb", "spec/spec/rails/matchers/redirect_to_spec.rb", "spec/spec/rails/matchers/render_template_spec.rb", "spec/spec/rails/matchers/should_change_spec.rb", "spec/spec/rails/mocks/ar_classes.rb", "spec/spec/rails/mocks/mock_model_spec.rb", "spec/spec/rails/mocks/stub_model_spec.rb", "spec/spec/rails/sample_modified_fixture.rb", "spec/spec/rails/sample_spec.rb", "spec/spec/rails/spec_server_spec.rb", "spec/spec/rails/spec_spec.rb", "spec/spec_helper.rb"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://rspec.info/}
16
16
  s.rdoc_options = ["--main", "README.txt"]
17
17
  s.require_paths = ["lib"]
18
18
  s.rubyforge_project = %q{rspec}
19
19
  s.rubygems_version = %q{1.3.1}
20
- s.summary = %q{rspec-rails 1.1.99.5}
20
+ s.summary = %q{rspec-rails 1.1.99.6}
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
24
  s.specification_version = 2
25
25
 
26
26
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<dchelimsky-rspec>, ["= 1.1.99.5"])
27
+ s.add_runtime_dependency(%q<dchelimsky-rspec>, ["= 1.1.99.6"])
28
28
  s.add_runtime_dependency(%q<rack>, [">= 0.4.0"])
29
29
  s.add_development_dependency(%q<cucumber>, [">= 0.1.13"])
30
30
  s.add_development_dependency(%q<hoe>, [">= 1.8.3"])
31
31
  else
32
- s.add_dependency(%q<dchelimsky-rspec>, ["= 1.1.99.5"])
32
+ s.add_dependency(%q<dchelimsky-rspec>, ["= 1.1.99.6"])
33
33
  s.add_dependency(%q<rack>, [">= 0.4.0"])
34
34
  end
35
35
  else
36
- s.add_dependency(%q<dchelimsky-rspec>, ["= 1.1.99.5"])
36
+ s.add_dependency(%q<dchelimsky-rspec>, ["= 1.1.99.6"])
37
37
  s.add_dependency(%q<rack>, [">= 0.4.0"])
38
38
  end
39
39
  end
@@ -104,7 +104,7 @@ class ControllerSpecController < ActionController::Base
104
104
  raise RescuedError
105
105
  end
106
106
 
107
- def other_error_action
107
+ def un_rescued_error_action
108
108
  raise UnRescuedError
109
109
  end
110
110
  end
@@ -158,57 +158,6 @@ require 'controller_spec_controller'
158
158
 
159
159
  end
160
160
 
161
- describe "with an error that is not rescued in the controller" do
162
- context "without rails' error handling" do
163
- it "raises the error" do
164
- lambda do
165
- get 'other_error_action'
166
- end.should raise_error(ControllerSpecController::UnRescuedError)
167
- end
168
- end
169
- context "with rails' error handling" do
170
- it "does not raise the error" do
171
- pending "deal with use_rails_error_handling" do
172
- controller.use_rails_error_handling!
173
- lambda do
174
- get 'other_error_action'
175
- end.should_not raise_error
176
- end
177
- end
178
- end
179
- end
180
-
181
- describe "with an error that is rescued in the controller" do
182
- context "without rails' error handling" do
183
- it "does not raise error" do
184
- lambda do
185
- get 'rescued_error_action'
186
- end.should_not raise_error
187
- end
188
-
189
- it "executes rescue_from" do
190
- get 'rescued_error_action'
191
- response.body.should == 'Rescued!'
192
- end
193
- end
194
-
195
- context "with rails' error handling" do
196
- before(:each) do
197
- controller.use_rails_error_handling!
198
- end
199
- it "does not raise error" do
200
- lambda do
201
- get 'rescued_error_action'
202
- end.should_not raise_error
203
- end
204
-
205
- it "executes rescue_from" do
206
- get 'rescued_error_action'
207
- response.body.should == 'Rescued!'
208
- end
209
- end
210
- end
211
-
212
161
  class CustomRouteSpecController < ActionController::Base; end
213
162
  class RspecOnRailsSpecsController < ActionController::Base; end
214
163
 
@@ -0,0 +1,90 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require 'controller_spec_controller'
3
+
4
+ ['integration', 'isolation'].each do |mode|
5
+ describe "A controller example running in #{mode} mode", :type => :controller do
6
+ controller_name :controller_spec
7
+ integrate_views if mode == 'integration'
8
+
9
+ describe "without use_rails_error_handling!" do
10
+ describe "with an error that is *not* rescued" do
11
+ it "raises the error" do
12
+ lambda do
13
+ get 'un_rescued_error_action'
14
+ end.should raise_error(ControllerSpecController::UnRescuedError)
15
+ end
16
+ end
17
+ describe "with an error that *is* rescued" do
18
+ it "returns a 200" do
19
+ get 'rescued_error_action'
20
+ response.response_code.should == 200
21
+ end
22
+ end
23
+ end
24
+
25
+ describe "with deprecated use_rails_error_handling!" do
26
+ before(:each) do
27
+ Kernel.stub!(:warn)
28
+ end
29
+
30
+ it "warns of deprecation" do
31
+ Kernel.should_receive(:warn).with(/DEPRECATION NOTICE/)
32
+ controller.use_rails_error_handling!
33
+ end
34
+
35
+ describe "with an error that is *not* rescued" do
36
+ it "returns the error code" do
37
+ controller.use_rails_error_handling!
38
+ get 'un_rescued_error_action'
39
+ response.response_code.should == 500
40
+ end
41
+ end
42
+
43
+ describe "with an error that *is* rescued" do
44
+ it "returns a 200" do
45
+ controller.use_rails_error_handling!
46
+ get 'rescued_error_action'
47
+ response.response_code.should == 200
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "with rescue_action_in_public!" do
53
+ describe "with an error that is *not* rescued" do
54
+ it "returns the error code" do
55
+ rescue_action_in_public!
56
+ get 'un_rescued_error_action'
57
+ response.response_code.should == 500
58
+ end
59
+ end
60
+
61
+ describe "with an error that *is* rescued" do
62
+ it "returns a 200" do
63
+ rescue_action_in_public!
64
+ get 'rescued_error_action'
65
+ response.response_code.should == 200
66
+ end
67
+ end
68
+ end
69
+
70
+ describe "with bypass_rescue" do
71
+ describe "with an error that is *not* rescued" do
72
+ it "raises the error" do
73
+ bypass_rescue
74
+ lambda do
75
+ get 'un_rescued_error_action'
76
+ end.should raise_error(ControllerSpecController::UnRescuedError)
77
+ end
78
+ end
79
+
80
+ describe "with an error that *is* rescued" do
81
+ it "raises the error" do
82
+ bypass_rescue
83
+ lambda do
84
+ get 'rescued_error_action'
85
+ end.should raise_error(ControllerSpecController::RescuedError)
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dchelimsky-rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.99.5
4
+ version: 1.1.99.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RSpec Development Team
@@ -9,20 +9,22 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-12 00:00:00 -08:00
12
+ date: 2009-02-15 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: dchelimsky-rspec
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
21
  - - "="
21
22
  - !ruby/object:Gem::Version
22
- version: 1.1.99.5
23
+ version: 1.1.99.6
23
24
  version:
24
25
  - !ruby/object:Gem::Dependency
25
26
  name: rack
27
+ type: :runtime
26
28
  version_requirement:
27
29
  version_requirements: !ruby/object:Gem::Requirement
28
30
  requirements:
@@ -30,6 +32,26 @@ dependencies:
30
32
  - !ruby/object:Gem::Version
31
33
  version: 0.4.0
32
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: cucumber
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.1.13
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hoe
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.3
54
+ version:
33
55
  description: Behaviour Driven Development for Ruby on Rails.
34
56
  email:
35
57
  - rspec-devel@rubyforge.org
@@ -43,7 +65,6 @@ extra_rdoc_files:
43
65
  - Manifest.txt
44
66
  - README.txt
45
67
  - TODO.txt
46
- - Upgrade.txt
47
68
  - generators/rspec/templates/previous_failures.txt
48
69
  files:
49
70
  - History.txt
@@ -52,7 +73,7 @@ files:
52
73
  - README.txt
53
74
  - Rakefile
54
75
  - TODO.txt
55
- - Upgrade.txt
76
+ - Upgrade.markdown
56
77
  - features/step_definitions/people.rb
57
78
  - features/support/env.rb
58
79
  - features/transactions/transactions_should_rollback.feature
@@ -99,6 +120,7 @@ files:
99
120
  - lib/spec/rails/example/view_example_group.rb
100
121
  - lib/spec/rails/extensions.rb
101
122
  - lib/spec/rails/extensions/action_controller/rescue.rb
123
+ - lib/spec/rails/extensions/action_controller/test_case.rb
102
124
  - lib/spec/rails/extensions/action_controller/test_response.rb
103
125
  - lib/spec/rails/extensions/action_view/base.rb
104
126
  - lib/spec/rails/extensions/active_record/base.rb
@@ -183,13 +205,13 @@ files:
183
205
  - spec/spec/rails/example/controller_example_group_spec.rb
184
206
  - spec/spec/rails/example/controller_isolation_spec.rb
185
207
  - spec/spec/rails/example/cookies_proxy_spec.rb
208
+ - spec/spec/rails/example/error_handling_spec.rb
186
209
  - spec/spec/rails/example/example_group_factory_spec.rb
187
210
  - spec/spec/rails/example/helper_example_group_spec.rb
188
211
  - spec/spec/rails/example/model_example_group_spec.rb
189
212
  - spec/spec/rails/example/shared_behaviour_spec.rb
190
213
  - spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb
191
214
  - spec/spec/rails/example/view_example_group_spec.rb
192
- - spec/spec/rails/extensions/action_controller_rescue_action_spec.rb
193
215
  - spec/spec/rails/extensions/action_view_base_spec.rb
194
216
  - spec/spec/rails/extensions/active_record_spec.rb
195
217
  - spec/spec/rails/interop/testcase_spec.rb
@@ -235,6 +257,6 @@ rubyforge_project: rspec
235
257
  rubygems_version: 1.2.0
236
258
  signing_key:
237
259
  specification_version: 2
238
- summary: rspec-rails 1.1.99.5
260
+ summary: rspec-rails 1.1.99.6
239
261
  test_files: []
240
262
 
data/Upgrade.txt DELETED
@@ -1,37 +0,0 @@
1
- === Upgrade to rspec-rails-1.1.99.4
2
-
3
- == update generated files
4
-
5
- Be sure to run "script/generate rspec" and allow the following files to be overwritten:
6
-
7
- * lib/tasks/rspec.rake
8
- * script/spec_server
9
-
10
- == route_for
11
-
12
- After a change to edge rails broke our monkey-patched #route_for method, I
13
- decided to just delegate to rails' #assert_generates method. For most cases,
14
- this will not present a problem, but for some it might. You'll know if you
15
- upgrade and see any newly failing, route-related examples. Here are the things
16
- that you might need to change.
17
-
18
- * Make sure IDs are strings
19
-
20
- If you had :id => 1 before, you need to change that to :id => "1"
21
-
22
- #old
23
- route_for(:controller => 'things', :action => 'show', :id => 1).should == "/things/1"
24
-
25
- #new
26
- route_for(:controller => 'things', :action => 'show', :id => "1").should == "/things/1"
27
-
28
- * Convert paths for non-get methods to hashes
29
-
30
- If you had an example with a route that requires post, put, or delete, you'll
31
- need to declare that explicitly.
32
-
33
- #old
34
- route_for(:controller => 'things', :action => 'create').should == "/things"
35
-
36
- #new
37
- route_for(:controller => 'things', :action => 'create').should == {:path => "/things", :method => :post}
@@ -1,57 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- module ActionController
4
- describe "Rescue", "#rescue_action in default mode" do
5
- before(:each) do
6
- @fixture = Object.new
7
- @fixture.extend ActionController::Rescue
8
- def @fixture.rescue_with_handler(exception)
9
- false
10
- end
11
- class << @fixture
12
- public :rescue_action
13
- end
14
- end
15
-
16
- it "should raise the passed in exception so examples fail fast" do
17
- proc {@fixture.rescue_action(RuntimeError.new("Foobar"))}.should raise_error(RuntimeError, "Foobar")
18
- end
19
- end
20
-
21
- class RescueOverriddenController < ActionController::Base
22
- def rescue_action(error)
23
- "successfully overridden"
24
- end
25
- end
26
-
27
- describe "Rescue", "#rescue_action, when overridden" do
28
- before(:each) do
29
- @fixture = RescueOverriddenController.new
30
- end
31
-
32
- it "should do whatever the overridden method does" do
33
- @fixture.rescue_action(RuntimeError.new("Foobar")).should == "successfully overridden"
34
- end
35
- end
36
-
37
- class SearchController < ActionController::Base
38
- end
39
-
40
- describe "Rescue", "#rescue_action when told to use rails error handling" do
41
- before(:each) do
42
- @controller = SearchController.new
43
- @controller.use_rails_error_handling!
44
- class << @controller
45
- public :rescue_action
46
- end
47
- end
48
-
49
- it "should use Rails exception handling" do
50
- exception = RuntimeError.new("The Error")
51
- exception.stub!(:backtrace).and_return(caller)
52
- @controller.should_receive(:rescue_action_locally).with(exception)
53
-
54
- @controller.rescue_action(exception)
55
- end
56
- end
57
- end