rspec-rails 1.3.2 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/.document +4 -6
- data/.yardopts +11 -0
- data/Capybara.md +28 -0
- data/Changelog.md +1343 -0
- data/LICENSE.md +25 -0
- data/README.md +383 -0
- data/lib/generators/rspec/channel/channel_generator.rb +12 -0
- data/lib/generators/rspec/channel/templates/channel_spec.rb.erb +7 -0
- data/lib/generators/rspec/controller/controller_generator.rb +51 -0
- data/lib/generators/rspec/controller/templates/controller_spec.rb +16 -0
- data/lib/generators/rspec/controller/templates/request_spec.rb +19 -0
- data/lib/generators/rspec/controller/templates/routing_spec.rb +13 -0
- data/lib/generators/rspec/controller/templates/view_spec.rb +5 -0
- data/lib/generators/rspec/feature/feature_generator.rb +29 -0
- data/lib/generators/rspec/feature/templates/feature_singular_spec.rb +5 -0
- data/lib/generators/rspec/feature/templates/feature_spec.rb +5 -0
- data/lib/generators/rspec/generator/generator_generator.rb +24 -0
- data/lib/generators/rspec/generator/templates/generator_spec.rb +5 -0
- data/lib/generators/rspec/helper/helper_generator.rb +16 -0
- data/lib/generators/rspec/helper/templates/helper_spec.rb +17 -0
- data/lib/generators/rspec/install/install_generator.rb +80 -0
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +89 -0
- data/lib/generators/rspec/job/job_generator.rb +13 -0
- data/lib/generators/rspec/job/templates/job_spec.rb.erb +7 -0
- data/lib/generators/rspec/mailbox/mailbox_generator.rb +14 -0
- data/lib/generators/rspec/mailbox/templates/mailbox_spec.rb.erb +7 -0
- data/lib/generators/rspec/mailer/mailer_generator.rb +30 -0
- data/lib/generators/rspec/mailer/templates/fixture +3 -0
- data/lib/generators/rspec/mailer/templates/mailer_spec.rb +25 -0
- data/lib/generators/rspec/mailer/templates/preview.rb +13 -0
- data/lib/generators/rspec/model/model_generator.rb +37 -0
- data/lib/generators/rspec/model/templates/fixtures.yml +19 -0
- data/lib/generators/rspec/model/templates/model_spec.rb +7 -0
- data/lib/generators/rspec/request/request_generator.rb +17 -0
- data/lib/generators/rspec/request/templates/request_spec.rb +10 -0
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +136 -0
- data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +129 -0
- data/lib/generators/rspec/scaffold/templates/api_request_spec.rb +131 -0
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +145 -0
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +27 -0
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +26 -0
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +22 -0
- data/lib/generators/rspec/scaffold/templates/request_spec.rb +138 -0
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +46 -0
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +21 -0
- data/lib/generators/rspec/system/system_generator.rb +24 -0
- data/lib/generators/rspec/system/templates/system_spec.rb +9 -0
- data/lib/generators/rspec/view/templates/view_spec.rb +5 -0
- data/lib/generators/rspec/view/view_generator.rb +22 -0
- data/lib/generators/rspec.rb +56 -0
- data/lib/rspec/rails/active_record.rb +25 -0
- data/lib/rspec/rails/adapters.rb +196 -0
- data/lib/rspec/rails/configuration.rb +222 -0
- data/lib/rspec/rails/example/channel_example_group.rb +93 -0
- data/lib/rspec/rails/example/controller_example_group.rb +217 -0
- data/lib/rspec/rails/example/feature_example_group.rb +53 -0
- data/lib/rspec/rails/example/helper_example_group.rb +42 -0
- data/lib/rspec/rails/example/job_example_group.rb +23 -0
- data/lib/rspec/rails/example/mailbox_example_group.rb +80 -0
- data/lib/rspec/rails/example/mailer_example_group.rb +38 -0
- data/lib/rspec/rails/example/model_example_group.rb +11 -0
- data/lib/rspec/rails/example/rails_example_group.rb +23 -0
- data/lib/rspec/rails/example/request_example_group.rb +27 -0
- data/lib/rspec/rails/example/routing_example_group.rb +61 -0
- data/lib/rspec/rails/example/system_example_group.rb +180 -0
- data/lib/rspec/rails/example/view_example_group.rb +214 -0
- data/lib/rspec/rails/example.rb +13 -0
- data/lib/rspec/rails/extensions/active_record/proxy.rb +11 -0
- data/lib/rspec/rails/extensions.rb +1 -0
- data/lib/rspec/rails/feature_check.rb +51 -0
- data/lib/rspec/rails/file_fixture_support.rb +18 -0
- data/lib/rspec/rails/fixture_file_upload_support.rb +45 -0
- data/lib/rspec/rails/fixture_support.rb +88 -0
- data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +173 -0
- data/lib/rspec/rails/matchers/action_cable/have_streams.rb +58 -0
- data/lib/rspec/rails/matchers/action_cable.rb +65 -0
- data/lib/rspec/rails/matchers/action_mailbox.rb +73 -0
- data/lib/rspec/rails/matchers/active_job.rb +517 -0
- data/lib/rspec/rails/matchers/base_matcher.rb +179 -0
- data/lib/rspec/rails/matchers/be_a_new.rb +83 -0
- data/lib/rspec/rails/matchers/be_new_record.rb +30 -0
- data/lib/rspec/rails/matchers/be_valid.rb +49 -0
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +258 -0
- data/lib/rspec/rails/matchers/have_http_status.rb +381 -0
- data/lib/rspec/rails/matchers/have_rendered.rb +64 -0
- data/lib/rspec/rails/matchers/redirect_to.rb +38 -0
- data/lib/rspec/rails/matchers/relation_match_array.rb +3 -0
- data/lib/rspec/rails/matchers/routing_matchers.rb +125 -0
- data/lib/rspec/rails/matchers/send_email.rb +122 -0
- data/lib/rspec/rails/matchers.rb +36 -0
- data/lib/rspec/rails/tasks/rspec.rake +49 -0
- data/lib/rspec/rails/vendor/capybara.rb +32 -0
- data/lib/rspec/rails/version.rb +9 -0
- data/lib/rspec/rails/view_assigns.rb +27 -0
- data/lib/rspec/rails/view_path_builder.rb +29 -0
- data/lib/rspec/rails/view_rendering.rb +166 -0
- data/lib/rspec/rails/view_spec_methods.rb +56 -0
- data/lib/rspec/rails.rb +18 -0
- data/lib/rspec-rails.rb +97 -0
- data.tar.gz.sig +0 -0
- metadata +307 -261
- metadata.gz.sig +0 -0
- data/Contribute.rdoc +0 -4
- data/History.rdoc +0 -302
- data/License.txt +0 -33
- data/Manifest.txt +0 -165
- data/README.rdoc +0 -45
- data/Rakefile +0 -72
- data/TODO.txt +0 -17
- data/Upgrade.rdoc +0 -148
- data/generators/integration_spec/integration_spec_generator.rb +0 -10
- data/generators/integration_spec/templates/integration_spec.rb +0 -4
- data/generators/rspec/CHANGES +0 -1
- data/generators/rspec/rspec_generator.rb +0 -72
- data/generators/rspec/templates/previous_failures.txt +0 -0
- data/generators/rspec/templates/rcov.opts +0 -2
- data/generators/rspec/templates/rspec.rake +0 -144
- data/generators/rspec/templates/script/autospec +0 -6
- data/generators/rspec/templates/script/spec +0 -10
- data/generators/rspec/templates/spec.opts +0 -4
- data/generators/rspec/templates/spec_helper.rb +0 -54
- data/generators/rspec_controller/USAGE +0 -33
- data/generators/rspec_controller/rspec_controller_generator.rb +0 -47
- data/generators/rspec_controller/templates/controller_spec.rb +0 -25
- data/generators/rspec_controller/templates/helper_spec.rb +0 -11
- data/generators/rspec_controller/templates/view_spec.rb +0 -12
- data/generators/rspec_default_values.rb +0 -28
- data/generators/rspec_model/USAGE +0 -18
- data/generators/rspec_model/rspec_model_generator.rb +0 -35
- data/generators/rspec_model/templates/model_spec.rb +0 -13
- data/generators/rspec_scaffold/rspec_scaffold_generator.rb +0 -154
- data/generators/rspec_scaffold/templates/controller_spec.rb +0 -131
- data/generators/rspec_scaffold/templates/edit_erb_spec.rb +0 -25
- data/generators/rspec_scaffold/templates/helper_spec.rb +0 -11
- data/generators/rspec_scaffold/templates/index_erb_spec.rb +0 -27
- data/generators/rspec_scaffold/templates/new_erb_spec.rb +0 -25
- data/generators/rspec_scaffold/templates/routing_spec.rb +0 -33
- data/generators/rspec_scaffold/templates/show_erb_spec.rb +0 -22
- data/init.rb +0 -9
- data/lib/autotest/discover.rb +0 -5
- data/lib/autotest/rails_rspec.rb +0 -76
- data/lib/spec/rails/example/assigns_hash_proxy.rb +0 -39
- data/lib/spec/rails/example/controller_example_group.rb +0 -285
- data/lib/spec/rails/example/cookies_proxy.rb +0 -29
- data/lib/spec/rails/example/functional_example_group.rb +0 -106
- data/lib/spec/rails/example/helper_example_group.rb +0 -153
- data/lib/spec/rails/example/integration_example_group.rb +0 -16
- data/lib/spec/rails/example/model_example_group.rb +0 -15
- data/lib/spec/rails/example/render_observer.rb +0 -80
- data/lib/spec/rails/example/routing_example_group.rb +0 -13
- data/lib/spec/rails/example/routing_helpers.rb +0 -66
- data/lib/spec/rails/example/view_example_group.rb +0 -199
- data/lib/spec/rails/example.rb +0 -48
- data/lib/spec/rails/extensions/action_controller/rescue.rb +0 -42
- data/lib/spec/rails/extensions/action_controller/test_case.rb +0 -16
- data/lib/spec/rails/extensions/action_controller/test_response.rb +0 -21
- data/lib/spec/rails/extensions/action_view/base.rb +0 -33
- data/lib/spec/rails/extensions/active_record/base.rb +0 -45
- data/lib/spec/rails/extensions/active_support/test_case.rb +0 -7
- data/lib/spec/rails/extensions/spec/matchers/have.rb +0 -23
- data/lib/spec/rails/extensions/spec/runner/configuration.rb +0 -44
- data/lib/spec/rails/extensions.rb +0 -11
- data/lib/spec/rails/interop/testcase.rb +0 -14
- data/lib/spec/rails/matchers/ar_be_valid.rb +0 -27
- data/lib/spec/rails/matchers/assert_select.rb +0 -180
- data/lib/spec/rails/matchers/change.rb +0 -13
- data/lib/spec/rails/matchers/have_text.rb +0 -57
- data/lib/spec/rails/matchers/include_text.rb +0 -54
- data/lib/spec/rails/matchers/redirect_to.rb +0 -126
- data/lib/spec/rails/matchers/render_template.rb +0 -129
- data/lib/spec/rails/matchers/route_to.rb +0 -149
- data/lib/spec/rails/matchers.rb +0 -32
- data/lib/spec/rails/mocks.rb +0 -136
- data/lib/spec/rails/version.rb +0 -16
- data/lib/spec/rails.rb +0 -26
- data/spec/autotest/mappings_spec.rb +0 -86
- data/spec/rails_suite.rb +0 -7
- data/spec/resources/controllers/action_view_base_spec_controller.rb +0 -2
- data/spec/resources/controllers/application.rb +0 -9
- data/spec/resources/controllers/controller_spec_controller.rb +0 -127
- data/spec/resources/controllers/example.txt +0 -1
- data/spec/resources/controllers/redirect_spec_controller.rb +0 -70
- data/spec/resources/controllers/render_spec_controller.rb +0 -34
- data/spec/resources/controllers/rjs_spec_controller.rb +0 -58
- data/spec/resources/helpers/addition_helper.rb +0 -5
- data/spec/resources/helpers/explicit_helper.rb +0 -46
- data/spec/resources/helpers/more_explicit_helper.rb +0 -5
- data/spec/resources/helpers/plugin_application_helper.rb +0 -6
- data/spec/resources/helpers/view_spec_helper.rb +0 -13
- data/spec/resources/models/animal.rb +0 -4
- data/spec/resources/models/person.rb +0 -18
- data/spec/resources/models/thing.rb +0 -3
- data/spec/resources/views/controller_spec/_partial.html.erb +0 -0
- data/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb +0 -1
- data/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb +0 -1
- data/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb +0 -0
- data/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb +0 -1
- data/spec/resources/views/controller_spec/action_with_template.html.erb +0 -1
- data/spec/resources/views/layouts/application.html.erb +0 -0
- data/spec/resources/views/layouts/simple.html.erb +0 -0
- data/spec/resources/views/objects/_object.html.erb +0 -1
- data/spec/resources/views/render_spec/_a_partial.html.erb +0 -0
- data/spec/resources/views/render_spec/action_with_alternate_layout.html.erb +0 -0
- data/spec/resources/views/render_spec/some_action.html.erb +0 -0
- data/spec/resources/views/render_spec/some_action.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/_replacement_partial.html.erb +0 -1
- data/spec/resources/views/rjs_spec/hide_div.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/hide_page_element.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/insert_html.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/replace.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/replace_html.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/visual_effect.js.rjs +0 -1
- data/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs +0 -1
- data/spec/resources/views/tag_spec/no_tags.html.erb +0 -1
- data/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb +0 -1
- data/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb +0 -1
- data/spec/resources/views/view_spec/_partial.html.erb +0 -2
- data/spec/resources/views/view_spec/_partial_used_twice.html.erb +0 -0
- data/spec/resources/views/view_spec/_partial_with_local_variable.html.erb +0 -1
- data/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb +0 -1
- data/spec/resources/views/view_spec/_spacer.html.erb +0 -1
- data/spec/resources/views/view_spec/accessor.html.erb +0 -6
- data/spec/resources/views/view_spec/block_helper.html.erb +0 -3
- data/spec/resources/views/view_spec/entry_form.html.erb +0 -2
- data/spec/resources/views/view_spec/explicit_helper.html.erb +0 -2
- data/spec/resources/views/view_spec/foo/show.html.erb +0 -1
- data/spec/resources/views/view_spec/implicit_helper.html.erb +0 -2
- data/spec/resources/views/view_spec/multiple_helpers.html.erb +0 -3
- data/spec/resources/views/view_spec/path_params.html.erb +0 -1
- data/spec/resources/views/view_spec/should_not_receive.html.erb +0 -3
- data/spec/resources/views/view_spec/template_with_partial.html.erb +0 -5
- data/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb +0 -3
- data/spec/resources/views/view_spec/template_with_partial_with_array.html.erb +0 -1
- data/spec/resources/views/view_spec/view_helpers.html.erb +0 -1
- data/spec/spec/rails/example/assigns_hash_proxy_spec.rb +0 -109
- data/spec/spec/rails/example/configuration_spec.rb +0 -65
- data/spec/spec/rails/example/controller_example_group_spec.rb +0 -307
- data/spec/spec/rails/example/controller_isolation_spec.rb +0 -75
- data/spec/spec/rails/example/cookies_proxy_spec.rb +0 -87
- data/spec/spec/rails/example/error_handling_spec.rb +0 -90
- data/spec/spec/rails/example/example_group_factory_spec.rb +0 -112
- data/spec/spec/rails/example/helper_example_group_spec.rb +0 -233
- data/spec/spec/rails/example/model_example_group_spec.rb +0 -32
- data/spec/spec/rails/example/routing_example_group_spec.rb +0 -10
- data/spec/spec/rails/example/shared_routing_example_group_examples.rb +0 -237
- data/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +0 -33
- data/spec/spec/rails/example/view_example_group_spec.rb +0 -346
- data/spec/spec/rails/extensions/action_view_base_spec.rb +0 -74
- data/spec/spec/rails/extensions/active_record_spec.rb +0 -14
- data/spec/spec/rails/interop/testcase_spec.rb +0 -70
- data/spec/spec/rails/matchers/ar_be_valid_spec.rb +0 -19
- data/spec/spec/rails/matchers/assert_select_spec.rb +0 -835
- data/spec/spec/rails/matchers/errors_on_spec.rb +0 -37
- data/spec/spec/rails/matchers/have_text_spec.rb +0 -69
- data/spec/spec/rails/matchers/include_text_spec.rb +0 -62
- data/spec/spec/rails/matchers/redirect_to_spec.rb +0 -253
- data/spec/spec/rails/matchers/render_template_spec.rb +0 -208
- data/spec/spec/rails/matchers/should_change_spec.rb +0 -15
- data/spec/spec/rails/mocks/ar_classes.rb +0 -10
- data/spec/spec/rails/mocks/mock_model_spec.rb +0 -109
- data/spec/spec/rails/mocks/stub_model_spec.rb +0 -80
- data/spec/spec/rails/sample_modified_fixture.rb +0 -8
- data/spec/spec/rails/sample_spec.rb +0 -8
- data/spec/spec/rails/spec_spec.rb +0 -11
- data/spec/spec_helper.rb +0 -78
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
require 'rack/utils'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module Rails
|
|
5
|
-
module Matchers
|
|
6
|
-
USAGE = ArgumentError.new( 'usage: { :method => "path" }.should route_to( :controller => "controller", :action => "action", [ args ] )' )
|
|
7
|
-
|
|
8
|
-
class PathDecomposer
|
|
9
|
-
def self.decompose_path(path)
|
|
10
|
-
method, path = if Hash === path
|
|
11
|
-
raise USAGE if path.keys.size > 1
|
|
12
|
-
path.entries.first
|
|
13
|
-
else
|
|
14
|
-
[:get, path]
|
|
15
|
-
end
|
|
16
|
-
path, querystring = path.split('?')
|
|
17
|
-
return method, path, querystring
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
class RouteTo #:nodoc:
|
|
22
|
-
def initialize(expected, example)
|
|
23
|
-
@route, @example = expected,example
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def matches?(path)
|
|
27
|
-
begin
|
|
28
|
-
@actual = path
|
|
29
|
-
method, path, querystring = PathDecomposer.decompose_path(path)
|
|
30
|
-
params = querystring.blank? ? {} : Rack::Utils.parse_query(querystring).symbolize_keys!
|
|
31
|
-
@example.assert_routing({ :method => method, :path => path }, @route, {}, params)
|
|
32
|
-
true
|
|
33
|
-
rescue ActionController::RoutingError, ::Test::Unit::AssertionFailedError, ActionController::MethodNotAllowed => e
|
|
34
|
-
raise e.class, "#{e}\nIf you're expecting this failure, we suggest { :#{method} => \"#{path}\" }.should_not be_routable"
|
|
35
|
-
rescue Exception => e
|
|
36
|
-
raise e.class, "#{e}\n#{e.backtrace.join( "\n" )}"
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def does_not_match(path)
|
|
41
|
-
raise ArgumentError, "Don't test a negative route like this."
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def failure_message_for_should
|
|
45
|
-
"Expected #{@expected.inspect} to route to #{@actual.inspect}, but it didn't.\n"+
|
|
46
|
-
"In this case, we expected you to get an exception. So this message probably means something weird happened."
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def failure_message_for_should_not
|
|
50
|
-
"Expected a routing error, but the route passed instead. \nNote, when expecting routes to fail, you should use 'should_not be_routable' instead."
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def description
|
|
54
|
-
"route to #{@expected.inspect}"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
attr_reader :expected
|
|
59
|
-
attr_reader :actual
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# :call-seq:
|
|
64
|
-
# "path".should route_to(expected) # assumes GET
|
|
65
|
-
# { :get => "path" }.should route_to(expected)
|
|
66
|
-
# { :put => "path" }.should route_to(expected)
|
|
67
|
-
#
|
|
68
|
-
# Uses ActionController::Routing::Routes to verify that
|
|
69
|
-
# the path-and-method routes to a given set of options.
|
|
70
|
-
# Also verifies route-generation, so that the expected options
|
|
71
|
-
# do generate a pathname consisten with the indicated path/method.
|
|
72
|
-
#
|
|
73
|
-
# For negative tests, only the route recognition failure can be
|
|
74
|
-
# tested; since route generation via path_to() will always generate
|
|
75
|
-
# a path as requested. Use .should_not be_routable() in this case.
|
|
76
|
-
#
|
|
77
|
-
# == Examples
|
|
78
|
-
# { :get => '/registrations/1/edit' }.
|
|
79
|
-
# should route_to(:controller => 'registrations', :action => 'edit', :id => '1')
|
|
80
|
-
# { :put => "/registrations/1" }.should
|
|
81
|
-
# route_to(:controller => 'registrations', :action => 'update', :id => 1)
|
|
82
|
-
# { :post => "/registrations/" }.should
|
|
83
|
-
# route_to(:controller => 'registrations', :action => 'create')
|
|
84
|
-
|
|
85
|
-
def route_to(expected)
|
|
86
|
-
RouteTo.new(expected, self)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
class BeRoutable
|
|
90
|
-
def initialize(example)
|
|
91
|
-
@example = example
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def matches?(path)
|
|
95
|
-
begin
|
|
96
|
-
@actual = path
|
|
97
|
-
method, path = PathDecomposer.decompose_path(path)
|
|
98
|
-
@example.assert_recognizes({}, { :method => method, :path => path }, {} )
|
|
99
|
-
true
|
|
100
|
-
rescue ActionController::RoutingError, ActionController::MethodNotAllowed
|
|
101
|
-
false
|
|
102
|
-
rescue ::Test::Unit::AssertionFailedError => e
|
|
103
|
-
# the second thingy will always be "<{}>" becaues of the way we called assert_recognizes({}...) above.
|
|
104
|
-
e.to_s =~ /<(.*)> did not match <\{\}>/ and @actual_place = $1 or raise
|
|
105
|
-
true
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
def failure_message_for_should
|
|
109
|
-
"Expected '#{@actual.keys.first.to_s.upcase} #{@actual.values.first}' to be routable, but it wasn't.\n"+
|
|
110
|
-
"To really test routability, we recommend #{@actual.inspect}.\n"+
|
|
111
|
-
" should route_to( :action => 'action', :controller => 'controller' )\n\n"+
|
|
112
|
-
|
|
113
|
-
"That way, you'll verify where your route goes to. Plus, we'll verify\n"+
|
|
114
|
-
"the generation of the expected path from the action/controller, as in\n"+
|
|
115
|
-
"the url_for() helper."
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def failure_message_for_should_not
|
|
119
|
-
"Expected '#{@actual.keys.first.to_s.upcase} #{@actual.values.first}' to fail, but it routed to #{@actual_place} instead"
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
end
|
|
123
|
-
# :call-seq:
|
|
124
|
-
# { "path" }.should_not be_routable # assumes GET
|
|
125
|
-
# { :get => "path" }.should_not be_routable
|
|
126
|
-
# { :put => "path" }.should_not be_routable
|
|
127
|
-
#
|
|
128
|
-
# Uses ActionController::Routing::Routes to verify that
|
|
129
|
-
# the path-and-method cannot be routed to a controller.
|
|
130
|
-
# Since url_for() will always generate a path, even if that
|
|
131
|
-
# path is not routable, the negative test only needs to be
|
|
132
|
-
# performed on the route recognition.
|
|
133
|
-
#
|
|
134
|
-
# Don't use this matcher for testing expected routability -
|
|
135
|
-
# use .should route_to( :controller => "controller", :action => "action" ) instead
|
|
136
|
-
#
|
|
137
|
-
# == Examples
|
|
138
|
-
# { :get => '/registrations/1/attendees/3/edit' }.should_not be_routable
|
|
139
|
-
# { :get => '/attendees/3/edit' }.should route_to( ...<controller/action>... )
|
|
140
|
-
|
|
141
|
-
def be_routable
|
|
142
|
-
BeRoutable.new(self)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
alias_method :be_routeable, :be_routable
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
data/lib/spec/rails/matchers.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Spec
|
|
2
|
-
module Rails
|
|
3
|
-
# Spec::Rails::Expectations::Matchers provides several expectation matchers
|
|
4
|
-
# intended to work with Rails components like models and responses. For example:
|
|
5
|
-
#
|
|
6
|
-
# response.should redirect_to("some/url") #redirect_to(url) is the matcher.
|
|
7
|
-
#
|
|
8
|
-
# In addition to those you see below, the arbitrary predicate feature of RSpec
|
|
9
|
-
# makes the following available as well:
|
|
10
|
-
#
|
|
11
|
-
# response.should be_success #passes if response.success?
|
|
12
|
-
# response.should be_redirect #passes if response.redirect?
|
|
13
|
-
#
|
|
14
|
-
# Note that many of these matchers are part of a wrapper of <tt>assert_select</tt>, so
|
|
15
|
-
# the documentation comes straight from that with some slight modifications.
|
|
16
|
-
# <tt>assert_select</tt> is a Test::Unit extension originally contributed to the
|
|
17
|
-
# Rails community as a plugin by Assaf Arkin and eventually shipped as part of Rails.
|
|
18
|
-
#
|
|
19
|
-
# For more info on <tt>assert_select</tt>, see the relevant Rails documentation.
|
|
20
|
-
module Matchers
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
require 'spec/rails/matchers/ar_be_valid'
|
|
26
|
-
require 'spec/rails/matchers/assert_select'
|
|
27
|
-
require 'spec/rails/matchers/change'
|
|
28
|
-
require 'spec/rails/matchers/have_text'
|
|
29
|
-
require 'spec/rails/matchers/include_text'
|
|
30
|
-
require 'spec/rails/matchers/redirect_to'
|
|
31
|
-
require 'spec/rails/matchers/route_to'
|
|
32
|
-
require 'spec/rails/matchers/render_template'
|
data/lib/spec/rails/mocks.rb
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
module Spec
|
|
2
|
-
module Rails
|
|
3
|
-
|
|
4
|
-
class IllegalDataAccessException < StandardError; end
|
|
5
|
-
|
|
6
|
-
module Mocks
|
|
7
|
-
|
|
8
|
-
# Creates a mock object instance for a +model_class+ with common
|
|
9
|
-
# methods stubbed out. Additional methods may be easily stubbed (via
|
|
10
|
-
# add_stubs) if +stubs+ is passed.
|
|
11
|
-
def mock_model(model_class, options_and_stubs = {})
|
|
12
|
-
id = options_and_stubs[:id] || next_id
|
|
13
|
-
options_and_stubs = options_and_stubs.reverse_merge({
|
|
14
|
-
:id => id,
|
|
15
|
-
:to_param => id.to_s,
|
|
16
|
-
:new_record? => false,
|
|
17
|
-
:destroyed? => false,
|
|
18
|
-
:errors => stub("errors", :count => 0)
|
|
19
|
-
})
|
|
20
|
-
m = mock("#{model_class.name}_#{id}", options_and_stubs)
|
|
21
|
-
m.__send__(:__mock_proxy).instance_eval <<-CODE
|
|
22
|
-
def @target.as_new_record
|
|
23
|
-
self.stub!(:id).and_return nil
|
|
24
|
-
self.stub!(:to_param).and_return nil
|
|
25
|
-
self.stub!(:new_record?).and_return true
|
|
26
|
-
self
|
|
27
|
-
end
|
|
28
|
-
def @target.is_a?(other)
|
|
29
|
-
#{model_class}.ancestors.include?(other)
|
|
30
|
-
end
|
|
31
|
-
def @target.kind_of?(other)
|
|
32
|
-
#{model_class}.ancestors.include?(other)
|
|
33
|
-
end
|
|
34
|
-
def @target.instance_of?(other)
|
|
35
|
-
other == #{model_class}
|
|
36
|
-
end
|
|
37
|
-
def @target.class
|
|
38
|
-
#{model_class}
|
|
39
|
-
end
|
|
40
|
-
CODE
|
|
41
|
-
yield m if block_given?
|
|
42
|
-
m
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
module ModelStubber
|
|
46
|
-
def connection
|
|
47
|
-
raise Spec::Rails::IllegalDataAccessException.new("stubbed models are not allowed to access the database")
|
|
48
|
-
end
|
|
49
|
-
def new_record?
|
|
50
|
-
id.nil?
|
|
51
|
-
end
|
|
52
|
-
def as_new_record
|
|
53
|
-
self.id = nil
|
|
54
|
-
self
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# :call-seq:
|
|
59
|
-
# stub_model(Model)
|
|
60
|
-
# stub_model(Model).as_new_record
|
|
61
|
-
# stub_model(Model, hash_of_stubs)
|
|
62
|
-
# stub_model(Model, instance_variable_name, hash_of_stubs)
|
|
63
|
-
#
|
|
64
|
-
# Creates an instance of +Model+ that is prohibited from accessing the
|
|
65
|
-
# database*. For each key in +hash_of_stubs+, if the model has a
|
|
66
|
-
# matching attribute (determined by asking it) are simply assigned the
|
|
67
|
-
# submitted values. If the model does not have a matching attribute, the
|
|
68
|
-
# key/value pair is assigned as a stub return value using RSpec's
|
|
69
|
-
# mocking/stubbing framework.
|
|
70
|
-
#
|
|
71
|
-
# <tt>new_record?</tt> is overridden to return the result of id.nil?
|
|
72
|
-
# This means that by default new_record? will return false. If you want
|
|
73
|
-
# the object to behave as a new record, sending it +as_new_record+ will
|
|
74
|
-
# set the id to nil. You can also explicitly set :id => nil, in which
|
|
75
|
-
# case new_record? will return true, but using +as_new_record+ makes the
|
|
76
|
-
# example a bit more descriptive.
|
|
77
|
-
#
|
|
78
|
-
# While you can use stub_model in any example (model, view, controller,
|
|
79
|
-
# helper), it is especially useful in view examples, which are
|
|
80
|
-
# inherently more state-based than interaction-based.
|
|
81
|
-
#
|
|
82
|
-
# == Database Independence
|
|
83
|
-
#
|
|
84
|
-
# +stub_model+ does not make your examples entirely
|
|
85
|
-
# database-independent. It does not stop the model class itself from
|
|
86
|
-
# loading up its columns from the database. It just prevents data access
|
|
87
|
-
# from the object itself. To completely decouple from the database, take
|
|
88
|
-
# a look at libraries like unit_record or NullDB.
|
|
89
|
-
#
|
|
90
|
-
# == Examples
|
|
91
|
-
#
|
|
92
|
-
# stub_model(Person)
|
|
93
|
-
# stub_model(Person).as_new_record
|
|
94
|
-
# stub_model(Person, :id => 37)
|
|
95
|
-
# stub_model(Person) do |person|
|
|
96
|
-
# person.first_name = "David"
|
|
97
|
-
# end
|
|
98
|
-
def stub_model(model_class, stubs={})
|
|
99
|
-
stubs = {:id => next_id}.merge(stubs)
|
|
100
|
-
returning model_class.new do |model|
|
|
101
|
-
model.id = stubs.delete(:id)
|
|
102
|
-
model.extend ModelStubber
|
|
103
|
-
stubs.each do |k,v|
|
|
104
|
-
if model.has_attribute?(k)
|
|
105
|
-
model[k] = stubs.delete(k)
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
model.stub!(stubs)
|
|
109
|
-
yield model if block_given?
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# DEPRECATED - use object.stub!(:method => value, :method2 => value)
|
|
114
|
-
#
|
|
115
|
-
# Stubs methods on +object+ (if +object+ is a symbol or string a new mock
|
|
116
|
-
# with that name will be created). +stubs+ is a Hash of +method=>value+
|
|
117
|
-
def add_stubs(object, stubs = {}) #:nodoc:
|
|
118
|
-
Kernel.warn <<-WARNING
|
|
119
|
-
DEPRECATION NOTICE: add_stubs is deprecated and will be removed
|
|
120
|
-
from a future version of rspec-rails. Use this instead:
|
|
121
|
-
|
|
122
|
-
object.stub!(:method => value, :method2 => value)
|
|
123
|
-
|
|
124
|
-
WARNING
|
|
125
|
-
object.stub!(stubs)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
private
|
|
129
|
-
@@model_id = 1000
|
|
130
|
-
def next_id
|
|
131
|
-
@@model_id += 1
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
data/lib/spec/rails/version.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module Spec # :nodoc:
|
|
2
|
-
module Rails # :nodoc:
|
|
3
|
-
module VERSION # :nodoc:
|
|
4
|
-
unless defined? MAJOR
|
|
5
|
-
MAJOR = 1
|
|
6
|
-
MINOR = 3
|
|
7
|
-
TINY = 2
|
|
8
|
-
PRE = nil
|
|
9
|
-
|
|
10
|
-
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
|
11
|
-
|
|
12
|
-
SUMMARY = "rspec-rails #{STRING}"
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
data/lib/spec/rails.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require_dependency 'application_controller'
|
|
3
|
-
rescue MissingSourceFile
|
|
4
|
-
require_dependency 'application'
|
|
5
|
-
end
|
|
6
|
-
require 'rack/utils'
|
|
7
|
-
|
|
8
|
-
require 'action_controller/test_process'
|
|
9
|
-
require 'action_controller/integration'
|
|
10
|
-
require 'active_support/test_case'
|
|
11
|
-
require 'active_record/fixtures' if defined?(ActiveRecord::Base)
|
|
12
|
-
|
|
13
|
-
require 'spec/test/unit'
|
|
14
|
-
|
|
15
|
-
require 'spec/rails/matchers'
|
|
16
|
-
require 'spec/rails/mocks'
|
|
17
|
-
require 'spec/rails/example'
|
|
18
|
-
require 'spec/rails/extensions'
|
|
19
|
-
require 'spec/rails/interop/testcase'
|
|
20
|
-
|
|
21
|
-
Spec::Example::ExampleGroupFactory.default(ActiveSupport::TestCase)
|
|
22
|
-
|
|
23
|
-
if ActionView::Base.respond_to?(:cache_template_extensions)
|
|
24
|
-
ActionView::Base.cache_template_extensions = false
|
|
25
|
-
end
|
|
26
|
-
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require File.dirname(__FILE__) + '/../../lib/autotest/rails_rspec'
|
|
3
|
-
require File.dirname(__FILE__) + '/../../../rspec/spec/autotest/autotest_matchers'
|
|
4
|
-
|
|
5
|
-
describe Autotest::RailsRspec, "file mapping" do
|
|
6
|
-
before(:each) do
|
|
7
|
-
@autotest = Autotest::RailsRspec.new
|
|
8
|
-
@autotest.hook :initialize
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should map model example to model" do
|
|
12
|
-
@autotest.should map_specs(['spec/models/thing_spec.rb']).
|
|
13
|
-
to('app/models/thing.rb')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should map controller example to controller" do
|
|
17
|
-
@autotest.should map_specs(['spec/controllers/things_controller_spec.rb']).
|
|
18
|
-
to('app/controllers/things_controller.rb')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should map view.rhtml" do
|
|
22
|
-
@autotest.should map_specs(['spec/views/things/index.rhtml_spec.rb']).
|
|
23
|
-
to('app/views/things/index.rhtml')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should map view.rhtml with underscores in example filename" do
|
|
27
|
-
@autotest.should map_specs(['spec/views/things/index_rhtml_spec.rb']).
|
|
28
|
-
to('app/views/things/index.rhtml')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should map view.html.erb" do
|
|
32
|
-
@autotest.should map_specs(['spec/views/things/index.html.erb_spec.rb']).
|
|
33
|
-
to('app/views/things/index.html.erb')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe "between routes.rb and things which depend on routes" do
|
|
37
|
-
it "should map routes.rb to controllers" do
|
|
38
|
-
@autotest.should map_specs(['spec/controllers/things_controller_spec.rb']).
|
|
39
|
-
to('config/routes.rb')
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "should map routes.rb to views" do
|
|
43
|
-
@autotest.should map_specs(['spec/views/things/action.html.erb_spec.rb']).
|
|
44
|
-
to('config/routes.rb')
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "should map routes.rb to helpers" do
|
|
48
|
-
@autotest.should map_specs(['spec/helpers/things_helper_spec.rb']).
|
|
49
|
-
to('config/routes.rb')
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "should map routing example to routes" do
|
|
53
|
-
@autotest.should map_specs(['spec/routing/thing_spec.rb']).
|
|
54
|
-
to('config/routes.rb')
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
describe "between the config and specs" do
|
|
59
|
-
['spec/controllers/things_controller_spec.rb',
|
|
60
|
-
'spec/views/things/action.html.erb_spec.rb',
|
|
61
|
-
'spec/helpers/things_helper_spec.rb',
|
|
62
|
-
'spec/routing/thing_spec.rb',
|
|
63
|
-
'spec/models/thing_spec.rb'].each do |file_path|
|
|
64
|
-
|
|
65
|
-
it "should map environment.rb to #{file_path}" do
|
|
66
|
-
@autotest.should map_specs([file_path]).
|
|
67
|
-
to('config/environment.rb')
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "should map environments/test.rb to #{file_path}" do
|
|
71
|
-
@autotest.should map_specs([file_path]).
|
|
72
|
-
to('config/environments/test.rb')
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "should map boot.rb to #{file_path}" do
|
|
76
|
-
@autotest.should map_specs([file_path]).
|
|
77
|
-
to('config/boot.rb')
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "should map spec_helper.rb to #{file_path}" do
|
|
81
|
-
@autotest.should map_specs([file_path]).
|
|
82
|
-
to('spec/spec_helper.rb')
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
data/spec/rails_suite.rb
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
class ControllerSpecController < ActionController::Base
|
|
2
|
-
before_filter :raise_error, :only => :action_with_skipped_before_filter
|
|
3
|
-
|
|
4
|
-
def raise_error
|
|
5
|
-
raise "from a before filter"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
skip_before_filter :raise_error
|
|
9
|
-
|
|
10
|
-
prepend_view_path File.join(File.dirname(__FILE__), "..", "views")
|
|
11
|
-
|
|
12
|
-
def some_action
|
|
13
|
-
render :template => "template/that/does/not/actually/exist"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def some_action_with_implied_template
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def action_with_template
|
|
20
|
-
render :template => "controller_spec/action_with_template"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def action_which_sets_flash
|
|
24
|
-
flash[:flash_key] = "flash value"
|
|
25
|
-
render :text => ""
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def action_which_gets_session
|
|
29
|
-
raise "expected #{params[:session_key].inspect}\ngot #{session[:session_key].inspect}" unless (session[:session_key] == params[:expected])
|
|
30
|
-
render :text => ""
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def action_which_sets_session
|
|
34
|
-
session[:session_key] = "session value"
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def action_which_gets_cookie
|
|
38
|
-
raise "expected #{params[:expected].inspect}, got #{cookies[:cookie_key].inspect}" unless (cookies[:cookie_key] == params[:expected])
|
|
39
|
-
render :text => ""
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def action_which_sets_cookie
|
|
43
|
-
cookies['cookie_key'] = params[:value]
|
|
44
|
-
render :text => ""
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def action_with_partial
|
|
48
|
-
render :partial => "controller_spec/partial"
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def action_with_partial_with_object
|
|
52
|
-
render :partial => "controller_spec/partial", :object => params[:thing]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def action_with_partial_with_locals
|
|
56
|
-
render :partial => "controller_spec/partial", :locals => {:thing => params[:thing]}
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def action_with_errors_in_template
|
|
60
|
-
render :template => "controller_spec/action_with_errors_in_template"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def action_setting_the_assigns_hash
|
|
64
|
-
@indirect_assigns_key = :indirect_assigns_key_value
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def action_setting_flash_after_session_reset
|
|
68
|
-
reset_session
|
|
69
|
-
flash[:after_reset] = "available"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def action_setting_flash_before_session_reset
|
|
73
|
-
flash[:before_reset] = 'available'
|
|
74
|
-
reset_session
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def action_with_render_update
|
|
78
|
-
render :update do |page|
|
|
79
|
-
page.replace :bottom, 'replace_me',
|
|
80
|
-
:partial => 'non_existent_partial'
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def action_with_skipped_before_filter
|
|
85
|
-
render :text => ""
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def action_that_renders_inline
|
|
89
|
-
render :inline => "<%= 'inline code' %>"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def action_that_assigns_false_to_a_variable
|
|
93
|
-
@a_variable = false
|
|
94
|
-
render :text => ""
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def action_with_two_arg_render
|
|
98
|
-
render :update, :status => 404 do |page|
|
|
99
|
-
page.visual_effect :highlight, 'user_list'
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
class RescuedError < Exception; end
|
|
104
|
-
class UnRescuedError < Exception; end
|
|
105
|
-
|
|
106
|
-
rescue_from RescuedError do |e|
|
|
107
|
-
render :text => 'Rescued!'
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def rescued_error_action
|
|
111
|
-
raise ControllerSpecController::RescuedError
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def un_rescued_error_action
|
|
115
|
-
raise ControllerSpecController::UnRescuedError
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def action_that_returns_headers
|
|
119
|
-
render :text => request.headers[params[:header]]
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
class ControllerInheritingFromApplicationControllerController < ApplicationController
|
|
124
|
-
def action_with_inherited_before_filter
|
|
125
|
-
render :text => ""
|
|
126
|
-
end
|
|
127
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This is an example file to download.
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
class RedirectSpecController < ApplicationController
|
|
2
|
-
|
|
3
|
-
def action_with_no_redirect
|
|
4
|
-
render :text => "this is just here to keep this from causing a MissingTemplate error"
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def action_with_redirect_to_somewhere
|
|
8
|
-
redirect_to :action => 'somewhere'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def action_with_redirect_to_other_somewhere
|
|
12
|
-
redirect_to :controller => 'render_spec', :action => 'text_action'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def action_with_redirect_to_somewhere_and_return
|
|
16
|
-
redirect_to :action => 'somewhere' and return
|
|
17
|
-
render :text => "this is after the return"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def somewhere
|
|
21
|
-
render :text => "this is just here to keep this from causing a MissingTemplate error"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def action_with_redirect_to_rspec_site
|
|
25
|
-
redirect_to "http://rspec.rubyforge.org"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def action_with_redirect_back
|
|
29
|
-
redirect_to :back
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def action_with_redirect_in_respond_to
|
|
33
|
-
respond_to do |wants|
|
|
34
|
-
wants.html { redirect_to :action => 'somewhere' }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def action_with_redirect_which_creates_query_string
|
|
39
|
-
redirect_to :action => "somewhere", :id => 1111, :param1 => "value1", :param2 => "value2"
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# note: sometimes this is the URL which rails will generate from the hash in
|
|
43
|
-
# action_with_redirect_which_creates_query_string
|
|
44
|
-
def action_with_redirect_with_query_string_order1
|
|
45
|
-
redirect_to "http://test.host/redirect_spec/somewhere/1111?param1=value1¶m2=value2"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# note: sometimes this is the URL which rails will generate from the hash in
|
|
49
|
-
# action_with_redirect_which_creates_query_string
|
|
50
|
-
def action_with_redirect_with_query_string_order2
|
|
51
|
-
redirect_to "http://test.host/redirect_spec/somewhere/1111?param2=value2¶m1=value1"
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def action_with_redirect_to_unroutable_url_inside_app
|
|
55
|
-
redirect_to :controller => "nonexistant", :action => "none"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def action_with_method_restriction
|
|
59
|
-
render :text => ''
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def action_to_redirect_to_action_with_method_restriction
|
|
63
|
-
redirect_to :action => 'action_with_method_restriction'
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def action_with_redirect_to_somewhere_with_status
|
|
67
|
-
redirect_to :action => 'somewhere', :status => 301
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|