rspec-rails 1.3.2 → 6.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +1286 -0
- data/LICENSE.md +25 -0
- data/README.md +381 -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 +84 -0
- data/lib/generators/rspec/integration/integration_generator.rb +29 -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 +160 -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 +153 -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 +25 -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 +172 -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 +89 -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 +465 -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 +227 -0
- data/lib/rspec/rails/matchers/have_http_status.rb +385 -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 +47 -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 +80 -0
- data.tar.gz.sig +2 -0
- metadata +308 -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,346 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "A template with an implicit helper", :type => :view do
|
4
|
-
before(:each) do
|
5
|
-
render "view_spec/implicit_helper"
|
6
|
-
end
|
7
|
-
|
8
|
-
accesses_configured_helper_methods
|
9
|
-
|
10
|
-
it "should include the helper" do
|
11
|
-
response.should have_tag('div', :content => "This is text from a method in the ViewSpecHelper")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should include the application helper" do
|
15
|
-
response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should have access to named routes" do
|
19
|
-
rspec_on_rails_specs_url.should == "http://test.host/rspec_on_rails_specs"
|
20
|
-
rspec_on_rails_specs_path.should == "/rspec_on_rails_specs"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "A template requiring an explicit helper", :type => :view do
|
25
|
-
before(:each) do
|
26
|
-
render "view_spec/explicit_helper", :helper => 'explicit'
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should include the helper if specified" do
|
30
|
-
response.should have_tag('div', :content => "This is text from a method in the ExplicitHelper")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should include the application helper" do
|
34
|
-
response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "A template requiring multiple explicit helpers", :type => :view do
|
39
|
-
before(:each) do
|
40
|
-
render "view_spec/multiple_helpers", :helpers => ['explicit', 'more_explicit']
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should include all specified helpers" do
|
44
|
-
response.should have_tag('div', :content => "This is text from a method in the ExplicitHelper")
|
45
|
-
response.should have_tag('div', :content => "This is text from a method in the MoreExplicitHelper")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should include the application helper" do
|
49
|
-
response.should have_tag('div', :content => "This is text from a method in the ApplicationHelper")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "Message Expectations on helper methods", :type => :view do
|
54
|
-
it "should work" do
|
55
|
-
template.should_receive(:method_in_plugin_application_helper).and_return('alternate message 1')
|
56
|
-
render "view_spec/implicit_helper"
|
57
|
-
response.body.should =~ /alternate message 1/
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should work twice" do
|
61
|
-
template.should_receive(:method_in_plugin_application_helper).and_return('alternate message 2')
|
62
|
-
render "view_spec/implicit_helper"
|
63
|
-
response.body.should =~ /alternate message 2/
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "A template that includes a partial", :type => :view do
|
68
|
-
def render!
|
69
|
-
render "view_spec/template_with_partial"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should render the enclosing template" do
|
73
|
-
render!
|
74
|
-
response.should have_tag('div', "method_in_partial in ViewSpecHelper")
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should render the partial" do
|
78
|
-
render!
|
79
|
-
response.should have_tag('div', "method_in_template_with_partial in ViewSpecHelper")
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should include the application helper" do
|
83
|
-
render!
|
84
|
-
response.should have_tag('div', "This is text from a method in the ApplicationHelper")
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should pass should_receive(:render) with the right partial" do
|
88
|
-
template.should_receive(:render).with(:partial => 'partial')
|
89
|
-
render!
|
90
|
-
template.verify_rendered
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should fail should_receive(:render) with the wrong partial" do
|
94
|
-
template.should_receive(:render).with(:partial => 'non_existent')
|
95
|
-
render!
|
96
|
-
begin
|
97
|
-
template.verify_rendered
|
98
|
-
rescue Spec::Mocks::MockExpectationError => e
|
99
|
-
ensure
|
100
|
-
e.backtrace.find{|line| line =~ /#{__FILE__}\:#{__LINE__ - 6}/}.should_not be_nil
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should pass should_receive(:render) when a partial is expected twice and happens twice" do
|
105
|
-
template.should_receive(:render).with(:partial => 'partial_used_twice').twice
|
106
|
-
render!
|
107
|
-
template.verify_rendered
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should pass should_receive(:render) when a partial is expected once and happens twice" do
|
111
|
-
template.should_receive(:render).with(:partial => 'partial_used_twice')
|
112
|
-
render!
|
113
|
-
begin
|
114
|
-
template.verify_rendered
|
115
|
-
rescue Spec::Mocks::MockExpectationError => e
|
116
|
-
ensure
|
117
|
-
e.backtrace.find{|line| line =~ /#{__FILE__}\:#{__LINE__ - 6}/}.should_not be_nil
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should fail should_receive(:render) with the right partial but wrong options" do
|
122
|
-
template.should_receive(:render).with(:partial => 'partial', :locals => {:thing => Object.new})
|
123
|
-
render!
|
124
|
-
lambda {template.verify_rendered}.should raise_error(Spec::Mocks::MockExpectationError)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "A partial that includes a partial", :type => :view do
|
129
|
-
it "should support should_receive(:render) with nested partial" do
|
130
|
-
obj = Object.new
|
131
|
-
template.should_receive(:render).with(:partial => 'partial', :object => obj)
|
132
|
-
render :partial => "view_spec/partial_with_sub_partial", :locals => { :partial => obj }
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe "A view that includes a partial using :collection and :spacer_template", :type => :view do
|
137
|
-
it "should render the partial w/ spacer_tamplate" do
|
138
|
-
render "view_spec/template_with_partial_using_collection"
|
139
|
-
response.should have_tag('div',/method_in_partial/)
|
140
|
-
response.should have_tag('div',/ApplicationHelper/)
|
141
|
-
response.should have_tag('div',/ViewSpecHelper/)
|
142
|
-
response.should have_tag('hr#spacer')
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should render the partial" do
|
146
|
-
template.should_receive(:render).with(:partial => 'partial',
|
147
|
-
:collection => ['Alice', 'Bob'],
|
148
|
-
:spacer_template => 'spacer')
|
149
|
-
render "view_spec/template_with_partial_using_collection"
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "A view that includes a partial using an array as partial_path", :type => :view do
|
155
|
-
before(:each) do
|
156
|
-
renderable_object = Object.new
|
157
|
-
renderable_object.stub!(:name).and_return("Renderable Object")
|
158
|
-
assigns[:array] = [renderable_object]
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should render the array passed through to render_partial without modification" do
|
162
|
-
render "view_spec/template_with_partial_with_array"
|
163
|
-
response.body.should match(/^Renderable Object$/)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe "Different types of renders (not :template)", :type => :view do
|
168
|
-
it "should render partial with local" do
|
169
|
-
render :partial => "view_spec/partial_with_local_variable", :locals => {:x => "Ender"}
|
170
|
-
response.should have_tag('div', :content => "Ender")
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
describe "A view", :type => :view do
|
175
|
-
before(:each) do
|
176
|
-
session[:key] = "session"
|
177
|
-
params[:key] = "params"
|
178
|
-
flash[:key] = "flash"
|
179
|
-
flash.now[:now_key] = "flash.now"
|
180
|
-
render "view_spec/accessor"
|
181
|
-
end
|
182
|
-
|
183
|
-
it "uses the template as the implicit subject" do
|
184
|
-
subject.should == template
|
185
|
-
end
|
186
|
-
|
187
|
-
it "has access to session data" do
|
188
|
-
response.should have_tag("div#session", "session")
|
189
|
-
end
|
190
|
-
|
191
|
-
it "has access to params data" do
|
192
|
-
response.should have_tag("div#params", "params")
|
193
|
-
end
|
194
|
-
|
195
|
-
it "has access to flash" do
|
196
|
-
response.should have_tag("div#flash", "flash")
|
197
|
-
end
|
198
|
-
|
199
|
-
it "has access to flash.now" do
|
200
|
-
response.should have_tag("div#flash_now", "flash.now")
|
201
|
-
end
|
202
|
-
|
203
|
-
it "has a controller param" do
|
204
|
-
response.should have_tag("div#controller", "view_spec")
|
205
|
-
end
|
206
|
-
|
207
|
-
it "has an action param" do
|
208
|
-
response.should have_tag("div#action", "accessor")
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "A view with a form_tag", :type => :view do
|
213
|
-
it "should render the right action" do
|
214
|
-
render "view_spec/entry_form"
|
215
|
-
response.should have_tag("form[action=?]","/view_spec/entry_form")
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "An instantiated ViewExampleGroupController", :type => :view do
|
220
|
-
before do
|
221
|
-
render "view_spec/foo/show"
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should return the name of the real controller that it replaces" do
|
225
|
-
@controller.controller_name.should == 'foo'
|
226
|
-
end
|
227
|
-
|
228
|
-
it "should return the path of the real controller that it replaces" do
|
229
|
-
@controller.controller_path.should == 'view_spec/foo'
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
describe "a block helper", :type => :view do
|
234
|
-
it "should not yield when not told to in the example" do
|
235
|
-
template.should_receive(:if_allowed)
|
236
|
-
render "view_spec/block_helper"
|
237
|
-
response.should_not have_tag("div","block helper was rendered")
|
238
|
-
end
|
239
|
-
|
240
|
-
it "should yield when told to in the example" do
|
241
|
-
template.should_receive(:if_allowed).and_yield
|
242
|
-
render "view_spec/block_helper"
|
243
|
-
response.should have_tag("div","block helper was rendered")
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe "render :inline => ...", :type => :view do
|
248
|
-
it "should render ERB right in the spec" do
|
249
|
-
render :inline => %|<%= text_field_tag('field_name', 'Value') %>|
|
250
|
-
response.should have_tag("input[type=?][name=?][value=?]","text","field_name","Value")
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe "render 'view_spec/foo/show'", :type => :view do
|
255
|
-
it "should derive action name using the first part of the template name" do
|
256
|
-
render 'view_spec/foo/show'
|
257
|
-
request.path_parameters[:action].should == 'show'
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
describe "view_spec/foo/show", :type => :view do
|
262
|
-
context "rendered with no args" do
|
263
|
-
it "renders just fine" do
|
264
|
-
render
|
265
|
-
request.path_parameters[:action].should == 'show'
|
266
|
-
end
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
describe "setting path parameters", :type => :view do
|
271
|
-
describe "(controller)" do
|
272
|
-
it "should supercede the default path parameters" do
|
273
|
-
render "view_spec/entry_form", :path_parameters => {:controller => 'foo'}
|
274
|
-
request.path_parameters[:controller].should == 'foo'
|
275
|
-
end
|
276
|
-
end
|
277
|
-
describe "(action)" do
|
278
|
-
it "should supercede the default path parameters" do
|
279
|
-
render "view_spec/entry_form", :path_parameters => {:action => 'foo'}
|
280
|
-
request.path_parameters[:action].should == 'foo'
|
281
|
-
end
|
282
|
-
end
|
283
|
-
describe "(something arbitrary)" do
|
284
|
-
it "should supercede the default path parameters" do
|
285
|
-
render "view_spec/entry_form", :path_parameters => {:foo => 'bar'}
|
286
|
-
request.path_parameters[:foo].should == 'bar'
|
287
|
-
end
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
describe "route helpers", :type => :view do
|
292
|
-
it "should be available before render is called" do
|
293
|
-
custom_route_path.should == '/custom_route'
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
module Spec
|
298
|
-
module Rails
|
299
|
-
module Example
|
300
|
-
describe ViewExampleGroup do
|
301
|
-
it "should clear its name from the description" do
|
302
|
-
group = describe("foo", :type => :view) do
|
303
|
-
$nested_group = describe("bar") do
|
304
|
-
end
|
305
|
-
end
|
306
|
-
group.description.to_s.should == "foo"
|
307
|
-
$nested_group.description.to_s.should == "foo bar"
|
308
|
-
end
|
309
|
-
|
310
|
-
it "should clear ActionView::Base.base_view_path on teardown" do
|
311
|
-
group = describe("base_view_path_cleared flag", :type => :view) {}
|
312
|
-
example = group.new(Spec::Example::ExampleProxy.new) {}
|
313
|
-
|
314
|
-
ActionView::Base.should_receive(:base_view_path=).with(nil)
|
315
|
-
example.run_after_each
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
describe "bug http://rspec.lighthouseapp.com/projects/5645/tickets/510", :type => :view do
|
323
|
-
describe "a view example with should_not_receive" do
|
324
|
-
it "should render the view" do
|
325
|
-
obj = mock('model')
|
326
|
-
obj.should_receive(:render_partial?).and_return false
|
327
|
-
assigns[:obj] = obj
|
328
|
-
template.should_not_receive(:render).with(:partial => 'some_partial')
|
329
|
-
render "view_spec/should_not_receive"
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
describe "bug https://rspec.lighthouseapp.com/projects/5645/tickets/787", :type => :view do
|
335
|
-
describe "a view example checking a link" do
|
336
|
-
it "should have access to link_to" do
|
337
|
-
render "view_spec/view_helpers"
|
338
|
-
response.body.should include(link_to("edit", "this_is_the_link"))
|
339
|
-
end
|
340
|
-
|
341
|
-
it "should use link_to within have_tag" do
|
342
|
-
render "view_spec/view_helpers"
|
343
|
-
response.body.should have_tag("span", :html => link_to("edit", "this_is_the_link"))
|
344
|
-
end
|
345
|
-
end
|
346
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'spec/mocks/errors'
|
3
|
-
|
4
|
-
describe ActionView::Base, "with RSpec extensions:", :type => :view do
|
5
|
-
|
6
|
-
describe "should_receive(:render)" do
|
7
|
-
it "should not raise when render has been received" do
|
8
|
-
template.should_receive(:render).with(:partial => "name")
|
9
|
-
template.render :partial => "name"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should raise when render has NOT been received" do
|
13
|
-
template.should_receive(:render).with(:partial => "name")
|
14
|
-
lambda {
|
15
|
-
template.verify_rendered
|
16
|
-
}.should raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should return something (like a normal mock)" do
|
20
|
-
template.should_receive(:render).with(:partial => "name").and_return("Little Johnny")
|
21
|
-
result = template.render :partial => "name"
|
22
|
-
result.should == "Little Johnny"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
[:stub!, :stub].each do |method|
|
27
|
-
describe "#{method}(:render)" do
|
28
|
-
it "should not raise when stubbing and render has been received" do
|
29
|
-
template.send(method, :render).with(:partial => "name")
|
30
|
-
template.render :partial => "name"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should not raise when stubbing and render has NOT been received" do
|
34
|
-
template.send(method, :render).with(:partial => "name")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should not raise when stubbing and render has been received with different options" do
|
38
|
-
template.send(method, :render).with(:partial => "name")
|
39
|
-
template.render :partial => "view_spec/spacer"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should not raise when stubbing and expecting and render has been received" do
|
43
|
-
template.send(method, :render).with(:partial => "name")
|
44
|
-
template.should_receive(:render).with(:partial => "name")
|
45
|
-
template.render(:partial => "name")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#{method}(:helper_method)" do
|
50
|
-
it "should not raise when stubbing and helper_method has been received" do
|
51
|
-
template.send(method, :helper_method).with(:arg => "value")
|
52
|
-
template.helper_method :arg => "value"
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should not raise when stubbing and helper_method has NOT been received" do
|
56
|
-
template.send(method, :helper_method).with(:arg => "value")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "SHOULD raise when stubbing and helper_method has been received with different options" do
|
60
|
-
template.send(method, :helper_method).with(:arg => "value")
|
61
|
-
expect { template.helper_method :arg => "other_value" }.
|
62
|
-
to raise_error(/undefined .* `helper_method'/)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should not raise when stubbing and expecting and helper_method has been received" do
|
66
|
-
template.send(method, :helper_method).with(:arg => "value")
|
67
|
-
template.should_receive(:helper_method).with(:arg => "value")
|
68
|
-
template.helper_method(:arg => "value")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "A model" do
|
4
|
-
fixtures :things
|
5
|
-
it "should tell you its required fields" do
|
6
|
-
Thing.new.should have(1).error_on(:name)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should tell you how many records it has" do
|
10
|
-
Thing.should have(:no).records
|
11
|
-
Thing.create(:name => "THE THING")
|
12
|
-
Thing.should have(1).record
|
13
|
-
end
|
14
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(ActiveSupport::Callbacks)
|
5
|
-
|
6
|
-
class TestUnitTesting < Test::Unit::TestCase
|
7
|
-
@@setup_callback_count = 0
|
8
|
-
@@setup_method_count = 0
|
9
|
-
@@teardown_callback_count = 0
|
10
|
-
@@teardown_method_count = 0
|
11
|
-
cattr_accessor :setup_callback_count, :setup_method_count, :teardown_callback_count, :teardown_method_count
|
12
|
-
|
13
|
-
setup :do_some_setup
|
14
|
-
teardown :do_some_teardown
|
15
|
-
|
16
|
-
@@has_been_run = false
|
17
|
-
def self.run?
|
18
|
-
@@has_been_run
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.run(options=Spec::Runner.options)
|
22
|
-
super options
|
23
|
-
end
|
24
|
-
|
25
|
-
def do_some_setup
|
26
|
-
@@setup_callback_count += 1
|
27
|
-
end
|
28
|
-
|
29
|
-
def setup
|
30
|
-
@@setup_method_count += 1
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_something
|
34
|
-
assert_equal true, true
|
35
|
-
@@has_been_run = true
|
36
|
-
end
|
37
|
-
|
38
|
-
def teardown
|
39
|
-
@@teardown_method_count += 1
|
40
|
-
end
|
41
|
-
|
42
|
-
def do_some_teardown
|
43
|
-
@@teardown_callback_count += 1
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
module Test
|
48
|
-
module Unit
|
49
|
-
describe "Running TestCase tests" do
|
50
|
-
before(:all) do
|
51
|
-
TestUnitTesting.run unless TestUnitTesting.run?
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should call the setup callbacks" do
|
55
|
-
TestUnitTesting.setup_callback_count.should == 1
|
56
|
-
end
|
57
|
-
it "should still only call the normal setup method once" do
|
58
|
-
TestUnitTesting.setup_method_count.should == 1
|
59
|
-
end
|
60
|
-
it "should call the teardown callbacks" do
|
61
|
-
TestUnitTesting.teardown_callback_count.should == 1
|
62
|
-
end
|
63
|
-
it "should still only call the normal teardown method once" do
|
64
|
-
TestUnitTesting.teardown_method_count.should == 1
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "be_valid" do
|
4
|
-
context "with valid attributes" do
|
5
|
-
it "returns true" do
|
6
|
-
be_valid.matches?(Thing.new(:name => 'thing')).should == true
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
context "with invalid attributes" do
|
11
|
-
it "returns false" do
|
12
|
-
be_valid.matches?(Thing.new).should == false
|
13
|
-
end
|
14
|
-
|
15
|
-
it "adds errors to the errors " do
|
16
|
-
expect { Thing.new.should be_valid }.to raise_error(/can't be blank/)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|