Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-rails
...
head fork: rspec/rspec-rails
  • 20 commits
  • 51 files changed
  • 3 commit comments
  • 5 contributors
Showing with 419 additions and 375 deletions.
  1. +1 −0  .gitignore
  2. +6 −0 Gemfile-3-0-stable
  3. +3 −0  Gemfile-3.0.0
  4. +3 −0  Gemfile-3.0.3
  5. +4 −8 Gemfile → Gemfile-base
  6. +5 −0 Gemfile-master
  7. +1 −114 History.md
  8. +2 −2 README.md
  9. +9 −7 Rakefile
  10. +7 −0 Thorfile
  11. +1 −63 Upgrade.md
  12. +5 −4 features/.nav
  13. +15 −8 features/Autotest.md
  14. +127 −0 features/Changelog.md
  15. +60 −0 features/Upgrade.md
  16. +3 −2 features/controller_specs/README.md
  17. +2 −2 features/controller_specs/anonymous_controller.feature
  18. +2 −2 features/controller_specs/isolation_from_views.feature
  19. +42 −60 features/controller_specs/render_views.feature
  20. +3 −3 features/helper_specs/helper_spec.feature
  21. +2 −2 features/mailer_specs/url_helpers.feature
  22. +2 −2 features/matchers/new_record_matcher.feature
  23. +1 −1  features/matchers/redirect_to_matcher.feature
  24. +1 −1  features/matchers/render_template_matcher.feature
  25. +5 −5 features/mocks/mock_model.feature
  26. +2 −2 features/mocks/stub_model.feature
  27. +1 −1  features/model_specs/errors_on.feature
  28. +4 −4 features/model_specs/transactional_examples.feature
  29. +3 −3 features/routing_specs/be_routable_matcher.feature
  30. +1 −1  features/routing_specs/named_routes.feature
  31. +1 −1  features/routing_specs/route_to_matcher.feature
  32. +1 −2  features/step_definitions/{rspec_steps.rb → additional_cli_steps.rb}
  33. +3 −3 features/view_specs/inferred_controller_path.feature
  34. +2 −2 features/view_specs/stub_template.feature
  35. +8 −8 features/view_specs/view_spec.feature
  36. +2 −2 lib/generators/rspec/integration/templates/request_spec.rb
  37. +1 −1  lib/generators/rspec/scaffold/templates/controller_spec.rb
  38. +1 −1  lib/generators/rspec/scaffold/templates/edit_spec.rb
  39. +1 −1  lib/generators/rspec/scaffold/templates/new_spec.rb
  40. +5 −3 lib/rspec/rails/example.rb
  41. +10 −6 lib/rspec/rails/example/controller_example_group.rb
  42. +1 −1  lib/rspec/rails/example/request_example_group.rb
  43. +6 −0 lib/rspec/rails/mocks.rb
  44. +1 −1  lib/rspec/rails/version.rb
  45. +1 −1  lib/rspec/rails/view_rendering.rb
  46. +13 −25 spec/rspec/rails/mocks/ar_classes.rb
  47. +6 −0 spec/rspec/rails/mocks/mock_model_spec.rb
  48. +9 −4 spec/rspec/rails/mocks/stub_model_spec.rb
  49. +7 −1 spec/rspec/rails/view_rendering_spec.rb
  50. +0 −15 templates/Gemfile
  51. +17 −0 templates/Gemfile-base
