rspec-rails 1.3.2 → 1.3.3.rc

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,15 @@
1
+ === Version 1.3.3 / (in git)
2
+
3
+ * enhancements
4
+ * replace use of 'returning' with 'tap'
5
+
6
+ * bug fixes
7
+ * support message expectation on template.render with locals (Sergey
8
+ Nebolsin). Closes #941.
9
+ * helper instance variable no longer persists across examples
10
+ (alex rothenberg). Closes #627.
11
+ * mock_model stubs marked_for_destruction? (returns false).
12
+
1
13
  === Version 1.3.2 / 2010-01-13
2
14
 
3
15
  * bug fix
@@ -13,6 +13,9 @@ Behaviour Driven Development for Ruby on Rails.
13
13
  rspec-rails is an RSpec extension that allows you to drive the development of
14
14
  Ruby on Rails applications with RSpec.
15
15
 
16
+ This is the repository for rspec-rails-1.x. If you're looking
17
+ for rspec-rails-2 for rails-3, see http://github.com/rspec/rspec-rails.
18
+
16
19
  == FEATURES:
17
20
 
18
21
  * Use RSpec to independently specify Rails Models, Views, Controllers and Helpers
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ Hoe.spec 'rspec-rails' do
15
15
  self.description = "Behaviour Driven Development for Ruby on Rails."
16
16
  self.rubyforge_name = 'rspec'
17
17
  self.developer 'RSpec Development Team', 'rspec-devel@rubyforge.org'
18
- self.extra_deps = [["rspec",">=1.3.0"],["rack",">=1.0.0"]]
18
+ self.extra_deps = [["rspec","1.3.1.rc"],["rack",">=1.0.0"]]
19
19
  self.extra_dev_deps = [["cucumber",">= 0.3.99"]]
20
20
  self.remote_rdoc_dir = "rspec-rails/#{Spec::Rails::VERSION::STRING}"
21
21
  self.history_file = 'History.rdoc'
@@ -56,7 +56,7 @@ module Spec
56
56
  end
57
57
 
58
58
  def helper
59
- @helper_object ||= returning HelperObject.new do |helper_object|
59
+ HelperObject.new.tap do |helper_object|
60
60
  if @helper_being_described.nil?
61
61
  if described_type.class == Module
62
62
  helper_object.extend described_type
@@ -87,7 +87,7 @@ module Spec
87
87
  # end
88
88
  #
89
89
  def helper
90
- self.class.helper
90
+ @helper ||= self.class.helper
91
91
  end
92
92
 
93
93
  def orig_assigns
@@ -110,7 +110,7 @@ module Spec
110
110
  @output_buffer = ""
111
111
  @template = helper
112
112
  ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
113
-
113
+
114
114
  helper.session = session
115
115
  helper.request = @request
116
116
  helper.flash = flash
@@ -3,7 +3,10 @@ module Spec
3
3
  module Example
4
4
 
5
5
  class RoutingExampleGroup < ActionController::TestCase
6
- tests Class.new(ActionController::Base)
6
+ class RoutingController < ActionController::Base
7
+ end
8
+
9
+ tests RoutingController
7
10
 
8
11
  Spec::Example::ExampleGroupFactory.register(:routing, self)
9
12
  end
@@ -20,7 +20,9 @@ module ActionView #:nodoc:
20
20
  alias_method_chain :render_partial, :base_view_path_handling
21
21
 
22
22
  def render_with_mock_proxy(options = {}, old_local_assigns = {}, &block)
23
- if render_proxy.__send__(:__mock_proxy).__send__(:find_matching_expectation, :render, options)
23
+ if render_proxy.__send__(:__mock_proxy).__send__(:find_matching_expectation, :render, options, old_local_assigns)
24
+ render_proxy.render(options, old_local_assigns)
25
+ elsif render_proxy.__send__(:__mock_proxy).__send__(:find_matching_expectation, :render, options)
24
26
  render_proxy.render(options)
25
27
  else
26
28
  unless render_proxy.__send__(:__mock_proxy).__send__(:find_matching_method_stub, :render, options)
@@ -30,6 +30,7 @@ if defined?(ActiveRecord::Base)
30
30
  end
31
31
  def fixture_path=(path)
32
32
  ActiveSupport::TestCase.fixture_path = path
33
+ ActionController::IntegrationTest.fixture_path = path
33
34
  end
34
35
 
35
36
  def global_fixtures
@@ -15,6 +15,7 @@ module Spec
15
15
  :to_param => id.to_s,
16
16
  :new_record? => false,
17
17
  :destroyed? => false,
18
+ :marked_for_destruction? => false,
18
19
  :errors => stub("errors", :count => 0)
19
20
  })
20
21
  m = mock("#{model_class.name}_#{id}", options_and_stubs)
@@ -97,7 +98,7 @@ module Spec
97
98
  # end
