Skip to content
This repository
  • 12 commits
  • 17 files changed
  • 0 comments
  • 1 contributor
46  Gemfile
... ...
@@ -1,24 +1,42 @@
1 1
 source "http://rubygems.org"
2 2
 
3  
-gem "rails", :path => File.expand_path("../vendor/rails", __FILE__)
4  
-gem "rack", :git => "git://github.com/rack/rack.git"
5  
-
6  
-%w[rspec-rails rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
7  
-  gem lib, :path => File.expand_path("../../#{lib}", __FILE__)
  3
+%w[rspec rspec-core rspec-expectations rspec-mocks].each do |lib|
  4
+  library_path = File.expand_path("../../#{lib}", __FILE__)
  5
+  if File.exist?(library_path)
  6
+    gem lib, :path => library_path
  7
+  else
  8
+    gem lib
  9
+  end
8 10
 end
9 11
 
10  
-gem "cucumber", :git => "git://github.com/dchelimsky/cucumber", :branch => "update-gemspec"
  12
+gem "rake", "0.8.7"
  13
+gem "cucumber", "0.9.4"
11 14
 gem "aruba", "0.2.2"
12  
-gem 'webrat', "0.7.2"
13  
-gem 'sqlite3-ruby', :require => 'sqlite3'
14  
-gem 'relish'
  15
+gem "rcov", "0.9.9"
  16
+gem "relish", "0.2.0"
  17
+gem "guard-rspec", "0.1.9"
  18
+gem "growl", "1.0.3"
  19
+gem "ZenTest", "~> 4.4.2"
  20
+
  21
+if RUBY_PLATFORM =~ /darwin/
  22
+  gem "autotest-fsevent", "~> 0.2.4"
  23
+  gem "autotest-growl", "~> 0.2.9"
  24
+end
15 25
 
16  
-gem 'autotest'
  26
+gem "ruby-debug", :platforms => :ruby_18
  27
+gem "ruby-debug19", "~> 0.11.6", :platforms => :ruby_19
17 28
 
18  
-platforms :mri_19 do
19  
-  gem 'ruby-debug19'
  29
+platforms :ruby_18, :ruby_19 do
  30
+  gem "rb-fsevent", "~> 0.3.9"
  31
+  gem "ruby-prof", "~> 0.9.2"
20 32
 end
21 33
 
22  
-platforms :mri_18 do
23  
-  gem 'ruby-debug'
  34
+platforms :jruby do
  35
+  gem "jruby-openssl"
24 36
 end
  37
+
  38
+#### rspec-rails only
  39
+gem "rails", :path => File.expand_path("../vendor/rails", __FILE__)
  40
+gem "rack", :git => "git://github.com/rack/rack.git"
  41
+gem 'webrat', "0.7.2"
  42
+gem 'sqlite3-ruby', :require => 'sqlite3'
14  History.md
Source Rendered
... ...
@@ -1,8 +1,16 @@
1  
-## rspec-rails-2 release history (incomplete)
  1
+## rspec-rails-2 release history
2 2
 
3  
-### 2.3.0 / in development
  3
+### 2.3.0 / 2010-12-12
4 4
 
5  
-[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...master)
  5
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
  6
+
  7
+* Changes
  8
+  * Generator no longer generates autotest/autodiscover.rb, as it is no longer
  9
+    needed (as of rspec-core-2.3.0)
  10
+
  11
+### 2.2.1 / 2010-12-01
  12
+
  13
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
6 14
 
7 15
 * Bug fixes
8 16
   * Depend on railties, activesupport, and actionpack instead of rails (Piotr
4  README.md
Source Rendered
@@ -6,10 +6,10 @@ NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2.
6 6
 
7 7
 ## Documentation
8 8
 
9  
-The [Cucumber features](http://relishapp.com/rspec/rspec-rails/v/2-2) are the
  9
+The [Cucumber features](http://relishapp.com/rspec/rspec-rails) are the
10 10
 most comprehensive and up-to-date docs for end-users.
11 11
 
12  
-The [RDoc](http://rubydoc.info/gems/rspec-rails/2.2.0/frames) provides additional
  12
+The [RDoc](http://rubydoc.info/gems/rspec-rails/2.3.0/frames) provides additional
13 13
 information for contributors and/or extenders.
14 14
 
15 15
 All of the documentation is open source and a work in progress. If you find it
13  Upgrade.markdown
Source Rendered
... ...
@@ -1,4 +1,14 @@
1  
-# Upgrade to rspec-rails-2
  1
+# rspec-rails-2.3.0
  2
+
  3
+## autotest integration
  4
+
  5
+Add a .rspec file to the project's root directory (if not already there) to
  6
+tell RSpec to tell Autotest to use RSpec's specialized Autotest class.
  7
+
  8
+NOTE that rspec-core-2.0, 2.1, and 2.2 required an autotest/discover.rb file in
  9
+the project's root directory. This worked with some, but not all versions of
  10
+autotest and/or the autotest command that ships with ZenTest. This new approach
  11
+will work regardless of which version of autotest/ZenTest you are using.
2 12
 
3 13
 ## Webrat and Capybara
4 14
 
@@ -51,4 +61,3 @@ to this:
51 61
     stub_model(Widget).as_new_record
52 62
 
53 63
 Generators in 2.0.0 final release will do the latter.
54  
-
1  autotest/discover.rb
... ...
@@ -1 +0,0 @@
1  
-Autotest.add_discovery { "rspec2" }
66  features/README.markdown
Source Rendered
@@ -6,6 +6,71 @@ for requests, controllers, models, views, and helpers.
6 6
 rspec-rails-2 supports rails-3.0.0 and later. For earlier versions of Rails,
7 7
 you need [rspec-rails-1.3](http://rspec.info).
8 8
 
  9
+## Install
  10
+
  11
+    gem install rspec-rails
  12
+
  13
+This installs the following gems:
  14
+
  15
+    rspec
  16
+    rspec-core
  17
+    rspec-expectations
  18
+    rspec-mocks
  19
+    rspec-rails
  20
+
  21
+## Configure
  22
+
  23
+Add rspec-rails to the :test and :development groups in the Gemfile:
  24
+
  25
+    group :test, :development do
  26
+      gem "rspec-rails", "~> 2.0.1"
  27
+    end
  28
+
  29
+It needs to be in the :development group to expose generators and rake tasks
  30
+without having to type RAILS_ENV=test.
  31
+
  32
+Now you can run:
  33
+
  34
+    script/rails generate rspec:install
  35
+
  36
+This adds the spec directory and some skeleton files, including a .rspec
  37
+file.
  38
+
  39
+## Generators
  40
+
  41
+If you type script/rails generate, the only RSpec generator you'll actually see
  42
+is rspec:install. That's because RSpec is registered with Rails as the test
  43
+framework, so whenever you generate application components like models,
  44
+controllers, etc, RSpec specs are generated instead of Test::Unit tests.
  45
+
  46
+Note that the generators are there to help you get started, but they are no
  47
+substitute for writing your own examples, and they are only guaranteed to work
  48
+out of the box for the default scenario (ActiveRecord + Webrat).
  49
+
  50
+## Autotest
  51
+
  52
+The rspec:install generator creates a .rspec file, which tells RSpec to tell
  53
+Autotest that you're using RSpec and Rails. You'll also need to add the ZenTest
  54
+gem to your Gemfile:
  55
+
  56
+    gem "ZenTest"
  57
+
  58
+At this point, if all of the gems in your Gemfile are installed in system gems,
  59
+you can just type autotest. If, however, Bundler is managing any gems for you
  60
+directly (i.e. you've got :git or :path attributes in the Gemfile), you'll need
  61
+to run bundle exec autotest.
  62
+
  63
+## Webrat and Capybara
  64
+
  65
+You can choose between webrat or capybara for simulating a browser, automating
  66
+a browser, or setting expectations using the matchers they supply. Just add
  67
+your preference to the Gemfile:
  68
+
  69
+    gem "webrat"
  70
+    gem "capybara"
  71
+
  72
+Note that Capybara matchers are not available in view or helper specs.
  73
+
9 74
 ## Issues
10 75
 
11 76
 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
15 80
 feature yourself, please [submit an
16 81
 issue](http://github.com/rspec/rspec-rails/issues) or a [pull
17 82
 request](http://github.com/rspec/rspec-rails).
  83
+
25  features/controller_specs/README.md
Source Rendered
... ...
@@ -0,0 +1,25 @@
  1
+A controller spec is an RSpec wrapper for a Rails functional test. It allows
  2
+you to simulate a single http request in each example, and then specify
  3
+expected outcomes, such as:
  4
+
  5
+* templates that are rendered by the action
  6
+* instance variables that are assigned in the controller to be shared with
  7
+  the view
  8
+* cookies that get sent back with the response
  9
+
  10
+To specify outcomes, you can use:
  11
+    
  12
+* standard rspec matchers (response.code.should eq(200))
  13
+* standard test/unit assertions (assert_equal 200, response.code)
  14
+* rails assertions (assert_response 200)
  15
+* rails-specific matchers:
  16
+  * response.should render_template (wraps assert_template)
  17
+  * response.should redirect_to (wraps assert_redirected_to)
  18
+  * assigns(:widget).should be_a_new(Widget)
  19
+    
  20
+Conventions:
  21
+
  22
+* pass the controller being spec'd to the describe method
  23
+  * this is only necessary for the outermost example group
  24
+* by default, views are not rendered. See "isolation from views" and
  25
+  "render_views" for details
19  features/controller_specs/controller_spec.feature
... ...
@@ -0,0 +1,19 @@
  1
+Feature: controller spec
  2
+
  3
+
  4
+  Scenario: simple passing example
  5
+    Given a file named "spec/controllers/widgets_controller_spec.rb" with:
  6
+      """
  7
+      require "spec_helper"
  8
+
  9
+      describe WidgetsController do
  10
+        describe "GET index" do
  11
+          it "has a 200 status code" do
  12
+            get :index
  13
+            response.code.should eq("200")
  14
+          end
  15
+        end
  16
+      end
  17
+      """
  18
+    When I run "rspec spec"
  19
+    Then the example should pass
18  features/controller_specs/readers.feature
... ...
@@ -1,18 +0,0 @@
1  
-Feature: controller spec readers
2  
-
3  
-  Controller specs expose a number of different
4  
-  attribute readers.
5  
-
6  
-  Scenario: access controller
7  
-    Given a file named "spec/controllers/widgets_controller_spec.rb" with:
8  
-      """
9  
-      require "spec_helper"
10  
-
11  
-      describe WidgetsController do
12  
-        it "is available before an action" do
13  
-          controller.should be_an_instance_of(WidgetsController)
14  
-        end
15  
-      end
16  
-      """
17  
-    When I run "rspec ./spec"
18  
-    Then the output should contain "1 example, 0 failures"
4  features/matchers/README.md
Source Rendered
... ...
@@ -0,0 +1,4 @@
  1
+rspec-rails offers a number of custom matchers, most of which are
  2
+rspec-compatible wrappers for Rails' assertions.
  3
+
  4
+
5  features/step_definitions/rspec_steps.rb
... ...
@@ -0,0 +1,5 @@
  1
+Then /^the example(s)? should( all)? pass$/ do |_,_|
  2
+  Then %q{the exit status should be 0}
  3
+  Then %q{the output should contain "0 failures"}
  4
+end
  5
+
2  lib/generators/rspec/install/templates/autotest/discover.rb
... ...
@@ -1,2 +0,0 @@
1  
-Autotest.add_discovery { "rails" }
2  
-Autotest.add_discovery { "rspec2" }
4  lib/rspec/rails/mocks.rb
@@ -15,6 +15,10 @@ def as_new_record
15 15
         def persisted?
16 16
           true
17 17
         end
  18
+
  19
+        def respond_to?(message)
  20
+          message.to_s =~ /_before_type_cast$/ ? false : super
  21
+        end
18 22
       end
19 23
 
20 24
       module ActiveRecordInstanceMethods
2  lib/rspec/rails/version.rb
... ...
@@ -1,7 +1,7 @@
1 1
 module RSpec # :nodoc:
2 2
   module Rails # :nodoc:
3 3
     module Version # :nodoc:
4  
-      STRING = '2.2.0'
  4
+      STRING = '2.3.0'
5 5
     end
6 6
   end
7 7
 end
6  rspec-rails.gemspec
@@ -57,9 +57,9 @@ Gem::Specification.new do |s|
57 57
 **************************************************
58 58
 }
59 59
 
60  
-  s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
61  
-  s.add_runtime_dependency(%q<actionpack>, [">= 3.0.0"])
62  
-  s.add_runtime_dependency(%q<railties>, [">= 3.0.0"])
  60
+  s.add_runtime_dependency(%q<activesupport>, ["~> 3.0"])
  61
+  s.add_runtime_dependency(%q<actionpack>, ["~> 3.0"])
  62
+  s.add_runtime_dependency(%q<railties>, ["~> 3.0"])
63 63
   s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].concat(['0']).join('.')}"
64 64
 end
65 65
 
30  spec/rspec/rails/mocks/mock_model_spec.rb
@@ -144,11 +144,27 @@
144 144
         MockableModel.stub(:column_names).and_return(["column_a", "column_b"])
145 145
         @model = mock_model(MockableModel)
146 146
       end
147  
-      it "says it will respond_to?(key) if RealModel has the attribute 'key'" do
148  
-        @model.respond_to?("column_a").should be(true)
  147
+      context "without as_null_object" do
  148
+        it "says it will respond_to?(key) if RealModel has the attribute 'key'" do
  149
+          @model.respond_to?("column_a").should be(true)
  150
+        end
  151
+        it "says it will not respond_to?(key) if RealModel does not have the attribute 'key'" do
  152
+          @model.respond_to?("column_c").should be(false)
  153
+        end
  154
+        it "says it will not respond_to?(xxx_before_type_cast)" do
  155
+          @model.respond_to?("title_before_type_cast").should be(false)
  156
+        end
149 157
       end
150  
-      it "does not say it will respond_to?(key) if RealModel does not have the attribute 'key'" do
151  
-        @model.respond_to?("column_c").should be(false)
  158
+      context "with as_null_object" do
  159
+        it "says it will respond_to?(key) if RealModel has the attribute 'key'" do
  160
+          @model.as_null_object.respond_to?("column_a").should be(true)
  161
+        end
  162
+        it "says it will respond_to?(key) even if RealModel does not have the attribute 'key'" do
  163
+          @model.as_null_object.respond_to?("column_c").should be(true)
  164
+        end
  165
+        it "says it will not respond_to?(xxx_before_type_cast)" do
  166
+          @model.as_null_object.respond_to?("title_before_type_cast").should be(false)
  167
+        end
152 168
       end
153 169
     end
154 170
 
@@ -157,6 +173,12 @@
157 173
         model = NonActiveRecordModel.new
158 174
         model.should respond_to(:to_param)
159 175
       end
  176
+      context "with as_null_object" do
  177
+        it "says it will not respond_to?(xxx_before_type_cast)" do
  178
+          model = NonActiveRecordModel.new.as_null_object
  179
+          model.respond_to?("title_before_type_cast").should be(false)
  180
+        end
  181
+      end
160 182
     end
161 183
   end
162 184
 
2  templates/generate_stuff.rb
@@ -7,7 +7,7 @@
7 7
 generate('helper things')
8 8
 generate('scaffold widget name:string category:string instock:boolean')
9 9
 generate('observer widget')
10  
-generate('scaffold gadget ') # scaffold with no attributes
  10
+generate('scaffold gadget') # scaffold with no attributes
11 11
 
12 12
 run('rake db:migrate')
13 13
 run('rake db:test:prepare')

No commit comments for this range

Something went wrong with that request. Please try again.