Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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
Checking mergeability… Don't worry, you can still create the pull request.
  • 12 commits
  • 17 files changed
  • 0 commit comments
  • 1 contributor
View
46 Gemfile
@@ -1,24 +1,42 @@
source "http://rubygems.org"
-gem "rails", :path => File.expand_path("../vendor/rails", __FILE__)
-gem "rack", :git => "git://github.com/rack/rack.git"
-
-%w[rspec-rails rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
- gem lib, :path => File.expand_path("../../#{lib}", __FILE__)
+%w[rspec rspec-core rspec-expectations rspec-mocks].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 "cucumber", :git => "git://github.com/dchelimsky/cucumber", :branch => "update-gemspec"
+gem "rake", "0.8.7"
+gem "cucumber", "0.9.4"
gem "aruba", "0.2.2"
-gem 'webrat', "0.7.2"
-gem 'sqlite3-ruby', :require => 'sqlite3'
-gem 'relish'
+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"
+
+if RUBY_PLATFORM =~ /darwin/
+ gem "autotest-fsevent", "~> 0.2.4"
+ gem "autotest-growl", "~> 0.2.9"
+end
-gem 'autotest'
+gem "ruby-debug", :platforms => :ruby_18
+gem "ruby-debug19", "~> 0.11.6", :platforms => :ruby_19
-platforms :mri_19 do
- gem 'ruby-debug19'
+platforms :ruby_18, :ruby_19 do
+ gem "rb-fsevent", "~> 0.3.9"
+ gem "ruby-prof", "~> 0.9.2"
end
-platforms :mri_18 do
- gem 'ruby-debug'
+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
14 History.md
@@ -1,8 +1,16 @@
-## rspec-rails-2 release history (incomplete)
+## rspec-rails-2 release history
-### 2.3.0 / in development
+### 2.3.0 / 2010-12-12
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...master)
+[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
View
4 README.md
@@ -6,10 +6,10 @@ NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2.
## Documentation
-The [Cucumber features](http://relishapp.com/rspec/rspec-rails/v/2-2) are the
+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.2.0/frames) provides additional
+The [RDoc](http://rubydoc.info/gems/rspec-rails/2.3.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
View
13 Upgrade.markdown
@@ -1,4 +1,14 @@
-# Upgrade to rspec-rails-2
+# 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
@@ -51,4 +61,3 @@ to this:
stub_model(Widget).as_new_record
Generators in 2.0.0 final release will do the latter.
-
View
1  autotest/discover.rb
@@ -1 +0,0 @@
-Autotest.add_discovery { "rspec2" }
View
66 features/README.markdown
@@ -6,6 +6,71 @@ for requests, controllers, models, views, and helpers.
rspec-rails-2 supports rails-3.0.0 and later. For earlier versions of Rails,
you need [rspec-rails-1.3](http://rspec.info).
+## Install
+
+ gem install rspec-rails
+
+This installs the following gems:
+
+ rspec
+ rspec-core
+ rspec-expectations
+ rspec-mocks
+ rspec-rails
+
+## Configure
+
+Add rspec-rails to the :test and :development groups in the Gemfile:
+
+ group :test, :development do
+ gem "rspec-rails", "~> 2.0.1"
+ end
+
+It needs to be in the :development group to expose generators and rake tasks
+without having to type RAILS_ENV=test.
+
+Now you can run:
+
+ script/rails generate rspec:install
+
+This adds the spec directory and some skeleton files, including a .rspec
+file.
+
+## Generators
+
+If you type script/rails generate, the only RSpec generator you'll actually see
+is rspec:install. That's because RSpec is registered with Rails as the test
+framework, so whenever you generate application components like models,
+controllers, etc, RSpec specs are generated instead of Test::Unit tests.
+
+Note that the generators are there to help you get started, but they are no
+substitute for writing your own examples, and they are only guaranteed to work
+out of the box for the default scenario (ActiveRecord + Webrat).
+
+## Autotest
+
+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:
+
+ gem "ZenTest"
+
+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.
+
+## Webrat and Capybara
+
+You can choose between webrat or capybara for simulating a browser, automating
+a browser, or setting expectations using the matchers they supply. Just add
+your preference to the Gemfile:
+
+ gem "webrat"
+ gem "capybara"
+
+Note that Capybara matchers are not available in view or helper specs.
+
## Issues
The documentation for rspec-rails is a work in progress. We'll be adding
@@ -15,3 +80,4 @@ incomplete or confusing, or, better yet, wish to write a missing Cucumber
feature yourself, please [submit an
issue](http://github.com/rspec/rspec-rails/issues) or a [pull
request](http://github.com/rspec/rspec-rails).
+
View
25 features/controller_specs/README.md
@@ -0,0 +1,25 @@
+A controller spec is an RSpec wrapper for a Rails functional test. It allows
+you to simulate a single http request in each example, and then specify
+expected outcomes, such as:
+
+* templates that are rendered by the action
+* instance variables that are assigned in the controller to be shared with
+ the view
+* cookies that get sent back with the response
+
+To specify outcomes, you can use:
+
+* standard rspec matchers (response.code.should eq(200))
+* standard test/unit assertions (assert_equal 200, response.code)
+* rails assertions (assert_response 200)
+* rails-specific matchers:
+ * response.should render_template (wraps assert_template)
+ * response.should redirect_to (wraps assert_redirected_to)
+ * assigns(:widget).should be_a_new(Widget)
+
+Conventions:
+
+* pass the controller being spec'd to the describe method
+ * this is only necessary for the outermost example group
+* by default, views are not rendered. See "isolation from views" and
+ "render_views" for details
View
19 features/controller_specs/controller_spec.feature
@@ -0,0 +1,19 @@
+Feature: controller spec
+
+
+ Scenario: simple passing example
+ Given a file named "spec/controllers/widgets_controller_spec.rb" with:
+ """
+ require "spec_helper"
+
+ describe WidgetsController do
+ describe "GET index" do
+ it "has a 200 status code" do
+ get :index
+ response.code.should eq("200")
+ end
+ end
+ end
+ """
+ When I run "rspec spec"
+ Then the example should pass
View
18 features/controller_specs/readers.feature
@@ -1,18 +0,0 @@
-Feature: controller spec readers
-
- Controller specs expose a number of different
- attribute readers.
-
- Scenario: access controller
- Given a file named "spec/controllers/widgets_controller_spec.rb" with:
- """
- require "spec_helper"
-
- describe WidgetsController do
- it "is available before an action" do
- controller.should be_an_instance_of(WidgetsController)
- end
- end
- """
- When I run "rspec ./spec"
- Then the output should contain "1 example, 0 failures"
View
4 features/matchers/README.md
@@ -0,0 +1,4 @@
+rspec-rails offers a number of custom matchers, most of which are
+rspec-compatible wrappers for Rails' assertions.
+
+
View
5 features/step_definitions/rspec_steps.rb
@@ -0,0 +1,5 @@
+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
2  lib/generators/rspec/install/templates/autotest/discover.rb
@@ -1,2 +0,0 @@
-Autotest.add_discovery { "rails" }
-Autotest.add_discovery { "rspec2" }
View
4 lib/rspec/rails/mocks.rb
@@ -15,6 +15,10 @@ def as_new_record
def persisted?
true
end
+
+ def respond_to?(message)
+ message.to_s =~ /_before_type_cast$/ ? false : super
+ end
end
module ActiveRecordInstanceMethods
View
2  lib/rspec/rails/version.rb
@@ -1,7 +1,7 @@
module RSpec # :nodoc:
module Rails # :nodoc:
module Version # :nodoc:
- STRING = '2.2.0'
+ STRING = '2.3.0'
end
end
end
View
6 rspec-rails.gemspec
@@ -57,9 +57,9 @@ Gem::Specification.new do |s|
**************************************************
}
- s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
- s.add_runtime_dependency(%q<actionpack>, [">= 3.0.0"])
- s.add_runtime_dependency(%q<railties>, [">= 3.0.0"])
+ s.add_runtime_dependency(%q<activesupport>, ["~> 3.0"])
+ s.add_runtime_dependency(%q<actionpack>, ["~> 3.0"])
+ s.add_runtime_dependency(%q<railties>, ["~> 3.0"])
s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].concat(['0']).join('.')}"
end
View
30 spec/rspec/rails/mocks/mock_model_spec.rb
@@ -144,11 +144,27 @@
MockableModel.stub(:column_names).and_return(["column_a", "column_b"])
@model = mock_model(MockableModel)
end
- it "says it will respond_to?(key) if RealModel has the attribute 'key'" do
- @model.respond_to?("column_a").should be(true)
+ context "without as_null_object" do
+ it "says it will respond_to?(key) if RealModel has the attribute 'key'" do
+ @model.respond_to?("column_a").should be(true)
+ end
+ it "says it will not respond_to?(key) if RealModel does not have the attribute 'key'" do
+ @model.respond_to?("column_c").should be(false)
+ end
+ it "says it will not respond_to?(xxx_before_type_cast)" do
+ @model.respond_to?("title_before_type_cast").should be(false)
+ end
end
- it "does not say it will respond_to?(key) if RealModel does not have the attribute 'key'" do
- @model.respond_to?("column_c").should be(false)
+ context "with as_null_object" do
+ it "says it will respond_to?(key) if RealModel has the attribute 'key'" do
+ @model.as_null_object.respond_to?("column_a").should be(true)
+ end
+ it "says it will respond_to?(key) even if RealModel does not have the attribute 'key'" do
+ @model.as_null_object.respond_to?("column_c").should be(true)
+ end
+ it "says it will not respond_to?(xxx_before_type_cast)" do
+ @model.as_null_object.respond_to?("title_before_type_cast").should be(false)
+ end
end
end
@@ -157,6 +173,12 @@
model = NonActiveRecordModel.new
model.should respond_to(:to_param)
end
+ context "with as_null_object" do
+ it "says it will not respond_to?(xxx_before_type_cast)" do
+ model = NonActiveRecordModel.new.as_null_object
+ model.respond_to?("title_before_type_cast").should be(false)
+ end
+ end
end
end
View
2  templates/generate_stuff.rb
@@ -7,7 +7,7 @@
generate('helper things')
generate('scaffold widget name:string category:string instock:boolean')
generate('observer widget')
-generate('scaffold gadget ') # scaffold with no attributes
+generate('scaffold gadget') # scaffold with no attributes
run('rake db:migrate')
run('rake db:test:prepare')

No commit comments for this range

Something went wrong with that request. Please try again.