98
99
  def stub_model(model_class, stubs={})
99
100
  stubs = {:id => next_id}.merge(stubs)
100
- returning model_class.new do |model|
101
+ model_class.new.tap do |model|
101
102
  model.id = stubs.delete(:id)
102
103
  model.extend ModelStubber
103
104
  stubs.each do |k,v|
@@ -4,8 +4,8 @@ module Spec # :nodoc:
4
4
  unless defined? MAJOR
5
5
  MAJOR = 1
6
6
  MINOR = 3
7
- TINY = 2
8
- PRE = nil
7
+ TINY = 3
8
+ PRE = 'rc'
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
11
11
 
@@ -44,12 +44,14 @@ module Spec
44
44
  it "should default to RAILS_ROOT + '/spec/fixtures'" do
45
45
  config.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
46
46
  ActiveSupport::TestCase.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
47
+ ActionController::IntegrationTest.fixture_path.should == RAILS_ROOT + '/spec/fixtures'
47
48
  end
48
49
 
49
50
  it "should set fixture_path" do
50
51
  config.fixture_path = "/new/path"
51
52
  config.fixture_path.should == "/new/path"
52
53
  ActiveSupport::TestCase.fixture_path.should == "/new/path"
54
+ ActionController::IntegrationTest.fixture_path.should == "/new/path"
53
55
  end
54
56
  end
55
57
 
