X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=spec%2Fmanifests%2Fballoon_spec.rb;fp=spec%2Fmanifests%2Fballoon_spec.rb;h=2ff1e83842d2912071510240865379411a0f2862;hp=91b36c04961b1d8c28aec5b3d9d474cd23f257d0;hb=4c06cc2cd9eae13117c47fb5ed81e68636b0b4ae;hpb=65cd4fb912cd3ecd5772dc8581429c44550c941a diff --git a/spec/manifests/balloon_spec.rb b/spec/manifests/balloon_spec.rb index 91b36c04..2ff1e838 100644 --- a/spec/manifests/balloon_spec.rb +++ b/spec/manifests/balloon_spec.rb @@ -8,15 +8,38 @@ describe Balloon do end describe 'ペタナイズに於いて' do - it 'スクコマを閉じるためのバインダーである' do - expect(@model.ancestors.include?(Peta::Binder)).to eq true + it 'フキダシの要素として利用されるエレメントである' do + expect(@model.ancestors.include?(Peta::Element)).to eq true end - it '親モデルは持たない' do - expect(@model.my_peta.parent_model_name).to be_blank + it '親モデルはフキダシである' do + expect(@model.my_peta.parent_model_name).to eq 'speech_balloon' end describe 'ブーストに於いて' do - it '特筆すべき注意事項はない' do - expect(@model.my_peta.boost.keys).to be_empty + before do + @boosts = @model.my_peta.boost + @boosts_names = ['speech_balloon_template'] + end + it 'これらのブーストが定義されている' do + set_boosts? @boosts, @boosts_names + end + describe 'フキダシテンプレートに於いて' do + before do + @mani = @boosts['speech_balloon_template'] + end + it 'フキダシテンプレート' do + expect(@mani.level).to eq 'post' + expect(@mani.template_name).to eq 'speech_balloon_template' + expect(@mani.column_name_for_template_module).to eq 'speech_balloon_template_module_name' + expect(@mani.settings_column_name).to eq 'speech_balloon_template_settings' + expect(@mani.foreign_key).to eq 'speech_balloon_template_id' + end + it 'フキダシテンプレート' do + expect(@mani.item_name_for_extend_model).to eq 'balloon' + expect(@mani.setter_method_name).to eq 'balloon_extend=' + expect(@mani.getter_method_name).to eq 'balloon_extend' + expect(@mani.extend_model_class_name).to eq 'Balloon' + expect(@mani.extend_module_name).to eq 'BalloonModule' + end end end @@ -26,15 +49,15 @@ describe Balloon do before do @controller = @model.my_controller end - it 'スクロールのためのコントローラである' do - expect(@model.item_name).to eq 'scroll' + it 'フキダシ枠のためのコントローラである' do + expect(@model.item_name).to eq 'balloon' end describe 'actionに於いて' do before do @actions = @controller.actions - @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show', - 'count', 'count_by_author', 'count_by_panel', - 'new', 'edit', 'create', 'update', 'destroy'] + @actions_names = ['index', 'by_author', 'show', + 'count', 'count_by_author', + 'new', 'edit'] end it 'これらのアクションが定義されている' do set_actions? @actions, @actions_names @@ -49,8 +72,8 @@ describe Balloon do expect(@action.type).to eq 'list' end it 'マニフェストから設定を取り出している' do - # スクロールの公開リストを返すように定義している - set_list_action? @action, 'scroll', 'public' + # フキダシ枠の公開リストを返すように定義している + set_list_action? @action, 'balloon', 'public' end end describe 'by_authorに於いて' do @@ -61,20 +84,8 @@ describe Balloon do expect(@action.type).to eq 'list' end it 'マニフェストから設定を取り出している' do - # スクロールの作家フィルタリストを返すように定義している - set_list_action? @action, 'scroll', 'by_author' - end - end - describe 'by_panelに於いて' do - before do - @action = @actions['by_panel'] - end - it 'listタイプのアクションである' do - expect(@action.type).to eq 'list' - end - it 'マニフェストから設定を取り出している' do - #スクロールのコマフィルタリストを返すように定義している - set_list_action? @action, 'scroll', 'by_panel' + # フキダシ枠の作家フィルタリストを返すように定義している + set_list_action? @action, 'balloon', 'by_author' end end describe 'countに於いて' do @@ -85,8 +96,8 @@ describe Balloon do expect(@action.type).to eq 'count' end it 'マニフェストから設定を取り出している' do - #スクロールの公開リストのカウントを返すように定義している - set_list_action? @action, 'scroll', 'public' + #フキダシ枠の公開リストのカウントを返すように定義している + set_list_action? @action, 'balloon', 'public' end end describe 'count_by_authorに於いて' do @@ -97,20 +108,8 @@ describe Balloon do expect(@action.type).to eq 'count' end it 'マニフェストから設定を取り出している' do - # スクロールの作家フィルタリストのカウントを返すように定義している - set_list_action? @action, 'scroll', 'by_author' - end - end - describe 'count_by_panelに於いて' do - before do - @action = @actions['count_by_panel'] - end - it 'countタイプのアクションである' do - expect(@action.type).to eq 'count' - end - it 'マニフェストから設定を取り出している' do - # スクロールのコマフィルタリストのカウントを返すように定義している - set_list_action? @action, 'scroll', 'by_panel' + # フキダシ枠の作家フィルタリストのカウントを返すように定義している + set_list_action? @action, 'balloon', 'by_author' end end describe 'newに於いて' do @@ -121,7 +120,7 @@ describe Balloon do expect(@action.type).to eq 'new' end it 'type' do - expect(@action.item_name).to eq 'scroll' + expect(@action.item_name).to eq 'balloon' end end describe 'editに於いて' do @@ -132,40 +131,7 @@ describe Balloon do expect(@action.type).to eq 'edit' end it 'type' do - expect(@action.item_name).to eq 'scroll' - end - end - describe 'createに於いて' do - before do - @action = @actions['create'] - end - it 'createタイプのアクションである' do - expect(@action.type).to eq 'create' - end - it 'type' do - expect(@action.item_name).to eq 'scroll' - end - end - describe 'updateに於いて' do - before do - @action = @actions['update'] - end - it 'updateタイプのアクションである' do - expect(@action.type).to eq 'update' - end - it 'type' do - expect(@action.item_name).to eq 'scroll' - end - end - describe 'destroyに於いて' do - before do - @action = @actions['destroy'] - end - it 'destroyタイプのアクションである' do - expect(@action.type).to eq 'destroy' - end - it 'type' do - expect(@action.item_name).to eq 'scroll' + expect(@action.item_name).to eq 'balloon' end end end @@ -177,76 +143,72 @@ describe Balloon do @my_manifest = @model.my_manifest end it 'サポート機能が動作している' do - expect(@my_manifest.model_name).to eq 'scroll' + expect(@my_manifest.model_name).to eq 'balloon' expect(@my_manifest.classify).to eq @model - expect(@my_manifest.table_name).to eq 'scrolls' + expect(@my_manifest.table_name).to eq 'balloons' end describe 'associationsに於いて' do describe 'belongs_toに於いて' do before do @belongs_to = @my_manifest.associations.belongs_to - @names = ['author'] + @names = ['speech_balloon', 'system_picture', 'speech_balloon_template'] end it 'これらのモデルに所属している' do set_associations? @belongs_to, @names end - describe 'authorに於いて' do + describe 'speech_balloonに於いて' do before do - @mani = @belongs_to['author'] + @mani = @belongs_to['speech_balloon'] end it 'マニフェストから設定を取り出している' do # モデル名と外部キーが定義あるいはデフォルト値補充されている - expect(@mani.model_name).to eq 'author' - expect(@mani.id_column).to eq 'author_id' + expect(@mani.model_name).to eq 'speech_balloon' + expect(@mani.id_column).to eq 'speech_balloon_id' end it 'サポート機能が動作している' do # モデルを再現できている - expect(@mani.model).to eq Author + expect(@mani.model).to eq SpeechBalloon end end - end - describe 'has_manyに於いて' do - before do - @has_many = @model.my_manifest.associations.has_many - @names = ['scroll_panels', 'panels'] - end - it 'これらのモデルを所持している' do - set_associations? @has_many, @names - end - describe 'scroll_panelsに於いて' do + describe 'system_pictureに於いて' do before do - @mani = @has_many['scroll_panels'] + @mani = @belongs_to['system_picture'] end it 'マニフェストから設定を取り出している' do - # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている - expect(@mani.model_name).to eq 'scroll_panel' - expect(@mani.foreign_key).to eq 'scroll_id' - expect(@mani.through).to be nil + # モデル名と外部キーが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'system_picture' + expect(@mani.id_column).to eq 'system_picture_id' end it 'サポート機能が動作している' do - # モデルを再現できている, 中間モデルフラグ - expect(@mani.through?).to be false - expect(@mani.model).to eq ScrollPanel + # モデルを再現できている + expect(@mani.model).to eq SystemPicture end end - describe 'panelsに於いて' do + describe 'speech_balloon_templateに於いて' do before do - @mani = @has_many['panels'] + @mani = @belongs_to['speech_balloon_template'] end it 'マニフェストから設定を取り出している' do - # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている - expect(@mani.model_name).to eq 'panel' - expect(@mani.foreign_key).to eq 'scroll_id' - expect(@mani.through).to eq 'scroll_panels' + # モデル名と外部キーが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'speech_balloon_template' + expect(@mani.id_column).to eq 'speech_balloon_template_id' end it 'サポート機能が動作している' do - # モデルを再現できている, 中間モデルフラグ - expect(@mani.through?).to be true - expect(@mani.model).to eq Panel + # モデルを再現できている + expect(@mani.model).to eq SpeechBalloonTemplate end end end + describe 'has_manyに於いて' do + before do + @has_many = @model.my_manifest.associations.has_many + @names = [] + end + it 'これらのモデルを所持している' do + set_associations? @has_many, @names + end + end end describe 'attributesに於いて' do @@ -255,45 +217,91 @@ describe Balloon do end it 'これらのカラムを定義している' do set_attributes? @attributes, - ['id', 'title', 'description', 'visible', 'author_id', + ['id', 'speech_balloon_id', 'speech_balloon_template_id', 'speech_balloon_template_module_name', + 'system_picture_id', 'x', 'y', 'width', 'height', 'r', + 'speech_balloon_template_settings', 'created_at', 'updated_at'] end - describe 'titleに於いて' do + describe 'speech_balloon_idに於いて' do before do - @attribute = @attributes['title'] + @attribute = @attributes['speech_balloon_id'] end - it 'textタイプである' do - expect(@attribute.type).to eq 'text' + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' + end + end + describe 'speech_balloon_template_idに於いて' do + before do + @attribute = @attributes['speech_balloon_template_id'] + end + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' end end - describe 'descriptionに於いて' do + describe 'speech_balloon_template_module_nameに於いて' do before do - @attribute = @attributes['description'] + @attribute = @attributes['speech_balloon_template_module_name'] end it 'textタイプである' do expect(@attribute.type).to eq 'text' end end - describe 'visibleに於いて' do + describe 'system_picture_idに於いて' do before do - @attribute = @attributes['visible'] + @attribute = @attributes['system_picture_id'] end it 'numberタイプである' do expect(@attribute.type).to eq 'number' end - it '選択肢を定数から取得できるように定義している' do - expect(@attribute.source.type).to eq 'magic_number' - expect(@attribute.source.select_item_name).to eq 'scroll_visible_items' + end + describe 'xに於いて' do + before do + @attribute = @attributes['x'] + end + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' end end - describe 'author_idに於いて' do + describe 'yに於いて' do before do - @attribute = @attributes['author_id'] + @attribute = @attributes['y'] end it 'numberタイプである' do expect(@attribute.type).to eq 'number' end end + describe 'widthに於いて' do + before do + @attribute = @attributes['width'] + end + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' + end + end + describe 'heightに於いて' do + before do + @attribute = @attributes['height'] + end + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' + end + end + describe 'rに於いて' do + before do + @attribute = @attributes['r'] + end + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' + end + end + describe 'speech_balloon_template_settingsに於いて' do + before do + @attribute = @attributes['speech_balloon_template_settings'] + end + it 'textタイプである' do + expect(@attribute.type).to eq 'text' + end + end end end