| 1 |
require File.dirname(__FILE__) + '/../../spec_helper' |
| 2 |
require 'controller_spec_controller' |
| 3 |
|
| 4 |
describe "a controller spec running in isolation mode", :type => :controller do |
| 5 |
controller_name :controller_spec |
| 6 |
|
| 7 |
it "should not care if the template doesn't exist" do |
| 8 |
get 'some_action' |
| 9 |
response.should be_success |
| 10 |
response.should render_template("template/that/does/not/actually/exist") |
| 11 |
end |
| 12 |
|
| 13 |
it "should not care if the template has errors" do |
| 14 |
get 'action_with_errors_in_template' |
| 15 |
response.should be_success |
| 16 |
response.should render_template("action_with_errors_in_template") |
| 17 |
end |
| 18 |
end |
| 19 |
|
| 20 |
describe "a controller spec running in integration mode", :type => :controller do |
| 21 |
controller_name :controller_spec |
| 22 |
integrate_views |
| 23 |
|
| 24 |
before(:each) do |
| 25 |
controller.class.send(:define_method, :rescue_action) { |e| raise e } |
| 26 |
end |
| 27 |
|
| 28 |
it "should render a template" do |
| 29 |
get 'action_with_template' |
| 30 |
response.should be_success |
| 31 |
response.should have_tag('div', 'This is action_with_template.rhtml') |
| 32 |
end |
| 33 |
|
| 34 |
it "should choke if the template doesn't exist" do |
| 35 |
lambda { get 'some_action' }.should raise_error(ActionController::MissingTemplate) |
| 36 |
response.should_not be_success |
| 37 |
end |
| 38 |
|
| 39 |
it "should choke if the template has errors" do |
| 40 |
lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError) |
| 41 |
response.should_not be_success |
| 42 |
end |
| 43 |
|
| 44 |
describe "nested" do |
| 45 |
it "should render a template" do |
| 46 |
get 'action_with_template' |
| 47 |
response.should be_success |
| 48 |
response.should have_tag('div', 'This is action_with_template.rhtml') |
| 49 |
end |
| 50 |
|
| 51 |
describe "with integrate_views turned off" do |
| 52 |
integrate_views false |
| 53 |
|
| 54 |
it "should not care if the template doesn't exist" do |
| 55 |
get 'some_action' |
| 56 |
response.should be_success |
| 57 |
response.should render_template("template/that/does/not/actually/exist") |
| 58 |
end |
| 59 |
end |
| 60 |
end |
| 61 |
end |