OSDN Git Service

Merge branch 'v03_test' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v03_test
[pettanr/pettanr.git] / spec / controllers / speach_balloons_controller_spec.rb
1 require 'spec_helper'
2
3 # This spec was generated by rspec-rails when you ran the scaffold generator.
4 # It demonstrates how one might use RSpec to specify the controller code that
5 # was generated by Rails when you ran the scaffold generator.
6 #
7 # It assumes that the implementation code is generated by the rails scaffold
8 # generator.  If you are using any extension libraries to generate different
9 # controller code, this generated spec may or may not pass.
10 #
11 # It only uses APIs available in rails and/or rspec-rails.  There are a number
12 # of tools you can use to make these specs even more expressive, but we're
13 # sticking to rails and rspec-rails APIs to keep things simple and stable.
14 #
15 # Compared to earlier versions of this generator, there is very limited use of
16 # stubs and message expectations in this spec.  Stubs are only used when there
17 # is no simpler way to get a handle on the object needed for the example.
18 # Message expectations are only used when there is no simpler way to specify
19 # that an instance is receiving a specific message.
20
21 describe SpeachBalloonsController do
22
23   # This should return the minimal set of attributes required to create a valid
24   # SpeachBaloon. As you add validations to SpeachBaloon, be sure to
25   # update the return value of this method accordingly.
26   def valid_attributes
27     {}
28   end
29
30   describe "GET index" do
31     it "assigns all speach_baloons as @speach_baloons" do
32       speach_baloon = SpeachBaloon.create! valid_attributes
33       get :index
34       assigns(:speach_baloons).should eq([speach_baloon])
35     end
36   end
37
38   describe "GET show" do
39     it "assigns the requested speach_baloon as @speach_baloon" do
40       speach_baloon = SpeachBaloon.create! valid_attributes
41       get :show, :id => speach_baloon.id
42       assigns(:speach_baloon).should eq(speach_baloon)
43     end
44   end
45
46   describe "GET new" do
47     it "assigns a new speach_baloon as @speach_baloon" do
48       get :new
49       assigns(:speach_baloon).should be_a_new(SpeachBaloon)
50     end
51   end
52
53   describe "GET edit" do
54     it "assigns the requested speach_baloon as @speach_baloon" do
55       speach_baloon = SpeachBaloon.create! valid_attributes
56       get :edit, :id => speach_baloon.id
57       assigns(:speach_baloon).should eq(speach_baloon)
58     end
59   end
60
61   describe "POST create" do
62     describe "with valid params" do
63       it "creates a new SpeachBaloon" do
64         expect {
65           post :create, :speach_baloon => valid_attributes
66         }.to change(SpeachBaloon, :count).by(1)
67       end
68
69       it "assigns a newly created speach_baloon as @speach_baloon" do
70         post :create, :speach_baloon => valid_attributes
71         assigns(:speach_baloon).should be_a(SpeachBaloon)
72         assigns(:speach_baloon).should be_persisted
73       end
74
75       it "redirects to the created speach_baloon" do
76         post :create, :speach_baloon => valid_attributes
77         response.should redirect_to(SpeachBaloon.last)
78       end
79     end
80
81     describe "with invalid params" do
82       it "assigns a newly created but unsaved speach_baloon as @speach_baloon" do
83         # Trigger the behavior that occurs when invalid params are submitted
84         SpeachBaloon.any_instance.stub(:save).and_return(false)
85         post :create, :speach_baloon => {}
86         assigns(:speach_baloon).should be_a_new(SpeachBaloon)
87       end
88
89       it "re-renders the 'new' template" do
90         # Trigger the behavior that occurs when invalid params are submitted
91         SpeachBaloon.any_instance.stub(:save).and_return(false)
92         post :create, :speach_baloon => {}
93         response.should render_template("new")
94       end
95     end
96   end
97
98   describe "PUT update" do
99     describe "with valid params" do
100       it "updates the requested speach_baloon" do
101         speach_baloon = SpeachBaloon.create! valid_attributes
102         # Assuming there are no other speach_baloons in the database, this
103         # specifies that the SpeachBaloon created on the previous line
104         # receives the :update_attributes message with whatever params are
105         # submitted in the request.
106         SpeachBaloon.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
107         put :update, :id => speach_baloon.id, :speach_baloon => {'these' => 'params'}
108       end
109
110       it "assigns the requested speach_baloon as @speach_baloon" do
111         speach_baloon = SpeachBaloon.create! valid_attributes
112         put :update, :id => speach_baloon.id, :speach_baloon => valid_attributes
113         assigns(:speach_baloon).should eq(speach_baloon)
114       end
115
116       it "redirects to the speach_baloon" do
117         speach_baloon = SpeachBaloon.create! valid_attributes
118         put :update, :id => speach_baloon.id, :speach_baloon => valid_attributes
119         response.should redirect_to(speach_baloon)
120       end
121     end
122
123     describe "with invalid params" do
124       it "assigns the speach_baloon as @speach_baloon" do
125         speach_baloon = SpeachBaloon.create! valid_attributes
126         # Trigger the behavior that occurs when invalid params are submitted
127         SpeachBaloon.any_instance.stub(:save).and_return(false)
128         put :update, :id => speach_baloon.id, :speach_baloon => {}
129         assigns(:speach_baloon).should eq(speach_baloon)
130       end
131
132       it "re-renders the 'edit' template" do
133         speach_baloon = SpeachBaloon.create! valid_attributes
134         # Trigger the behavior that occurs when invalid params are submitted
135         SpeachBaloon.any_instance.stub(:save).and_return(false)
136         put :update, :id => speach_baloon.id, :speach_baloon => {}
137         response.should render_template("edit")
138       end
139     end
140   end
141
142   describe "DELETE destroy" do
143     it "destroys the requested speach_baloon" do
144       speach_baloon = SpeachBaloon.create! valid_attributes
145       expect {
146         delete :destroy, :id => speach_baloon.id
147       }.to change(SpeachBaloon, :count).by(-1)
148     end
149
150     it "redirects to the speach_baloons list" do
151       speach_baloon = SpeachBaloon.create! valid_attributes
152       delete :destroy, :id => speach_baloon.id
153       response.should redirect_to(speach_baloons_url)
154     end
155   end
156
157 end