@@ -8,7 +8,7 @@ require File.join(File.dirname(__FILE__), "/shared_routing_example_group_example
8
8
  integrate_views if mode == 'integration'
9
9
 
10
10
  accesses_configured_helper_methods
11
- include RoutingExampleGroupSpec
11
+ it_should_behave_like "a routing example"
12
12
 
13
13
  describe "with an implicit subject" do
14
14
  it "uses the controller" do
@@ -175,6 +175,20 @@ module Spec
175
175
  end
176
176
  end
177
177
 
178
+ # both specs the same as textmate invokes first-then-second but rake spec:plugins:rspec_on_rails invokes second-then-first
179
+ describe HelperExampleGroup, "new helper for each spec - instance variables side effects are isolated", :type=> :helper do
180
+ it 'should be able to set an instance variable on the helper on a new instance of the helper' do
181
+ helper.instance_variable_get(:@test_instance_var).should be_nil
182
+ helper.instance_variable_set(:@test_instance_var, :first_value)
183
+ helper.instance_variable_get(:@test_instance_var).should == :first_value
184
+ end
185
+
186
+ it 'should get a clean copy of the helper with no saved instance variables from the last run' do
187
+ helper.instance_variable_get(:@test_instance_var).should be_nil
188
+ helper.instance_variable_set(:@test_instance_var, :second_value)
189
+ helper.instance_variable_get(:@test_instance_var).should == :second_value
190
+ end
191
+ end
178
192
  end
179
193
  end
180
194
  end
@@ -3,8 +3,7 @@ require 'controller_spec_controller'
3
3
  require File.join(File.dirname(__FILE__), "/shared_routing_example_group_examples.rb")
4
4
 
5
5
  describe "Routing Examples", :type => :routing do
6
-
7
- include RoutingExampleGroupSpec
8
- include RouteToExampleGroupSpec
9
- include BeRoutableExampleGroupSpec
6
+ it_should_behave_like "a routing example"
7
+ it_should_behave_like "a be routable spec"
8
+ it_should_behave_like "a route to spec"
10
9
  end
@@ -1,7 +1,7 @@
1
1
  class CustomRouteSpecController < ActionController::Base; end
2
2
  class RspecOnRailsSpecsController < ActionController::Base; end
3
3
 
4
- share_as :RoutingExampleGroupSpec do
4
+ shared_examples_for "a routing example" do
5
5
  describe "using backward compatible route_for()" do
6
6
  it "translates GET-only paths to be explicit" do
7
7
  self.should_receive(:assert_routing).with(hash_including(:method => :get), anything, {}, anything)
@@ -93,7 +93,7 @@ share_as :RoutingExampleGroupSpec do
93
93
  end
94
94
  end
95
95
 
96
- share_as :BeRoutableExampleGroupSpec do
96
+ shared_examples_for "a be routable spec" do
97
97
  describe "using should_not be_routable()" do
98
98
  it "passes for a bad route" do
99
99
  { :put => "/rspec_on_rails_specs/bad_route/37" }.
@@ -151,7 +151,7 @@ share_as :BeRoutableExampleGroupSpec do
151
151
  end
152
152
  end
153
153
 
154
- share_as :RouteToExampleGroupSpec do
154
+ shared_examples_for "a route to spec" do
155
155
  describe "using should[_not] route_to()" do
156
156
  it "supports existing routes" do
157
157
  { :get => "/controller_spec/some_action" }.
@@ -9,6 +9,11 @@ describe ActionView::Base, "with RSpec extensions:", :type => :view do
9
9
  template.render :partial => "name"
10
10
  end
11
11
 
12
+ it "should not raise when render with local assignments has been received" do
13
+ template.should_receive(:render).with('name', :param => 1)
14
+ template.render 'name', :param => 1
15
+ end
16
+
12
17
  it "should raise when render has NOT been received" do
13
18
  template.should_receive(:render).with(:partial => "name")
14
19
  lambda {
@@ -27,6 +27,9 @@ describe "mock_model" do
27
27
  it "should say it is not destroyed" do
28
28
  @model.destroyed?(SubMockableModel).should be(false)
29
29
  end
30
+ it "should say it is not marked_for_destruction" do
31
+ @model.marked_for_destruction?.should be(false)
32
+ end
30
33
  end
31
34
 
32
35
  describe "with params" do
metadata CHANGED
@@ -1,7 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ hash: 7712030
5
+ prerelease: true
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 3
10
+ - rc
11
+ version: 1.3.3.rc
5
12
  platform: ruby
6
13
  authors:
7
14
  - RSpec Development Team
@@ -9,49 +16,74 @@ autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2010-01-13 00:00:00 -06:00
19
+ date: 2010-10-03 00:00:00 -05:00
13
20
  default_executable:
14
21
  dependencies:
15
22
  - !ruby/object:Gem::Dependency
16
23
  name: rspec
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
20
27
  requirements:
21
- - - ">="
28
+ - - "="
22
29
  - !ruby/object:Gem::Version
23
- version: 1.3.0
24
- version:
30
+ hash: 7712022
31
+ segments:
32
+ - 1
33
+ - 3
34
+ - 1
35
+ - rc
36
+ version: 1.3.1.rc
37
+ type: :runtime
38
+ version_requirements: *id001
25
39
  - !ruby/object:Gem::Dependency
26
40
  name: rack
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
47
+ hash: 23
48
+ segments:
49
+ - 1
50
+ - 0
51
+ - 0
33
52
  version: 1.0.0
34
- version:
53
+ type: :runtime
54
+ version_requirements: *id002
35
55
  - !ruby/object:Gem::Dependency
36
56
  name: cucumber
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
57
+ prerelease: false
58
+ requirement: &id003 !ruby/object:Gem::Requirement
59
+ none: false
40
60
  requirements:
41
61
  - - ">="
42
62
  - !ruby/object:Gem::Version
63
+ hash: 213
64
+ segments:
65
+ - 0
66
+ - 3
67
+ - 99
43
68
  version: 0.3.99
44
- version:
69
+ type: :development
70
+ version_requirements: *id003
45
71
  - !ruby/object:Gem::Dependency
46
72
  name: hoe
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
73
+ prerelease: false
74
+ requirement: &id004 !ruby/object:Gem::Requirement
75
+ none: false
50
76
  requirements:
51
77
  - - ">="
52
78
  - !ruby/object:Gem::Version
53
- version: 2.3.3
54
- version:
79
+ hash: 19
80
+ segments:
81
+ - 2
82
+ - 6
83
+ - 2
84
+ version: 2.6.2
85
+ type: :development
86
+ version_requirements: *id004
55
87
  description: Behaviour Driven Development for Ruby on Rails.
56
88
  email:
57
89
  - rspec-devel@rubyforge.org
@@ -237,7 +269,7 @@ licenses: []
237
269
  post_install_message: |
238
270
  **************************************************
239
271
 
240
- Thank you for installing rspec-rails-1.3.2
272
+ Thank you for installing rspec-rails-1.3.3.rc
241
273
 
242
274
  If you are upgrading, do this in each of your rails apps
243
275
  that you want to upgrade:
@@ -255,23 +287,31 @@ rdoc_options:
255
287
  require_paths:
256
288
  - lib
257
289
  required_ruby_version: !ruby/object:Gem::Requirement
290
+ none: false
258
291
  requirements:
259
292
  - - ">="
260
293
  - !ruby/object:Gem::Version
294
+ hash: 3
295
+ segments:
296
+ - 0
261
297
  version: "0"
262
- version:
263
298
  required_rubygems_version: !ruby/object:Gem::Requirement
299
+ none: false
264
300
  requirements:
265
- - - ">="
301
+ - - ">"
266
302
  - !ruby/object:Gem::Version
267
- version: "0"
268
- version:
303
+ hash: 25
304
+ segments:
305
+ - 1
306
+ - 3
307
+ - 1
308
+ version: 1.3.1
269
309
  requirements: []
270
310
 
271
311
  rubyforge_project: rspec
272
- rubygems_version: 1.3.5
312
+ rubygems_version: 1.3.7
273
313
  signing_key:
274
314
  specification_version: 3
275
- summary: rspec-rails 1.3.2
315
+ summary: rspec-rails 1.3.3.rc
276
316
  test_files: []
277
317