rspec-rails 2.8.1 → 2.9.0.rc2

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.
Files changed (37) hide show
  1. data/.document +5 -0
  2. data/.yardopts +9 -0
  3. data/Changelog.md +250 -0
  4. data/README.md +6 -6
  5. data/features/support/env.rb +1 -1
  6. data/features/view_specs/inferred_controller_path.feature +3 -3
  7. data/features/view_specs/stub_template.feature +2 -2
  8. data/features/view_specs/view_spec.feature +3 -3
  9. data/lib/generators/rspec/scaffold/scaffold_generator.rb +3 -0
  10. data/lib/generators/rspec/scaffold/templates/index_spec.rb +3 -1
  11. data/lib/generators/rspec/scaffold/templates/show_spec.rb +3 -1
  12. data/lib/rspec/rails/example/view_example_group.rb +1 -1
  13. data/lib/rspec/rails/matchers/be_a_new.rb +1 -1
  14. data/lib/rspec/rails/matchers/be_new_record.rb +1 -1
  15. data/lib/rspec/rails/matchers/have_extension.rb +2 -2
  16. data/lib/rspec/rails/matchers/redirect_to.rb +1 -1
  17. data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
  18. data/lib/rspec/rails/matchers/render_template.rb +1 -1
  19. data/lib/rspec/rails/matchers/routing_matchers.rb +7 -2
  20. data/lib/rspec/rails/mocks.rb +1 -1
  21. data/lib/rspec/rails/tasks/rspec.rake +6 -1
  22. data/lib/rspec/rails/vendor/webrat.rb +2 -2
  23. data/lib/rspec/rails/version.rb +1 -1
  24. data/spec/generators/rspec/controller/controller_generator_spec.rb +8 -8
  25. data/spec/generators/rspec/helper/helper_generator_spec.rb +2 -2
  26. data/spec/generators/rspec/integration/integration_generator_spec.rb +6 -6
  27. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +7 -7
  28. data/spec/generators/rspec/model/model_generator_spec.rb +4 -4
  29. data/spec/generators/rspec/observer/observer_generator_spec.rb +2 -2
  30. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +18 -18
  31. data/spec/generators/rspec/view/view_generator_spec.rb +6 -6
  32. data/spec/rspec/rails/matchers/be_a_new_spec.rb +10 -7
  33. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +1 -1
  34. data/spec/rspec/rails/matchers/route_to_spec.rb +10 -0
  35. data/spec/rspec/rails/mocks/mock_model_spec.rb +6 -1
  36. data/spec/spec_helper.rb +3 -0
  37. metadata +28 -20
