rspec-rails 2.0.0.beta.22 → 2.6.0
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.
- data/.gitignore +10 -4
- data/.rspec +1 -0
- data/.travis.yml +10 -0
- data/History.md +1 -33
- data/License.txt +23 -0
- data/{README.markdown → README.md} +27 -7
- data/README_DEV.md +43 -0
- data/Rakefile +105 -35
- data/Thorfile +40 -0
- data/Upgrade.md +1 -0
- data/features/.nav +34 -0
- data/features/Autotest.md +24 -0
- data/features/Changelog.md +151 -0
- data/features/Generators.md +8 -0
- data/features/GettingStarted.md +84 -0
- data/features/README.md +58 -0
- data/features/Upgrade.md +117 -0
- data/features/controller_specs/README.md +45 -0
- data/features/controller_specs/anonymous_controller.feature +7 -7
- data/features/controller_specs/controller_spec.feature +18 -0
- data/features/controller_specs/isolation_from_views.feature +55 -8
- data/features/controller_specs/render_views.feature +63 -52
- data/features/helper_specs/helper_spec.feature +40 -6
- data/features/mailer_specs/url_helpers.feature +4 -4
- data/features/matchers/README.md +4 -0
- data/features/matchers/new_record_matcher.feature +6 -48
- data/features/matchers/redirect_to_matcher.feature +5 -6
- data/features/matchers/render_template_matcher.feature +13 -10
- data/features/mocks/mock_model.feature +29 -13
- data/features/mocks/stub_model.feature +4 -4
- data/features/model_specs/README.md +21 -0
- data/features/model_specs/errors_on.feature +2 -2
- data/features/model_specs/transactional_examples.feature +14 -9
- data/features/request_specs/request_spec.feature +49 -0
- data/features/routing_specs/README.md +17 -0
- data/features/{matchers → routing_specs}/be_routable_matcher.feature +25 -25
- data/features/routing_specs/named_routes.feature +18 -0
- data/features/routing_specs/route_to_matcher.feature +58 -0
- data/features/step_definitions/additional_cli_steps.rb +4 -0
- data/features/support/env.rb +14 -6
- data/features/view_specs/inferred_controller_path.feature +6 -6
- data/features/view_specs/stub_template.feature +51 -0
- data/features/view_specs/view_spec.feature +23 -42
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/base.rb +58 -0
- data/gemfiles/rails-3-0-stable +6 -0
- data/gemfiles/rails-3.0.0 +5 -0
- data/gemfiles/rails-3.0.1 +5 -0
- data/gemfiles/rails-3.0.2 +5 -0
- data/gemfiles/rails-3.0.3 +5 -0
- data/gemfiles/rails-3.0.4 +5 -0
- data/gemfiles/rails-3.0.5 +5 -0
- data/gemfiles/rails-3.0.6 +5 -0
- data/gemfiles/rails-3.0.7 +5 -0
- data/gemfiles/rails-3.1.0.beta1 +5 -0
- data/gemfiles/rails-master +7 -0
- data/lib/autotest/rails_rspec2.rb +1 -1
- data/lib/generators/rspec/controller/controller_generator.rb +4 -4
- data/lib/generators/rspec/helper/helper_generator.rb +3 -3
- data/lib/generators/rspec/install/install_generator.rb +0 -8
- data/lib/generators/rspec/integration/integration_generator.rb +15 -1
- data/lib/generators/rspec/integration/templates/request_spec.rb +7 -1
- data/lib/generators/rspec/mailer/mailer_generator.rb +2 -2
- data/lib/generators/rspec/model/model_generator.rb +1 -1
- data/lib/generators/rspec/observer/observer_generator.rb +1 -1
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +40 -11
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +90 -58
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +15 -7
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +7 -2
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +14 -7
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +14 -14
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +7 -2
- data/lib/generators/rspec/view/view_generator.rb +1 -1
- data/lib/rspec/rails/example/controller_example_group.rb +25 -34
- data/lib/rspec/rails/example/helper_example_group.rb +5 -11
- data/lib/rspec/rails/example/mailer_example_group.rb +0 -14
- data/lib/rspec/rails/example/model_example_group.rb +0 -4
- data/lib/rspec/rails/example/rails_example_group.rb +0 -2
- data/lib/rspec/rails/example/request_example_group.rb +5 -30
- data/lib/rspec/rails/example/routing_example_group.rb +3 -5
- data/lib/rspec/rails/example/view_example_group.rb +20 -11
- data/lib/rspec/rails/example.rb +31 -1
- data/lib/rspec/rails/extensions/active_record/base.rb +28 -32
- data/lib/rspec/rails/fixture_support.rb +1 -1
- data/lib/rspec/rails/matchers/be_new_record.rb +5 -0
- data/lib/rspec/rails/matchers/redirect_to.rb +6 -2
- data/lib/rspec/rails/matchers/render_template.rb +5 -1
- data/lib/rspec/rails/matchers/routing_matchers.rb +24 -3
- data/lib/rspec/rails/matchers.rb +1 -1
- data/lib/rspec/rails/mocks.rb +118 -79
- data/lib/rspec/rails/module_inclusion.rb +17 -0
- data/lib/rspec/rails/tasks/rspec.rake +1 -1
- data/lib/rspec/rails/vendor/capybara.rb +29 -0
- data/lib/rspec/rails/vendor/webrat.rb +33 -0
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_assigns.rb +23 -4
- data/lib/rspec/rails/view_rendering.rb +50 -13
- data/lib/rspec/rails.rb +7 -10
- data/lib/rspec-rails.rb +4 -2
- data/rspec-rails.gemspec +11 -39
- data/spec/autotest/rails_rspec2_spec.rb +25 -14
- data/spec/rspec/rails/configuration_spec.rb +26 -0
- data/spec/rspec/rails/deprecations_spec.rb +18 -0
- data/spec/rspec/rails/example/controller_example_group_spec.rb +47 -5
- data/spec/rspec/rails/example/helper_example_group_spec.rb +19 -1
- data/spec/rspec/rails/example/request_example_group_spec.rb +2 -0
- data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +23 -0
- data/spec/rspec/rails/extensions/active_record/records_spec.rb +9 -0
- data/spec/rspec/rails/matchers/be_new_record_spec.rb +17 -0
- data/spec/rspec/rails/matchers/be_routable_spec.rb +41 -0
- data/spec/rspec/rails/matchers/redirect_to_spec.rb +67 -8
- data/spec/rspec/rails/matchers/render_template_spec.rb +67 -10
- data/spec/rspec/rails/matchers/route_to_spec.rb +77 -31
- data/spec/rspec/rails/mocks/ar_classes.rb +17 -25
- data/spec/rspec/rails/mocks/mock_model_spec.rb +50 -13
- data/spec/rspec/rails/mocks/stub_model_spec.rb +121 -67
- data/spec/rspec/rails/view_rendering_spec.rb +105 -0
- data/spec/spec_helper.rb +0 -22
- data/spec/support/matchers.rb +9 -0
- data/templates/generate_stuff.rb +10 -2
- data/templates/run_specs.rb +2 -2
- metadata +141 -79
- data/Gemfile +0 -24
- data/Gotchas.markdown +0 -14
- data/Upgrade.markdown +0 -31
- data/autotest/discover.rb +0 -1
- data/features/README.markdown +0 -12
- data/features/controller_specs/readers.feature +0 -18
- data/features/routing_specs/access_to_named_routes.feature +0 -15
- data/lib/generators/rspec/install/templates/autotest/discover.rb +0 -2
- data/lib/rspec/rails/browser_simulators.rb +0 -30
- data/spec/rspec/rails/example/view_rendering_spec.rb +0 -110
- data/specs.watchr +0 -59
- data/templates/Gemfile +0 -18
data/.gitignore
CHANGED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/History.md
CHANGED
|
@@ -1,33 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
### 2.0.0.beta.22 / 2010-09-12
|
|
4
|
-
|
|
5
|
-
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0.beta.20...v2.0.0.beta.22)
|
|
6
|
-
|
|
7
|
-
* Enhancements
|
|
8
|
-
* autotest mapping improvements (Andreas Neuhaus)
|
|
9
|
-
|
|
10
|
-
* Bug fixes
|
|
11
|
-
* delegate flunk to assertion delegate
|
|
12
|
-
|
|
13
|
-
### 2.0.0.beta.20 / 2010-08-24
|
|
14
|
-
|
|
15
|
-
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0.beta.19...v2.0.0.beta.20)
|
|
16
|
-
|
|
17
|
-
* Enhancements
|
|
18
|
-
* infer controller and action path_params in view specs
|
|
19
|
-
* more cucumber features (Justin Ko)
|
|
20
|
-
* clean up spec helper (Andre Arko)
|
|
21
|
-
* render views in controller specs if controller class is not
|
|
22
|
-
ActionController::Base
|
|
23
|
-
* routing specs can access named routes
|
|
24
|
-
* add assign(name, value) to helper specs (Justin Ko)
|
|
25
|
-
* stub_model supports primary keys other than id (Justin Ko)
|
|
26
|
-
* encapsulate Test::Unit and/or MiniTest assertions in a separate object
|
|
27
|
-
* support choice between Webrat/Capybara (Justin Ko)
|
|
28
|
-
* removed hard dependency on Webrat
|
|
29
|
-
* support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
|
|
30
|
-
* be_a_new matcher supports args (Justin Ko)
|
|
31
|
-
|
|
32
|
-
* Bug fixes
|
|
33
|
-
* support T::U components in mailer and request specs (Brasten Sager)
|
|
1
|
+
See features/Changelog.md
|
data/License.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2009 David Chelimsky
|
|
4
|
+
Copyright (c) 2005 The RSpec Development Team
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -2,9 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
rspec-2 for rails-3 with lightweight extensions to each
|
|
4
4
|
|
|
5
|
+
[](http://travis-ci.org/rspec/rspec-rails)
|
|
6
|
+
|
|
7
|
+
NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
The [Cucumber features](http://relishapp.com/rspec/rspec-rails) are the
|
|
12
|
+
most comprehensive and up-to-date docs for end-users.
|
|
13
|
+
|
|
14
|
+
The [RDoc](http://rubydoc.info/gems/rspec-rails/2.4.0/frames) provides additional
|
|
15
|
+
information for contributors and/or extenders.
|
|
16
|
+
|
|
17
|
+
All of the documentation is open source and a work in progress. If you find it
|
|
18
|
+
lacking or confusing, you can help improve it by submitting requests and
|
|
19
|
+
patches to the [rspec-rails issue
|
|
20
|
+
tracker](https://github.com/rspec/rspec-rails/issues).
|
|
21
|
+
|
|
5
22
|
## Install
|
|
6
23
|
|
|
7
|
-
gem install rspec-rails
|
|
24
|
+
gem install rspec-rails
|
|
8
25
|
|
|
9
26
|
This installs the following gems:
|
|
10
27
|
|
|
@@ -19,7 +36,7 @@ This installs the following gems:
|
|
|
19
36
|
Add `rspec-rails` to the `:test` and `:development` groups in the Gemfile:
|
|
20
37
|
|
|
21
38
|
group :test, :development do
|
|
22
|
-
gem "rspec-rails", "
|
|
39
|
+
gem "rspec-rails", "~> 2.4"
|
|
23
40
|
end
|
|
24
41
|
|
|
25
42
|
It needs to be in the `:development` group to expose generators and rake
|
|
@@ -45,7 +62,7 @@ out of the box for the default scenario (`ActiveRecord` + `Webrat`).
|
|
|
45
62
|
|
|
46
63
|
### Autotest
|
|
47
64
|
|
|
48
|
-
The `rspec:install` generator creates an
|
|
65
|
+
The `rspec:install` generator creates an `.rspec` file, which
|
|
49
66
|
tells Autotest that you're using RSpec and Rails. You'll also need to add the
|
|
50
67
|
autotest (not autotest-rails) gem to your Gemfile:
|
|
51
68
|
|
|
@@ -99,8 +116,6 @@ not send you to the doctor with a migraine.
|
|
|
99
116
|
|
|
100
117
|
See http://github.com/rspec/rspec-rails/issues
|
|
101
118
|
|
|
102
|
-
Also see [Gotchas.markdown](http://github.com/rspec/rspec-rails/blob/master/Gotchas.markdown)
|
|
103
|
-
|
|
104
119
|
# Request Specs
|
|
105
120
|
|
|
106
121
|
Request specs live in spec/requests.
|
|
@@ -129,8 +144,8 @@ You can use RSpec expectations/matchers or Test::Unit assertions.
|
|
|
129
144
|
## `render_views`
|
|
130
145
|
By default, controller specs do not render views. This supports specifying
|
|
131
146
|
controllers without concern for whether the views they render work correctly
|
|
132
|
-
(NOTE: the template must exist, unlike rspec-rails-1. See Upgrade.
|
|
133
|
-
|
|
147
|
+
(NOTE: the template must exist, unlike rspec-rails-1. See Upgrade.md for more
|
|
148
|
+
information about this). If you prefer to render the views (a la Rails'
|
|
134
149
|
functional tests), you can use the `render_views` declaration in each example
|
|
135
150
|
group:
|
|
136
151
|
|
|
@@ -182,6 +197,11 @@ This means that most of the time you don't need to set these values. When
|
|
|
182
197
|
spec'ing a partial that is included across different controllers, you _may_
|
|
183
198
|
need to override these values before rendering the view.
|
|
184
199
|
|
|
200
|
+
To provide a layout for the render, you'll need to specify _both_ the template
|
|
201
|
+
and the layout explicitly. For example:
|
|
202
|
+
|
|
203
|
+
render :template => "events/show", :layout => "layouts/application"
|
|
204
|
+
|
|
185
205
|
## `assign(key, val)`
|
|
186
206
|
|
|
187
207
|
Use this to assign values to instance variables in the view:
|
data/README_DEV.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Information for rspec-rails developers
|
|
2
|
+
|
|
3
|
+
rspec-rails lives in a complicated ecosystem. We need to run it against
|
|
4
|
+
multiple versions of rails and multiple versions of Ruby as well. There are
|
|
5
|
+
several tools already available to manage running against multiple versions of
|
|
6
|
+
Ruby (e.g. rvm), and there are even some multi-rails tools (e.g. multi-rails)
|
|
7
|
+
but we haven't found one that does exactly what we need here, so we've rolled
|
|
8
|
+
our own.
|
|
9
|
+
|
|
10
|
+
## The short version
|
|
11
|
+
|
|
12
|
+
thor rails:use 3.0.6
|
|
13
|
+
rake
|
|
14
|
+
|
|
15
|
+
## The long version
|
|
16
|
+
|
|
17
|
+
### thor rails:use
|
|
18
|
+
|
|
19
|
+
The `thor rails:use` task accepts any released version of rails, or either the
|
|
20
|
+
3-0-stable or master branches.
|
|
21
|
+
|
|
22
|
+
thor rails:use master
|
|
23
|
+
thor rails:use 3-0-stable
|
|
24
|
+
thor rails:use 3.0.6
|
|
25
|
+
thor rails:use 3.0.5
|
|
26
|
+
thor rails:use 3.0.4
|
|
27
|
+
thor rails:use 3.0.3
|
|
28
|
+
thor rails:use 3.0.2
|
|
29
|
+
thor rails:use 3.0.1
|
|
30
|
+
thor rails:use 3.0.0
|
|
31
|
+
|
|
32
|
+
It then does several things:
|
|
33
|
+
|
|
34
|
+
* generates a .gemfile file with the version listed. This is used internally by
|
|
35
|
+
assorted rake tasks.
|
|
36
|
+
* installs the bundle using the appropriate file in the gemfiles directory
|
|
37
|
+
** this includes binstubs, which are stored in ./gemfiles/bin
|
|
38
|
+
* symlinks the gemfiles/bin directory to ./bin (in the project root) to support
|
|
39
|
+
running bin/rspec from the project root
|
|
40
|
+
|
|
41
|
+
At any time, if you want to change rails versions, run `thor rails:use` with a
|
|
42
|
+
new version number. To play it safe, you probably want to also run `rake
|
|
43
|
+
clobber` to delete all the code generated by the previous rails version.
|
data/Rakefile
CHANGED
|
@@ -1,74 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require 'pathname'
|
|
2
|
+
ENV["BUNDLE_GEMFILE"] ||= begin
|
|
3
|
+
version = if File.exist?("./.gemfile")
|
|
4
|
+
File.read("./.gemfile").chomp
|
|
5
|
+
else
|
|
6
|
+
"rails-3.0.7"
|
|
7
|
+
end
|
|
8
|
+
File.expand_path("../gemfiles/#{version}", __FILE__)
|
|
9
|
+
end
|
|
10
|
+
puts "Using gemfile: #{ENV["BUNDLE_GEMFILE"].gsub(Pathname.new(__FILE__).dirname.to_s,'').sub(/^\//,'')}"
|
|
11
|
+
require "bundler"
|
|
12
|
+
begin
|
|
13
|
+
Bundler.setup
|
|
14
|
+
rescue
|
|
15
|
+
if ENV["CI"]
|
|
16
|
+
sh "bundle install"
|
|
17
|
+
Bundler.setup
|
|
18
|
+
else
|
|
19
|
+
raise "You need to install a bundle first. Try 'thor gemfile:use 3.0.7'"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
5
23
|
|
|
6
|
-
|
|
7
|
-
git clone git://github.com/rails/rails.git vendor/rails
|
|
24
|
+
task :build => :raise_if_psych_is_defined
|
|
8
25
|
|
|
9
|
-
|
|
26
|
+
task :raise_if_psych_is_defined do
|
|
27
|
+
if defined?(Psych)
|
|
28
|
+
raise <<-MSG
|
|
29
|
+
===============================================================================
|
|
30
|
+
Gems compiled in Ruby environments with Psych loaded are incompatible with Ruby
|
|
31
|
+
environments that don't have Psych loaded. Try building this gem in Ruby 1.8.7
|
|
32
|
+
instead.
|
|
33
|
+
===============================================================================
|
|
34
|
+
MSG
|
|
35
|
+
end
|
|
10
36
|
end
|
|
11
|
-
require "bundler"
|
|
12
|
-
Bundler.setup
|
|
13
|
-
Bundler::GemHelper.install_tasks
|
|
14
37
|
|
|
15
38
|
require 'rake'
|
|
16
39
|
require 'yaml'
|
|
17
40
|
|
|
18
|
-
require 'rake/rdoctask'
|
|
19
41
|
require 'rspec'
|
|
20
42
|
require 'rspec/core/rake_task'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
|
|
44
|
+
begin
|
|
45
|
+
require 'cucumber/rake/task'
|
|
46
|
+
|
|
47
|
+
Cucumber::Rake::Task.new(:cucumber)
|
|
48
|
+
|
|
49
|
+
namespace :cucumber do
|
|
50
|
+
desc "Run cucumber features using rcov"
|
|
51
|
+
Cucumber::Rake::Task.new :rcov => :cleanup_rcov_files do |t|
|
|
52
|
+
t.cucumber_opts = %w{--format progress}
|
|
53
|
+
t.rcov = true
|
|
54
|
+
t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
|
|
55
|
+
t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
rescue LoadError
|
|
59
|
+
puts "unable to load cucumber, some tasks unavailable"
|
|
60
|
+
task :cucumber do
|
|
61
|
+
# no-op
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
task :cleanup_rcov_files do
|
|
65
|
+
rm_rf 'coverage.data'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
desc "Run all examples"
|
|
69
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
70
|
+
t.rspec_opts = %w[--color]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
namespace :spec do
|
|
75
|
+
desc "Run all examples using rcov"
|
|
76
|
+
RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
|
|
77
|
+
t.rcov = true
|
|
78
|
+
t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
|
|
79
|
+
t.rcov_opts << %[--text-report --sort coverage --no-html --aggregate coverage.data]
|
|
29
80
|
end
|
|
30
81
|
end
|
|
31
|
-
Cucumber::Rake::Task.new(:cucumber)
|
|
32
82
|
|
|
33
83
|
namespace :generate do
|
|
34
84
|
desc "generate a fresh app with rspec installed"
|
|
35
85
|
task :app do |t|
|
|
36
86
|
unless File.directory?('./tmp/example_app')
|
|
37
|
-
sh "
|
|
38
|
-
|
|
39
|
-
|
|
87
|
+
sh "rails new ./tmp/example_app --skip-javascript --skip-gemfile --skip-git"
|
|
88
|
+
bindir = File.expand_path("gemfiles/bin")
|
|
89
|
+
if test ?d, bindir
|
|
90
|
+
Dir.chdir("./tmp/example_app") do
|
|
91
|
+
sh "rm -rf test"
|
|
92
|
+
sh "ln -s #{bindir}"
|
|
93
|
+
application_filename = "config/application.rb"
|
|
94
|
+
application_file = File.read(application_filename)
|
|
95
|
+
sh "rm #{application_filename}"
|
|
96
|
+
puts "rewrite #{application_filename} with config.assets.enabled = false"
|
|
97
|
+
File.open(application_filename, "w") do |f|
|
|
98
|
+
f.write application_file.gsub("config.assets.enabled = true","config.assets.enabled = false")
|
|
99
|
+
end
|
|
100
|
+
"config/initializers/wrap_parameters.rb".tap do |f|
|
|
101
|
+
sh "rm #{f}" if test ?f, f
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
40
105
|
end
|
|
41
106
|
end
|
|
42
107
|
|
|
43
108
|
desc "generate a bunch of stuff with generators"
|
|
44
109
|
task :stuff do
|
|
45
|
-
|
|
46
|
-
|
|
110
|
+
in_example_app "rake rails:template LOCATION='../../templates/generate_stuff.rb'"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def in_example_app(command)
|
|
115
|
+
Dir.chdir("./tmp/example_app/") do
|
|
116
|
+
Bundler.with_clean_env do
|
|
117
|
+
sh command
|
|
47
118
|
end
|
|
48
119
|
end
|
|
49
120
|
end
|
|
50
121
|
|
|
51
122
|
namespace :db do
|
|
52
123
|
task :migrate do
|
|
53
|
-
|
|
54
|
-
sh "rake db:migrate"
|
|
55
|
-
end
|
|
124
|
+
in_example_app "rake db:migrate"
|
|
56
125
|
end
|
|
57
126
|
|
|
58
127
|
namespace :test do
|
|
59
128
|
task :prepare do
|
|
60
|
-
|
|
61
|
-
sh "rake db:test:prepare"
|
|
62
|
-
end
|
|
129
|
+
in_example_app "rake db:test:prepare"
|
|
63
130
|
end
|
|
64
131
|
end
|
|
65
132
|
end
|
|
66
133
|
|
|
67
134
|
desc "run a variety of specs against the generated app"
|
|
68
135
|
task :smoke do
|
|
69
|
-
|
|
70
|
-
sh "rake rails:template LOCATION='../../templates/run_specs.rb'"
|
|
71
|
-
end
|
|
136
|
+
in_example_app "rake rails:template --trace LOCATION='../../templates/run_specs.rb'"
|
|
72
137
|
end
|
|
73
138
|
|
|
74
139
|
desc 'clobber generated files'
|
|
@@ -85,5 +150,10 @@ namespace :clobber do
|
|
|
85
150
|
end
|
|
86
151
|
end
|
|
87
152
|
|
|
88
|
-
|
|
153
|
+
desc "Push docs/cukes to relishapp using the relish-client-gem"
|
|
154
|
+
task :relish, :version do |t, args|
|
|
155
|
+
raise "rake relish[VERSION]" unless args[:version]
|
|
156
|
+
sh "relish push rspec/rspec-rails:#{args[:version]}"
|
|
157
|
+
end
|
|
89
158
|
|
|
159
|
+
task :default => [:spec, "clobber:app", "generate:app", "generate:stuff", :smoke, :cucumber]
|
data/Thorfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class Gemfile < Thor
|
|
2
|
+
desc "use VERSION", "installs the bundle using gemfiles/rails-VERSION"
|
|
3
|
+
def use(version)
|
|
4
|
+
"gemfiles/rails-#{version}".tap do |gemfile|
|
|
5
|
+
ENV["BUNDLE_GEMFILE"] = File.expand_path(gemfile)
|
|
6
|
+
say "Using #{gemfile}"
|
|
7
|
+
end
|
|
8
|
+
"bundle install --binstubs".tap do |m|
|
|
9
|
+
say m
|
|
10
|
+
system m
|
|
11
|
+
end
|
|
12
|
+
unless version =~ /^\d\.\d\.\d/
|
|
13
|
+
"bundle update rails".tap do |m|
|
|
14
|
+
say m
|
|
15
|
+
system m
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
say `ln -s gemfiles/bin` unless File.exist?('bin')
|
|
19
|
+
`echo rails-#{version} > ./.gemfile`
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "which", "print out the configured gemfile"
|
|
23
|
+
def which
|
|
24
|
+
say `cat ./.gemfile`
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc "list", "list the available options for 'thor gemfile:use'"
|
|
28
|
+
def list
|
|
29
|
+
all = `ls gemfiles`.chomp.split.grep(/^rails/).reject {|i| i =~ /lock$/}
|
|
30
|
+
|
|
31
|
+
versions = all.grep(/^rails-\d\.\d/)
|
|
32
|
+
branches = all - versions
|
|
33
|
+
|
|
34
|
+
puts "releases:"
|
|
35
|
+
versions.sort.reverse.each {|i| puts i}
|
|
36
|
+
puts
|
|
37
|
+
puts "branches:"
|
|
38
|
+
branches.sort.reverse.each {|i| puts i}
|
|
39
|
+
end
|
|
40
|
+
end
|
data/Upgrade.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
See features/Upgrade.md
|
data/features/.nav
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
- GettingStarted.md (Start from scratch)
|
|
2
|
+
- Generators.md (Generators)
|
|
3
|
+
- transactional_examples.feature
|
|
4
|
+
- Autotest.md (Autotest integration)
|
|
5
|
+
- Changelog.md
|
|
6
|
+
- Upgrade.md
|
|
7
|
+
- request_specs:
|
|
8
|
+
- request_spec.feature
|
|
9
|
+
- model_specs:
|
|
10
|
+
- errors_on.feature
|
|
11
|
+
- controller_specs:
|
|
12
|
+
- controller_spec.feature
|
|
13
|
+
- isolation_from_views.feature
|
|
14
|
+
- render_views.feature
|
|
15
|
+
- anonymous_controller.feature
|
|
16
|
+
- helper_specs:
|
|
17
|
+
- helper_spec.feature
|
|
18
|
+
- mailer_specs:
|
|
19
|
+
- url_helpers.feature
|
|
20
|
+
- routing_specs:
|
|
21
|
+
- route_to_matcher.feature
|
|
22
|
+
- be_routable_matcher.feature
|
|
23
|
+
- named_routes.feature
|
|
24
|
+
- view_specs:
|
|
25
|
+
- view_spec.feature
|
|
26
|
+
- stub_template.feature
|
|
27
|
+
- inferred_controller_path.feature
|
|
28
|
+
- matchers:
|
|
29
|
+
- new_record_matcher.feature
|
|
30
|
+
- render_template_matcher.feature
|
|
31
|
+
- redirect_to_matcher.feature
|
|
32
|
+
- mocks:
|
|
33
|
+
- mock_model.feature
|
|
34
|
+
- stub_model.feature
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
The `rspec:install` generator creates a `.rspec` file, which tells RSpec to
|
|
2
|
+
tell Autotest that you're using RSpec. You'll also need to add the ZenTest and
|
|
3
|
+
autotest-rails gems to your Gemfile:
|
|
4
|
+
|
|
5
|
+
gem "ZenTest", "~> 4.4.2"
|
|
6
|
+
gem "autotest-rails", "~> 4.1.0"
|
|
7
|
+
|
|
8
|
+
If all of the gems in your Gemfile are installed in system gems, you can just
|
|
9
|
+
type
|
|
10
|
+
|
|
11
|
+
autotest
|
|
12
|
+
|
|
13
|
+
If Bundler is managing any gems for you directly (i.e. you've got `:git` or
|
|
14
|
+
`:path` attributes in the Gemfile), however, you may need to run
|
|
15
|
+
|
|
16
|
+
bundle exec autotest
|
|
17
|
+
|
|
18
|
+
If you do, you require Autotest's bundler plugin in a `.autotest` file in the
|
|
19
|
+
project root directory or your home directory:
|
|
20
|
+
|
|
21
|
+
require "autotest/bundler"
|
|
22
|
+
|
|
23
|
+
Now you can just type `autotest`, it should prefix the generated shell command
|
|
24
|
+
with `bundle exec`.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
### 2.6.0 / 2011-05-12
|
|
2
|
+
|
|
3
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.5.0...v2.6.0)
|
|
4
|
+
|
|
5
|
+
* Enhancements
|
|
6
|
+
* rails 3 shortcuts for routing specs (Joe Fiorini)
|
|
7
|
+
* support nested resources in generators (Tim McEwan)
|
|
8
|
+
* require 'rspec/rails/mocks' to use `mock_model` without requiring the whole
|
|
9
|
+
rails framework
|
|
10
|
+
* Update the controller spec generated by the rails scaffold generator:
|
|
11
|
+
* Add documentation to the generated spec
|
|
12
|
+
* Use `any_instance` to avoid stubbing finders
|
|
13
|
+
* Use real objects instead of `mock_model`
|
|
14
|
+
* Update capybara integration to work with capy 0.4 and 1.0.0.beta
|
|
15
|
+
* Decorate paths passed to `[append|prepend]_view_paths` with empty templates
|
|
16
|
+
unless rendering views. (Mark Turner)
|
|
17
|
+
|
|
18
|
+
* Bug fixes
|
|
19
|
+
* fix typo in "rake spec:statsetup" (Curtis Schofield)
|
|
20
|
+
* expose named routes in anonymous controller specs (Andy Lindeman)
|
|
21
|
+
* error when generating namespaced scaffold resources (Andy Lindeman)
|
|
22
|
+
* Fix load order issue w/ Capybara (oleg dashevskii)
|
|
23
|
+
* Fix monkey patches that broke due to internal changes in rails-3.1.0.beta1
|
|
24
|
+
|
|
25
|
+
### 2.5.0 / 2011-02-05
|
|
26
|
+
|
|
27
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.1...v2.5.0)
|
|
28
|
+
|
|
29
|
+
* Enhancements
|
|
30
|
+
* use index_helper instead of table_name when generating specs (Reza
|
|
31
|
+
Primardiansyah)
|
|
32
|
+
|
|
33
|
+
* Bug fixes
|
|
34
|
+
* fixed bug in which `render_views` in a nested group set the value in its
|
|
35
|
+
parent group.
|
|
36
|
+
* only include MailerExampleGroup when it is defined (Steve Sloan)
|
|
37
|
+
* mock_model.as_null_object.attribute.blank? returns false (Randy Schmidt)
|
|
38
|
+
* fix typo in request specs (Paco Guzman)
|
|
39
|
+
|
|
40
|
+
### 2.4.1 / 2011-01-03
|
|
41
|
+
|
|
42
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...v2.4.1)
|
|
43
|
+
|
|
44
|
+
* Bug fixes
|
|
45
|
+
* fixed bug caused by including some Rails modules before RSpec's
|
|
46
|
+
RailsExampleGroup
|
|
47
|
+
|
|
48
|
+
### 2.4.0 / 2011-01-02
|
|
49
|
+
|
|
50
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...v2.4.0)
|
|
51
|
+
|
|
52
|
+
* Enhancements
|
|
53
|
+
* include ApplicationHelper in helper object in helper specs
|
|
54
|
+
* include request spec extensions in files in spec/integration
|
|
55
|
+
* include controller spec extensions in groups that use :type => :controller
|
|
56
|
+
* same for :model, :view, :helper, :mailer, :request, :routing
|
|
57
|
+
|
|
58
|
+
* Bug fixes
|
|
59
|
+
* restore global config.render_views so you only need to say it once
|
|
60
|
+
* support overriding render_views in nested groups
|
|
61
|
+
* matchers that delegate to Rails' assertions capture
|
|
62
|
+
ActiveSupport::TestCase::Assertion (so they work properly now with
|
|
63
|
+
should_not in Ruby 1.8.7 and 1.9.1)
|
|
64
|
+
|
|
65
|
+
* Deprecations
|
|
66
|
+
* include_self_when_dir_matches
|
|
67
|
+
|
|
68
|
+
### 2.3.1 / 2010-12-16
|
|
69
|
+
|
|
70
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
|
|
71
|
+
|
|
72
|
+
* Bug fixes
|
|
73
|
+
* respond_to? correctly handles 2 args
|
|
74
|
+
* scaffold generator no longer fails on autotest directory
|
|
75
|
+
|
|
76
|
+
### 2.3.0 / 2010-12-12
|
|
77
|
+
|
|
78
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
|
|
79
|
+
|
|
80
|
+
* Changes
|
|
81
|
+
* Generator no longer generates autotest/autodiscover.rb, as it is no longer
|
|
82
|
+
needed (as of rspec-core-2.3.0)
|
|
83
|
+
|
|
84
|
+
### 2.2.1 / 2010-12-01
|
|
85
|
+
|
|
86
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
|
|
87
|
+
|
|
88
|
+
* Bug fixes
|
|
89
|
+
* Depend on railties, activesupport, and actionpack instead of rails (Piotr
|
|
90
|
+
Solnica)
|
|
91
|
+
* Got webrat integration working properly across different types of specs
|
|
92
|
+
|
|
93
|
+
* Deprecations
|
|
94
|
+
* --webrat-matchers flag for generators is deprecated. use --webrat instead.
|
|
95
|
+
|
|
96
|
+
### 2.2.0 / 2010-11-28
|
|
97
|
+
|
|
98
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0)
|
|
99
|
+
|
|
100
|
+
* Enhancements
|
|
101
|
+
* Added stub_template in view specs
|
|
102
|
+
|
|
103
|
+
* Bug fixes
|
|
104
|
+
* Properly include helpers in views (Jonathan del Strother)
|
|
105
|
+
* Fix bug in which method missing led to a stack overflow
|
|
106
|
+
* Fix stack overflow in request specs with open_session
|
|
107
|
+
* Fix stack overflow in any spec when method_missing was invoked
|
|
108
|
+
* Add gem dependency on rails ~> 3.0.0 (ensures bundler won't install
|
|
109
|
+
rspec-rails-2 with rails-2 apps).
|
|
110
|
+
|
|
111
|
+
### 2.1.0 / 2010-11-07
|
|
112
|
+
|
|
113
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
|
|
114
|
+
|
|
115
|
+
* Enhancements
|
|
116
|
+
* Move errors_on to ActiveModel to support other AM-compliant ORMs
|
|
117
|
+
|
|
118
|
+
* Bug fixes
|
|
119
|
+
* Check for presence of ActiveRecord instead of checking Rails config
|
|
120
|
+
(gets rspec out of the way of multiple ORMs in the same app)
|
|
121
|
+
|
|
122
|
+
### 2.0.1 / 2010-10-15
|
|
123
|
+
|
|
124
|
+
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
|
|
125
|
+
|
|
126
|
+
* Enhancements
|
|
127
|
+
* Add option to not generate request spec (--skip-request-specs)
|
|
128
|
+
|
|
129
|
+
* Bug fixes
|
|
130
|
+
* Updated the mock_[model] method generated in controller specs so it adds
|
|
131
|
+
any stubs submitted each time it is called.
|
|
132
|
+
* Fixed bug where view assigns weren't making it to the view in view specs in Rails-3.0.1.
|
|
133
|
+
(Emanuele Vicentini)
|
|
134
|
+
|
|
135
|
+
### 2.0.0 / 2010-10-10
|
|
136
|
+
|
|
137
|
+
[full changelog](https://github.com/rspec/rspec-rails/compare/ea6bdef...v2.0.0)
|
|
138
|
+
|
|
139
|
+
* Enhancements
|
|
140
|
+
* ControllerExampleGroup uses controller as the implicit subject by default (Paul Rosania)
|
|
141
|
+
* autotest mapping improvements (Andreas Neuhaus)
|
|
142
|
+
* more cucumber features (Justin Ko)
|
|
143
|
+
* clean up spec helper (Andre Arko)
|
|
144
|
+
* add assign(name, value) to helper specs (Justin Ko)
|
|
145
|
+
* stub_model supports primary keys other than id (Justin Ko)
|
|
146
|
+
* support choice between Webrat/Capybara (Justin Ko)
|
|
147
|
+
* support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
|
|
148
|
+
* be_a_new matcher supports args (Justin Ko)
|
|
149
|
+
|
|
150
|
+
* Bug fixes
|
|
151
|
+
* support T::U components in mailer and request specs (Brasten Sager)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
If you type script/rails generate, the only RSpec generator you'll actually see
|
|
2
|
+
is rspec:install. That's because RSpec is registered with Rails as the test
|
|
3
|
+
framework, so whenever you generate application components like models,
|
|
4
|
+
controllers, etc, RSpec specs are generated instead of Test::Unit tests.
|
|
5
|
+
|
|
6
|
+
Note that the generators are there to help you get started, but they are no
|
|
7
|
+
substitute for writing your own examples, and they are only guaranteed to work
|
|
8
|
+
out of the box for with Rails' defaults (ActiveRecord, no Capybara or Webrat).
|