rspec-rails 1.3.4 → 2.0.0.a2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -7
- data/README.markdown +58 -0
- data/Rakefile +51 -9
- data/example_app_template.rb +33 -0
- data/lib/generators/rspec.rb +25 -0
- data/lib/generators/rspec/controller/controller_generator.rb +26 -0
- data/lib/generators/rspec/controller/templates/controller_spec.rb +15 -0
- data/lib/generators/rspec/controller/templates/view_spec.rb +12 -0
- data/lib/generators/rspec/helper/helper_generator.rb +11 -0
- data/lib/generators/rspec/helper/templates/helper_spec.rb +14 -0
- data/lib/generators/rspec/install/install_generator.rb +29 -0
- data/lib/generators/rspec/install/templates/lib/tasks/rspec.rake +119 -0
- data/lib/generators/rspec/install/templates/script/rspec.tt +4 -0
- data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/rcov.opts +0 -0
- data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/spec.opts +0 -0
- data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/spec_helper.rb +14 -12
- data/lib/generators/rspec/integration/integration_generator.rb +12 -0
- data/{generators/integration_spec/templates/integration_spec.rb → lib/generators/rspec/integration/templates/request_spec.rb} +0 -0
- data/lib/generators/rspec/mailer/mailer_generator.rb +21 -0
- data/lib/generators/rspec/mailer/templates/fixture +3 -0
- data/lib/generators/rspec/mailer/templates/mailer_spec.rb +14 -0
- data/lib/generators/rspec/model/model_generator.rb +22 -0
- data/lib/generators/rspec/model/templates/fixtures.yml +19 -0
- data/{generators/rspec_model → lib/generators/rspec/model}/templates/model_spec.rb +1 -1
- data/lib/generators/rspec/observer/observer_generator.rb +12 -0
- data/lib/generators/rspec/observer/templates/observer_spec.rb +5 -0
- data/lib/generators/rspec/plugin/plugin_generator.rb +11 -0
- data/lib/generators/rspec/plugin/templates/%file_name%_spec.rb.tt +5 -0
- data/lib/generators/rspec/plugin/templates/test_helper.rb +5 -0
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +112 -0
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +127 -0
- data/{generators/rspec_scaffold/templates/edit_erb_spec.rb → lib/generators/rspec/scaffold/templates/edit_spec.rb} +3 -3
- data/{generators/rspec_scaffold/templates/index_erb_spec.rb → lib/generators/rspec/scaffold/templates/index_spec.rb} +4 -4
- data/{generators/rspec_scaffold/templates/new_erb_spec.rb → lib/generators/rspec/scaffold/templates/new_spec.rb} +3 -3
- data/{generators/rspec_scaffold → lib/generators/rspec/scaffold}/templates/routing_spec.rb +4 -0
- data/{generators/rspec_scaffold/templates/show_erb_spec.rb → lib/generators/rspec/scaffold/templates/show_spec.rb} +4 -4
- data/lib/rspec/rails.rb +2 -0
- data/lib/rspec/rails/example.rb +2 -0
- data/lib/rspec/rails/example/controller_example_group.rb +31 -0
- data/lib/rspec/rails/example/request_example_group.rb +26 -0
- data/lib/rspec/rails/matchers.rb +14 -0
- data/lib/rspec/rails/transactional_database_support.rb +38 -0
- data/lib/rspec/rails/version.rb +16 -0
- data/rspec-rails.gemspec +78 -18
- metadata +97 -321
- data/.document +0 -7
- data/Contribute.rdoc +0 -4
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -27
- data/History.rdoc +0 -321
- data/License.txt +0 -33
- data/Manifest.txt +0 -165
- data/README.rdoc +0 -48
- data/TODO.txt +0 -17
- data/Upgrade.rdoc +0 -148
- data/generators/integration_spec/integration_spec_generator.rb +0 -10
- 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/rspec.rake +0 -144
- data/generators/rspec/templates/script/autospec +0 -6
- data/generators/rspec/templates/script/spec +0 -10
- 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_scaffold/rspec_scaffold_generator.rb +0 -154
- data/generators/rspec_scaffold/templates/controller_spec.rb +0 -131
- data/generators/rspec_scaffold/templates/helper_spec.rb +0 -11
- data/init.rb +0 -9
- data/lib/autotest/discover.rb +0 -5
- data/lib/autotest/rails_rspec.rb +0 -76
- data/lib/spec/rails.rb +0 -26
- data/lib/spec/rails/example.rb +0 -48
- 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 -16
- data/lib/spec/rails/example/routing_helpers.rb +0 -66
- data/lib/spec/rails/example/view_example_group.rb +0 -203
- data/lib/spec/rails/extensions.rb +0 -11
- 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 -35
- 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 -45
- data/lib/spec/rails/interop/testcase.rb +0 -14
- data/lib/spec/rails/matchers.rb +0 -32
- 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/mocks.rb +0 -140
- data/lib/spec/rails/version.rb +0 -16
- 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/controller_spec/non_existent_action_with_existent_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 -67
- 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 -247
- data/spec/spec/rails/example/model_example_group_spec.rb +0 -32
- data/spec/spec/rails/example/routing_example_group_spec.rb +0 -9
- 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 -79
- 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 -112
- 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/README.rdoc
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
= Spec::Rails
|
2
|
-
|
3
|
-
* http://rspec.info
|
4
|
-
* http://rubyforge.org/projects/rspec
|
5
|
-
* http://github.com/dchelimsky/rspec-rails
|
6
|
-
* http://wiki.github.com/dchelimsky/rspec/rails
|
7
|
-
* mailto:rspec-devel@rubyforge.org
|
8
|
-
|
9
|
-
== DESCRIPTION:
|
10
|
-
|
11
|
-
Behaviour Driven Development for Ruby on Rails.
|
12
|
-
|
13
|
-
rspec-rails is an RSpec extension that allows you to drive the development of
|
14
|
-
Ruby on Rails applications with RSpec.
|
15
|
-
|
16
|
-
This is the repository for rspec-rails-1.x. If you're looking
|
17
|
-
for rspec-rails-2 for rails-3, see http://github.com/rspec/rspec-rails.
|
18
|
-
|
19
|
-
== FEATURES:
|
20
|
-
|
21
|
-
* Use RSpec to independently specify Rails Models, Views, Controllers and Helpers
|
22
|
-
* Integrated fixture loading
|
23
|
-
* Special generators for Resources, Models, Views and Controllers that generate RSpec code examples.
|
24
|
-
|
25
|
-
== VISION:
|
26
|
-
|
27
|
-
For people for whom TDD is a brand new concept, the testing support built into
|
28
|
-
Ruby on Rails is a huge leap forward. The fact that it is built right in is
|
29
|
-
fantastic, and Ruby on Rails apps are generally much easier to maintain than
|
30
|
-
they might have been without such support.
|
31
|
-
|
32
|
-
For those of us coming from a history with TDD, and now BDD, the existing
|
33
|
-
support presents some problems related to dependencies across examples. To
|
34
|
-
that end, RSpec on Rails supports 4 types of examples. We’ve also built in
|
35
|
-
first class mocking and stubbing support in order to break dependencies across
|
36
|
-
these different concerns.
|
37
|
-
|
38
|
-
== MORE INFORMATION:
|
39
|
-
|
40
|
-
See Spec::Rails::Example for information about the different kinds of example
|
41
|
-
groups you can use to spec the different Rails components
|
42
|
-
|
43
|
-
See Spec::Rails::Matchers for information about Rails-specific
|
44
|
-
expectations you can set on responses and models, etc.
|
45
|
-
|
46
|
-
== INSTALL
|
47
|
-
|
48
|
-
* Visit http://wiki.github.com/dchelimsky/rspec/rails for installation instructions.
|
data/TODO.txt
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
* wiki
|
2
|
-
* need a matrix of which rspec-rails versions support which rails versions
|
3
|
-
* CI
|
4
|
-
* need a robust CI setup that runs
|
5
|
-
* Multiple rubies
|
6
|
-
* MRI: 1.8.6
|
7
|
-
* MRI: 1.8.7
|
8
|
-
* MRI: 1.9.1
|
9
|
-
* JRuby
|
10
|
-
* IronRuby??? (perhaps using mono)
|
11
|
-
* Multiple rails-es
|
12
|
-
* 2.0.5
|
13
|
-
* 2.1.2
|
14
|
-
* 2.2.2
|
15
|
-
* 2.3.4
|
16
|
-
* 3.0 (once available)
|
17
|
-
* With and without ActiveRecord
|
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
|