changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb

changeset 16: 01fd3f10ae84
author: moriq@moriq.com
date: Mon Mar 10 10:13:18 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec_on_rails
1require File.dirname(__FILE__) + '/../../spec_helper'
2require 'controller_spec_controller'
3
4describe "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
18end
19
20describe "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
43end