rspec-rails 2.2.1 → 2.3.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/Gemfile CHANGED
@@ -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'
data/History.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## rspec-rails-2 release history
2
2
 
3
+ ### 2.3.0 / 2010-12-12
4
+
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
+
3
11
  ### 2.2.1 / 2010-12-01
4
12
 
5
13
  [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
data/README.md CHANGED
@@ -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.1/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
@@ -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
-
@@ -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
+
@@ -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
@@ -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
@@ -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
+
@@ -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
+
@@ -15,6 +15,10 @@ module RSpec
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
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Rails # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.2.1'
4
+ STRING = '2.3.0'
5
5
  end
6
6
  end
7
7
  end
@@ -144,11 +144,27 @@ describe "mock_model(RealModel)" do
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 @@ describe "mock_model(RealModel)" do
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
 
@@ -7,7 +7,7 @@ generate('model thing name:string')
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')
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 3
4
5
  prerelease: false
5
6
  segments:
6
7
  - 2
7
- - 2
8
- - 1
9
- version: 2.2.1
8
+ - 3
9
+ - 0
10
+ version: 2.3.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - David Chelimsky
@@ -14,64 +15,68 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-12-01 00:00:00 -06:00
18
+ date: 2010-12-12 00:00:00 -06:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: activesupport
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
+ hash: 7
27
28
  segments:
28
29
  - 3
29
30
  - 0
30
31
  version: "3.0"
31
32
  type: :runtime
33
+ name: activesupport
32
34
  prerelease: false
33
35
  version_requirements: *id001
34
36
  - !ruby/object:Gem::Dependency
35
- name: actionpack
36
37
  requirement: &id002 !ruby/object:Gem::Requirement
37
38
  none: false
38
39
  requirements:
39
40
  - - ~>
40
41
  - !ruby/object:Gem::Version
42
+ hash: 7
41
43
  segments:
42
44
  - 3
43
45
  - 0
44
46
  version: "3.0"
45
47
  type: :runtime
48
+ name: actionpack
46
49
  prerelease: false
47
50
  version_requirements: *id002
48
51
  - !ruby/object:Gem::Dependency
49
- name: railties
50
52
  requirement: &id003 !ruby/object:Gem::Requirement
51
53
  none: false
52
54
  requirements:
53
55
  - - ~>
54
56
  - !ruby/object:Gem::Version
57
+ hash: 7
55
58
  segments:
56
59
  - 3
57
60
  - 0
58
61
  version: "3.0"
59
62
  type: :runtime
63
+ name: railties
60
64
  prerelease: false
61
65
  version_requirements: *id003
62
66
  - !ruby/object:Gem::Dependency
63
- name: rspec
64
67
  requirement: &id004 !ruby/object:Gem::Requirement
65
68
  none: false
66
69
  requirements:
67
70
  - - ~>
68
71
  - !ruby/object:Gem::Version
72
+ hash: 3
69
73
  segments:
70
74
  - 2
71
- - 2
75
+ - 3
72
76
  - 0
73
- version: 2.2.0
77
+ version: 2.3.0
74
78
  type: :runtime
79
+ name: rspec
75
80
  prerelease: false
76
81
  version_requirements: *id004
77
82
  description: RSpec-2 for Rails-3
@@ -92,15 +97,16 @@ files:
92
97
  - Rakefile
93
98
  - Thorfile
94
99
  - Upgrade.markdown
95
- - autotest/discover.rb
96
100
  - cucumber.yml
97
101
  - features/README.markdown
102
+ - features/controller_specs/README.md
98
103
  - features/controller_specs/anonymous_controller.feature
104
+ - features/controller_specs/controller_spec.feature
99
105
  - features/controller_specs/isolation_from_views.feature
100
- - features/controller_specs/readers.feature
101
106
  - features/controller_specs/render_views.feature
102
107
  - features/helper_specs/helper_spec.feature
103
108
  - features/mailer_specs/url_helpers.feature
109
+ - features/matchers/README.md
104
110
  - features/matchers/be_routable_matcher.feature
105
111
  - features/matchers/new_record_matcher.feature
106
112
  - features/matchers/redirect_to_matcher.feature
@@ -111,6 +117,7 @@ files:
111
117
  - features/model_specs/transactional_examples.feature
112
118
  - features/routing_specs/access_to_named_routes.feature
113
119
  - features/step_definitions/model_steps.rb
120
+ - features/step_definitions/rspec_steps.rb
114
121
  - features/support/env.rb
115
122
  - features/view_specs/inferred_controller_path.feature
116
123
  - features/view_specs/stub_template.feature
@@ -124,7 +131,6 @@ files:
124
131
  - lib/generators/rspec/helper/templates/helper_spec.rb
125
132
  - lib/generators/rspec/install/install_generator.rb
126
133
  - lib/generators/rspec/install/templates/.rspec
127
- - lib/generators/rspec/install/templates/autotest/discover.rb
128
134
  - lib/generators/rspec/install/templates/spec/spec_helper.rb
129
135
  - lib/generators/rspec/integration/integration_generator.rb
130
136
  - lib/generators/rspec/integration/templates/request_spec.rb
@@ -211,7 +217,7 @@ licenses: []
211
217
  post_install_message: |
212
218
  **************************************************
213
219
 
214
- Thank you for installing rspec-rails-2.2.1!
220
+ Thank you for installing rspec-rails-2.3.0!
215
221
 
216
222
  This version of rspec-rails only works with versions of rails >= 3.0.0
217
223
 
@@ -221,7 +227,7 @@ post_install_message: |
221
227
  can access its generators and rake tasks.
222
228
 
223
229
  group :development, :test do
224
- gem "rspec-rails", ">= 2.2.1"
230
+ gem "rspec-rails", ">= 2.3.0"
225
231
  end
226
232
 
227
233
  Be sure to run the following command in each of your Rails apps if you're
@@ -252,7 +258,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
258
  requirements:
253
259
  - - ">="
254
260
  - !ruby/object:Gem::Version
255
- hash: 1117426161329304162
261
+ hash: 3
256
262
  segments:
257
263
  - 0
258
264
  version: "0"
@@ -261,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
267
  requirements:
262
268
  - - ">="
263
269
  - !ruby/object:Gem::Version
264
- hash: 1117426161329304162
270
+ hash: 3
265
271
  segments:
266
272
  - 0
267
273
  version: "0"
@@ -271,15 +277,17 @@ rubyforge_project: rspec
271
277
  rubygems_version: 1.3.7
272
278
  signing_key:
273
279
  specification_version: 3
274
- summary: rspec-rails-2.2.1
280
+ summary: rspec-rails-2.3.0
275
281
  test_files:
276
282
  - features/README.markdown
283
+ - features/controller_specs/README.md
277
284
  - features/controller_specs/anonymous_controller.feature
285
+ - features/controller_specs/controller_spec.feature
278
286
  - features/controller_specs/isolation_from_views.feature
279
- - features/controller_specs/readers.feature
280
287
  - features/controller_specs/render_views.feature
281
288
  - features/helper_specs/helper_spec.feature
282
289
  - features/mailer_specs/url_helpers.feature
290
+ - features/matchers/README.md
283
291
  - features/matchers/be_routable_matcher.feature
284
292
  - features/matchers/new_record_matcher.feature
285
293
  - features/matchers/redirect_to_matcher.feature
@@ -290,6 +298,7 @@ test_files:
290
298
  - features/model_specs/transactional_examples.feature
291
299
  - features/routing_specs/access_to_named_routes.feature
292
300
  - features/step_definitions/model_steps.rb
301
+ - features/step_definitions/rspec_steps.rb
293
302
  - features/support/env.rb
294
303
  - features/view_specs/inferred_controller_path.feature
295
304
  - features/view_specs/stub_template.feature
@@ -1 +0,0 @@
1
- Autotest.add_discovery { "rspec2" }
@@ -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"
@@ -1,2 +0,0 @@
1
- Autotest.add_discovery { "rails" }
2
- Autotest.add_discovery { "rspec2" }