@lg = FactoryGirl.create :license_group
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@user = FactoryGirl.create( :user_yas)
- @author = @user.author
+ @author = FactoryGirl.create :author, :user_id => @user.id
@sbt = FactoryGirl.create :speech_balloon_template
end
SpeechBalloonTemplate.stub(:list).and_return([@sbt, @sbt, @sbt])
end
context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :index
- response.should be_success
- end
it 'フキダシテンプレートモデルに一覧を問い合わせている' do
SpeechBalloonTemplate.should_receive(:list).exactly(1)
get :index
assigns(:speech_balloon_templates).should have_at_least(3).items
end
context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
it 'indexテンプレートを描画する' do
get :index
response.should render_template("index")
end
end
context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index, :format => :json
+ response.should be_success
+ end
it 'jsonデータを返す' do
get :index, :format => :json
lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
end
+ it 'フキダシテンプレートモデルにjson一覧出力オプションを問い合わせている' do
+ SpeechBalloonTemplate.should_receive(:list_json_opt).exactly(1)
+ get :index, :format => :json
+ end
it 'データがリスト構造になっている' do
get :index, :format => :json
json = JSON.parse response.body
it 'リストの先頭くらいはフキダシテンプレートっぽいものであって欲しい' do
get :index, :format => :json
json = JSON.parse response.body
+ json.first.has_key?("name").should be_true
json.first.has_key?("classname").should be_true
+ json.first.has_key?("t").should be_true
end
end
end
describe '単体表示に於いて' do
before do
sign_in @user
- SpeechBalloonTemplate.stub(:show).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, @author).and_return(@sbt)
end
context 'つつがなく終わるとき' do
- it 'ステータスコード200 OKを返す' do
- get :show, :id => @sbt.id
- response.should be_success
- end
it 'フキダシテンプレートモデルに単体取得を問い合わせている' do
SpeechBalloonTemplate.should_receive(:show).exactly(1)
get :show
end
it '@speech_balloon_templateにアレを取得している' do
get :show, :id => @sbt.id
- assigns(:speech_balloon_template).id.should eq(@sbt.id)
+ assigns(:speech_balloon_template).should eq(@sbt)
end
context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id
+ response.should be_success
+ end
it 'showテンプレートを描画する' do
get :show, :id => @sbt.id
response.should render_template("show")
end
end
context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id, :format => :json
+ response.should be_success
+ end
it 'jsonデータを返す' do
get :show, :id => @sbt.id, :format => :json
lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
end
+ it 'フキダシテンプレートモデルにjson単体出力オプションを問い合わせている' do
+ SpeechBalloonTemplate.should_receive(:show_json_opt).exactly(1)
+ get :show, :id => @sbt.id, :format => :json
+ end
it 'データがアレになっている' do
get :show, :id => @sbt.id, :format => :json
json = JSON.parse response.body