changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.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
1module Spec
2 module Rails
3 module Example
4 class FunctionalExampleGroup < RailsExampleGroup
5 include ActionController::TestProcess
6 include ActionController::Assertions
7
8 attr_reader :request, :response
9 before(:each) do
10 @controller_class = Object.path2class @controller_class_name
11 raise "Can't determine controller class for #{@controller_class_name}" if @controller_class.nil?
12
13 @controller = @controller_class.new
14
15 @request = ActionController::TestRequest.new
16 @response = ActionController::TestResponse.new
17 end
18
19 def params
20 request.parameters
21 end
22
23 def flash
24 response.flash
25 end
26
27 def session
28 request.session
29 end
30
31 # :call-seq:
32 # assigns()
33 #
34 # Hash of instance variables to values that are made available to
35 # views. == Examples
36 #
37 # #in thing_controller.rb
38 # def new
39 # @thing = Thing.new
40 # end
41 #
42 # #in thing_controller_spec
43 # get 'new'
44 # assigns[:registration].should == Thing.new
45 #--
46 # NOTE - Even though docs only use assigns[:key] format, this supports
47 # assigns(:key) in order to avoid breaking old specs.
48 #++
49 def assigns(key = nil)
50 if key.nil?
51 @controller.assigns
52 _controller_ivar_proxy
53 else
54 @controller.assigns[key]
55 _controller_ivar_proxy[key]
56 end
57 end
58
59 protected
60 def _controller_ivar_proxy
61 @controller_ivar_proxy ||= IvarProxy.new @controller
62 end
63 end
64 end
65 end
66end