@@ -0,0 +1,5 @@
1
+ README.markdown
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ License.txt
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --exclude features
3
+ --exclude lib/generators/**/*_spec.rb
4
+ --markup markdown
5
+ --template-path yard/template/
6
+ -
7
+ README.md
8
+ Changelog.md
9
+ License.txt
@@ -0,0 +1,250 @@
1
+ ### 2.9.0.rc2 / 2012-03-12
2
+ [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.1...v2.9.0.rc2)
3
+
4
+ Enhancments
5
+ * add description method to RouteToMatcher (John Wulff)
6
+ * Run "db:test:clone_structure" instead of "db:test:prepare" if Active Record's
7
+ schema format is ":sql". (Andrey Voronkov)
8
+
9
+ Bug fixes
10
+ * mock_model(XXX).as_null_object.unknown_method returns self again
11
+ * Generated view specs use different IDs for each attribute.
12
+
13
+ ### 2.8.1 / 2012-01-04
14
+
15
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.8.0...v2.8.1)
16
+
17
+ NOTE: there was a change in rails-3.2.0.rc2 which broke compatibility with
18
+ stub_model in rspec-rails. This release fixes that issue, but it means that
19
+ you'll have to upgrade to rspec-rails-2.8.1 when you upgrade to rails >=
20
+ 3.2.0.rc2.
21
+
22
+ * Bug fixes
23
+ * Explicitly stub valid? in stub_model. Fixes stub_model for rails versions
24
+ >= 3.2.0.rc2.
25
+
26
+ ### 2.8.0 / 2012-01-04
27
+
28
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.8.0.rc2...v2.8.0)
29
+
30
+ * Enhancements
31
+ * Eliminate deprecation warnings in generated view specs in Rails 3.2
32
+ * Ensure namespaced helpers are included automatically (Evgeniy Dolzhenko)
33
+ * Added cuke scenario documenting which routes are generated for anonymous
34
+ controllers (Alan Shields)
35
+
36
+ ### 2.8.0.rc2 / 2011-12-19
37
+
38
+ [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc1...v2.8.0.rc2)
39
+
40
+ * Enhancements
41
+ * Add session hash to generated controller specs (Thiago Almeida)
42
+ * Eliminate deprecation warnings about InstanceMethods modules in Rails 3.2
43
+
44
+ * Bug fixes
45
+ * Stub attribute accessor after `respond_to?` call on mocked model (Igor
46
+ Afonov)
47
+
48
+ ### 2.8.0.rc1 / 2011-11-06
49
+
50
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.7.0...v2.8.0.rc1)
51
+
52
+ * Enhancements
53
+ * Removed unnecessary "config.mock_with :rspec" from spec_helper.rb (Paul
54
+ Annesley)
55
+
56
+ * Changes
57
+ * No API changes for rspec-rails in this release, but some internals
58
+ changed to align with rspec-core-2.8
59
+
60
+ * [rspec-core](https://github.com/rspec/rspec-core/blob/master/Changelog.md)
61
+ * [rspec-expectations](https://github.com/rspec/rspec-expectations/blob/master/Changelog.md)
62
+ * [rspec-mocks](https://github.com/rspec/rspec-mocks/blob/master/Changelog.md)
63
+
64
+ ### 2.7.0 / 2011-10-16
65
+
66
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.6.1...v2.7.0)
67
+
68
+ * Enhancments
69
+ * `ActiveRecord::Relation` can use the `=~` matcher (Andy Lindeman)
70
+ * Make generated controller spec more consistent with regard to ids
71
+ (Brent J. Nordquist)
72
+ * Less restrictive autotest mapping between spec and implementation files
73
+ (José Valim)
74
+ * `require 'rspec/autorun'` from generated `spec_helper.rb` (David Chelimsky)
75
+ * add `bypass_rescue` (Lenny Marks)
76
+ * `route_to` accepts query string (Marc Weil)
77
+
78
+ * Internal
79
+ * Added specs for generators using ammeter (Alex Rothenberg)
80
+
81
+ * Bug fixes
82
+ * Fix configuration/integration bug with rails 3.0 (fixed in 3.1) in which
83
+ `fixure_file_upload` reads from `ActiveSupport::TestCase.fixture_path` and
84
+ misses RSpec's configuration (David Chelimsky)
85
+ * Support nested resource in view spec generator (David Chelimsky)
86
+ * Define `primary_key` on class generated by `mock_model("WithAString")`
87
+ (David Chelimsky)
88
+
89
+ ### 2.6.1 / 2011-05-25
90
+
91
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.6.0...v2.6.1)
92
+
93
+ This release is compatible with rails-3.1.0.rc1, but not rails-3.1.0.beta1
94
+
95
+ * Bug fixes
96
+ * fix controller specs with anonymous controllers with around filters
97
+ * exclude spec directory from rcov metrics (Rodrigo Navarro)
98
+ * guard against calling prerequisites on nil default rake task (Jack Dempsey)
99
+
100
+ ### 2.6.0 / 2011-05-12
101
+
102
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.5.0...v2.6.0)
103
+
104
+ * Enhancements
105
+ * rails 3 shortcuts for routing specs (Joe Fiorini)
106
+ * support nested resources in generators (Tim McEwan)
107
+ * require 'rspec/rails/mocks' to use `mock_model` without requiring the whole
108
+ rails framework
109
+ * Update the controller spec generated by the rails scaffold generator:
110
+ * Add documentation to the generated spec
111
+ * Use `any_instance` to avoid stubbing finders
112
+ * Use real objects instead of `mock_model`
113
+ * Update capybara integration to work with capy 0.4 and 1.0.0.beta
114
+ * Decorate paths passed to `[append|prepend]_view_paths` with empty templates
115
+ unless rendering views. (Mark Turner)
116
+
117
+ * Bug fixes
118
+ * fix typo in "rake spec:statsetup" (Curtis Schofield)
119
+ * expose named routes in anonymous controller specs (Andy Lindeman)
120
+ * error when generating namespaced scaffold resources (Andy Lindeman)
121
+ * Fix load order issue w/ Capybara (oleg dashevskii)
122
+ * Fix monkey patches that broke due to internal changes in rails-3.1.0.beta1
123
+
124
+ ### 2.5.0 / 2011-02-05
125
+
126
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.1...v2.5.0)
127
+
128
+ * Enhancements
129
+ * use index_helper instead of table_name when generating specs (Reza
130
+ Primardiansyah)
131
+
132
+ * Bug fixes
133
+ * fixed bug in which `render_views` in a nested group set the value in its
134
+ parent group.
135
+ * only include MailerExampleGroup when it is defined (Steve Sloan)
136
+ * mock_model.as_null_object.attribute.blank? returns false (Randy Schmidt)
137
+ * fix typo in request specs (Paco Guzman)
138
+
139
+ ### 2.4.1 / 2011-01-03
140
+
141
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...v2.4.1)
142
+
143
+ * Bug fixes
144
+ * fixed bug caused by including some Rails modules before RSpec's
145
+ RailsExampleGroup
146
+
147
+ ### 2.4.0 / 2011-01-02
148
+
149
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...v2.4.0)
150
+
151
+ * Enhancements
152
+ * include ApplicationHelper in helper object in helper specs
153
+ * include request spec extensions in files in spec/integration
154
+ * include controller spec extensions in groups that use :type => :controller
155
+ * same for :model, :view, :helper, :mailer, :request, :routing
156
+
157
+ * Bug fixes
158
+ * restore global config.render_views so you only need to say it once
159
+ * support overriding render_views in nested groups
160
+ * matchers that delegate to Rails' assertions capture
161
+ ActiveSupport::TestCase::Assertion (so they work properly now with
162
+ should_not in Ruby 1.8.7 and 1.9.1)
163
+
164
+ * Deprecations
165
+ * include_self_when_dir_matches
166
+
167
+ ### 2.3.1 / 2010-12-16
168
+
169
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.0...v2.3.1)
170
+
171
+ * Bug fixes
172
+ * respond_to? correctly handles 2 args
173
+ * scaffold generator no longer fails on autotest directory
174
+
175
+ ### 2.3.0 / 2010-12-12
176
+
177
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.1...v2.3.0)
178
+
179
+ * Changes
180
+ * Generator no longer generates autotest/autodiscover.rb, as it is no longer
181
+ needed (as of rspec-core-2.3.0)
182
+
183
+ ### 2.2.1 / 2010-12-01
184
+
185
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1)
186
+
187
+ * Bug fixes
188
+ * Depend on railties, activesupport, and actionpack instead of rails (Piotr
189
+ Solnica)
190
+ * Got webrat integration working properly across different types of specs
191
+
192
+ * Deprecations
193
+ * --webrat-matchers flag for generators is deprecated. use --webrat instead.
194
+
195
+ ### 2.2.0 / 2010-11-28
196
+
197
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0)
198
+
199
+ * Enhancements
200
+ * Added stub_template in view specs
201
+
202
+ * Bug fixes
203
+ * Properly include helpers in views (Jonathan del Strother)
204
+ * Fix bug in which method missing led to a stack overflow
205
+ * Fix stack overflow in request specs with open_session
206
+ * Fix stack overflow in any spec when method_missing was invoked
207
+ * Add gem dependency on rails ~> 3.0.0 (ensures bundler won't install
208
+ rspec-rails-2 with rails-2 apps).
209
+
210
+ ### 2.1.0 / 2010-11-07
211
+
212
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.1...v2.1.0)
213
+
214
+ * Enhancements
215
+ * Move errors_on to ActiveModel to support other AM-compliant ORMs
216
+
217
+ * Bug fixes
218
+ * Check for presence of ActiveRecord instead of checking Rails config
219
+ (gets rspec out of the way of multiple ORMs in the same app)
220
+
221
+ ### 2.0.1 / 2010-10-15
222
+
223
+ [full changelog](http://github.com/rspec/rspec-rails/compare/v2.0.0...v2.0.1)
224
+
225
+ * Enhancements
226
+ * Add option to not generate request spec (--skip-request-specs)
227
+
228
+ * Bug fixes
229
+ * Updated the mock_[model] method generated in controller specs so it adds
230
+ any stubs submitted each time it is called.
231
+ * Fixed bug where view assigns weren't making it to the view in view specs in Rails-3.0.1.
232
+ (Emanuele Vicentini)
233
+
234
+ ### 2.0.0 / 2010-10-10
235
+
236
+ [full changelog](https://github.com/rspec/rspec-rails/compare/ea6bdef...v2.0.0)
237
+
238
+ * Enhancements
239
+ * ControllerExampleGroup uses controller as the implicit subject by default (Paul Rosania)
240
+ * autotest mapping improvements (Andreas Neuhaus)
241
+ * more cucumber features (Justin Ko)
242
+ * clean up spec helper (Andre Arko)
243
+ * add assign(name, value) to helper specs (Justin Ko)
244
+ * stub_model supports primary keys other than id (Justin Ko)
245
+ * support choice between Webrat/Capybara (Justin Ko)
246
+ * support specs for 'abstract' subclasses of ActionController::Base (Mike Gehard)
247
+ * be_a_new matcher supports args (Justin Ko)
248
+
249
+ * Bug fixes
250
+ * support T::U components in mailer and request specs (Brasten Sager)
data/README.md CHANGED
@@ -109,7 +109,7 @@ a black box approach.
109
109
 
110
110
  ```ruby
111
111
  describe "home page" do
112
- it "diplays the user's username after successful login" do
112
+ it "displays the user's username after successful login" do
113
113
  user = User.create!(:username => "jdoe", :password => "secret")
114
114
  get "/login"
115
115
  assert_select "form.login" do
@@ -129,14 +129,14 @@ users like to use extension libraries like FactoryGirl and Capybara:
129
129
 
130
130
  ```ruby
131
131
  describe "home page" do
132
- it "diplays the user's username after successful login" do
132
+ it "displays the user's username after successful login" do
133
133
  user = Factory(:user, :username => "jdoe", :password => "secret")
134
134
  visit "/login"
135
135
  fill_in "Username", :with => "jdoe"
136
136
  fill_in "Password", :with => "secret"
137
- click_buton "Log in"
137
+ click_button "Log in"
138
138
 
139
- page.should have_selector(".header .username", :content => "jdoe")
139
+ page.should have_selector(".header .username", :text => "jdoe")
140
140
  end
141
141
  end
142
142
  ```
@@ -260,7 +260,7 @@ assigns(:widgets).should eq(expected_value)
260
260
  View specs live in spec/views, and mix in ActionView::TestCase::Behavior.
261
261
 
262
262
  ```ruby
263
- describe "events/index.html.erb" do
263
+ describe "events/index" do
264
264
  it "renders _event partial for each event" do
265
265
  assign(:events, [stub_model(Event), stub_model(Event)])
266
266
  render
@@ -268,7 +268,7 @@ describe "events/index.html.erb" do
268
268
  end
269
269
  end
270
270
 
271
- describe "events/show.html.erb" do
271
+ describe "events/show" do
272
272
  it "displays the event location" do
273
273
  assign(:event, stub_model(Event,
274
274
  :location => "Chicago"
@@ -9,7 +9,7 @@ end
9
9
  World(ArubaExt)
10
10
 
11
11
  Before do
12
- @aruba_timeout_seconds = 15
12
+ @aruba_timeout_seconds = 30
13
13
  end
14
14
 
15
15
  unless File.directory?('./tmp/example_app')
@@ -5,7 +5,7 @@ Feature: view spec infers controller path and action
5
5
  """
6
6
  require "spec_helper"
7
7
 
8
- describe "widgets/new.html.erb" do
8
+ describe "widgets/new" do
9
9
  it "infers the controller path" do
10
10
  controller.request.path_parameters["controller"].should eq("widgets")
11
11
  end
@@ -19,7 +19,7 @@ Feature: view spec infers controller path and action
19
19
  """
20
20
  require "spec_helper"
21
21
 
22
- describe "widgets/new.html.erb" do
22
+ describe "widgets/new" do
23
23
  it "infers the controller path" do
24
24
  controller.request.path_parameters["action"].should eq("new")
25
25
  end
@@ -33,7 +33,7 @@ Feature: view spec infers controller path and action
33
33
  """
34
34
  require "spec_helper"
35
35
 
36
- describe "widgets/_form.html.erb" do
36
+ describe "widgets/_form" do
37
37
  it "includes a link to new" do
38
38
  controller.request.path_parameters["action"].should be_nil
39
39
  end
@@ -8,7 +8,7 @@ Feature: stub template
8
8
  """
9
9
  require "spec_helper"
10
10
 
11
- describe "gadgets/list.html.erb" do
11
+ describe "gadgets/list" do
12
12
  it "renders the gadget partial for each gadget" do
13
13
  assign(:gadgets, [
14
14
  mock_model(Gadget, :id => 1, :name => "First"),
@@ -34,7 +34,7 @@ Feature: stub template
34
34
  """
35
35
  require "spec_helper"
36
36
 
37
- describe "gadgets/edit.html.erb" do
37
+ describe "gadgets/edit" do
38
38
  before(:each) do
39
39
  @gadget = assign(:gadget, stub_model(Gadget))
40
40
  end
@@ -7,7 +7,7 @@ Feature: view spec
7
7
  """
8
8
  require "spec_helper"
9
9
 
10
- describe "widgets/index.html.erb" do
10
+ describe "widgets/index" do
11
11
  it "displays all the widgets" do
12
12
  assign(:widgets, [
13
13
  stub_model(Widget, :name => "slicer"),
@@ -29,7 +29,7 @@ Feature: view spec
29
29
  """
30
30
  require "spec_helper"
31
31
 
32
- describe "widgets/index.html.erb" do
32
+ describe "widgets/index" do
33
33
 
34
34
  context "with 2 widgets" do
35
35
  before(:each) do
@@ -145,7 +145,7 @@ Feature: view spec
145
145
  """
146
146
  require 'spec_helper'
147
147
 
148
- describe 'secrets/index.html.erb' do
148
+ describe 'secrets/index' do
149
149
  before do
150
150
  view.stub(:admin?).and_return(true)
151
151
  end
@@ -146,6 +146,9 @@ module Rspec
146
146
  case attribute.type
147
147
  when :string
148
148
  "#{attribute.name.titleize}".inspect
149
+ when :integer
150
+ @attribute_id_map ||= {}
151
+ @attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next.to_s
149
152
  else
150
153
  attribute.default.inspect
151
154
  end
@@ -18,11 +18,13 @@ describe "<%= ns_table_name %>/index" do
18
18
 
19
19
  it "renders a list of <%= ns_table_name %>" do
20
20
  render
21
+ <% unless webrat? -%>
22
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
23
+ <% end -%>
21
24
  <% for attribute in output_attributes -%>
22
25
  <% if webrat? -%>
23
26
  rendered.should have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2)
24
27
  <% else -%>
25
- # Run the generator again with the --webrat flag if you want to use webrat matchers
26
28
  assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
27
29
  <% end -%>
28
30
  <% end -%>
@@ -14,11 +14,13 @@ describe "<%= ns_table_name %>/show" do
14
14
 
15
15
  it "renders attributes in <p>" do
16
16
  render
17
+ <% unless webrat? -%>
18
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
19
+ <% end -%>
17
20
  <% for attribute in output_attributes -%>
18
21
  <% if webrat? -%>
19
22
  rendered.should contain(<%= value_for(attribute) %>.to_s)
20
23
  <% else -%>
21
- # Run the generator again with the --webrat flag if you want to use webrat matchers
22
24
  rendered.should match(/<%= eval(value_for(attribute)) %>/)
23
25
  <% end -%>
24
26
  <% end -%>
@@ -122,7 +122,7 @@ module RSpec::Rails
122
122
  include ExampleMethods
123
123
 
124
124
  metadata[:type] = :view
125
- helper *_default_helpers
125
+ helper(*_default_helpers)
126
126
 
127
127
  before do
128
128
  _include_controller_helpers
@@ -1,6 +1,6 @@
1
1
  module RSpec::Rails::Matchers
2
2
  class BeANew
3
- include RSpec::Matchers::BaseMatcher
3
+ include RSpec::Matchers::BuiltIn::BaseMatcher
4
4
 
5
5
  # @api private
6
6
  def matches?(actual)
@@ -1,6 +1,6 @@
1
1
  module RSpec::Rails::Matchers
2
2
  class BeANewRecord
3
- include RSpec::Matchers::BaseMatcher
3
+ include RSpec::Matchers::BuiltIn::BaseMatcher
4
4
 
5
5
  # @api private
6
6
  def matches?(actual)
@@ -1,5 +1,5 @@
1
1
  require 'active_support/core_ext/module/aliasing'
2
- require 'rspec/matchers/have'
2
+ require 'rspec/matchers/built_in/have'
3
3
 
4
4
  module RSpec::Rails::Matchers
5
5
  module HaveExtensions
@@ -30,6 +30,6 @@ module RSpec::Rails::Matchers
30
30
  end
31
31
  end
32
32
 
33
- RSpec::Matchers::Have.class_eval do
33
+ RSpec::Matchers::BuiltIn::Have.class_eval do
34
34
  include RSpec::Rails::Matchers::HaveExtensions
35
35
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec::Rails::Matchers
2
2
  module RedirectTo
3
3
  class RedirectTo
4
- include RSpec::Matchers::BaseMatcher
4
+ include RSpec::Matchers::BuiltIn::BaseMatcher
5
5
 
6
6
  def initialize(scope, expected)
7
7
  super(expected)
@@ -1,3 +1,3 @@
1
1
  if defined?(ActiveRecord::Relation)
2
- RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::MatchArray)
2
+ RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::MatchArray)
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec::Rails::Matchers
2
2
  module RenderTemplate
3
3
  class RenderTemplateMatcher
4
- include RSpec::Matchers::BaseMatcher
4
+ include RSpec::Matchers::BuiltIn::BaseMatcher
5
5
 
6
6
  def initialize(scope, expected, message=nil)
7
7
  super(Symbol === expected ? expected.to_s : expected)
@@ -3,7 +3,7 @@ module RSpec::Rails::Matchers
3
3
  extend RSpec::Matchers::DSL
4
4
 
5
5
  class RouteToMatcher
6
- include RSpec::Matchers::BaseMatcher
6
+ include RSpec::Matchers::BuiltIn::BaseMatcher
7
7
 
8
8
  def initialize(scope, *expected)
9
9
  @scope = scope
@@ -15,9 +15,14 @@ module RSpec::Rails::Matchers
15
15
  @expected_options.merge!(:controller => controller, :action => action)
16
16
  end
17
17
  end
18
+
19
+ def description
20
+ "route #{@verb_to_path_map.inspect} to #{@expected_options.inspect}"
21
+ end
18
22
 
19
23
  # @api private
20
24
  def matches?(verb_to_path_map)
25
+ @verb_to_path_map = verb_to_path_map
21
26
  match_unless_raises ActiveSupport::TestCase::Assertion do
22
27
  path, query = *verb_to_path_map.values.first.split('?')
23
28
  @scope.assert_recognizes(
@@ -52,7 +57,7 @@ module RSpec::Rails::Matchers
52
57
  end
53
58
 
54
59
  class BeRoutableMatcher
55
- include RSpec::Matchers::BaseMatcher
60
+ include RSpec::Matchers::BuiltIn::BaseMatcher
56
61
 
57
62
  def initialize(scope)
58
63
  @scope = scope
@@ -132,7 +132,7 @@ EOM
132
132
  end unless #{stubs.has_key?(:respond_to?)}
133
133
 
134
134
  def @object.method_missing(m, *a, &b)
135
- respond_to?(m) ? nil : super
135
+ respond_to?(m) ? null_object? ? self : nil : super
136
136
  end
137
137
 
138
138
  def @object.class
@@ -4,7 +4,12 @@ if default = Rake.application.instance_variable_get('@tasks')['default']
4
4
  default.prerequisites.delete('test')
5
5
  end
6
6
 
7
- spec_prereq = Rails.configuration.generators.options[:rails][:orm] == :active_record ? "db:test:prepare" : :noop
7
+ orm_setting = Rails.configuration.generators.options[:rails][:orm]
8
+ spec_prereq = if(orm_setting == :active_record)
9
+ Rails.configuration.active_record[:schema_format] == :sql ? "db:test:clone_structure" : "db:test:prepare"
10
+ else
11
+ :noop
12
+ end
8
13
  task :noop do; end
9
14
  task :default => :spec
10
15
 
@@ -23,11 +23,11 @@ RSpec.configure do |c|
23
23
  c.include RequestInstanceMethods, :type => :request
24
24
 
25
25
  c.before :type => :controller do
26
- Webrat.configure {|c| c.mode = :rails}
26
+ Webrat.configure {|w| w.mode = :rails}
27
27
  end
28
28
 
29
29
  c.before :type => :request do
30
- Webrat.configure {|c| c.mode = :rack}
30
+ Webrat.configure {|w| w.mode = :rack}
31
31
  end
32
32
  end
33
33
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Rails
3
3
  module Version
4
- STRING = '2.8.1'
4
+ STRING = '2.9.0.rc2'
5
5
  end
6
6
  end
7
7
  end
@@ -18,8 +18,8 @@ describe Rspec::Generators::ControllerGenerator do
18
18
 
19
19
  describe 'the spec' do
20
20
  it { should exist }
21
- it { should contain /require 'spec_helper'/ }
22
- it { should contain /describe PostsController/ }
21
+ it { should contain(/require 'spec_helper'/) }
22
+ it { should contain(/describe PostsController/) }
23
23
  end
24
24
  end
25
25
  describe 'skipped with a flag' do
@@ -60,14 +60,14 @@ describe Rspec::Generators::ControllerGenerator do
60
60
  describe 'index.html.erb' do
61
61
  subject { file('spec/views/posts/index.html.erb_spec.rb') }
62
62
  it { should exist }
63
- it { should contain /require 'spec_helper'/ }
64
- it { should contain /describe "posts\/index.html.erb"/ }
63
+ it { should contain(/require 'spec_helper'/) }
64
+ it { should contain(/describe "posts\/index.html.erb"/) }
65
65
  end
66
66
  describe 'show.html.erb' do
67
67
  subject { file('spec/views/posts/show.html.erb_spec.rb') }
68
68
  it { should exist }
69
- it { should contain /require 'spec_helper'/ }
70
- it { should contain /describe "posts\/show.html.erb"/ }
69
+ it { should contain(/require 'spec_helper'/) }
70
+ it { should contain(/describe "posts\/show.html.erb"/) }
71
71
  end
72
72
  end
73
73
  describe 'with haml' do
@@ -77,8 +77,8 @@ describe Rspec::Generators::ControllerGenerator do
77
77
  describe 'index.html.haml' do
78
78
  subject { file('spec/views/posts/index.html.haml_spec.rb') }
79
79
  it { should exist }
80
- it { should contain /require 'spec_helper'/ }
81
- it { should contain /describe "posts\/index.html.haml"/ }
80
+ it { should contain(/require 'spec_helper'/) }
81
+ it { should contain(/describe "posts\/index.html.haml"/) }
82
82
  end
83
83
  end
84
84
  end
@@ -17,8 +17,8 @@ describe Rspec::Generators::HelperGenerator do
17
17
 
18
18
  describe 'the spec' do
19
19
  it { should exist }
20
- it { should contain /require 'spec_helper'/ }
21
- it { should contain /describe PostsHelper/ }
20
+ it { should contain(/require 'spec_helper'/) }
21
+ it { should contain(/describe PostsHelper/) }
22
22
  end
23
23
  end
24
24
  describe 'skipped with a flag' do
@@ -26,9 +26,9 @@ describe Rspec::Generators::IntegrationGenerator do
26
26
  end
27
27
  subject { file('spec/requests/posts_spec.rb') }
28
28
  it { should exist }
29
- it { should contain /require 'spec_helper'/ }
30
- it { should contain /describe "GET \/posts"/ }
31
- it { should contain /get posts_index_path/ }
29
+ it { should contain(/require 'spec_helper'/) }
30
+ it { should contain(/describe "GET \/posts"/) }
31
+ it { should contain(/get posts_index_path/) }
32
32
  end
33
33
  describe 'with webrat matchers' do
34
34
  before do
@@ -36,9 +36,9 @@ describe Rspec::Generators::IntegrationGenerator do
36
36
  end
37
37
  subject { file('spec/requests/posts_spec.rb') }
38
38
  it { should exist }
39
- it { should contain /require 'spec_helper'/ }
40
- it { should contain /describe "GET \/posts"/ }
41
- it { should contain /visit posts_index_path/ }
39
+ it { should contain(/require 'spec_helper'/) }
40
+ it { should contain(/describe "GET \/posts"/) }
41
+ it { should contain(/visit posts_index_path/) }
42
42
  end
43
43
  end
44
44
  end
@@ -16,17 +16,17 @@ describe Rspec::Generators::MailerGenerator do
16
16
  run_generator %w(posts index show)
17
17
  end
18
18
  it { should exist }
19
- it { should contain /require "spec_helper"/ }
20
- it { should contain /describe "index" do/ }
21
- it { should contain /describe "show" do/ }
19
+ it { should contain(/require "spec_helper"/) }
20
+ it { should contain(/describe "index" do/) }
21
+ it { should contain(/describe "show" do/) }
22
22
  end
23
23
  describe 'creates placeholder when no actions specified' do
24
24
  before do
25
25
  run_generator %w(posts)
26
26
  end
27
27
  it { should exist }
28
- it { should contain /require "spec_helper"/ }
29
- it { should contain /pending "add some examples to \(or delete\)/ }
28
+ it { should contain(/require "spec_helper"/) }
29
+ it { should contain(/pending "add some examples to \(or delete\)/) }
30
30
  end
31
31
  end
32
32
 
@@ -37,12 +37,12 @@ describe Rspec::Generators::MailerGenerator do
37
37
  describe 'index' do
38
38
  subject { file('spec/fixtures/posts/index') }
39
39
  it { should exist }
40
- it { should contain /Posts#index/ }
40
+ it { should contain(/Posts#index/) }
41
41
  end
42
42
  describe 'show' do
43
43
  subject { file('spec/fixtures/posts/show') }
44
44
  it { should exist }
45
- it { should contain /Posts#show/ }
45
+ it { should contain(/Posts#show/) }
46
46
  end
47
47
  end
48
48
  end
@@ -26,14 +26,14 @@ describe Rspec::Generators::ModelGenerator do
26
26
  subject { file('spec/models/posts_spec.rb') }
27
27
 
28
28
  it { should exist }
29
- it { should contain /require 'spec_helper'/ }
30
- it { should contain /describe Posts/ }
29
+ it { should contain(/require 'spec_helper'/) }
30
+ it { should contain(/describe Posts/) }
31
31
  end
32
32
 
33
33
  describe 'the fixtures' do
34
34
  subject { file('spec/fixtures/posts.yml') }
35
35
 
36
- it { should contain Regexp.new '# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html' }
36
+ it { should contain(Regexp.new('# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html')) }
37
37
  end
38
38
  end
39
39
 
@@ -49,4 +49,4 @@ describe Rspec::Generators::ModelGenerator do
49
49
  end
50
50
  end
51
51
  end
52
- end
52
+ end
@@ -15,7 +15,7 @@ describe Rspec::Generators::ObserverGenerator do
15
15
 
16
16
  describe 'the spec' do
17
17
  it { should exist }
18
- it { should contain /require 'spec_helper'/ }
19
- it { should contain /describe PostsObserver/ }
18
+ it { should contain(/require 'spec_helper'/) }
19
+ it { should contain(/describe PostsObserver/) }
20
20
  end
21
21
  end
@@ -12,8 +12,8 @@ describe Rspec::Generators::ScaffoldGenerator do
12
12
 
13
13
  describe 'with no options' do
14
14
  before { run_generator %w(posts) }
15
- it { should contain /require 'spec_helper'/ }
16
- it { should contain /describe PostsController/ }
15
+ it { should contain(/require 'spec_helper'/) }
16
+ it { should contain(/describe PostsController/) }
17
17
  end
18
18
 
19
19
  describe 'with --no-controller_specs' do
@@ -25,7 +25,7 @@ describe Rspec::Generators::ScaffoldGenerator do
25
25
  describe 'namespaced controller spec' do
26
26
  subject { file('spec/controllers/admin/posts_controller_spec.rb') }
27
27
  before { run_generator %w(admin/posts) }
28
- it { should contain /describe Admin::PostsController/ }
28
+ it { should contain(/describe Admin::PostsController/)}
29
29
  end
30
30
 
31
31
  describe 'view specs' do
@@ -34,33 +34,33 @@ describe Rspec::Generators::ScaffoldGenerator do
34
34
  describe 'edit' do
35
35
  subject { file("spec/views/posts/edit.html.erb_spec.rb") }
36
36
  it { should exist }
37
- it { should contain /require 'spec_helper'/ }
38
- it { should contain /describe "(.*)\/edit"/ }
39
- it { should contain /it "renders the edit (.*) form"/ }
37
+ it { should contain(/require 'spec_helper'/) }
38
+ it { should contain(/describe "(.*)\/edit"/) }
39
+ it { should contain(/it "renders the edit (.*) form"/) }
40
40
  end
41
41
 
42
42
  describe 'index' do
43
43
  subject { file("spec/views/posts/index.html.erb_spec.rb") }
44
44
  it { should exist }
45
- it { should contain /require 'spec_helper'/ }
46
- it { should contain /describe "(.*)\/index"/ }
47
- it { should contain /it "renders a list of (.*)"/ }
45
+ it { should contain(/require 'spec_helper'/) }
46
+ it { should contain(/describe "(.*)\/index"/) }
47
+ it { should contain(/it "renders a list of (.*)"/) }
48
48
  end
49
49
 
50
50
  describe 'new' do
51
51
  subject { file("spec/views/posts/new.html.erb_spec.rb") }
52
52
  it { should exist }
53
- it { should contain /require 'spec_helper'/ }
54
- it { should contain /describe "(.*)\/new"/ }
55
- it { should contain /it "renders new (.*) form"/ }
53
+ it { should contain(/require 'spec_helper'/) }
54
+ it { should contain(/describe "(.*)\/new"/) }
55
+ it { should contain(/it "renders new (.*) form"/) }
56
56
  end
57
57
 
58
58
  describe 'show' do
59
59
  subject { file("spec/views/posts/show.html.erb_spec.rb") }
60
60
  it { should exist }
61
- it { should contain /require 'spec_helper'/ }
62
- it { should contain /describe "(.*)\/show"/ }
63
- it { should contain /it "renders attributes in <p>"/ }
61
+ it { should contain(/require 'spec_helper'/) }
62
+ it { should contain(/describe "(.*)\/show"/) }
63
+ it { should contain(/it "renders attributes in <p>"/) }
64
64
  end
65
65
  end
66
66
 
@@ -94,9 +94,9 @@ describe Rspec::Generators::ScaffoldGenerator do
94
94
 
95
95
  describe 'with default options' do
96
96
  before { run_generator %w(posts) }
97
- it { should contain /require "spec_helper"/ }
98
- it { should contain /describe PostsController/ }
99
- it { should contain /describe "routing"/ }
97
+ it { should contain(/require "spec_helper"/) }
98
+ it { should contain(/describe PostsController/) }
99
+ it { should contain(/describe "routing"/) }
100
100
  end
101
101
 
102
102
  describe 'with --no-routing-specs' do
@@ -13,8 +13,8 @@ describe Rspec::Generators::ViewGenerator do
13
13
  it 'generates a spec for the supplied action' do
14
14
  run_generator %w(posts index)
15
15
  file('spec/views/posts/index.html.erb_spec.rb').tap do |f|
16
- f.should contain /require 'spec_helper'/
17
- f.should contain /describe "posts\/index"/
16
+ f.should contain(/require 'spec_helper'/)
17
+ f.should contain(/describe "posts\/index"/)
18
18
  end
19
19
  end
20
20
 
@@ -22,8 +22,8 @@ describe Rspec::Generators::ViewGenerator do
22
22
  it 'generates a spec for the supplied action' do
23
23
  run_generator %w(admin/posts index)
24
24
  file('spec/views/admin/posts/index.html.erb_spec.rb').tap do |f|
25
- f.should contain /require 'spec_helper'/
26
- f.should contain /describe "admin\/posts\/index"/
25
+ f.should contain(/require 'spec_helper'/)
26
+ f.should contain(/describe "admin\/posts\/index"/)
27
27
  end
28
28
  end
29
29
  end
@@ -33,8 +33,8 @@ describe Rspec::Generators::ViewGenerator do
33
33
  it 'generates a spec for the supplied action' do
34
34
  run_generator %w(posts index --template_engine haml)
35
35
  file('spec/views/posts/index.html.haml_spec.rb').tap do |f|
36
- f.should contain /require 'spec_helper'/
37
- f.should contain /describe "posts\/index"/
36
+ f.should contain(/require 'spec_helper'/)
37
+ f.should contain(/describe "posts\/index"/)
38
38
  end
39
39
  end
40
40
  end
@@ -71,9 +71,11 @@ describe "be_a_new matcher" do
71
71
  it "fails" do
72
72
  expect {
73
73
  record.should be_a_new(record.class).with(:zoo => 'zoo', :car => 'car')
74
- }.to raise_error(
75
- %Q(attributes {"zoo"=>"zoo", "car"=>"car"} were not set on #{record.inspect})
76
- )
74
+ }.to raise_error {|e|
75
+ e.message.should match(/attributes {.*} were not set on #{record.inspect}/)
76
+ e.message.should match(/"zoo"=>"zoo"/)
77
+ e.message.should match(/"car"=>"car"/)
78
+ }
77
79
  end
78
80
  end
79
81
 
@@ -117,10 +119,11 @@ describe "be_a_new matcher" do
117
119
  it "fails" do
118
120
  expect {
119
121
  record.should be_a_new(String).with(:zoo => 'zoo', :car => 'car')
120
- }.to raise_error(
121
- "expected #{record.inspect} to be a new String and " +
122
- %Q(attributes {"zoo"=>"zoo", "car"=>"car"} were not set on #{record.inspect})
123
- )
122
+ }.to raise_error {|e|
123
+ e.message.should match(/expected #{record.inspect} to be a new String and attributes {.*} were not set on #{record.inspect}/)
124
+ e.message.should match(/"zoo"=>"zoo"/)
125
+ e.message.should match(/"car"=>"car"/)
126
+ }
124
127
  end
125
128
  end
126
129
 
@@ -10,7 +10,7 @@ describe "ActiveSupport::Relation =~ matcher" do
10
10
  end
11
11
 
12
12
  it "fails if the scope encompasses more records than on the right hand side" do
13
- another_model = MockableModel.create
13
+ MockableModel.create
14
14
  MockableModel.scoped.should_not =~ models.reverse
15
15
  end
16
16
 
@@ -4,6 +4,16 @@ describe "route_to" do
4
4
  include RSpec::Rails::Matchers::RoutingMatchers
5
5
  include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
6
6
 
7
+ def assert_recognizes(*)
8
+ # no-op
9
+ end
10
+
11
+ it "provides a description" do
12
+ matcher = route_to("these" => "options")
13
+ matcher.matches?(:get => "path")
14
+ matcher.description.should == "route {:get=>\"path\"} to {\"these\"=>\"options\"}"
15
+ end
16
+
7
17
  it "delegates to assert_recognizes" do
8
18
  self.should_receive(:assert_recognizes).with({ "these" => "options" }, { :method=> :get, :path=>"path" }, {})
9
19
  {:get => "path"}.should route_to("these" => "options")
@@ -80,7 +80,7 @@ describe "mock_model(RealModel)" do
80
80
  describe "with params" do
81
81
  it "does not mutate its parameters" do
82
82
  params = {:a => 'b'}
83
- model = mock_model(MockableModel, params)
83
+ mock_model(MockableModel, params)
84
84
  params.should == {:a => 'b'}
85
85
  end
86
86
  end
@@ -234,6 +234,11 @@ describe "mock_model(RealModel)" do
234
234
  it "says it will not respond_to?(xxx_before_type_cast)" do
235
235
  @model.as_null_object.respond_to?("title_before_type_cast").should be(false)
236
236
  end
237
+ it "returns self for any unprepared message" do
238
+ @model.as_null_object.tap do |x|
239
+ x.non_existant_message.should be(@model)
240
+ end
241
+ end
237
242
  end
238
243
  end
239
244
 
@@ -17,6 +17,9 @@ class RSpec::Core::ExampleGroup
17
17
  end
18
18
 
19
19
  RSpec.configure do |config|
20
+ config.treat_symbols_as_metadata_keys_with_true_values = true
21
+ config.filter_run :focus
22
+ config.run_all_when_everything_filtered = true
20
23
  config.before(:each) do
21
24
  @real_world = RSpec.world
22
25
  RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 45
5
- prerelease:
4
+ hash: 2895758085
5
+ prerelease: 6
6
6
  segments:
7
7
  - 2
8
- - 8
9
- - 1
10
- version: 2.8.1
8
+ - 9
9
+ - 0
10
+ - rc
11
+ - 2
12
+ version: 2.9.0.rc2
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Chelimsky
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-01-05 00:00:00 Z
20
+ date: 2012-03-12 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -66,14 +68,16 @@ dependencies:
66
68
  version_requirements: &id004 !ruby/object:Gem::Requirement
67
69
  none: false
68
70
  requirements:
69
- - - ~>
71
+ - - "="
70
72
  - !ruby/object:Gem::Version
71
- hash: 47
73
+ hash: 2895758085
72
74
  segments:
73
75
  - 2
74
- - 8
76
+ - 9
75
77
  - 0
76
- version: 2.8.0
78
+ - rc
79
+ - 2
80
+ version: 2.9.0.rc2
77
81
  prerelease: false
78
82
  requirement: *id004
79
83
  name: rspec
@@ -84,9 +88,8 @@ executables: []
84
88
 
85
89
  extensions: []
86
90
 
87
- extra_rdoc_files:
88
- - README.md
89
- - License.txt
91
+ extra_rdoc_files: []
92
+
90
93
  files:
91
94
  - lib/autotest/rails_rspec2.rb
92
95
  - lib/generators/rspec.rb
@@ -148,8 +151,11 @@ files:
148
151
  - lib/rspec/rails/version.rb
149
152
  - lib/rspec/rails/view_assigns.rb
150
153
  - lib/rspec/rails/view_rendering.rb
151
- - License.txt
152
154
  - README.md
155
+ - License.txt
156
+ - Changelog.md
157
+ - .yardopts
158
+ - .document
153
159
  - features/Autotest.md
154
160
  - features/Generators.md
155
161
  - features/GettingStarted.md
@@ -245,19 +251,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
251
  required_rubygems_version: !ruby/object:Gem::Requirement
246
252
  none: false
247
253
  requirements:
248
- - - ">="
254
+ - - ">"
249
255
  - !ruby/object:Gem::Version
250
- hash: 3
256
+ hash: 25
251
257
  segments:
252
- - 0
253
- version: "0"
258
+ - 1
259
+ - 3
260
+ - 1
261
+ version: 1.3.1
254
262
  requirements: []
255
263
 
256
264
  rubyforge_project: rspec
257
- rubygems_version: 1.8.11
265
+ rubygems_version: 1.8.15
258
266
  signing_key:
259
267
  specification_version: 3
260
- summary: rspec-rails-2.8.1
268
+ summary: rspec-rails-2.9.0.rc2
261
269
  test_files:
262
270
  - features/Autotest.md
263
271
  - features/Generators.md