View
1  .gitignore
@@ -6,3 +6,4 @@ doc
vendor
.bundle
Gemfile.lock
+Gemfile
View
6 Gemfile-3-0-stable
@@ -0,0 +1,6 @@
+instance_eval(File.read("./Gemfile-base"))
+
+gem "rails", :git => "https://github.com/rails/rails.git", :branch => "3-0-stable"
+gem "arel", :git => "https://github.com/rails/arel.git"
+gem "rack", :git => "git://github.com/rack/rack.git"
+
View
3  Gemfile-3.0.0
@@ -0,0 +1,3 @@
+instance_eval(File.read("./Gemfile-base"))
+
+gem "rails", "3.0.0"
View
3  Gemfile-3.0.3
@@ -0,0 +1,3 @@
+instance_eval(File.read("./Gemfile-base"))
+
+gem "rails", "3.0.3"
View
12 Gemfile → Gemfile-base
@@ -1,6 +1,6 @@
source "http://rubygems.org"
-%w[rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
+%w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
library_path = File.expand_path("../../#{lib}", __FILE__)
if File.exist?(library_path)
gem lib, :path => library_path
@@ -9,14 +9,16 @@ source "http://rubygems.org"
end
end
+gem 'sqlite3-ruby', :require => 'sqlite3'
gem "rake", "0.8.7"
-gem "cucumber", "0.9.4"
+gem "cucumber", "0.10.0"
gem "aruba", "0.2.2"
gem "rcov", "0.9.9"
gem "relish", "0.2.0"
gem "guard-rspec", "0.1.9"
gem "growl", "1.0.3"
gem "ZenTest", "~> 4.4.2"
+gem "webrat", "0.7.2"
if RUBY_PLATFORM =~ /darwin/
gem "autotest-fsevent", "~> 0.2.4"
@@ -34,9 +36,3 @@ end
platforms :jruby do
gem "jruby-openssl"
end
-
-#### rspec-rails only
-gem "rails", :path => File.expand_path("../vendor/rails", __FILE__)
-gem "rack", :git => "git://github.com/rack/rack.git"
-gem 'webrat', "0.7.2"
-gem 'sqlite3-ruby', :require => 'sqlite3'
View
5 Gemfile-master
@@ -0,0 +1,5 @@
+instance_eval(File.read("./Gemfile-base"))
+
+gem "rails", :git => "https://github.com/rails/rails.git"
+gem "arel", :git => "https://github.com/rails/arel.git"
+gem "rack", :git => "https://github.com/rack/rack.git"
View
115 History.md
@@ -1,114 +1 @@
-## rspec-rails-2 release history
-
-### 2.4.1 / 2011-01-03
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...2.4.1)
-
-* Bug fixes
- * fixed bug caused by including some Rails modules before RSpec's
- RailsExampleGroup
-
-### 2.4.0 / 2011-01-02
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...2.4.0)
-
-* Enhancements
- * include ApplicationHelper in helper object in helper specs
- * include request spec extensions in files in spec/integration
- * include controller spec extensions in groups that use :type => :controller
- * same for :model, :view, :helper, :mailer, :request, :routing
-
-* Bug fixes
- * restore global config.render_views so you only need to say it once
- * support overriding render_views in nested groups
- * matchers that delegate to Rails' assertions capture
- ActiveSupport::TestCase::Assertion (so they work properly now with
- should_not in Ruby 1.8.7 and 1.9.1)
-
-* Deprecations
- * include_self_when_dir_matches
-
-### 2.3.1 / 2010-12-16
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
-
-* Bug fixes
- * respond_to? correctly handles 2 args
- * scaffold generator no longer fails on autotest directory
-
-### 2.3.0 / 2010-12-12
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
-
-* Changes
- * Generator no longer generates autotest/autodiscover.rb, as it is no longer
- needed (as of rspec-core-2.3.0)
-
-### 2.2.1 / 2010-12-01
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
-
-* Bug fixes
- * Depend on railties, activesupport, and actionpack instead of rails (Piotr
- Solnica)
- * Got webrat integration working properly across different types of specs
-
-* Deprecations
- * --webrat-matchers flag for generators is deprecated. use --webrat instead.
-
-### 2.2.0 / 2010-11-28
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0)
-
-* Enhancements
- * Added stub_template in view specs
-
-* Bug fixes
- * Properly include helpers in views (Jonathan del Strother)
- * Fix bug in which method missing led to a stack overflow
- * Fix stack overflow in request specs with open_session
- * Fix stack overflow in any spec when method_missing was invoked
- * Add gem dependency on rails ~> 3.0.0 (ensures bundler won't install
- rspec-rails-2 with rails-2 apps).
-
-### 2.1.0 / 2010-11-07
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
-
-* Enhancements
- * Move errors_on to ActiveModel to support other AM-compliant ORMs
-
-* Bug fixes
- * Check for presence of ActiveRecord instead of checking Rails config
- (gets rspec out of the way of multiple ORMs in the same app)
-
-### 2.0.1 / 2010-10-15
-
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
-
-* Enhancements
- * Add option to not generate request spec (--skip-request-specs)
-
-* Bug fixes
- * Updated the mock_[model] method generated in controller specs so it adds
- any stubs submitted each time it is called.
- * Fixed bug where view assigns weren't making it to the view in view specs in Rails-3.0.1.
- (Emanuele Vicentini)
-
-### 2.0.0 / 2010-10-10
-
-[full changelog](https://github.com/rspec/rspec-rails/compare/ea6bdef...v2.0.0)
-
-* Enhancements
- * ControllerExampleGroup uses controller as the implicit subject by default (Paul Rosania)
- * autotest mapping improvements (Andreas Neuhaus)
- * more cucumber features (Justin Ko)
- * clean up spec helper (Andre Arko)
- * add assign(name, value) to helper specs (Justin Ko)
- * stub_model supports primary keys other than id (Justin Ko)
- * support choice between Webrat/Capybara (Justin Ko)
- * support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
- * be_a_new matcher supports args (Justin Ko)
-
-* Bug fixes
- * support T::U components in mailer and request specs (Brasten Sager)
+See features/Changelog.md
View
4 README.md
@@ -9,7 +9,7 @@ NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2.
The [Cucumber features](http://relishapp.com/rspec/rspec-rails) are the
most comprehensive and up-to-date docs for end-users.
-The [RDoc](http://rubydoc.info/gems/rspec-rails/2.3.0/frames) provides additional
+The [RDoc](http://rubydoc.info/gems/rspec-rails/2.4.0/frames) provides additional
information for contributors and/or extenders.
All of the documentation is open source and a work in progress. If you find it
@@ -34,7 +34,7 @@ This installs the following gems:
Add `rspec-rails` to the `:test` and `:development` groups in the Gemfile:
group :test, :development do
- gem "rspec-rails", "~> 2.0.1"
+ gem "rspec-rails", "~> 2.4"
end
It needs to be in the `:development` group to expose generators and rake
View
16 Rakefile
@@ -1,10 +1,12 @@
-unless File.directory?("vendor/rails")
+unless File.exist?('./Gemfile')
raise <<-MESSAGE
-You need to clone the rails git repository into ./vendor before you can use any
-of the rake tasks.
-
- git clone git://github.com/rails/rails.git vendor/rails
+Could not find a Gemfile. Please run any of:
+ thor rails:use 3-0-stable
+ thor rails:use master
+ thor rails:use 3.0.0
+ thor rails:use 3.0.3
+And then run 'bundle install'
MESSAGE
end
require "bundler"
@@ -54,8 +56,8 @@ namespace :generate do
task :app do |t|
unless File.directory?('./tmp/example_app')
sh "bundle exec rails new ./tmp/example_app"
- sh "cp ./templates/Gemfile ./tmp/example_app/"
- sh "cp ./specs.watchr ./tmp/example_app/"
+ sh "cp ./templates/Gemfile-base ./tmp/example_app/"
+ sh "cp ./Gemfile ./tmp/example_app/"
end
end
View
7 Thorfile
@@ -15,4 +15,11 @@ class Rails < Thor
`git fetch`
end
end
+
+ desc "use VERSION", "copies the appropriate Gemfile to Gemfile"
+ def use(version)
+ `cp ./Gemfile-#{version} ./Gemfile`
+ `rm ./Gemfile.lock`
+ system "bundle install"
+ end
end
View
64 Upgrade.md
@@ -1,63 +1 @@
-# rspec-rails-2.3.0
-
-## autotest integration
-
-Add a .rspec file to the project's root directory (if not already there) to
-tell RSpec to tell Autotest to use RSpec's specialized Autotest class.
-
-NOTE that rspec-core-2.0, 2.1, and 2.2 required an autotest/discover.rb file in
-the project's root directory. This worked with some, but not all versions of
-autotest and/or the autotest command that ships with ZenTest. This new approach
-will work regardless of which version of autotest/ZenTest you are using.
-
-## Webrat and Capybara
-
-Earlier 2.0.0.beta versions depended on Webrat. As of
-rspec-rails-2.0.0.beta.20, this dependency and offers you a choice of using
-webrat or capybara. Just add the library of your choice to your Gemfile.
-
-## Controller specs
-
-### islation from view templates
-
-By default, controller specs do _not_ render view templates. This keeps
-controller specs isolated from the content of views and their requirements.
-
-NOTE that the template must exist, but it will not be rendered. This is
-different from rspec-rails-1.x, in which the template didn't need to exist, but
-ActionController makes a number of new decisions in Rails 3 based on the
-existence of the template. To keep the RSpec code free of monkey patches, and
-to keep the rspec user experience simpler, we decided that this would be a fair
-trade-off.
-
-## View specs
-
-### view.should render_template
-
-Rails changed the way it renders partials, so to set an expectation that a
-partial gets rendered, you need
-
- render
- view.should render_template(:partial => "widget/_row")
-
-### stub_template
-
-Introduced in rspec-rails-2.2, simulates the presence of view templates on the
-file system. This supports isolation from partials rendered by the vew template
-that is the subject of a view example:
-
- stub_template "widgets/_widget.html.erb" => "This Content"
-
-### as_new_record
-
-Earlier versions of the view generators generated stub_model with `:new_record?
-=> true`. That is no longer recognized in rspec-rails-2, so you need to change
-this:
-
- stub_model(Widget, :new_record? => true)
-
-to this:
-
- stub_model(Widget).as_new_record
-
-Generators in 2.0.0 final release will do the latter.
+See features/Upgrade.md
View
9 features/.nav
@@ -1,8 +1,9 @@
-- GettingStarted.md (Getting started)
-- Upgrade.md
-- Generators.md (Rails generators)
-- Autotest.md (Autotest integration)
+- GettingStarted.md (Start from scratch)
+- Generators.md (Generators)
- transactional_examples.feature
+- Autotest.md (Autotest integration)
+- Changelog.md
+- Upgrade.md
- model_specs:
- errors_on.feature
- controller_specs:
View
23 features/Autotest.md
@@ -1,10 +1,17 @@
-The rspec:install generator creates a .rspec file, which tells RSpec to tell
-Autotest that you're using RSpec and Rails. You'll also need to add the ZenTest
-gem to your Gemfile:
+The `rspec:install` generator creates a `.rspec` file, which tells RSpec to
+tell Autotest that you're using RSpec. You'll also need to add the ZenTest and
+autotest-rails gems to your Gemfile:
- gem "ZenTest"
+ gem "ZenTest", "~> 4.4.2"
+ gem "autotest-rails", "~> 4.1.0"
+
+If all of the gems in your Gemfile are installed in system gems, you can just
+type
+
+ autotest
+
+If Bundler is managing any gems for you directly (i.e. you've got `:git` or
+`:path` attributes in the Gemfile), however, you may need to run
+
+ bundle exec autotest
-At this point, if all of the gems in your Gemfile are installed in system gems,
-you can just type autotest. If, however, Bundler is managing any gems for you
-directly (i.e. you've got :git or :path attributes in the Gemfile), you'll need
-to run bundle exec autotest.
View
127 features/Changelog.md
@@ -0,0 +1,127 @@
+### 2.5.0 / 2011-02-05
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.1...v2.5.0)
+
+* Enhancements
+ * use index_helper instead of table_name when generating specs (Reza
+ Primardiansyah)
+
+* Bug fixes
+ * fixed bug in which `render_views` in a nested group set the value in its
+ parent group.
+ * only include MailerExampleGroup when it is defiend (Steve Sloan)
+ * mock_model.as_null_object.attribute.blank? returns false (Randy Schmidt)
+ * fix typo in request specs (Paco Guzman)
+
+### 2.4.1 / 2011-01-03
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...v2.4.1)
+
+* Bug fixes
+ * fixed bug caused by including some Rails modules before RSpec's
+ RailsExampleGroup
+
+### 2.4.0 / 2011-01-02
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...v2.4.0)
+
+* Enhancements
+ * include ApplicationHelper in helper object in helper specs
+ * include request spec extensions in files in spec/integration
+ * include controller spec extensions in groups that use :type => :controller
+ * same for :model, :view, :helper, :mailer, :request, :routing
+
+* Bug fixes
+ * restore global config.render_views so you only need to say it once
+ * support overriding render_views in nested groups
+ * matchers that delegate to Rails' assertions capture
+ ActiveSupport::TestCase::Assertion (so they work properly now with
+ should_not in Ruby 1.8.7 and 1.9.1)
+
+* Deprecations
+ * include_self_when_dir_matches
+
+### 2.3.1 / 2010-12-16
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
+
+* Bug fixes
+ * respond_to? correctly handles 2 args
+ * scaffold generator no longer fails on autotest directory
+
+### 2.3.0 / 2010-12-12
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
+
+* Changes
+ * Generator no longer generates autotest/autodiscover.rb, as it is no longer
+ needed (as of rspec-core-2.3.0)
+
+### 2.2.1 / 2010-12-01
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
+
+* Bug fixes
+ * Depend on railties, activesupport, and actionpack instead of rails (Piotr
+ Solnica)
+ * Got webrat integration working properly across different types of specs
+
+* Deprecations
+ * --webrat-matchers flag for generators is deprecated. use --webrat instead.
+
+### 2.2.0 / 2010-11-28
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0)
+
+* Enhancements
+ * Added stub_template in view specs
+
+* Bug fixes
+ * Properly include helpers in views (Jonathan del Strother)
+ * Fix bug in which method missing led to a stack overflow
+ * Fix stack overflow in request specs with open_session
+ * Fix stack overflow in any spec when method_missing was invoked
+ * Add gem dependency on rails ~> 3.0.0 (ensures bundler won't install
+ rspec-rails-2 with rails-2 apps).
+
+### 2.1.0 / 2010-11-07
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
+
+* Enhancements
+ * Move errors_on to ActiveModel to support other AM-compliant ORMs
+
+* Bug fixes
+ * Check for presence of ActiveRecord instead of checking Rails config
+ (gets rspec out of the way of multiple ORMs in the same app)
+
+### 2.0.1 / 2010-10-15
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
+
+* Enhancements
+ * Add option to not generate request spec (--skip-request-specs)
+
+* Bug fixes
+ * Updated the mock_[model] method generated in controller specs so it adds
+ any stubs submitted each time it is called.
+ * Fixed bug where view assigns weren't making it to the view in view specs in Rails-3.0.1.
+ (Emanuele Vicentini)
+
+### 2.0.0 / 2010-10-10
+
+[full changelog](https://github.com/rspec/rspec-rails/compare/ea6bdef...v2.0.0)
+
+* Enhancements
+ * ControllerExampleGroup uses controller as the implicit subject by default (Paul Rosania)
+ * autotest mapping improvements (Andreas Neuhaus)
+ * more cucumber features (Justin Ko)
+ * clean up spec helper (Andre Arko)
+ * add assign(name, value) to helper specs (Justin Ko)
+ * stub_model supports primary keys other than id (Justin Ko)
+ * support choice between Webrat/Capybara (Justin Ko)
+ * support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
+ * be_a_new matcher supports args (Justin Ko)
+
+* Bug fixes
+ * support T::U components in mailer and request specs (Brasten Sager)
View
60 features/Upgrade.md
@@ -36,6 +36,18 @@ is what you need to change:
## Controller specs
+### islation from view templates
+
+By default, controller specs do _not_ render view templates. This keeps
+controller specs isolated from the content of views and their requirements.
+
+NOTE that the template must exist, but it will not be rendered. This is
+different from rspec-rails-1.x, in which the template didn't need to exist, but
+ActionController makes a number of new decisions in Rails 3 based on the
+existence of the template. To keep the RSpec code free of monkey patches, and
+to keep the rspec user experience simpler, we decided that this would be a fair
+trade-off.
+
### `response.should render_template`
This needs to move from before the action to after. For example:
@@ -54,3 +66,51 @@ fix releases in RSpec). Part of the philosophy of rspec-rails-2 is to rely on
public APIs in Rails as much as possible. In this case, `render_template`
delegates directly to Rails' `assert_template`, which only works after the
action.
+
+## View specs
+
+### `view.should render_template`
+
+Rails changed the way it renders partials, so to set an expectation that a
+partial gets rendered, you need
+
+ render
+ view.should render_template(:partial => "widget/_row")
+
+### stub_template
+
+Introduced in rspec-rails-2.2, simulates the presence of view templates on the
+file system. This supports isolation from partials rendered by the vew template
+that is the subject of a view example:
+
+ stub_template "widgets/_widget.html.erb" => "This Content"
+
+### No more `have_tag`
+
+Before Webrat came along, rspec-rails had its own `have_tag` matcher that
+wrapped Rails' `assert_select`. Webrat included a replacement for `have_tag` as
+well as new matchers (`have_selector` and `have_xpath`), all of which rely on
+Nokogiri to do its work, and are far less brittle than RSpec's `have_tag`.
+
+Capybara has similar matchers, which will soon be available view specs (they
+are already available in controller specs with `render_views`).
+
+Given the brittleness of RSpec's `have_tag` matcher and the presence of new
+Webrat and Capybara matchers that do a better job, `have_tag` was not included
+in rspec-rails-2.
+
+## Mocks, stubs, doubles
+
+### as_new_record
+
+Earlier versions of the view generators generated stub_model with `:new_record?
+=> true`. That is no longer recognized in rspec-rails-2, so you need to change
+this:
+
+ stub_model(Widget, :new_record? => true)
+
+to this:
+
+ stub_model(Widget).as_new_record
+
+Generators in 2.0.0 final release will do the latter.
View
5 features/controller_specs/README.md
@@ -2,8 +2,9 @@ Controller specs live in `spec/controllers` or any example group with
`:type => :controller`.
A controller spec is an RSpec wrapper for a Rails functional test
-(ActionController::TestCase::Behavior). It allows you to simulate a single
-http request in each example, and then specify expected outcomes, including:
+([ActionController::TestCase::Behavior](https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb)).
+It allows you to simulate a single http request in each example, and then
+specify expected outcomes such as:
* rendered templates
* redirects
View
4 features/controller_specs/anonymous_controller.feature
@@ -37,7 +37,7 @@ Feature: anonymous controller
end
"""
When I run "rspec spec"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: specify error handling in subclass of ApplicationController
Given a file named "spec/controllers/application_controller_subclass_spec.rb" with:
@@ -75,4 +75,4 @@ Feature: anonymous controller
end
"""
When I run "rspec spec"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
4 features/controller_specs/isolation_from_views.feature
@@ -1,6 +1,6 @@
Feature: views are stubbed by default
- By default, controller specs stub views with template that renders an empty
+ By default, controller specs stub views with a template that renders an empty
string instead of the views in the app. This allows you specify which view
template an action should try to render regardless of whether the template
compiles cleanly.
@@ -28,7 +28,7 @@ Feature: views are stubbed by default
end
"""
When I run "rspec ./spec"
- Then the output should contain "2 examples, 0 failures"
+ Then the examples should all pass
Scenario: expect template that is not rendered by controller action (fails)
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
View
102 features/controller_specs/render_views.feature
@@ -1,9 +1,9 @@
Feature: render_views
You can tell a controller example group to render views with the
- `render_views` declaration.
+ `render_views` declaration in any individual group, or globally.
- Scenario: expect template that exists and is rendered by controller (passes)
+ Scenario: render_views directly in a single group
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
"""
require "spec_helper"
@@ -11,48 +11,18 @@ Feature: render_views
describe WidgetsController do
render_views
- describe "index" do
- it "renders the index template" do
+ describe "GET index" do
+ it "says 'Listing widgets'" do
get :index
- response.should contain("Listing widgets")
- end
-
- it "renders the widgets/index template" do
- get :index
- response.should contain("Listing widgets")
+ response.body.should =~ /Listing widgets/m
end
end
end
"""
When I run "rspec spec"
- Then the output should contain "2 examples, 0 failures"
+ Then the examples should all pass
- Scenario: expect template that does not exist and is rendered by controller (fails)
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
- """
- require "spec_helper"
-
- describe WidgetsController do
- render_views
-
- before do
- def controller.index
- render :template => "other"
- end
- end
-
- describe "index" do
- it "renders the other template" do
- get :index
- end
- end
- end
- """
- When I run "rspec spec"
- Then the output should contain "1 example, 1 failure"
- And the output should contain "Missing template"
-
- Scenario: render_views on and off in diff contexts
+ Scenario: render_views on and off in nested groups
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
"""
require "spec_helper"
@@ -61,19 +31,30 @@ Feature: render_views
context "with render_views" do
render_views
- describe "index" do
+ describe "GET index" do
it "renders the actual template" do
get :index
response.body.should =~ /Listing widgets/m
end
end
+
+ context "with render_views(false) nested in a group with render_views" do
+ render_views false
+
+ describe "GET index" do
+ it "renders the RSpec generated template" do
+ get :index
+ response.body.should eq("")
+ end
+ end
+ end
end
context "without render_views" do
- describe "index" do
+ describe "GET index" do
it "renders the RSpec generated template" do
get :index
- response.body.should == ""
+ response.body.should eq("")
end
end
end
@@ -81,26 +62,32 @@ Feature: render_views
context "with render_views again" do
render_views
- describe "index" do
+ describe "GET index" do
it "renders the actual template" do
get :index
response.body.should =~ /Listing widgets/m
end
end
end
-
- context "without render_views again" do
- describe "index" do
- it "renders the RSpec generated template" do
- get :index
- response.body.should == ""
- end
- end
- end
end
"""
- When I run "rspec spec"
- Then the output should contain "4 examples, 0 failures"
+ When I run "rspec spec --format documentation"
+ Then the output should contain:
+ """
+ WidgetsController
+ with render_views
+ GET index
+ renders the actual template
+ with render_views(false) nested in a group with render_views
+ GET index
+ renders the RSpec generated template
+ without render_views
+ GET index
+ renders the RSpec generated template
+ with render_views again
+ GET index
+ renders the actual template
+ """
Scenario: render_views globally
Given a file named "spec/support/render_views.rb" with:
@@ -114,19 +101,14 @@ Feature: render_views
require "spec_helper"
describe WidgetsController do
- describe "index" do
+ describe "GET index" do
it "renders the index template" do
get :index
- response.should contain("Listing widgets")
- end
-
- it "renders the widgets/index template" do
- get :index
- response.should contain("Listing widgets")
+ response.body.should =~ /Listing widgets/m
end
end
end
"""
When I run "rspec spec"
- Then the output should contain "2 examples, 0 failures"
+ Then the examples should all pass
View
6 features/helper_specs/helper_spec.feature
@@ -26,7 +26,7 @@ Feature: helper spec
end
"""
When I run "rspec spec/helpers/application_helper_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: helper method that accesses an instance variable
Given a file named "spec/helpers/application_helper_spec.rb" with:
@@ -51,7 +51,7 @@ Feature: helper spec
end
"""
When I run "rspec spec/helpers/application_helper_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: application helper is included in helper object
Given a file named "spec/helpers/widgets_helper_spec.rb" with:
@@ -84,4 +84,4 @@ Feature: helper spec
end
"""
When I run "rspec spec/helpers/widgets_helper_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
4 features/mailer_specs/url_helpers.feature
@@ -16,7 +16,7 @@ Feature: URL helpers in mailer examples
end
"""
When I run "rspec spec"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: using URL helpers without default options
Given a file named "config/initializers/mailer_defaults.rb" with:
@@ -35,4 +35,4 @@ Feature: URL helpers in mailer examples
end
"""
When I run "rspec spec"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
4 features/matchers/new_record_matcher.feature
@@ -25,7 +25,7 @@ Feature: be_a_new matcher
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "4 examples, 0 failures"
+ Then the examples should all pass
Scenario: example spec using be_a_new.with
Given a file named "spec/models/widget_spec.rb" with:
@@ -67,4 +67,4 @@ Feature: be_a_new matcher
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "4 examples, 0 failures"
+ Then the examples should all pass
View
2  features/matchers/redirect_to_matcher.feature
@@ -37,4 +37,4 @@ Feature: redirect_to matcher
end
"""
When I run "rspec spec/controllers/widgets_controller_spec.rb"
- Then the output should contain "4 examples, 0 failures"
+ Then the examples should all pass
View
2  features/matchers/render_template_matcher.feature
@@ -22,4 +22,4 @@ Feature: render_template matcher
end
"""
When I run "rspec spec/controllers/gadgets_spec.rb"
- Then the output should contain "3 examples, 0 failures"
+ Then the examples should all pass
View
10 features/mocks/mock_model.feature
@@ -37,7 +37,7 @@ Feature: mock_model
end
"""
When I run "rspec spec/models/car_spec.rb"
- Then the output should contain "3 examples, 0 failures"
+ Then the examples should all pass
Scenario: passing a string that represents an existing constant
Given a file named "spec/models/widget_spec.rb" with:
@@ -52,7 +52,7 @@ Feature: mock_model
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing a class that does not extend ActiveModel::Naming
Given a file named "spec/models/string_spec.rb" with:
@@ -66,7 +66,7 @@ Feature: mock_model
end
"""
When I run "rspec spec/models/string_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing an Active Record constant
Given a file named "spec/models/widget_spec.rb" with:
@@ -95,7 +95,7 @@ Feature: mock_model
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "4 examples, 0 failures"
+ Then the examples should all pass
Scenario: passing an Active Record constant with method stubs
Given a file named "spec/models/widget_spec.rb" with:
@@ -128,4 +128,4 @@ Feature: mock_model
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "3 examples, 0 failures"
+ Then the examples should all pass
View
4 features/mocks/stub_model.feature
@@ -35,7 +35,7 @@ Feature: stub_model
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "4 examples, 0 failures"
+ Then the examples should all pass
Scenario: passing an Active Record constant with a block of stubs
Given a file named "spec/models/widget_spec.rb" with:
@@ -55,4 +55,4 @@ Feature: stub_model
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
2  features/model_specs/errors_on.feature
@@ -29,4 +29,4 @@ Feature: errors_on
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "4 examples, 0 failures"
+ Then the examples should all pass
View
8 features/model_specs/transactional_examples.feature
@@ -21,7 +21,7 @@ Feature: transactional examples
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "3 examples, 0 failures"
+ Then the examples should all pass
Scenario: run in transactions (explicit)
Given a file named "spec/models/widget_spec.rb" with:
@@ -48,7 +48,7 @@ Feature: transactional examples
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "3 examples, 0 failures"
+ Then the examples should all pass
Scenario: disable transactions (explicit)
Given a file named "spec/models/widget_spec.rb" with:
@@ -77,7 +77,7 @@ Feature: transactional examples
end
"""
When I run "rspec spec/models/widget_spec.rb"
- Then the output should contain "3 examples, 0 failures"
+ Then the examples should all pass
Scenario: run in transactions with fixture
Given a file named "spec/models/thing_spec.rb" with:
@@ -97,7 +97,7 @@ Feature: transactional examples
name: MyString
"""
When I run "rspec spec/models/thing_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
6 features/routing_specs/be_routable_matcher.feature
@@ -32,7 +32,7 @@ Feature: be_routable matcher
"""
When I run "rspec spec/routing/widgets_routing_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: specify routeable route should be routable (passes)
Given a file named "spec/routing/widgets_routing_spec.rb" with:
@@ -47,7 +47,7 @@ Feature: be_routable matcher
"""
When I run "rspec spec/routing/widgets_routing_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: specify non-routeable route should be routable (fails)
Given a file named "spec/routing/widgets_routing_spec.rb" with:
@@ -77,4 +77,4 @@ Feature: be_routable matcher
"""
When I run "rspec spec/controllers/widgets_controller_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
2  features/routing_specs/named_routes.feature
@@ -15,4 +15,4 @@ Feature: named routes
end
"""
When I run "rspec spec"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
2  features/routing_specs/route_to_matcher.feature
@@ -19,7 +19,7 @@ Feature: route_to matcher
"""
When I run "rspec spec/routing/widgets_routing_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: route spec for a route that doesn't exist (fails)
Given a file named "spec/routing/widgets_routing_spec.rb" with:
View
3  features/step_definitions/rspec_steps.rb → .../step_definitions/additional_cli_steps.rb
@@ -1,5 +1,4 @@
-Then /^the example(s)? should( all)? pass$/ do |_,_|
+Then /^the example(s)? should( all)? pass$/ do |_, _|
Then %q{the exit status should be 0}
Then %q{the output should contain "0 failures"}
end
-
View
6 features/view_specs/inferred_controller_path.feature
@@ -12,7 +12,7 @@ Feature: view spec infers controller path and action
end
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: infer action
Given a file named "spec/views/widgets/new.html.erb_spec.rb" with:
@@ -26,7 +26,7 @@ Feature: view spec infers controller path and action
end
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: do not infer action in a partial
Given a file named "spec/views/widgets/_form.html.erb_spec.rb" with:
@@ -40,5 +40,5 @@ Feature: view spec infers controller path and action
end
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
4 features/view_specs/stub_template.feature
@@ -27,7 +27,7 @@ Feature: stub template
<%= render :partial => "gadget", :collection => @gadgets %>
"""
When I run "rspec spec/views/gadgets/list.html.erb_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: stub template that exists
Given a file named "spec/views/gadgets/edit.html.erb_spec.rb" with:
@@ -47,5 +47,5 @@ Feature: stub template
end
"""
When I run "rspec spec/views/gadgets/edit.html.erb_spec.rb"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
16 features/view_specs/view_spec.feature
@@ -22,7 +22,7 @@ Feature: view spec
end
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing spec with before and nesting
Given a file named "spec/views/widgets/index.html.erb_spec.rb" with:
@@ -49,7 +49,7 @@ Feature: view spec
end
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing spec with explicit template rendering
Given a file named "spec/views/widgets/widget.html.erb_spec.rb" with:
@@ -71,7 +71,7 @@ Feature: view spec
<h2><%= @widget.name %></h2>
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing spec with rendering of locals in a partial
Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
@@ -93,7 +93,7 @@ Feature: view spec
<h3><%= widget.name %></h3>
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing spec with rendering of locals in an implicit partial
Given a file named "spec/views/widgets/_widget.html.erb_spec.rb" with:
@@ -115,7 +115,7 @@ Feature: view spec
<h3><%= widget.name %></h3>
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing spec with rendering of text
Given a file named "spec/views/widgets/direct.html.erb_spec.rb" with:
@@ -132,7 +132,7 @@ Feature: view spec
end
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: passing spec with rendering of Prototype helper update
Given a file named "spec/views/widgets/prototype_update.html.erb_spec.rb" with:
@@ -151,7 +151,7 @@ Feature: view spec
end
"""
When I run "rspec spec/views"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
Scenario: spec with view that accesses helper_method helpers
Given a file named "app/views/secrets/index.html.erb" with:
@@ -182,4 +182,4 @@ Feature: view spec
end
"""
When I run "rspec spec/views/secrets"
- Then the output should contain "1 example, 0 failures"
+ Then the examples should all pass
View
4 lib/generators/rspec/integration/templates/request_spec.rb
@@ -4,10 +4,10 @@
describe "GET /<%= table_name %>" do
it "works! (now write some real specs)" do
<% if webrat? -%>
- visit <%= table_name %>_path
+ visit <%= index_helper %>_path
<% else -%>
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
- get <%= table_name %>_path
+ get <%= index_helper %>_path
<% end -%>
response.status.should be(200)
end
View
2  lib/generators/rspec/scaffold/templates/controller_spec.rb
@@ -120,7 +120,7 @@ def <%= mock_file_name %>(stubs={})
it "redirects to the <%= table_name %> list" do
<%= stub orm_class.find(class_name) %> { <%= mock_file_name %> }
delete :destroy, :id => "1"
- response.should redirect_to(<%= table_name %>_url)
+ response.should redirect_to(<%= index_helper %>_url)
end
end
View
2  lib/generators/rspec/scaffold/templates/edit_spec.rb
@@ -21,7 +21,7 @@
end
<% else -%>
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => <%= file_name %>_path(@<%= file_name %>), :method => "post" do
+ assert_select "form", :action => <%= index_helper %>_path(@<%= file_name %>), :method => "post" do
<% for attribute in output_attributes -%>
assert_select "<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]"
<% end -%>
View
2  lib/generators/rspec/scaffold/templates/new_spec.rb
@@ -20,7 +20,7 @@
end
<% else -%>
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => <%= table_name %>_path, :method => "post" do
+ assert_select "form", :action => <%= index_helper %>_path, :method => "post" do
<% for attribute in output_attributes -%>
assert_select "<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]"
<% end -%>
View
8 lib/rspec/rails/example.rb
@@ -18,9 +18,11 @@ def c.escaped_path(*parts)
c.include RSpec::Rails::HelperExampleGroup, :type => :helper, :example_group => {
:file_path => c.escaped_path(%w[spec helpers])
}
- c.include RSpec::Rails::MailerExampleGroup, :type => :mailer, :example_group => {
- :file_path => c.escaped_path(%w[spec mailers])
- }
+ if defined?(RSpec::Rails::MailerExampleGroup)
+ c.include RSpec::Rails::MailerExampleGroup, :type => :mailer, :example_group => {
+ :file_path => c.escaped_path(%w[spec mailers])
+ }
+ end
c.include RSpec::Rails::ModelExampleGroup, :type => :model, :example_group => {
:file_path => c.escaped_path(%w[spec models])
}
View
16 lib/rspec/rails/example/controller_example_group.rb
@@ -56,15 +56,19 @@ module RSpec::Rails
#
# RSpec's preferred approach to spec'ing controller behaviour is to isolate
# the controller from its collaborators. By default, therefore, controller
- # example groups do not render views. This means that a view template need
- # not even exist in order to run a controller spec, and you can still specify
- # which template the controller should render.
+ # example groups do not render the views in your app. Due to the way Rails
+ # searches for view templates, the template still needs to exist, but it
+ # won't actually be loaded.
+ #
+ # NOTE that this is different from rspec-rails-1 with rails-2, which did not
+ # require the presence of the file at all. Due to changes in rails-3, this
+ # was no longer feasible in rspec-rails-2.
#
# == View rendering
#
- # If you prefer a more integrated approach, similar to that of
- # Rails' functional tests, you can tell controller groups to
- # render views with the +render_views+ declaration:
+ # If you prefer a more integrated approach, similar to that of Rails'
+ # functional tests, you can tell controller groups to render the views in the
+ # app with the +render_views+ declaration:
#
# describe WidgetsController do
# render_views
View
2  lib/rspec/rails/example/request_example_group.rb
@@ -48,7 +48,7 @@ def last_response
metadata[:type] = :request
before do
- @router = ::Rails.application.routes
+ @routes = ::Rails.application.routes
end
webrat do
View
6 lib/rspec/rails/mocks.rb
@@ -27,6 +27,10 @@ def destroy
self.stub(:id) { nil }
end
+ def [](key)
+ send(key)
+ end
+
def new_record?
!persisted?
end
@@ -77,6 +81,7 @@ def mock_model(string_or_model_class, stubs = {})
stubs = stubs.reverse_merge(:persisted? => !!stubs[:id])
stubs = stubs.reverse_merge(:destroyed? => false)
stubs = stubs.reverse_merge(:marked_for_destruction? => false)
+ stubs = stubs.reverse_merge(:blank? => false)
mock("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m|
m.extend ActiveModelInstanceMethods
@@ -188,6 +193,7 @@ def stub_model(model_class, stubs={})
stubs = stubs.reverse_merge(:id => next_id)
stubs = stubs.reverse_merge(:persisted? => !!stubs[:id])
end
+ stubs = stubs.reverse_merge(:blank? => false)
stubs.each do |k,v|
m.__send__("#{k}=", stubs.delete(k)) if m.respond_to?("#{k}=")
end
View
2  lib/rspec/rails/version.rb
@@ -1,7 +1,7 @@
module RSpec # :nodoc:
module Rails # :nodoc:
module Version # :nodoc:
- STRING = '2.4.1'
+ STRING = '2.5.0'
end
end
end
View
2  lib/rspec/rails/view_rendering.rb
@@ -23,7 +23,7 @@ module ViewRendering
module ClassMethods
def metadata_for_rspec_rails
- metadata[:rspec_rails] ||= {}
+ metadata[:rspec_rails] = metadata[:rspec_rails] ? metadata[:rspec_rails].dup : {}
end
# See RSpec::Rails::ControllerExampleGroup
View
38 spec/rspec/rails/mocks/ar_classes.rb
@@ -1,14 +1,13 @@
-module NoConnections
- def self.included(mod)
- (class << mod; self; end).class_eval do
- def columns
- []
- end
-
- def connection
- RSpec::Mocks::Mock.new.as_null_object
- end
- end
+module Connections
+ def self.extended(host)
+ host.establish_connection :adapter => 'sqlite3',
+ :database => ':memory:'
+
+ host.connection.execute <<-eosql
+ CREATE TABLE #{host.table_name} (
+ #{host.primary_key} integer PRIMARY KEY AUTOINCREMENT
+ )
+ eosql
end
end
@@ -18,7 +17,7 @@ class NonActiveRecordModel
end
class MockableModel < ActiveRecord::Base
- include NoConnections
+ extend Connections
has_one :associated_model
end
@@ -26,23 +25,12 @@ class SubMockableModel < MockableModel
end
class AssociatedModel < ActiveRecord::Base
- include NoConnections
+ extend Connections
belongs_to :mockable_model
end
class AlternatePrimaryKeyModel < ActiveRecord::Base
- include NoConnections
self.primary_key = :my_id
+ extend Connections
attr_accessor :my_id
end
-
-class ConnectableModel < ActiveRecord::Base
- establish_connection :adapter => 'sqlite3',
- :database => ':memory:'
-
- connection.execute <<-eosql
- CREATE TABLE connectable_models (
- id integer PRIMARY KEY AUTOINCREMENT
- )
- eosql
-end
View
6 spec/rspec/rails/mocks/mock_model_spec.rb
@@ -260,6 +260,12 @@
end
end
+ describe "#blank?" do
+ it "is false" do
+ mock_model(MockableModel).should_not be_blank
+ end
+ end
+
describe "ActiveModel Lint tests" do
require 'test/unit/assertions'
require 'active_model/lint'
View
13 spec/rspec/rails/mocks/stub_model_spec.rb
@@ -35,6 +35,11 @@
second.to_param.to_i.should == (first.to_param.to_i + 1)
end
+ describe "#blank?" do
+ it "is false" do
+ stub_model(model_class).should_not be_blank
+ end
+ end
end
context "with ActiveModel (not ActiveRecord)" do
@@ -84,7 +89,7 @@ def model_class
it "raises when hitting the db" do
lambda do
- stub_model(ConnectableModel).connection
+ stub_model(MockableModel).connection
end.should raise_error(RSpec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
end
@@ -108,7 +113,7 @@ def model_class
describe "alternate primary key" do
it "has the correct primary_key name" do
- stub_model(AlternatePrimaryKeyModel).class.primary_key.should eql('my_id')
+ stub_model(AlternatePrimaryKeyModel).class.primary_key.to_s.should eql('my_id')
end
it "has a primary_key" do
@@ -138,11 +143,11 @@ def model_class
end
it "passes associated_model == mock" do
- @stub_model.should == @real.mockable_model
+ @stub_model.should == @real.mockable_model
end
it "passes mock == associated_model" do
- @real.mockable_model.should == @stub_model
+ @real.mockable_model.should == @stub_model
end
end
View
8 spec/rspec/rails/view_rendering_spec.rb
@@ -88,7 +88,13 @@ def example.controller
end
end
- it "overrides the parent group" do
+ it "leaves the parent group as/is" do
+ group.render_views
+ nested_group.render_views false
+ group.new.render_views?.should be_true
+ end
+
+ it "overrides the value inherited from the parent group" do
group.render_views
nested_group.render_views false
nested_group.new.render_views?.should be_false
View
15 templates/Gemfile
@@ -1,15 +0,0 @@
-source 'http://rubygems.org'
-
-gem "rack", :git => "git://github.com/rack/rack.git"
-gem 'rails', :path => File.expand_path("../../../vendor/rails", __FILE__)
-gem 'sqlite3-ruby', :require => 'sqlite3'
-
-group :development, :test do
- %w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
- gem lib, :path => File.expand_path("../../../../#{lib}", __FILE__)
- end
- gem "rcov"
- gem "webrat"
- gem "autotest"
- gem "watchr"
-end
View
17 templates/Gemfile-base
@@ -0,0 +1,17 @@
+source 'http://rubygems.org'
+
+group :development, :test do
+ %w[rspec rspec-core rspec-expectations rspec-mocks rspec-rails].each do |lib|
+ library_path = File.expand_path("../../../../#{lib}", __FILE__)
+ if File.exist?(library_path)
+ gem lib, :path => library_path
+ else
+ gem lib
+ end
+ end
+ gem "rcov"
+ gem "webrat", "0.7.2"
+ gem "ZenTest", "4.4.2"
+end
+
+gem 'sqlite3-ruby', :require => 'sqlite3'

Showing you all comments on commits in this comparison.

@JESii

At http://www.ruby-forum.com/topic/217922, you referenced this fix for a problem with the have_text? matcher, but I see that you have updated the docs for the have_tag? matcher instead. Can you add information about have_text? and what the recommended replacement for it is?

Thanks...jon

@dchelimsky
Owner

See d3f5e0b

@JESii
Something went wrong with that request. Please try again.