describe 'シリアライズチェックに於いて' do\r
context 'つつがなく終わるとき' do\r
it '0からシリアライズされているならTrueを返す' do\r
- r = Panel.validate_t [0, 1, 2]\r
+ r = Panel.validate_serial [0, 1, 2]\r
r.should be_true\r
end\r
it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do\r
- r = Panel.validate_t [0, 2, 1]\r
+ r = Panel.validate_serial [0, 2, 1]\r
r.should be_true\r
end\r
it '見た目はシリアライズされてなくてもソート結果が無事ならtrueを返す' do\r
- r = Panel.validate_t [ 2, 1, 4, 3, 0]\r
+ r = Panel.validate_serial [ 2, 1, 4, 3, 0]\r
+ r.should be_true\r
+ end\r
+ end\r
+ context 'オフセットが1のとき' do\r
+ it '0からシリアライズされているならFalseを返す' do\r
+ r = Panel.validate_serial [0, 1, 2], 1\r
+ r.should be_false\r
+ end\r
+ it '1からシリアライズされているならTrueを返す' do\r
+ r = Panel.validate_serial [1, 2, 3], 1\r
r.should be_true\r
end\r
end\r
context '異常なとき' do\r
it '0から始まらないならFalseを返す' do\r
- r = Panel.validate_t [1, 2, 3]\r
+ r = Panel.validate_serial [1, 2, 3]\r
r.should be_false\r
end\r
it '連続していないならFalseを返す' do\r
- r = Panel.validate_t [0, 1, 2, 4]\r
+ r = Panel.validate_serial [0, 1, 2, 4]\r
r.should be_false\r
end\r
it '連続していないならFalseを返す' do\r
- r = Panel.validate_t [0, 1, 2, 4, 5]\r
+ r = Panel.validate_serial [0, 1, 2, 4, 5]\r
r.should be_false\r
end\r
end\r
end\r
- describe 'tチェック単体に於いて' do\r
+ describe 'シリアライズチェック単体に於いて' do\r
before do\r
end\r
context 'つつがなく終わるとき' do\r
it '検証値収集を依頼している' do\r
Panel.should_receive(:collect_element_value).with(any_args).exactly(1)\r
Panel.stub(:collect_element_value).with(any_args).and_return([])\r
- Panel.stub(:validate_t).with(any_args).and_return(true)\r
- r = Panel.validate_element_t [], :t\r
+ Panel.stub(:validate_serial).with(any_args).and_return(true)\r
+ r = Panel.validate_element_serial [], :t\r
end\r
it 'シリアライズチェック依頼している' do\r
Panel.stub(:collect_element_value).with(any_args).and_return([])\r
- Panel.should_receive(:validate_t).with(any_args).exactly(1)\r
- Panel.stub(:validate_t).with(any_args).and_return(true)\r
- r = Panel.validate_element_t [], :t\r
+ Panel.should_receive(:validate_serial).with(any_args).exactly(1)\r
+ Panel.stub(:validate_serial).with(any_args).and_return(true)\r
+ r = Panel.validate_element_serial [], :t\r
end\r
end\r
end\r
it 'trueを返している' do\r
@panel = FactoryGirl.build :panel, :author_id => @author.id\r
@panel.panel_pictures.build(\r
- FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0)\r
+ FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0, :z => 0+1)\r
)\r
@panel.panel_pictures.build(\r
- FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1)\r
+ FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1, :z => 1+1)\r
)\r
sb1 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)\r
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
)\r
sb1.balloons.build(\r
FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)\r
FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)\r
)\r
sb2 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 3)\r
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 3, :z => 3+1)\r
)\r
sb2.balloons.build(\r
FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)\r
FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)\r
)\r
@gc = @panel.ground_colors.build(\r
- FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4)\r
+ FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4, :z => 4+1)\r
)\r
@gp = @panel.ground_pictures.build(\r
- FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 5)\r
+ FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 5, :z => 5+1)\r
)\r
r = @panel.validate_child\r
r.should be_true\r
end\r
end\r
- context 'シリアライズされていないとき' do\r
+ context 'tシリアライズされていないとき' do\r
it 'falseを返している' do\r
@panel = FactoryGirl.build :panel, :author_id => @author.id\r
@panel.panel_pictures.build(\r
- FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0)\r
+ FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0, :z => 0+1)\r
)\r
@panel.panel_pictures.build(\r
- FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1)\r
+ FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1, :z => 1+1)\r
)\r
sb1 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2)\r
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
)\r
sb1.balloons.build(\r
FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)\r
FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)\r
)\r
sb2 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 4)\r
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 4, :z => 3+1)\r
+ )\r
+ sb2.balloons.build(\r
+ FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)\r
+ )\r
+ sb2.speeches.build(\r
+ FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)\r
+ )\r
+ @gc = @panel.ground_colors.build(\r
+ FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4, :z => 4+1)\r
+ )\r
+ @gp = @panel.ground_pictures.build(\r
+ FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 5, :z => 5+1)\r
+ )\r
+ r = @panel.validate_child\r
+ r.should be_false\r
+ end\r
+ end\r
+ context 'zシリアライズされていないとき' do\r
+ it 'falseを返している' do\r
+ @panel = FactoryGirl.build :panel, :author_id => @author.id\r
+ @panel.panel_pictures.build(\r
+ FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 0, :z => 0+1)\r
+ )\r
+ @panel.panel_pictures.build(\r
+ FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1, :z => 0+1)\r
+ )\r
+ sb1 = @panel.speech_balloons.build(\r
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
+ )\r
+ sb1.balloons.build(\r
+ FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)\r
+ )\r
+ sb1.speeches.build(\r
+ FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)\r
+ )\r
+ sb2 = @panel.speech_balloons.build(\r
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 3, :z => 3+1)\r
)\r
sb2.balloons.build(\r
FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)\r
FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)\r
)\r
@gc = @panel.ground_colors.build(\r
- FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4)\r
+ FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4, :z => 4+1)\r
)\r
@gp = @panel.ground_pictures.build(\r
- FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 5)\r
+ FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 5, :z => 5+1)\r
)\r
r = @panel.validate_child\r
r.should be_false\r