get :new
assigns(:story).should be_a_new(Story)
end
- it 'ã\82³ã\83\9eã\83¢ã\83\87ã\83«ã\81«ã\83\87ã\83\95ã\82©ã\83«ã\83\88å\80¤è£\9cå\85\85ã\82\92ä¾\9dé ¼ã\81\97ã\81¦ã\81\84ã\82\8b' do
+ it 'モデルにデフォルト値補充を依頼している' do
Story.any_instance.should_receive(:supply_default).exactly(1)
get :new
end
sign_in @user
end
context 'つつがなく終わるとき' do
+ it 'デフォルト値補充を依頼する' do
+ Story.any_instance.should_receive(:supply_default).exactly(1)
+ post :create, :story => @attr
+ end
+ it 'POSTデータから、カラム値を復元している' do
+ Story.any_instance.stub(:store).and_return(true)
+ Story.any_instance.should_receive(:attributes=).exactly(1)
+ post :create, :story => @attr
+ end
+ it '上書き補充を依頼する' do
+ Story.any_instance.should_receive(:overwrite).exactly(1)
+ post :create, :story => @attr
+ end
it 'モデルに保存依頼する' do
Story.any_instance.should_receive(:store).exactly(1)
post :create, :story => @attr
response.should redirect_to(:action => :show, :id => @attr[:comic_id])
end
end
- context 'js形式' do
- it 'ステータスコード302 Foundを返す' do
- Story.any_instance.stub(:store).and_return(true)
- post :create, :story => @attr, :format => :js
- response.status.should eq 302
- end
- it 'コミックのストーリー表示へ遷移する' do
-# Story.any_instance.stub(:store).and_return(true)
- post :create, :story => @attr, :format => :js
- response.should redirect_to(:action => :show, :id => @attr[:comic_id])
- end
- end
context 'json形式' do
it 'ステータスコード200 OKを返す' do
# Story.any_instance.stub(:store).and_return(true)
it 'データがアレになっている' do
post :create, :story => @attr, :format => :json
json = JSON.parse response.body
- json["t"].should eq @story.t
+ json["t"].should eq 0
end
end
end
Story.should_receive(:show).exactly(1)
put :update, :id => @story.id, :story => @attr
end
+ it 'POSTデータから、カラム値を復元している' do
+ Story.any_instance.stub(:store).and_return(true)
+ Story.any_instance.should_receive(:attributes=).exactly(1)
+ put :update, :id => @story.id, :story => @attr
+ end
+ it '上書き補充を依頼する' do
+ Story.any_instance.should_receive(:overwrite).exactly(1)
+ put :update, :id => @story.id, :story => @attr
+ end
it 'モデルに保存依頼する' do
Story.any_instance.should_receive(:store).exactly(1)
put :update, :id => @story.id, :story => @attr