dchelimsky-rspec-rails 1.1.11.7 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -1
- data/Rakefile +1 -1
- data/lib/spec/rails/example/controller_example_group.rb +4 -27
- data/lib/spec/rails/example/helper_example_group.rb +5 -4
- data/lib/spec/rails/extensions/action_controller/rescue.rb +9 -5
- data/lib/spec/rails/matchers/redirect_to.rb +22 -3
- data/lib/spec/rails/version.rb +2 -2
- data/rspec-rails.gemspec +7 -7
- data/spec/resources/controllers/controller_spec_controller.rb +15 -0
- data/spec/resources/controllers/redirect_spec_controller.rb +4 -0
- data/spec/resources/helpers/explicit_helper.rb +8 -0
- data/spec/spec/rails/example/controller_isolation_spec.rb +0 -4
- data/spec/spec/rails/example/controller_spec_spec.rb +51 -2
- data/spec/spec/rails/example/helper_spec_spec.rb +26 -0
- data/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb +3 -0
- data/spec/spec/rails/matchers/assert_select_spec.rb +0 -4
- data/spec/spec/rails/matchers/redirect_to_spec.rb +24 -0
- metadata +4 -5
data/History.txt
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
=== Maintenance
|
2
2
|
|
3
|
+
IMPORTANT: rspec-rails supports rails 2.0.2, 2.1.2 and 2.2.2. We are no longer supporting 1.x versions of rails.
|
4
|
+
|
5
|
+
* 1 enhancement
|
6
|
+
|
7
|
+
* Adding status codes to redirect_to matcher (Damian Janowski). Closes #570.
|
8
|
+
|
9
|
+
=== Version 1.1.12 / 2009-01-11
|
10
|
+
|
3
11
|
* 2 deprecations
|
4
12
|
|
5
13
|
* TestResponse#[] is deprecated if you're using Rails <= 2.2.x and removed if you're using Rails 2.3
|
@@ -9,6 +17,7 @@
|
|
9
17
|
|
10
18
|
* support controller and action path params in view specs (Mike Vincent).
|
11
19
|
* use ActiveSupport::TestCase when available, else Test::Unit::TestCase - supports Rails 1.2.6 (Brandon Keepers). Closes #620.
|
20
|
+
* support form tag helpers in helpers (Ivo Dancet). Closes #641.
|
12
21
|
|
13
22
|
* 3 minor enhancements
|
14
23
|
|
@@ -16,7 +25,7 @@
|
|
16
25
|
* use more liberal globs to allow for specs in symlinked dirs (Martin Luder). Closes #361.
|
17
26
|
* Enable loading fixtures from arbitrary locations (Jacek Becela). Closes #464.
|
18
27
|
|
19
|
-
*
|
28
|
+
* 7 bug fixes
|
20
29
|
|
21
30
|
* Attempt to load application_controller before falling back to application (Geoff Garside). Closes #626.
|
22
31
|
* Include _id and reduce quoting of default values in view specs (Steen Lehmann). Closes #598.
|
@@ -24,6 +33,7 @@
|
|
24
33
|
* config.gem 'rspec' can't be unpacked. Closes #629.
|
25
34
|
* spec_server not working with Rails 2.2.2 (Andreas Wolff). Closes #631.
|
26
35
|
* redirect_to doesn't work with http method constrained urls (Maxim Kulkin). Closes #648.
|
36
|
+
* rescue_with declarations are no longer by-passed (Brandon Keepers). #85
|
27
37
|
|
28
38
|
=== Version 1.1.11 / 2008-10-24
|
29
39
|
|
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 = [["rspec","1.1.
|
23
|
+
p.extra_deps = [["rspec","1.1.12"]]
|
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
|
@@ -38,29 +38,9 @@ module Spec
|
|
38
38
|
#
|
39
39
|
# == Expecting Errors
|
40
40
|
#
|
41
|
-
# Rspec on Rails will raise errors that occur in controller actions
|
42
|
-
#
|
43
|
-
# actions and return an error code in the header. If you wish to override
|
44
|
-
# Rspec and have Rail's default behaviour,tell the controller to use
|
45
|
-
# rails error handling ...
|
41
|
+
# Rspec on Rails will raise errors that occur in controller actions and
|
42
|
+
# are not rescued or handeled with rescue_from.
|
46
43
|
#
|
47
|
-
# before(:each) do
|
48
|
-
# controller.use_rails_error_handling!
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# When using Rail's error handling, you can expect error codes in headers ...
|
52
|
-
#
|
53
|
-
# it "should return an error in the header" do
|
54
|
-
# response.should be_error
|
55
|
-
# end
|
56
|
-
#
|
57
|
-
# it "should return a 501" do
|
58
|
-
# response.response_code.should == 501
|
59
|
-
# end
|
60
|
-
#
|
61
|
-
# it "should return a 501" do
|
62
|
-
# response.code.should == "501"
|
63
|
-
# end
|
64
44
|
class ControllerExampleGroup < FunctionalExampleGroup
|
65
45
|
class << self
|
66
46
|
|
@@ -176,10 +156,7 @@ module Spec
|
|
176
156
|
# This gets added to the controller's singleton meta class,
|
177
157
|
# allowing Controller Examples to run in two modes, freely switching
|
178
158
|
# from context to context.
|
179
|
-
def render(options=nil,
|
180
|
-
if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
|
181
|
-
deprecated_status_or_extra_options = {}
|
182
|
-
end
|
159
|
+
def render(options=nil, &block)
|
183
160
|
|
184
161
|
unless block_given?
|
185
162
|
unless integrate_views?
|
@@ -223,7 +200,7 @@ module Spec
|
|
223
200
|
if matching_stub_exists(options)
|
224
201
|
@performed_render = true
|
225
202
|
else
|
226
|
-
super(options,
|
203
|
+
super(options, &block)
|
227
204
|
end
|
228
205
|
end
|
229
206
|
end
|
@@ -26,6 +26,8 @@ module Spec
|
|
26
26
|
# end
|
27
27
|
# end
|
28
28
|
class HelperExampleGroup < FunctionalExampleGroup
|
29
|
+
attr_accessor :output_buffer
|
30
|
+
|
29
31
|
class HelperObject < ActionView::Base
|
30
32
|
def protect_against_forgery?
|
31
33
|
false
|
@@ -117,7 +119,9 @@ module Spec
|
|
117
119
|
|
118
120
|
@flash = ActionController::Flash::FlashHash.new
|
119
121
|
session['flash'] = @flash
|
120
|
-
|
122
|
+
|
123
|
+
@output_buffer = ""
|
124
|
+
@template = helper
|
121
125
|
ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
|
122
126
|
|
123
127
|
helper.session = session
|
@@ -161,9 +165,6 @@ module Spec
|
|
161
165
|
|
162
166
|
class HelperExampleGroupController < ApplicationController #:nodoc:
|
163
167
|
attr_accessor :request, :url
|
164
|
-
|
165
|
-
# Re-raise errors
|
166
|
-
def rescue_action(e); raise e; end
|
167
168
|
end
|
168
169
|
end
|
169
170
|
end
|
@@ -8,14 +8,18 @@ module ActionController
|
|
8
8
|
@use_rails_error_handling ||= false
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
protected
|
12
|
+
|
12
13
|
def rescue_action_with_fast_errors(exception)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
17
|
+
else
|
18
|
+
raise exception
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
alias_method_chain :rescue_action, :fast_errors
|
23
|
+
|
20
24
|
end
|
21
25
|
end
|
@@ -4,6 +4,8 @@ module Spec
|
|
4
4
|
|
5
5
|
class RedirectTo #:nodoc:
|
6
6
|
|
7
|
+
include ActionController::StatusCodes
|
8
|
+
|
7
9
|
def initialize(request, expected)
|
8
10
|
@expected = expected
|
9
11
|
@request = request
|
@@ -13,12 +15,20 @@ module Spec
|
|
13
15
|
@redirected = response.redirect?
|
14
16
|
@actual = response.redirect_url
|
15
17
|
return false unless @redirected
|
18
|
+
|
19
|
+
if @expected_status
|
20
|
+
@actual_status = interpret_status(response.code.to_i)
|
21
|
+
@status_matched = @expected_status == @actual_status
|
22
|
+
else
|
23
|
+
@status_matched = true
|
24
|
+
end
|
25
|
+
|
16
26
|
if @expected.instance_of? Hash
|
17
27
|
return false unless @actual =~ %r{^\w+://#{@request.host}}
|
18
28
|
return false unless actual_redirect_to_valid_route
|
19
|
-
return actual_hash == expected_hash
|
29
|
+
return actual_hash == expected_hash && @status_matched
|
20
30
|
else
|
21
|
-
return @actual == expected_url
|
31
|
+
return @actual == expected_url && @status_matched
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
@@ -48,6 +58,11 @@ module Spec
|
|
48
58
|
QueryParameterParser.parse_query_parameters(query, @request)
|
49
59
|
end
|
50
60
|
|
61
|
+
def with(options)
|
62
|
+
@expected_status = interpret_status(options[:status])
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
51
66
|
def expected_url
|
52
67
|
case @expected
|
53
68
|
when Hash
|
@@ -63,7 +78,11 @@ module Spec
|
|
63
78
|
|
64
79
|
def failure_message
|
65
80
|
if @redirected
|
66
|
-
|
81
|
+
if @status_matched
|
82
|
+
return %Q{expected redirect to #{@expected.inspect}, got redirect to #{@actual.inspect}}
|
83
|
+
else
|
84
|
+
return %Q{expected redirect to #{@expected.inspect} with status #{@expected_status}, got #{@actual_status}}
|
85
|
+
end
|
67
86
|
else
|
68
87
|
return %Q{expected redirect to #{@expected.inspect}, got no redirect}
|
69
88
|
end
|
data/lib/spec/rails/version.rb
CHANGED
data/rspec-rails.gemspec
CHANGED
@@ -2,35 +2,35 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rspec-rails}
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.12"
|
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-01-
|
9
|
+
s.date = %q{2009-01-11}
|
10
10
|
s.description = %q{Behaviour Driven Development for Ruby on Rails.}
|
11
11
|
s.email = ["rspec-devel@rubyforge.org"]
|
12
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", "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/
|
13
|
+
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "TODO.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/rails_example_group.rb", "lib/spec/rails/example/render_observer.rb", "lib/spec/rails/example/view_example_group.rb", "lib/spec/rails/extensions.rb", "lib/spec/rails/extensions/action_controller/base.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/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/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_isolation_spec.rb", "spec/spec/rails/example/controller_spec_spec.rb", "spec/spec/rails/example/cookies_proxy_spec.rb", "spec/spec/rails/example/example_group_factory_spec.rb", "spec/spec/rails/example/helper_spec_spec.rb", "spec/spec/rails/example/model_spec_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_spec_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"]
|
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.
|
20
|
+
s.summary = %q{rspec-rails 1.1.12}
|
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<
|
27
|
+
s.add_runtime_dependency(%q<rspec>, ["= 1.1.12"])
|
28
28
|
s.add_development_dependency(%q<cucumber>, [">= 0.1.13"])
|
29
29
|
s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
|
30
30
|
else
|
31
|
-
s.add_dependency(%q<rspec>, ["= 1.1.
|
31
|
+
s.add_dependency(%q<rspec>, ["= 1.1.12"])
|
32
32
|
end
|
33
33
|
else
|
34
|
-
s.add_dependency(%q<rspec>, ["= 1.1.
|
34
|
+
s.add_dependency(%q<rspec>, ["= 1.1.12"])
|
35
35
|
end
|
36
36
|
end
|
@@ -86,6 +86,21 @@ class ControllerSpecController < ActionController::Base
|
|
86
86
|
@a_variable = false
|
87
87
|
render :text => ""
|
88
88
|
end
|
89
|
+
|
90
|
+
class RescuedError < Exception; end
|
91
|
+
class UnRescuedError < Exception; end
|
92
|
+
|
93
|
+
rescue_from RescuedError do |e|
|
94
|
+
render :text => 'Rescued!'
|
95
|
+
end
|
96
|
+
|
97
|
+
def rescued_error_action
|
98
|
+
raise RescuedError
|
99
|
+
end
|
100
|
+
|
101
|
+
def other_error_action
|
102
|
+
raise UnRescuedError
|
103
|
+
end
|
89
104
|
end
|
90
105
|
|
91
106
|
class ControllerInheritingFromApplicationControllerController < ApplicationController
|
@@ -62,5 +62,9 @@ class RedirectSpecController < ApplicationController
|
|
62
62
|
def action_to_redirect_to_action_with_method_restriction
|
63
63
|
redirect_to :action => 'action_with_method_restriction'
|
64
64
|
end
|
65
|
+
|
66
|
+
def action_with_redirect_to_somewhere_with_status
|
67
|
+
redirect_to :action => 'somewhere', :status => 301
|
68
|
+
end
|
65
69
|
end
|
66
70
|
|
@@ -21,10 +21,6 @@ describe "a controller spec running in integration mode", :type => :controller d
|
|
21
21
|
controller_name :controller_spec
|
22
22
|
integrate_views
|
23
23
|
|
24
|
-
before(:each) do
|
25
|
-
controller.class.send(:define_method, :rescue_action) { |e| raise e }
|
26
|
-
end
|
27
|
-
|
28
24
|
it "should render a template" do
|
29
25
|
get 'action_with_template'
|
30
26
|
response.should be_success
|
@@ -6,8 +6,6 @@ require 'controller_spec_controller'
|
|
6
6
|
controller_name :controller_spec
|
7
7
|
integrate_views if mode == 'integration'
|
8
8
|
|
9
|
-
specify "this example should be pending, not an error"
|
10
|
-
|
11
9
|
it "should provide controller.session as session" do
|
12
10
|
get 'action_with_template'
|
13
11
|
session.should equal(controller.session)
|
@@ -161,6 +159,57 @@ require 'controller_spec_controller'
|
|
161
159
|
end
|
162
160
|
|
163
161
|
end
|
162
|
+
|
163
|
+
describe "with an error that is not rescued in the controller" do
|
164
|
+
context "without rails' error handling" do
|
165
|
+
it "raises the error" do
|
166
|
+
lambda do
|
167
|
+
get 'other_error_action'
|
168
|
+
end.should raise_error(ControllerSpecController::UnRescuedError)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
context "with rails' error handling" do
|
172
|
+
it "does not raise the error" do
|
173
|
+
controller.use_rails_error_handling!
|
174
|
+
lambda do
|
175
|
+
get 'other_error_action'
|
176
|
+
end.should_not raise_error
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
if Rails::VERSION::MAJOR >= 2
|
182
|
+
describe "with an error that is rescued in the controller" do
|
183
|
+
context "without rails' error handling" do
|
184
|
+
it "does not raise error" do
|
185
|
+
lambda do
|
186
|
+
get 'rescued_error_action'
|
187
|
+
end.should_not raise_error
|
188
|
+
end
|
189
|
+
|
190
|
+
it "executes rescue_from" do
|
191
|
+
get 'rescued_error_action'
|
192
|
+
response.body.should == 'Rescued!'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context "with rails' error handling" do
|
197
|
+
before(:each) do
|
198
|
+
controller.use_rails_error_handling!
|
199
|
+
end
|
200
|
+
it "does not raise error" do
|
201
|
+
lambda do
|
202
|
+
get 'rescued_error_action'
|
203
|
+
end.should_not raise_error
|
204
|
+
end
|
205
|
+
|
206
|
+
it "executes rescue_from" do
|
207
|
+
get 'rescued_error_action'
|
208
|
+
response.body.should == 'Rescued!'
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
164
213
|
|
165
214
|
it "should support custom routes" do
|
166
215
|
route_for(:controller => "custom_route_spec", :action => "custom_route").should == "/custom_route"
|
@@ -143,6 +143,32 @@ module Spec
|
|
143
143
|
assigns[:addend].should == 3
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
describe HelperExampleGroup, "using a helper that uses output_buffer inside helper", :type => :helper do
|
148
|
+
helper_name :explicit
|
149
|
+
|
150
|
+
it "should not raise an error" do
|
151
|
+
lambda { method_using_output_buffer }.should_not raise_error
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should put the output in the output_buffer" do
|
155
|
+
method_using_output_buffer
|
156
|
+
output_buffer.should == "the_text_from_concat"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe HelperExampleGroup, "using a helper that tries to access @template", :type => :helper do
|
161
|
+
helper_name :explicit
|
162
|
+
|
163
|
+
it "should not raise an error" do
|
164
|
+
lambda { method_using_template }.should_not raise_error
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should have the correct output" do
|
168
|
+
method_using_template.should have_text(/#some_id/)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
146
172
|
end
|
147
173
|
end
|
148
174
|
end
|
@@ -87,6 +87,16 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
87
87
|
response.should redirect_to("http://test.host/nonexistant/none")
|
88
88
|
end
|
89
89
|
|
90
|
+
it "redirected to a URL with a specific status code" do
|
91
|
+
get "action_with_redirect_to_somewhere_with_status"
|
92
|
+
response.should redirect_to(:action => 'somewhere').with(:status => 301)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "redirected to a URL with a specific status code (using names)" do
|
96
|
+
get "action_with_redirect_to_somewhere_with_status"
|
97
|
+
response.should redirect_to(:action => 'somewhere').with(:status => :moved_permanently)
|
98
|
+
end
|
99
|
+
|
90
100
|
end
|
91
101
|
|
92
102
|
|
@@ -147,6 +157,20 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
147
157
|
response.should redirect_to(:action => 'somewhere_else')
|
148
158
|
}.should fail_with("expected redirect to {:action=>\"somewhere_else\"}, got redirect to \"http://test.host/redirect_spec/somewhere\"")
|
149
159
|
end
|
160
|
+
|
161
|
+
it "redirected with wrong status code" do
|
162
|
+
get 'action_with_redirect_to_somewhere_with_status'
|
163
|
+
lambda {
|
164
|
+
response.should redirect_to(:action => 'somewhere').with(:status => 302)
|
165
|
+
}.should fail_with("expected redirect to {:action=>\"somewhere\"} with status 302 Found, got 301 Moved Permanently")
|
166
|
+
end
|
167
|
+
|
168
|
+
it "redirected with wrong status code (using names)" do
|
169
|
+
get 'action_with_redirect_to_somewhere_with_status'
|
170
|
+
lambda {
|
171
|
+
response.should redirect_to(:action => 'somewhere').with(:status => :found)
|
172
|
+
}.should fail_with("expected redirect to {:action=>\"somewhere\"} with status 302 Found, got 301 Moved Permanently")
|
173
|
+
end
|
150
174
|
|
151
175
|
it "redirected to incorrect path with leading /" do
|
152
176
|
get 'action_with_redirect_to_somewhere'
|
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.
|
4
|
+
version: 1.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RSpec Development Team
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-11 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.1.
|
22
|
+
version: 1.1.12
|
23
23
|
version:
|
24
24
|
description: Behaviour Driven Development for Ruby on Rails.
|
25
25
|
email:
|
@@ -82,7 +82,6 @@ files:
|
|
82
82
|
- lib/spec/rails/example/cookies_proxy.rb
|
83
83
|
- lib/spec/rails/example/functional_example_group.rb
|
84
84
|
- lib/spec/rails/example/helper_example_group.rb
|
85
|
-
- lib/spec/rails/example/mailer_example_group.rb
|
86
85
|
- lib/spec/rails/example/model_example_group.rb
|
87
86
|
- lib/spec/rails/example/rails_example_group.rb
|
88
87
|
- lib/spec/rails/example/render_observer.rb
|
@@ -224,6 +223,6 @@ rubyforge_project: rspec
|
|
224
223
|
rubygems_version: 1.2.0
|
225
224
|
signing_key:
|
226
225
|
specification_version: 2
|
227
|
-
summary: rspec-rails 1.1.
|
226
|
+
summary: rspec-rails 1.1.12
|
228
227
|
test_files: []
|
229
228
|
|