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.
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.
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.
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.
21 describe SpeachTemplatesController do
23 # This should return the minimal set of attributes required to create a valid
24 # SpeachTemplate. As you add validations to SpeachTemplate, be sure to
25 # update the return value of this method accordingly.
30 describe "GET index" do
31 it "assigns all speach_templates as @speach_templates" do
32 speach_template = SpeachTemplate.create! valid_attributes
34 assigns(:speach_templates).should eq([speach_template])
38 describe "GET show" do
39 it "assigns the requested speach_template as @speach_template" do
40 speach_template = SpeachTemplate.create! valid_attributes
41 get :show, :id => speach_template.id
42 assigns(:speach_template).should eq(speach_template)
47 it "assigns a new speach_template as @speach_template" do
49 assigns(:speach_template).should be_a_new(SpeachTemplate)
53 describe "GET edit" do
54 it "assigns the requested speach_template as @speach_template" do
55 speach_template = SpeachTemplate.create! valid_attributes
56 get :edit, :id => speach_template.id
57 assigns(:speach_template).should eq(speach_template)
61 describe "POST create" do
62 describe "with valid params" do
63 it "creates a new SpeachTemplate" do
65 post :create, :speach_template => valid_attributes
66 }.to change(SpeachTemplate, :count).by(1)
69 it "assigns a newly created speach_template as @speach_template" do
70 post :create, :speach_template => valid_attributes
71 assigns(:speach_template).should be_a(SpeachTemplate)
72 assigns(:speach_template).should be_persisted
75 it "redirects to the created speach_template" do
76 post :create, :speach_template => valid_attributes
77 response.should redirect_to(SpeachTemplate.last)
81 describe "with invalid params" do
82 it "assigns a newly created but unsaved speach_template as @speach_template" do
83 # Trigger the behavior that occurs when invalid params are submitted
84 SpeachTemplate.any_instance.stub(:save).and_return(false)
85 post :create, :speach_template => {}
86 assigns(:speach_template).should be_a_new(SpeachTemplate)
89 it "re-renders the 'new' template" do
90 # Trigger the behavior that occurs when invalid params are submitted
91 SpeachTemplate.any_instance.stub(:save).and_return(false)
92 post :create, :speach_template => {}
93 response.should render_template("new")
98 describe "PUT update" do
99 describe "with valid params" do
100 it "updates the requested speach_template" do
101 speach_template = SpeachTemplate.create! valid_attributes
102 # Assuming there are no other speach_templates in the database, this
103 # specifies that the SpeachTemplate created on the previous line
104 # receives the :update_attributes message with whatever params are
105 # submitted in the request.
106 SpeachTemplate.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
107 put :update, :id => speach_template.id, :speach_template => {'these' => 'params'}
110 it "assigns the requested speach_template as @speach_template" do
111 speach_template = SpeachTemplate.create! valid_attributes
112 put :update, :id => speach_template.id, :speach_template => valid_attributes
113 assigns(:speach_template).should eq(speach_template)
116 it "redirects to the speach_template" do
117 speach_template = SpeachTemplate.create! valid_attributes
118 put :update, :id => speach_template.id, :speach_template => valid_attributes
119 response.should redirect_to(speach_template)
123 describe "with invalid params" do
124 it "assigns the speach_template as @speach_template" do
125 speach_template = SpeachTemplate.create! valid_attributes
126 # Trigger the behavior that occurs when invalid params are submitted
127 SpeachTemplate.any_instance.stub(:save).and_return(false)
128 put :update, :id => speach_template.id, :speach_template => {}
129 assigns(:speach_template).should eq(speach_template)
132 it "re-renders the 'edit' template" do
133 speach_template = SpeachTemplate.create! valid_attributes
134 # Trigger the behavior that occurs when invalid params are submitted
135 SpeachTemplate.any_instance.stub(:save).and_return(false)
136 put :update, :id => speach_template.id, :speach_template => {}
137 response.should render_template("edit")
142 describe "DELETE destroy" do
143 it "destroys the requested speach_template" do
144 speach_template = SpeachTemplate.create! valid_attributes
146 delete :destroy, :id => speach_template.id
147 }.to change(SpeachTemplate, :count).by(-1)
150 it "redirects to the speach_templates list" do
151 speach_template = SpeachTemplate.create! valid_attributes
152 delete :destroy, :id => speach_template.id
153 response.should redirect_to(speach_templates_url)