rspec-rails 1.1.12 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +7 -0
- data/History.txt +55 -0
- data/License.txt +1 -1
- data/Manifest.txt +53 -48
- data/README.txt +5 -4
- data/Rakefile +9 -2
- data/TODO.txt +1 -0
- data/Upgrade.markdown +103 -0
- data/generators/rspec/rspec_generator.rb +1 -0
- data/generators/rspec/templates/rspec.rake +134 -111
- data/generators/rspec/templates/script/autospec +1 -0
- data/generators/rspec/templates/script/spec +21 -4
- data/generators/rspec/templates/script/spec_server +34 -107
- data/generators/rspec/templates/spec_helper.rb +1 -1
- data/generators/rspec_controller/rspec_controller_generator.rb +1 -5
- data/generators/rspec_scaffold/rspec_scaffold_generator.rb +13 -17
- data/generators/rspec_scaffold/templates/controller_spec.rb +27 -29
- data/generators/rspec_scaffold/templates/edit_erb_spec.rb +2 -2
- data/generators/rspec_scaffold/templates/helper_spec.rb +1 -1
- data/generators/rspec_scaffold/templates/index_erb_spec.rb +2 -2
- data/generators/rspec_scaffold/templates/new_erb_spec.rb +2 -2
- data/generators/rspec_scaffold/templates/routing_spec.rb +24 -20
- data/generators/rspec_scaffold/templates/show_erb_spec.rb +2 -2
- data/lib/spec/rails.rb +10 -9
- data/lib/spec/rails/example.rb +2 -2
- data/lib/spec/rails/example/assigns_hash_proxy.rb +1 -2
- data/lib/spec/rails/example/controller_example_group.rb +117 -123
- data/lib/spec/rails/example/functional_example_group.rb +7 -22
- data/lib/spec/rails/example/helper_example_group.rb +15 -33
- data/lib/spec/rails/example/model_example_group.rb +1 -1
- data/lib/spec/rails/example/render_observer.rb +0 -26
- data/lib/spec/rails/example/routing_example_group.rb +13 -0
- data/lib/spec/rails/example/routing_helpers.rb +68 -0
- data/lib/spec/rails/example/view_example_group.rb +50 -47
- data/lib/spec/rails/extensions.rb +2 -1
- data/lib/spec/rails/extensions/action_controller/rescue.rb +25 -8
- data/lib/spec/rails/extensions/action_controller/test_case.rb +16 -0
- data/lib/spec/rails/extensions/action_controller/test_response.rb +4 -3
- data/lib/spec/rails/extensions/action_view/base.rb +9 -9
- data/lib/spec/rails/extensions/active_record/base.rb +39 -23
- data/lib/spec/rails/extensions/active_support/test_case.rb +7 -0
- data/lib/spec/rails/extensions/spec/matchers/have.rb +8 -6
- data/lib/spec/rails/extensions/spec/runner/configuration.rb +12 -44
- data/lib/spec/rails/matchers/ar_be_valid.rb +8 -5
- data/lib/spec/rails/matchers/assert_select.rb +36 -21
- data/lib/spec/rails/matchers/have_text.rb +3 -3
- data/lib/spec/rails/matchers/include_text.rb +4 -4
- data/lib/spec/rails/matchers/redirect_to.rb +30 -19
- data/lib/spec/rails/matchers/render_template.rb +7 -3
- data/lib/spec/rails/mocks.rb +1 -1
- data/lib/spec/rails/spec_server.rb +97 -0
- data/lib/spec/rails/story_adapter.rb +4 -4
- data/lib/spec/rails/version.rb +2 -2
- data/spec/resources/controllers/controller_spec_controller.rb +14 -6
- data/spec/resources/controllers/example.txt +1 -0
- data/spec/resources/controllers/redirect_spec_controller.rb +4 -0
- data/spec/resources/controllers/render_spec_controller.rb +1 -1
- data/spec/resources/controllers/rjs_spec_controller.rb +1 -1
- data/spec/resources/helpers/explicit_helper.rb +1 -1
- data/spec/resources/views/controller_spec/{_partial.rhtml → _partial.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_setting_flash_after_session_reset.rhtml → action_setting_flash_after_session_reset.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_setting_flash_before_session_reset.rhtml → action_setting_flash_before_session_reset.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_setting_the_assigns_hash.rhtml → action_setting_the_assigns_hash.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_with_errors_in_template.rhtml → action_with_errors_in_template.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_with_template.rhtml → action_with_template.html.erb} +0 -0
- data/spec/resources/views/layouts/{application.rhtml → application.html.erb} +0 -0
- data/spec/resources/views/layouts/{simple.rhtml → simple.html.erb} +0 -0
- data/spec/resources/views/render_spec/{_a_partial.rhtml → _a_partial.html.erb} +0 -0
- data/spec/resources/views/render_spec/{action_with_alternate_layout.rhtml → action_with_alternate_layout.html.erb} +0 -0
- data/spec/resources/views/rjs_spec/{_replacement_partial.rhtml → _replacement_partial.html.erb} +0 -0
- data/spec/resources/views/rjs_spec/{hide_div.rjs → hide_div.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{hide_page_element.rjs → hide_page_element.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{insert_html.rjs → insert_html.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{replace.rjs → replace.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{replace_html.rjs → replace_html.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{replace_html_with_partial.rjs → replace_html_with_partial.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{visual_effect.rjs → visual_effect.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{visual_toggle_effect.rjs → visual_toggle_effect.js.rjs} +0 -0
- data/spec/resources/views/tag_spec/{no_tags.rhtml → no_tags.html.erb} +0 -0
- data/spec/resources/views/tag_spec/{single_div_with_no_attributes.rhtml → single_div_with_no_attributes.html.erb} +0 -0
- data/spec/resources/views/tag_spec/{single_div_with_one_attribute.rhtml → single_div_with_one_attribute.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial.rhtml → _partial.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial_used_twice.rhtml → _partial_used_twice.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial_with_local_variable.rhtml → _partial_with_local_variable.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial_with_sub_partial.rhtml → _partial_with_sub_partial.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_spacer.rhtml → _spacer.html.erb} +0 -0
- data/spec/resources/views/view_spec/{accessor.rhtml → accessor.html.erb} +0 -0
- data/spec/resources/views/view_spec/{block_helper.rhtml → block_helper.html.erb} +0 -0
- data/spec/resources/views/view_spec/{entry_form.rhtml → entry_form.html.erb} +0 -0
- data/spec/resources/views/view_spec/{explicit_helper.rhtml → explicit_helper.html.erb} +0 -0
- data/spec/resources/views/view_spec/foo/{show.rhtml → show.html.erb} +0 -0
- data/spec/resources/views/view_spec/{implicit_helper.rhtml → implicit_helper.html.erb} +0 -0
- data/spec/resources/views/view_spec/{multiple_helpers.rhtml → multiple_helpers.html.erb} +0 -0
- data/spec/resources/views/view_spec/{should_not_receive.rhtml → should_not_receive.html.erb} +0 -0
- data/spec/resources/views/view_spec/{template_with_partial.rhtml → template_with_partial.html.erb} +0 -0
- data/spec/resources/views/view_spec/{template_with_partial_using_collection.rhtml → template_with_partial_using_collection.html.erb} +0 -0
- data/spec/resources/views/view_spec/{template_with_partial_with_array.rhtml → template_with_partial_with_array.html.erb} +0 -0
- data/spec/spec/rails/example/assigns_hash_proxy_spec.rb +18 -5
- data/spec/spec/rails/example/configuration_spec.rb +15 -29
- data/spec/spec/rails/example/{controller_spec_spec.rb → controller_example_group_spec.rb} +40 -96
- data/spec/spec/rails/example/cookies_proxy_spec.rb +32 -36
- data/spec/spec/rails/example/error_handling_spec.rb +90 -0
- data/spec/spec/rails/example/example_group_factory_spec.rb +5 -5
- data/spec/spec/rails/example/{helper_spec_spec.rb → helper_example_group_spec.rb} +45 -13
- data/spec/spec/rails/example/{model_spec_spec.rb → model_example_group_spec.rb} +3 -1
- data/spec/spec/rails/example/routing_example_group_spec.rb +9 -0
- data/spec/spec/rails/example/shared_routing_example_group_examples.rb +45 -0
- data/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +1 -1
- data/spec/spec/rails/example/{view_spec_spec.rb → view_example_group_spec.rb} +44 -17
- data/spec/spec/rails/matchers/ar_be_valid_spec.rb +10 -0
- data/spec/spec/rails/matchers/assert_select_spec.rb +59 -60
- data/spec/spec/rails/matchers/have_text_spec.rb +12 -4
- data/spec/spec/rails/matchers/include_text_spec.rb +11 -13
- data/spec/spec/rails/matchers/redirect_to_spec.rb +224 -189
- data/spec/spec/rails/matchers/render_template_spec.rb +169 -158
- data/spec/spec/rails/spec_server_spec.rb +18 -7
- data/spec/spec_helper.rb +21 -9
- metadata +68 -53
- data/lib/spec/rails/example/rails_example_group.rb +0 -28
- data/lib/spec/rails/extensions/action_controller/base.rb +0 -14
- data/rspec-rails.gemspec +0 -36
- data/spec/resources/views/render_spec/some_action.rjs +0 -1
- data/spec/spec/rails/example/shared_behaviour_spec.rb +0 -16
- data/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb +0 -57
@@ -2,17 +2,25 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
2
|
|
3
3
|
describe "have_text" do
|
4
4
|
|
5
|
+
|
6
|
+
it "should have a helpful description" do
|
7
|
+
matcher = have_text("foo bar")
|
8
|
+
matcher.description.should == 'have text "foo bar"'
|
9
|
+
end
|
10
|
+
|
5
11
|
describe "where target is a Regexp" do
|
6
12
|
it 'should should match submitted text using a regexp' do
|
7
|
-
|
8
|
-
|
13
|
+
matcher = have_text(/fo*/)
|
14
|
+
matcher.matches?('foo').should be_true
|
15
|
+
matcher.matches?('bar').should be_nil
|
9
16
|
end
|
10
17
|
end
|
11
18
|
|
12
19
|
describe "where target is a String" do
|
13
20
|
it 'should match submitted text using a string' do
|
14
|
-
|
15
|
-
|
21
|
+
matcher = have_text('foo')
|
22
|
+
matcher.matches?('foo').should be_true
|
23
|
+
matcher.matches?('foo bar').should be_false
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
@@ -2,21 +2,19 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
2
2
|
|
3
3
|
describe "include_text" do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
5
|
+
it "should have a helpful description" do
|
6
|
+
matcher = include_text("foo bar")
|
7
|
+
matcher.description.should == 'include text "foo bar"'
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
it 'should match if the text is contained' do
|
11
|
+
matcher = include_text('big piece')
|
12
|
+
matcher.matches?('I am a big piece of text').should be_true
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
15
|
+
it 'should not match if text is not contained' do
|
16
|
+
matcher = include_text('foo bar')
|
17
|
+
matcher.matches?('hello world').should be_false
|
20
18
|
end
|
21
19
|
|
22
20
|
end
|
@@ -1,218 +1,253 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
2
|
|
3
|
-
[
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
3
|
+
[:response, :controller].each do |subject_method|
|
4
|
+
['isolation','integration'].each do |mode|
|
5
|
+
describe "redirect_to behaviour", :type => :controller do
|
6
|
+
if mode == 'integration'
|
7
|
+
integrate_views
|
8
|
+
end
|
9
|
+
controller_name :redirect_spec
|
10
|
+
|
11
|
+
subject { send(subject_method) }
|
12
|
+
|
13
|
+
it "redirected to another action" do
|
14
|
+
get 'action_with_redirect_to_somewhere'
|
15
|
+
should redirect_to(:action => 'somewhere')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "redirected to another controller and action" do
|
19
|
+
get 'action_with_redirect_to_other_somewhere'
|
20
|
+
should redirect_to(:controller => 'render_spec', :action => 'text_action')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "redirected to another action (with 'and return')" do
|
24
|
+
get 'action_with_redirect_to_somewhere_and_return'
|
25
|
+
should redirect_to(:action => 'somewhere')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "redirected from an SSL action to a non-SSL action" do
|
29
|
+
request.stub!(:ssl?).and_return true
|
30
|
+
get 'action_with_redirect_to_somewhere'
|
31
|
+
should redirect_to(:action => 'somewhere')
|
32
|
+
end
|
24
33
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
it "redirected to correct path with leading /" do
|
35
|
+
get 'action_with_redirect_to_somewhere'
|
36
|
+
should redirect_to('/redirect_spec/somewhere')
|
37
|
+
end
|
38
|
+
|
39
|
+
it "redirected to correct path without leading /" do
|
40
|
+
get 'action_with_redirect_to_somewhere'
|
41
|
+
should redirect_to('redirect_spec/somewhere')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "redirected to correct internal URL" do
|
45
|
+
get 'action_with_redirect_to_somewhere'
|
46
|
+
should redirect_to("http://test.host/redirect_spec/somewhere")
|
47
|
+
end
|
35
48
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
49
|
+
it "redirected to correct external URL" do
|
50
|
+
get 'action_with_redirect_to_rspec_site'
|
51
|
+
should redirect_to("http://rspec.rubyforge.org")
|
52
|
+
end
|
40
53
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
it "redirected to correct external URL" do
|
47
|
-
get 'action_with_redirect_to_rspec_site'
|
48
|
-
response.should redirect_to("http://rspec.rubyforge.org")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "redirected :back" do
|
52
|
-
request.env['HTTP_REFERER'] = "http://test.host/previous/page"
|
53
|
-
get 'action_with_redirect_back'
|
54
|
-
response.should redirect_to(:back)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "redirected :back and should redirect_to URL matches" do
|
58
|
-
request.env['HTTP_REFERER'] = "http://test.host/previous/page"
|
59
|
-
get 'action_with_redirect_back'
|
60
|
-
response.should redirect_to("http://test.host/previous/page")
|
61
|
-
end
|
54
|
+
it "redirected :back" do
|
55
|
+
request.env['HTTP_REFERER'] = "http://test.host/previous/page"
|
56
|
+
get 'action_with_redirect_back'
|
57
|
+
should redirect_to(:back)
|
58
|
+
end
|
62
59
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
it "redirected :back and should redirect_to URL matches" do
|
61
|
+
request.env['HTTP_REFERER'] = "http://test.host/previous/page"
|
62
|
+
get 'action_with_redirect_back'
|
63
|
+
should redirect_to("http://test.host/previous/page")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "redirected from within a respond_to block" do
|
67
|
+
get 'action_with_redirect_in_respond_to'
|
68
|
+
should redirect_to('redirect_spec/somewhere')
|
69
|
+
end
|
67
70
|
|
68
|
-
|
71
|
+
params_as_hash = {:action => "somewhere", :id => 1111, :param1 => "value1", :param2 => "value2"}
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
73
|
+
it "redirected to an internal URL containing a query string" do
|
74
|
+
get "action_with_redirect_which_creates_query_string"
|
75
|
+
should redirect_to(params_as_hash)
|
76
|
+
end
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
it "redirected to an internal URL containing a query string, one way it might be generated" do
|
79
|
+
get "action_with_redirect_with_query_string_order1"
|
80
|
+
should redirect_to(params_as_hash)
|
81
|
+
end
|
79
82
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
it "redirected to an internal URL containing a query string, another way it might be generated" do
|
84
|
+
get "action_with_redirect_with_query_string_order2"
|
85
|
+
should redirect_to(params_as_hash)
|
86
|
+
end
|
84
87
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
it "redirected to an internal URL which is unroutable but matched via a string" do
|
89
|
+
get "action_with_redirect_to_unroutable_url_inside_app"
|
90
|
+
should redirect_to("http://test.host/nonexistant/none")
|
91
|
+
end
|
89
92
|
|
90
|
-
|
93
|
+
it "redirected to a URL with a specific status code" do
|
94
|
+
get "action_with_redirect_to_somewhere_with_status"
|
95
|
+
should redirect_to(:action => 'somewhere').with(:status => 301)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "redirected to a URL with a specific status code (using names)" do
|
99
|
+
get "action_with_redirect_to_somewhere_with_status"
|
100
|
+
should redirect_to(:action => 'somewhere').with(:status => :moved_permanently)
|
101
|
+
end
|
91
102
|
|
92
|
-
|
93
|
-
describe "redirect_to with a controller spec in #{mode} mode and a custom request.host", :type => :controller do
|
94
|
-
if mode == 'integration'
|
95
|
-
integrate_views
|
96
|
-
end
|
97
|
-
controller_name :redirect_spec
|
98
|
-
before do
|
99
|
-
request.host = "some.custom.host"
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should pass when redirected to another action" do
|
103
|
-
get 'action_with_redirect_to_somewhere'
|
104
|
-
response.should redirect_to(:action => 'somewhere')
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "Given a controller spec in #{mode} mode", :type => :controller do
|
109
|
-
if mode == 'integration'
|
110
|
-
integrate_views
|
111
|
-
end
|
112
|
-
controller_name :redirect_spec
|
113
|
-
|
114
|
-
it "an action that redirects should not result in an error if no should redirect_to expectation is called" do
|
115
|
-
get 'action_with_redirect_to_somewhere'
|
116
103
|
end
|
104
|
+
|
117
105
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
106
|
+
describe "redirect_to with a controller spec in #{mode} mode and a custom request.host", :type => :controller do
|
107
|
+
if mode == 'integration'
|
108
|
+
integrate_views
|
109
|
+
end
|
110
|
+
controller_name :redirect_spec
|
122
111
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
112
|
+
subject { send(subject_method) }
|
113
|
+
|
114
|
+
before do
|
115
|
+
request.host = "some.custom.host"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should pass when redirected to another action" do
|
119
|
+
get 'action_with_redirect_to_somewhere'
|
120
|
+
should redirect_to(:action => 'somewhere')
|
121
|
+
end
|
128
122
|
end
|
123
|
+
|
124
|
+
describe "Given a controller spec in #{mode} mode", :type => :controller do
|
125
|
+
if mode == 'integration'
|
126
|
+
integrate_views
|
127
|
+
end
|
128
|
+
controller_name :redirect_spec
|
129
|
+
|
130
|
+
subject { send(subject_method) }
|
131
|
+
|
132
|
+
it "an action that redirects should not result in an error if no should redirect_to expectation is called" do
|
133
|
+
get 'action_with_redirect_to_somewhere'
|
134
|
+
end
|
135
|
+
|
136
|
+
it "an action that redirects should not result in an error if should_not redirect_to expectation was called, but not to that action" do
|
137
|
+
get 'action_with_redirect_to_somewhere'
|
138
|
+
should_not redirect_to(:action => 'another_destination')
|
139
|
+
end
|
129
140
|
|
130
|
-
|
131
|
-
|
132
|
-
|
141
|
+
it "an action that redirects should result in an error if should_not redirect_to expectation was called to that action" do
|
142
|
+
get 'action_with_redirect_to_somewhere'
|
143
|
+
lambda {
|
144
|
+
should_not redirect_to(:action => 'somewhere')
|
145
|
+
}.should fail_with("expected not to be redirected to {:action=>\"somewhere\"}, but was")
|
146
|
+
end
|
147
|
+
|
148
|
+
it "an action that does not redirects should not result in an error if should_not redirect_to expectation was called" do
|
149
|
+
get 'action_with_no_redirect'
|
150
|
+
should_not redirect_to(:action => 'any_destination')
|
151
|
+
end
|
152
|
+
|
153
|
+
|
133
154
|
end
|
155
|
+
|
156
|
+
describe "Given a controller spec in #{mode} mode, should redirect_to should fail when", :type => :controller do
|
157
|
+
if mode == 'integration'
|
158
|
+
integrate_views
|
159
|
+
end
|
160
|
+
controller_name :redirect_spec
|
161
|
+
|
162
|
+
subject { send(subject_method) }
|
134
163
|
|
164
|
+
it "redirected to wrong action" do
|
165
|
+
get 'action_with_redirect_to_somewhere'
|
166
|
+
lambda {
|
167
|
+
should redirect_to(:action => 'somewhere_else')
|
168
|
+
}.should fail_with("expected redirect to {:action=>\"somewhere_else\"}, got redirect to \"http://test.host/redirect_spec/somewhere\"")
|
169
|
+
end
|
170
|
+
|
171
|
+
it "redirected with wrong status code" do
|
172
|
+
get 'action_with_redirect_to_somewhere_with_status'
|
173
|
+
lambda {
|
174
|
+
should redirect_to(:action => 'somewhere').with(:status => 302)
|
175
|
+
}.should fail_with("expected redirect to {:action=>\"somewhere\"} with status 302 Found, got 301 Moved Permanently")
|
176
|
+
end
|
177
|
+
|
178
|
+
it "redirected with wrong status code (using names)" do
|
179
|
+
get 'action_with_redirect_to_somewhere_with_status'
|
180
|
+
lambda {
|
181
|
+
should redirect_to(:action => 'somewhere').with(:status => :found)
|
182
|
+
}.should fail_with("expected redirect to {:action=>\"somewhere\"} with status 302 Found, got 301 Moved Permanently")
|
183
|
+
end
|
184
|
+
|
185
|
+
it "redirected to incorrect path with leading /" do
|
186
|
+
get 'action_with_redirect_to_somewhere'
|
187
|
+
lambda {
|
188
|
+
should redirect_to('/redirect_spec/somewhere_else')
|
189
|
+
}.should fail_with('expected redirect to "/redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"')
|
190
|
+
end
|
135
191
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
controller_name :redirect_spec
|
192
|
+
it "redirected to incorrect path without leading /" do
|
193
|
+
get 'action_with_redirect_to_somewhere'
|
194
|
+
lambda {
|
195
|
+
should redirect_to('redirect_spec/somewhere_else')
|
196
|
+
}.should fail_with('expected redirect to "redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"')
|
197
|
+
end
|
143
198
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
199
|
+
it "redirected to incorrect internal URL (based on the action)" do
|
200
|
+
get 'action_with_redirect_to_somewhere'
|
201
|
+
lambda {
|
202
|
+
should redirect_to("http://test.host/redirect_spec/somewhere_else")
|
203
|
+
}.should fail_with('expected redirect to "http://test.host/redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"')
|
204
|
+
end
|
205
|
+
|
206
|
+
it "redirected to wrong external URL" do
|
207
|
+
get 'action_with_redirect_to_rspec_site'
|
208
|
+
lambda {
|
209
|
+
should redirect_to("http://test.unit.rubyforge.org")
|
210
|
+
}.should fail_with('expected redirect to "http://test.unit.rubyforge.org", got redirect to "http://rspec.rubyforge.org"')
|
211
|
+
end
|
150
212
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
it "redirected to incorrect path without leading /" do
|
159
|
-
get 'action_with_redirect_to_somewhere'
|
160
|
-
lambda {
|
161
|
-
response.should redirect_to('redirect_spec/somewhere_else')
|
162
|
-
}.should fail_with('expected redirect to "redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"')
|
163
|
-
end
|
164
|
-
|
165
|
-
it "redirected to incorrect internal URL (based on the action)" do
|
166
|
-
get 'action_with_redirect_to_somewhere'
|
167
|
-
lambda {
|
168
|
-
response.should redirect_to("http://test.host/redirect_spec/somewhere_else")
|
169
|
-
}.should fail_with('expected redirect to "http://test.host/redirect_spec/somewhere_else", got redirect to "http://test.host/redirect_spec/somewhere"')
|
170
|
-
end
|
213
|
+
it "redirected to incorrect internal URL (based on the directory path)" do
|
214
|
+
get 'action_with_redirect_to_somewhere'
|
215
|
+
lambda {
|
216
|
+
should redirect_to("http://test.host/non_existent_controller/somewhere")
|
217
|
+
}.should fail_with('expected redirect to "http://test.host/non_existent_controller/somewhere", got redirect to "http://test.host/redirect_spec/somewhere"')
|
218
|
+
end
|
171
219
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
it "redirected to incorrect internal URL (based on the directory path)" do
|
180
|
-
get 'action_with_redirect_to_somewhere'
|
181
|
-
lambda {
|
182
|
-
response.should redirect_to("http://test.host/non_existent_controller/somewhere")
|
183
|
-
}.should fail_with('expected redirect to "http://test.host/non_existent_controller/somewhere", got redirect to "http://test.host/redirect_spec/somewhere"')
|
184
|
-
end
|
185
|
-
|
186
|
-
it "expected redirect :back, but redirected to a new URL" do
|
187
|
-
get 'action_with_no_redirect'
|
188
|
-
lambda {
|
189
|
-
response.should redirect_to(:back)
|
190
|
-
}.should fail_with('expected redirect to :back, got no redirect')
|
191
|
-
end
|
192
|
-
|
193
|
-
it "no redirect at all" do
|
194
|
-
get 'action_with_no_redirect'
|
195
|
-
lambda {
|
196
|
-
response.should redirect_to(:action => 'nowhere')
|
197
|
-
}.should fail_with("expected redirect to {:action=>\"nowhere\"}, got no redirect")
|
198
|
-
end
|
199
|
-
|
200
|
-
it "redirected to an internal URL which is unroutable and matched via a hash" do
|
201
|
-
get "action_with_redirect_to_unroutable_url_inside_app"
|
202
|
-
route = {:controller => "nonexistant", :action => "none"}
|
203
|
-
lambda {
|
204
|
-
response.should redirect_to(route)
|
205
|
-
}.should raise_error(ActionController::RoutingError, /(no route found to match|No route matches) \"\/nonexistant\/none\" with \{.*\}/)
|
206
|
-
end
|
220
|
+
it "expected redirect :back, but redirected to a new URL" do
|
221
|
+
get 'action_with_no_redirect'
|
222
|
+
lambda {
|
223
|
+
should redirect_to(:back)
|
224
|
+
}.should fail_with('expected redirect to :back, got no redirect')
|
225
|
+
end
|
207
226
|
|
208
|
-
|
209
|
-
|
210
|
-
|
227
|
+
it "no redirect at all" do
|
228
|
+
get 'action_with_no_redirect'
|
229
|
+
lambda {
|
230
|
+
should redirect_to(:action => 'nowhere')
|
231
|
+
}.should fail_with("expected redirect to {:action=>\"nowhere\"}, got no redirect")
|
232
|
+
end
|
233
|
+
|
234
|
+
it "redirected to an internal URL which is unroutable and matched via a hash" do
|
235
|
+
get "action_with_redirect_to_unroutable_url_inside_app"
|
236
|
+
route = {:controller => "nonexistant", :action => "none"}
|
237
|
+
lambda {
|
238
|
+
should redirect_to(route)
|
239
|
+
}.should raise_error(ActionController::RoutingError, /(no route found to match|No route matches) \"\/nonexistant\/none\" with \{.*\}/)
|
240
|
+
end
|
241
|
+
|
242
|
+
it "provides a description" do
|
243
|
+
redirect_to("foo/bar").description.should == %q|redirect to "foo/bar"|
|
244
|
+
end
|
211
245
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
246
|
+
it "redirects to action with http method restriction" do
|
247
|
+
post 'action_to_redirect_to_action_with_method_restriction'
|
248
|
+
should redirect_to(:action => 'action_with_method_restriction')
|
249
|
+
end
|
216
250
|
|
251
|
+
end
|
217
252
|
end
|
218
253
|
end
|