Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: rspec/rspec-rails
...
head fork: rspec/rspec-rails
  • 4 commits
  • 12 files changed
  • 0 commit comments
  • 1 contributor
6 History.md
View
@@ -1,8 +1,8 @@
-## rspec-rails-2 release history (incomplete)
+## rspec-rails-2 release history
-### 2.3.0 / in development
+### 2.2.1 / 2010-12-01
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...master)
+[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
2  README.md
View
@@ -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/v/2-2) 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.2.1/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
17 features/README.markdown
View
@@ -1,17 +0,0 @@
-rspec-rails extends Rails' built-in testing framework to support rspec examples
-for requests, controllers, models, views, and helpers.
-
-## Rails-3
-
-rspec-rails-2 supports rails-3.0.0 and later. For earlier versions of Rails,
-you need [rspec-rails-1.3](http://rspec.info).
-
-## Issues
-
-The documentation for rspec-rails is a work in progress. We'll be adding
-Cucumber features over time, and clarifying existing ones. If you have
-specific features you'd like to see added, find the existing documentation
-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).
25 features/controller_specs/README.md
View
@@ -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
19 features/controller_specs/controller_spec.feature
View
@@ -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
18 features/controller_specs/readers.feature
View
@@ -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"
4 features/matchers/README.md
View
@@ -0,0 +1,4 @@
+rspec-rails offers a number of custom matchers, most of which are
+rspec-compatible wrappers for Rails' assertions.
+
+
5 features/step_definitions/rspec_steps.rb
View
@@ -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
+
4 lib/rspec/rails/mocks.rb
View
@@ -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
2  lib/rspec/rails/version.rb
View
@@ -1,7 +1,7 @@
module RSpec # :nodoc:
module Rails # :nodoc:
module Version # :nodoc:
- STRING = '2.2.0'
+ STRING = '2.2.1'
end
end
end
6 rspec-rails.gemspec
View
@@ -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
30 spec/rspec/rails/mocks/mock_model_spec.rb
View
@@ -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

No commit comments for this range

Something went wrong with that request. Please try again.