josevalim-inherited_resources 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ # Version 0.4.3
2
+
3
+ * rspec bug fix is not automatically required anymore. User has to do it
4
+ explicitly.
5
+
1
6
  # Version 0.4.2
2
7
 
3
8
  * Added a file which fix a rspec bug when render is called inside a method
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  Inherited Resources
2
2
  License: MIT
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
 
5
5
  You can also read this README in pretty html at the GitHub project Wiki page:
6
6
 
@@ -33,6 +33,16 @@ If you want it as plugin, just do:
33
33
 
34
34
  script/plugin install git://github.com/josevalim/inherited_resources.git
35
35
 
36
+ rspec-rails <= 1.1.12 known bug
37
+ -------------------------------
38
+
39
+ InheritedResources has a known bug with rspec-rails when using blocks inside
40
+ actions. This will be fixed in the next rspec release, but until it comes out,
41
+ InheritedResources ships with a patch. To apply it, just put the line below on
42
+ your spec_helper.rb after loading rspec and rspec-rails:
43
+
44
+ require 'inherited_resources/spec'
45
+
36
46
  Basic Usage
37
47
  -----------
38
48
 
@@ -166,7 +166,6 @@ require File.dirname(__FILE__) + '/class_methods.rb'
166
166
  require File.dirname(__FILE__) + '/dumb_responder.rb'
167
167
  require File.dirname(__FILE__) + '/polymorphic_helpers.rb'
168
168
  require File.dirname(__FILE__) + '/singleton_helpers.rb'
169
- require File.dirname(__FILE__) + '/spec.rb'
170
169
  require File.dirname(__FILE__) + '/url_helpers.rb'
171
170
 
172
171
  module InheritedResources
@@ -0,0 +1,75 @@
1
+ # This is a nasty rspec bug fix when using InheritedResources.
2
+ # The bug exists on rspec <= 1.1.12 versions.
3
+ #
4
+ if defined?(Spec::Rails::Example::ControllerExampleGroup)
5
+ unless Spec::Rails::Example::ControllerExampleGroup.const_defined?('TemplateIsolationExtensions')
6
+
7
+ module Spec::Rails::Example
8
+ class ControllerExampleGroup < FunctionalExampleGroup
9
+ module ControllerInstanceMethods #:nodoc:
10
+
11
+ # === render(options = nil, deprecated_status_or_extra_options = nil, &block)
12
+ #
13
+ # This gets added to the controller's singleton meta class,
14
+ # allowing Controller Examples to run in two modes, freely switching
15
+ # from context to context.
16
+ def render(options=nil, deprecated_status_or_extra_options=nil, &block)
17
+ if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
18
+ deprecated_status_or_extra_options = {}
19
+ end
20
+
21
+ unless block_given?
22
+ unless integrate_views?
23
+ if @template.respond_to?(:finder)
24
+ (class << @template.finder; self; end).class_eval do
25
+ define_method :file_exists? do; true; end
26
+ end
27
+ else
28
+ (class << @template; self; end).class_eval do
29
+ define_method :file_exists? do; true; end
30
+ end
31
+ end
32
+
33
+ (class << @template; self; end).send :include, TemplateIsolationExtensions
34
+ end
35
+ end
36
+
37
+ if matching_message_expectation_exists(options)
38
+ render_proxy.render(options, &block)
39
+ @performed_render = true
40
+ else
41
+ if matching_stub_exists(options)
42
+ @performed_render = true
43
+ else
44
+ super(options, deprecated_status_or_extra_options, &block)
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ module TemplateIsolationExtensions
51
+ def render_file(*args)
52
+ @first_render ||= args[0] unless args[0] =~ /^layouts/
53
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
54
+ end
55
+
56
+ def _pick_template(*args)
57
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
58
+ PickedTemplate.new
59
+ end
60
+
61
+ def render(*args)
62
+ if @_rendered
63
+ opts = args[0]
64
+ (@_rendered[:template] ||= opts[:file]) if opts[:file]
65
+ (@_rendered[:partials][opts[:partial]] += 1) if opts[:partial]
66
+ else
67
+ super
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ end
75
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: josevalim-inherited_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jos\xC3\xA9 Valim"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-17 00:00:00 -08:00
12
+ date: 2009-02-26 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -36,6 +36,7 @@ files:
36
36
  - lib/inherited_resources/polymorphic_helpers.rb
37
37
  - lib/inherited_resources/respond_to.rb
38
38
  - lib/inherited_resources/singleton_helpers.rb
39
+ - lib/inherited_resources/spec.rb
39
40
  - lib/inherited_resources/url_helpers.rb
40
41
  has_rdoc: true
41
42
  homepage: http://github.com/josevalim/inherited_resources