Commit 4df2c72157a36da905827c946cc7098c2124a9c7
- Date: Mon Mar 17 09:22:26 +0000 2008
- Committer: David Chelimsky (dchelimsky@gmail.com)
- Author: Pat Maddox (pat.maddox@gmail.com)
- Commit SHA1: 4df2c72157a36da905827c946cc7098c2124a9c7
- Tree SHA1: 3885a2e8c48f4641986d13893bd1c643dc44f7ba
got nested integrate_views working
Commit diff
| |   |
| 72 | 72 | # |
| 73 | 73 | # See Spec::Rails::Example::ControllerExampleGroup for more information about |
| 74 | 74 | # Integration and Isolation modes. |
| 75 | | def integrate_views |
| 76 | | @integrate_views = true |
| 75 | def integrate_views(integrate_views = true) |
| 76 | @integrate_views = integrate_views |
| 77 | 77 | end |
| 78 | |
| 78 | 79 | def integrate_views? # :nodoc: |
| 79 | 80 | @integrate_views |
| 80 | 81 | end |
| 82 | |
| 83 | def inherited(klass) # :nodoc: |
| 84 | klass.integrate_views(integrate_views?) |
| 85 | super |
| 86 | end |
| 81 | 87 | |
| 82 | 88 | # You MUST provide a controller_name within the context of |
| 83 | 89 | # your controller specs: |
| toggle raw diff |
--- a/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
+++ b/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
@@ -72,12 +72,18 @@ module Spec
#
# See Spec::Rails::Example::ControllerExampleGroup for more information about
# Integration and Isolation modes.
- def integrate_views
- @integrate_views = true
+ def integrate_views(integrate_views = true)
+ @integrate_views = integrate_views
end
+
def integrate_views? # :nodoc:
@integrate_views
end
+
+ def inherited(klass) # :nodoc:
+ klass.integrate_views(integrate_views?)
+ super
+ end
# You MUST provide a controller_name within the context of
# your controller specs: |
| |   |
| 40 | 40 | lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError) |
| 41 | 41 | response.should_not be_success |
| 42 | 42 | end |
| 43 | |
| 44 | describe "nested" do |
| 45 | controller_name :controller_spec |
| 46 | |
| 47 | it "should render a template" do |
| 48 | get 'action_with_template' |
| 49 | response.should be_success |
| 50 | response.should have_tag('div', 'This is action_with_template.rhtml') |
| 51 | end |
| 52 | |
| 53 | describe "with integrate_views turned off" do |
| 54 | controller_name :controller_spec |
| 55 | integrate_views false |
| 56 | |
| 57 | it "should not care if the template doesn't exist" do |
| 58 | get 'some_action' |
| 59 | response.should be_success |
| 60 | response.should render_template("template/that/does/not/actually/exist") |
| 61 | end |
| 62 | end |
| 63 | end |
| 43 | 64 | end |
| toggle raw diff |
--- a/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
+++ b/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
@@ -40,4 +40,25 @@ describe "a controller spec running in integration mode", :type => :controller d
lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError)
response.should_not be_success
end
+
+ describe "nested" do
+ controller_name :controller_spec
+
+ it "should render a template" do
+ get 'action_with_template'
+ response.should be_success
+ response.should have_tag('div', 'This is action_with_template.rhtml')
+ end
+
+ describe "with integrate_views turned off" do
+ controller_name :controller_spec
+ integrate_views false
+
+ it "should not care if the template doesn't exist" do
+ get 'some_action'
+ response.should be_success
+ response.should render_template("template/that/does/not/actually/exist")
+ end
+ end
+ end
end |