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
data/Upgrade.rdoc
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
= Upgrade to 1.2.8 - 1.3.2
|
|
2
|
-
|
|
3
|
-
== What's new
|
|
4
|
-
|
|
5
|
-
=== route_to and be_routable matchers
|
|
6
|
-
|
|
7
|
-
Stop using route_for and params_from today! These new matchers from Randy
|
|
8
|
-
Harmon are more expressive and more reliable. Here's how you use them:
|
|
9
|
-
|
|
10
|
-
{ :put => "/projects/37" }.should route_to(:controller => 'projects', :action => 'update', :id => '37')
|
|
11
|
-
|
|
12
|
-
{ :get => "/nonexisting_route" }.should_not be_routable
|
|
13
|
-
|
|
14
|
-
== What's changed
|
|
15
|
-
|
|
16
|
-
=== spec_server has been removed
|
|
17
|
-
|
|
18
|
-
spec_server was deprecated in 1.2.7 and has now been removed. Admittedly, this
|
|
19
|
-
was a short deprecation cycle, but spec server never quite worked right in all
|
|
20
|
-
situations and spork is a great solution that you can use today! This is all
|
|
21
|
-
you need to do:
|
|
22
|
-
|
|
23
|
-
[sudo] gem install spork
|
|
24
|
-
cd path/to/project
|
|
25
|
-
spork --bootsrap
|
|
26
|
-
|
|
27
|
-
Now open up spec/spec_helper.rb and follow the directions at the top. You'll
|
|
28
|
-
be up and running in no time.
|
|
29
|
-
|
|
30
|
-
For more info:
|
|
31
|
-
|
|
32
|
-
* http://github.com/timcharper/spork
|
|
33
|
-
* http://groups.google.com/group/sporkgem
|
|
34
|
-
|
|
35
|
-
= Upgrade to 1.2.7
|
|
36
|
-
|
|
37
|
-
== What's changed
|
|
38
|
-
|
|
39
|
-
=== spec_server is deprecated
|
|
40
|
-
|
|
41
|
-
spec_server is deprecated in favor of Tim Harper's new spork library
|
|
42
|
-
(http://github.com/timcharper/spork). Get it. Use it. Love it.
|
|
43
|
-
|
|
44
|
-
gem install spork
|
|
45
|
-
|
|
46
|
-
= Upgrade to 1.2.0-1.2.6
|
|
47
|
-
|
|
48
|
-
== What's changed
|
|
49
|
-
|
|
50
|
-
=== Supported Rails Versions
|
|
51
|
-
|
|
52
|
-
This release supports the following versions of rails:
|
|
53
|
-
|
|
54
|
-
* 2.0.5
|
|
55
|
-
* 2.1.2
|
|
56
|
-
* 2.2.2
|
|
57
|
-
* 2.3.2
|
|
58
|
-
|
|
59
|
-
=== update generated files
|
|
60
|
-
|
|
61
|
-
Be sure to run "script/generate rspec" and allow the following files to be overwritten:
|
|
62
|
-
|
|
63
|
-
* lib/tasks/rspec.rake
|
|
64
|
-
* script/spec
|
|
65
|
-
* script/spec_server
|
|
66
|
-
|
|
67
|
-
=== controller.use_rails_error_handling! is deprecated
|
|
68
|
-
|
|
69
|
-
Use <tt>rescue_action_in_public!</tt> instead. It comes directly from rails and does
|
|
70
|
-
exactly the same thing
|
|
71
|
-
|
|
72
|
-
=== route_for
|
|
73
|
-
|
|
74
|
-
After a change to edge rails broke our monkey-patched <tt>route_for</tt> method, I
|
|
75
|
-
decided to just delegate to rails' <tt>assert_generates</tt> method. For most cases,
|
|
76
|
-
this will not present a problem, but for some it might. You'll know if you
|
|
77
|
-
upgrade and see any newly failing, route-related examples. Here are the things
|
|
78
|
-
that you might need to change.
|
|
79
|
-
|
|
80
|
-
==== Make sure IDs are strings
|
|
81
|
-
|
|
82
|
-
If you had :id => 1 before, you need to change that to :id => "1"
|
|
83
|
-
|
|
84
|
-
#old
|
|
85
|
-
route_for(:controller => 'things', :action => 'show', :id => 1).should == "/things/1"
|
|
86
|
-
|
|
87
|
-
#new
|
|
88
|
-
route_for(:controller => 'things', :action => 'show', :id => "1").should == "/things/1"
|
|
89
|
-
|
|
90
|
-
==== Convert paths for non-get methods to hashes
|
|
91
|
-
|
|
92
|
-
If you had an example with a route that requires post, put, or delete, you'll
|
|
93
|
-
need to declare that explicitly.
|
|
94
|
-
|
|
95
|
-
#old
|
|
96
|
-
route_for(:controller => 'things', :action => 'create').should == "/things"
|
|
97
|
-
|
|
98
|
-
#new
|
|
99
|
-
route_for(:controller => 'things', :action => 'create').should == {:path => "/things", :method => :post}
|
|
100
|
-
|
|
101
|
-
=== Controller/template isolation
|
|
102
|
-
|
|
103
|
-
Even though controller specs do not render views by default (use
|
|
104
|
-
<tt>integrate_views</tt> to get them to render views), the way this works has
|
|
105
|
-
changed in this version.
|
|
106
|
-
|
|
107
|
-
It used to be that the view template need not even exist, but due to changes
|
|
108
|
-
in rails it became much more difficult to manage that for all the different
|
|
109
|
-
versions of rails that rspec-rails supports. So now the template must exist,
|
|
110
|
-
but it still won't be rendered unless you declare <tt>integrate_views</tt>.
|
|
111
|
-
|
|
112
|
-
== What's new
|
|
113
|
-
|
|
114
|
-
=== render no longer requires a path
|
|
115
|
-
|
|
116
|
-
The <tt>render()</tt> method in view specs will infer the path from the
|
|
117
|
-
first argument passed to <tt>describe()</tt>.
|
|
118
|
-
|
|
119
|
-
describe "players/show" do
|
|
120
|
-
it "does something" do
|
|
121
|
-
render
|
|
122
|
-
response.should have_tag("....")
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
=== routing specs live in spec/routing
|
|
127
|
-
|
|
128
|
-
<tt>script/generate rspec_scaffold</tt> now generates its routing spec in
|
|
129
|
-
<tt>spec/routing/</tt>.
|
|
130
|
-
|
|
131
|
-
=== bypass_rescue
|
|
132
|
-
|
|
133
|
-
Added a new <tt>bypass_rescue()</tt> declaration for controller specs. Use this
|
|
134
|
-
when you want to specify that an error is raised by an action, even if that
|
|
135
|
-
error is later captured by a <tt>rescue_from()</tt> declaration.
|
|
136
|
-
|
|
137
|
-
describe AccountController do
|
|
138
|
-
describe "GET @account" do
|
|
139
|
-
context "requested by anonymous user" do
|
|
140
|
-
it "denies access" do
|
|
141
|
-
bypass_rescue
|
|
142
|
-
lambda do
|
|
143
|
-
get :show, :id => "37"
|
|
144
|
-
end.should raise_error(AccessDenied)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../rspec_default_values'
|
|
2
|
-
|
|
3
|
-
class IntegrationSpecGenerator < ModelGenerator
|
|
4
|
-
def manifest
|
|
5
|
-
record do |m|
|
|
6
|
-
m.class_collisions class_path, class_name
|
|
7
|
-
m.template 'integration_spec.rb', File.join('spec/integration', class_path, "#{class_name.tableize}_spec.rb")
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
data/generators/rspec/CHANGES
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Please refer to the CHANGES file for RSpec's core
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require 'rbconfig'
|
|
2
|
-
|
|
3
|
-
# This generator bootstraps a Rails project for use with RSpec
|
|
4
|
-
class RspecGenerator < Rails::Generator::Base
|
|
5
|
-
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
|
6
|
-
Config::CONFIG['ruby_install_name'])
|
|
7
|
-
|
|
8
|
-
def initialize(runtime_args, runtime_options = {})
|
|
9
|
-
if test ?f, 'spec/spec_helper.rb'
|
|
10
|
-
|
|
11
|
-
puts <<-HELPFUL_INSTRUCTIONS
|
|
12
|
-
|
|
13
|
-
It looks like you are upgrading rspec-rails in this application. Please let
|
|
14
|
-
this script overwrite everything it wants to with the following exceptions,
|
|
15
|
-
*if* you have customized any of these files:
|
|
16
|
-
|
|
17
|
-
* spec/spec.opts
|
|
18
|
-
* spec/rcov.opts
|
|
19
|
-
* spec/spec_helper.rb
|
|
20
|
-
|
|
21
|
-
If you have customized spec/spec_helper.rb, please set aside a copy of that
|
|
22
|
-
file so that it can be updated and you can manually restore your changes.
|
|
23
|
-
|
|
24
|
-
HELPFUL_INSTRUCTIONS
|
|
25
|
-
end
|
|
26
|
-
Dir.mkdir('lib/tasks') unless File.directory?('lib/tasks')
|
|
27
|
-
|
|
28
|
-
if Rails::VERSION::STRING >= '2.1'
|
|
29
|
-
test_env = 'config/environments/test.rb'
|
|
30
|
-
contents = File.read(test_env)
|
|
31
|
-
unless contents =~ /config\.gem\s+(\"|\')rspec/m
|
|
32
|
-
puts "Configuring rspec and rspec-rails gems in #{test_env} ..."
|
|
33
|
-
puts
|
|
34
|
-
require File.expand_path('../../../lib/spec/rails/version.rb', __FILE__)
|
|
35
|
-
rspec_config = <<-EOF
|
|
36
|
-
config.gem 'rspec-rails', :version => '>= #{Spec::Rails::VERSION::STRING}', :lib => false unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
|
|
37
|
-
EOF
|
|
38
|
-
File.open(test_env, "wb") do |f|
|
|
39
|
-
f.puts contents
|
|
40
|
-
f.puts
|
|
41
|
-
f.puts rspec_config
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
super
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def manifest
|
|
50
|
-
record do |m|
|
|
51
|
-
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
|
|
52
|
-
|
|
53
|
-
m.directory 'lib/tasks'
|
|
54
|
-
m.file 'rspec.rake', 'lib/tasks/rspec.rake'
|
|
55
|
-
|
|
56
|
-
m.file 'script/autospec', 'script/autospec', script_options
|
|
57
|
-
m.file 'script/spec', 'script/spec', script_options
|
|
58
|
-
|
|
59
|
-
m.directory 'spec'
|
|
60
|
-
m.file 'rcov.opts', 'spec/rcov.opts'
|
|
61
|
-
m.file 'spec.opts', 'spec/spec.opts'
|
|
62
|
-
m.template 'spec_helper.rb', 'spec/spec_helper.rb'
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
protected
|
|
67
|
-
|
|
68
|
-
def banner
|
|
69
|
-
"Usage: #{$0} rspec"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
end
|
|
File without changes
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
|
2
|
-
rspec_gem_dir = nil
|
|
3
|
-
Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
|
|
4
|
-
rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
|
|
5
|
-
end
|
|
6
|
-
rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
|
|
7
|
-
|
|
8
|
-
if rspec_gem_dir && (test ?d, rspec_plugin_dir)
|
|
9
|
-
raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
if rspec_gem_dir
|
|
13
|
-
$LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
|
|
14
|
-
elsif File.exist?(rspec_plugin_dir)
|
|
15
|
-
$LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Don't load rspec if running "rake gems:*"
|
|
19
|
-
unless ARGV.any? {|a| a =~ /^gems/}
|
|
20
|
-
|
|
21
|
-
begin
|
|
22
|
-
require 'spec/rake/spectask'
|
|
23
|
-
rescue MissingSourceFile
|
|
24
|
-
module Spec
|
|
25
|
-
module Rake
|
|
26
|
-
class SpecTask
|
|
27
|
-
def initialize(name)
|
|
28
|
-
task name do
|
|
29
|
-
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
|
30
|
-
require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment"))
|
|
31
|
-
|
|
32
|
-
# ... otherwise, do this:
|
|
33
|
-
raise <<-MSG
|
|
34
|
-
|
|
35
|
-
#{"*" * 80}
|
|
36
|
-
* You are trying to run an rspec rake task defined in
|
|
37
|
-
* #{__FILE__},
|
|
38
|
-
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
|
39
|
-
#{"*" * 80}
|
|
40
|
-
MSG
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
Rake.application.instance_variable_get('@tasks').delete('default')
|
|
49
|
-
|
|
50
|
-
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
|
51
|
-
task :noop do
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
task :default => :spec
|
|
55
|
-
task :stats => "spec:statsetup"
|
|
56
|
-
|
|
57
|
-
desc "Run all specs in spec directory (excluding plugin specs)"
|
|
58
|
-
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
|
59
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
|
60
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
namespace :spec do
|
|
64
|
-
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
|
65
|
-
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
66
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
|
67
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
68
|
-
t.rcov = true
|
|
69
|
-
t.rcov_opts = lambda do
|
|
70
|
-
IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
desc "Print Specdoc for all specs (excluding plugin specs)"
|
|
75
|
-
Spec::Rake::SpecTask.new(:doc) do |t|
|
|
76
|
-
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
|
77
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
desc "Print Specdoc for all plugin examples"
|
|
81
|
-
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
|
82
|
-
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
|
83
|
-
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
[:models, :controllers, :views, :helpers, :lib, :integration].each do |sub|
|
|
87
|
-
desc "Run the code examples in spec/#{sub}"
|
|
88
|
-
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
|
89
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
|
90
|
-
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
|
95
|
-
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
|
|
96
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
|
97
|
-
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
namespace :plugins do
|
|
101
|
-
desc "Runs the examples for rspec_on_rails"
|
|
102
|
-
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
|
103
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
|
104
|
-
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# Setup specs for stats
|
|
109
|
-
task :statsetup do
|
|
110
|
-
require 'code_statistics'
|
|
111
|
-
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
|
112
|
-
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
|
113
|
-
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
|
114
|
-
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
|
115
|
-
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
|
116
|
-
::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
|
|
117
|
-
::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration')
|
|
118
|
-
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
|
119
|
-
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
|
120
|
-
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
|
121
|
-
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
|
122
|
-
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
|
123
|
-
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
|
124
|
-
::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration')
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
namespace :db do
|
|
128
|
-
namespace :fixtures do
|
|
129
|
-
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
|
|
130
|
-
task :load => :environment do
|
|
131
|
-
ActiveRecord::Base.establish_connection(Rails.env)
|
|
132
|
-
base_dir = File.join(Rails.root, 'spec', 'fixtures')
|
|
133
|
-
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
|
134
|
-
|
|
135
|
-
require 'active_record/fixtures'
|
|
136
|
-
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
|
137
|
-
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
end
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
|
3
|
-
ENV['RSPEC'] = 'true' # allows autotest to discover rspec
|
|
4
|
-
ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
|
|
5
|
-
system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
|
|
6
|
-
$stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH")
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
|
|
3
|
-
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
|
4
|
-
else
|
|
5
|
-
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
|
6
|
-
ENV["RAILS_ENV"] ||= 'test'
|
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") unless defined?(RAILS_ROOT)
|
|
8
|
-
end
|
|
9
|
-
require 'spec/autorun'
|
|
10
|
-
exit ::Spec::Runner::CommandLine.run
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
|
2
|
-
# from the project root directory.
|
|
3
|
-
ENV["RAILS_ENV"] ||= 'test'
|
|
4
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
|
|
5
|
-
require 'spec/autorun'
|
|
6
|
-
require 'spec/rails'
|
|
7
|
-
|
|
8
|
-
# Uncomment the next line to use webrat's matchers
|
|
9
|
-
#require 'webrat/integrations/rspec-rails'
|
|
10
|
-
|
|
11
|
-
# Requires supporting files with custom matchers and macros, etc,
|
|
12
|
-
# in ./support/ and its subdirectories.
|
|
13
|
-
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
|
14
|
-
|
|
15
|
-
Spec::Runner.configure do |config|
|
|
16
|
-
# If you're not using ActiveRecord you should remove these
|
|
17
|
-
# lines, delete config/database.yml and disable :active_record
|
|
18
|
-
# in your config/boot.rb
|
|
19
|
-
config.use_transactional_fixtures = true
|
|
20
|
-
config.use_instantiated_fixtures = false
|
|
21
|
-
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
|
22
|
-
|
|
23
|
-
# == Fixtures
|
|
24
|
-
#
|
|
25
|
-
# You can declare fixtures for each example_group like this:
|
|
26
|
-
# describe "...." do
|
|
27
|
-
# fixtures :table_a, :table_b
|
|
28
|
-
#
|
|
29
|
-
# Alternatively, if you prefer to declare them only once, you can
|
|
30
|
-
# do so right here. Just uncomment the next line and replace the fixture
|
|
31
|
-
# names with your fixtures.
|
|
32
|
-
#
|
|
33
|
-
# config.global_fixtures = :table_a, :table_b
|
|
34
|
-
#
|
|
35
|
-
# If you declare global fixtures, be aware that they will be declared
|
|
36
|
-
# for all of your examples, even those that don't use them.
|
|
37
|
-
#
|
|
38
|
-
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
|
|
39
|
-
#
|
|
40
|
-
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
|
41
|
-
#
|
|
42
|
-
# == Mock Framework
|
|
43
|
-
#
|
|
44
|
-
# RSpec uses its own mocking framework by default. If you prefer to
|
|
45
|
-
# use mocha, flexmock or RR, uncomment the appropriate line:
|
|
46
|
-
#
|
|
47
|
-
# config.mock_with :mocha
|
|
48
|
-
# config.mock_with :flexmock
|
|
49
|
-
# config.mock_with :rr
|
|
50
|
-
#
|
|
51
|
-
# == Notes
|
|
52
|
-
#
|
|
53
|
-
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
|
|
54
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
The rspec_controller generator creates stub specs and files for a new
|
|
3
|
-
controller and its views.
|
|
4
|
-
|
|
5
|
-
The generator takes a controller name and a list of views as arguments.
|
|
6
|
-
The controller name may be given in CamelCase or under_score and should
|
|
7
|
-
not be suffixed with 'Controller'. To create a controller within a
|
|
8
|
-
module, specify the controller name as 'module/controller'.
|
|
9
|
-
|
|
10
|
-
The generator creates stubs for a controller (and spec), a view (and spec)
|
|
11
|
-
for each view in the argument list, plus a helper.
|
|
12
|
-
|
|
13
|
-
Example:
|
|
14
|
-
./script/generate rspec_controller dog bark fetch
|
|
15
|
-
...
|
|
16
|
-
create spec/controllers/dog_controller_spec.rb
|
|
17
|
-
create app/controllers/dog_controller.rb
|
|
18
|
-
create app/helpers/dog_helper.rb
|
|
19
|
-
create spec/views/dog/bark_view_spec.rb
|
|
20
|
-
create app/views/dog/bark.rhtml
|
|
21
|
-
create spec/views/dog/fetch_view_spec.rb
|
|
22
|
-
create app/views/dog/fetch.rhtml
|
|
23
|
-
|
|
24
|
-
Modules Example:
|
|
25
|
-
./script/generate rspec_controller 'pets/dog' bark fetch
|
|
26
|
-
...
|
|
27
|
-
create spec/controllers/pets/dog_controller_spec.rb
|
|
28
|
-
create app/controllers/pets/dog_controller.rb
|
|
29
|
-
create app/helpers/pets/dog_helper.rb
|
|
30
|
-
create spec/views/pets/dog/bark_view_spec.rb
|
|
31
|
-
create app/views/pets/dog/bark.rhtml
|
|
32
|
-
create spec/views/pets/dog/fetch_view_spec.rb
|
|
33
|
-
create app/views/pets/dog/fetch.rhtml
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require 'rails_generator/generators/components/controller/controller_generator'
|
|
2
|
-
|
|
3
|
-
class RspecControllerGenerator < ControllerGenerator
|
|
4
|
-
|
|
5
|
-
def manifest
|
|
6
|
-
record do |m|
|
|
7
|
-
# Check for class naming collisions.
|
|
8
|
-
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
|
|
9
|
-
|
|
10
|
-
# Controller, helper, views, and spec directories.
|
|
11
|
-
m.directory File.join('app/controllers', class_path)
|
|
12
|
-
m.directory File.join('app/helpers', class_path)
|
|
13
|
-
m.directory File.join('app/views', class_path, file_name)
|
|
14
|
-
m.directory File.join('spec/controllers', class_path)
|
|
15
|
-
m.directory File.join('spec/helpers', class_path)
|
|
16
|
-
m.directory File.join('spec/views', class_path, file_name)
|
|
17
|
-
|
|
18
|
-
@default_file_extension = "html.erb"
|
|
19
|
-
|
|
20
|
-
# Controller spec, class, and helper.
|
|
21
|
-
m.template 'controller_spec.rb',
|
|
22
|
-
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
|
|
23
|
-
|
|
24
|
-
m.template 'helper_spec.rb',
|
|
25
|
-
File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
|
|
26
|
-
|
|
27
|
-
m.template 'controller:controller.rb',
|
|
28
|
-
File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
|
29
|
-
|
|
30
|
-
m.template 'controller:helper.rb',
|
|
31
|
-
File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
# Spec and view template for each action.
|
|
36
|
-
actions.each do |action|
|
|
37
|
-
m.template 'view_spec.rb',
|
|
38
|
-
File.join('spec/views', class_path, file_name, "#{action}.#{@default_file_extension}_spec.rb"),
|
|
39
|
-
:assigns => { :action => action, :model => file_name }
|
|
40
|
-
path = File.join('app/views', class_path, file_name, "#{action}.#{@default_file_extension}")
|
|
41
|
-
m.template "controller:view.#{@default_file_extension}",
|
|
42
|
-
path,
|
|
43
|
-
:assigns => { :action => action, :path => path }
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe <%= class_name %>Controller do
|
|
4
|
-
|
|
5
|
-
<% if actions.empty? -%>
|
|
6
|
-
#Delete this example and add some real ones
|
|
7
|
-
<% else -%>
|
|
8
|
-
#Delete these examples and add some real ones
|
|
9
|
-
<% end -%>
|
|
10
|
-
it "should use <%= class_name %>Controller" do
|
|
11
|
-
controller.should be_an_instance_of(<%= class_name %>Controller)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
<% unless actions.empty? -%>
|
|
15
|
-
<% for action in actions -%>
|
|
16
|
-
|
|
17
|
-
describe "GET '<%= action %>'" do
|
|
18
|
-
it "should be successful" do
|
|
19
|
-
get '<%= action %>'
|
|
20
|
-
response.should be_success
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
<% end -%>
|
|
24
|
-
<% end -%>
|
|
25
|
-
end
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe <%= class_name %>Helper do
|
|
4
|
-
|
|
5
|
-
#Delete this example and add some real ones or delete this file
|
|
6
|
-
it "should be included in the object returned by #helper" do
|
|
7
|
-
included_modules = (class << helper; self; end).send :included_modules
|
|
8
|
-
included_modules.should include(<%= class_name %>Helper)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "/<%= class_name.underscore %>/<%= action %>" do
|
|
4
|
-
before(:each) do
|
|
5
|
-
render '<%= class_name.underscore %>/<%= action %>'
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
#Delete this example and add some real ones or delete this file
|
|
9
|
-
it "should tell you where to find the file" do
|
|
10
|
-
response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>])
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module Rails
|
|
2
|
-
module Generator
|
|
3
|
-
class GeneratedAttribute
|
|
4
|
-
def default_value
|
|
5
|
-
@default_value ||= case type
|
|
6
|
-
when :int, :integer then "1"
|
|
7
|
-
when :float then "1.5"
|
|
8
|
-
when :decimal then "9.99"
|
|
9
|
-
when :datetime, :timestamp, :time then "Time.now"
|
|
10
|
-
when :date then "Date.today"
|
|
11
|
-
when :string, :text then "\"value for #{@name}\""
|
|
12
|
-
when :boolean then "false"
|
|
13
|
-
when :belongs_to, :references then "1"
|
|
14
|
-
else
|
|
15
|
-
""
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def name_or_reference
|
|
20
|
-
if ::Rails::VERSION::STRING >= '2.2'
|
|
21
|
-
reference? ? :"#{name}_id" : name
|
|
22
|
-
else
|
|
23
|
-
name
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Description:
|
|
2
|
-
The rspec_model generator creates stubs for a new model.
|
|
3
|
-
|
|
4
|
-
The generator takes a model name as its argument. The model name may be
|
|
5
|
-
given in CamelCase or under_score and should not be suffixed with 'Model'.
|
|
6
|
-
|
|
7
|
-
The generator creates a model class in app/models, an RSpec spec in
|
|
8
|
-
spec/models, database fixtures in spec/fixtures/plural_name.yml, and a migration
|
|
9
|
-
in db/migrate.
|
|
10
|
-
|
|
11
|
-
Example:
|
|
12
|
-
./script/generate rspec_model Account
|
|
13
|
-
|
|
14
|
-
This will create an Account model:
|
|
15
|
-
Model: app/models/account.rb
|
|
16
|
-
Spec: spec/models/account_spec.rb
|
|
17
|
-
Fixtures: spec/fixtures/accounts.yml
|
|
18
|
-
Migration: db/migrate/XXX_add_accounts.rb
|