--- /dev/null
+# -*- encoding: utf-8 -*-\r
+require 'spec_helper'\r
+#フキダシ枠\r
+describe Balloon do\r
+ include ManifestsMacros\r
+ before do\r
+ @model = Balloon\r
+ end\r
+ \r
+ describe 'ペタナイズに於いて' do\r
+ it 'スクコマを閉じるためのバインダーである' do\r
+ expect(@model.ancestors.include?(Peta::Binder)).to eq true\r
+ end\r
+ it '親モデルは持たない' do\r
+ expect(@model.my_peta.parent_model_name).to be_blank\r
+ end\r
+ describe 'ブーストに於いて' do\r
+ it '特筆すべき注意事項はない' do\r
+ expect(@model.my_peta.boost.keys).to be_empty\r
+ end\r
+ end\r
+ \r
+ end\r
+ \r
+ describe 'コントローラに於いて' do\r
+ before do\r
+ @controller = @model.my_controller\r
+ end\r
+ it 'スクロールのためのコントローラである' do\r
+ expect(@model.item_name).to eq 'scroll'\r
+ end\r
+ describe 'actionに於いて' do\r
+ before do\r
+ @actions = @controller.actions\r
+ @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show', \r
+ 'count', 'count_by_author', 'count_by_panel', \r
+ 'new', 'edit', 'create', 'update', 'destroy']\r
+ end\r
+ it 'これらのアクションが定義されている' do\r
+ set_actions? @actions, @actions_names\r
+ end\r
+ describe 'baseに於いて' do\r
+ end\r
+ describe 'indexに於いて' do\r
+ before do\r
+ @action = @actions['index']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # スクロールの公開リストを返すように定義している\r
+ set_list_action? @action, 'scroll', 'public'\r
+ end\r
+ end\r
+ describe 'by_authorに於いて' do\r
+ before do\r
+ @action = @actions['by_author']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # スクロールの作家フィルタリストを返すように定義している\r
+ set_list_action? @action, 'scroll', 'by_author'\r
+ end\r
+ end\r
+ describe 'by_panelに於いて' do\r
+ before do\r
+ @action = @actions['by_panel']\r
+ end\r
+ it 'listタイプのアクションである' do\r
+ expect(@action.type).to eq 'list'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ #スクロールのコマフィルタリストを返すように定義している\r
+ set_list_action? @action, 'scroll', 'by_panel'\r
+ end\r
+ end\r
+ describe 'countに於いて' do\r
+ before do\r
+ @action = @actions['count']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ #スクロールの公開リストのカウントを返すように定義している\r
+ set_list_action? @action, 'scroll', 'public'\r
+ end\r
+ end\r
+ describe 'count_by_authorに於いて' do\r
+ before do\r
+ @action = @actions['count_by_author']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # スクロールの作家フィルタリストのカウントを返すように定義している\r
+ set_list_action? @action, 'scroll', 'by_author'\r
+ end\r
+ end\r
+ describe 'count_by_panelに於いて' do\r
+ before do\r
+ @action = @actions['count_by_panel']\r
+ end\r
+ it 'countタイプのアクションである' do\r
+ expect(@action.type).to eq 'count'\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # スクロールのコマフィルタリストのカウントを返すように定義している\r
+ set_list_action? @action, 'scroll', 'by_panel'\r
+ end\r
+ end\r
+ describe 'newに於いて' do\r
+ before do\r
+ @action = @actions['new']\r
+ end\r
+ it 'newタイプのアクションである' do\r
+ expect(@action.type).to eq 'new'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'scroll'\r
+ end\r
+ end\r
+ describe 'editに於いて' do\r
+ before do\r
+ @action = @actions['edit']\r
+ end\r
+ it 'editタイプのアクションである' do\r
+ expect(@action.type).to eq 'edit'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'scroll'\r
+ end\r
+ end\r
+ describe 'createに於いて' do\r
+ before do\r
+ @action = @actions['create']\r
+ end\r
+ it 'createタイプのアクションである' do\r
+ expect(@action.type).to eq 'create'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'scroll'\r
+ end\r
+ end\r
+ describe 'updateに於いて' do\r
+ before do\r
+ @action = @actions['update']\r
+ end\r
+ it 'updateタイプのアクションである' do\r
+ expect(@action.type).to eq 'update'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'scroll'\r
+ end\r
+ end\r
+ describe 'destroyに於いて' do\r
+ before do\r
+ @action = @actions['destroy']\r
+ end\r
+ it 'destroyタイプのアクションである' do\r
+ expect(@action.type).to eq 'destroy'\r
+ end\r
+ it 'type' do\r
+ expect(@action.item_name).to eq 'scroll'\r
+ end\r
+ end\r
+ end\r
+ \r
+ end\r
+ \r
+ describe 'モデルに於いて' do\r
+ before do\r
+ @my_manifest = @model.my_manifest\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ expect(@my_manifest.model_name).to eq 'scroll'\r
+ expect(@my_manifest.classify).to eq @model\r
+ expect(@my_manifest.table_name).to eq 'scrolls'\r
+ end\r
+ \r
+ describe 'associationsに於いて' do\r
+ describe 'belongs_toに於いて' do\r
+ before do\r
+ @belongs_to = @my_manifest.associations.belongs_to\r
+ @names = ['author']\r
+ end\r
+ it 'これらのモデルに所属している' do\r
+ set_associations? @belongs_to, @names\r
+ end\r
+ describe 'authorに於いて' do\r
+ before do\r
+ @mani = @belongs_to['author']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'author'\r
+ expect(@mani.id_column).to eq 'author_id'\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている\r
+ expect(@mani.model).to eq Author\r
+ end\r
+ end\r
+ end\r
+ describe 'has_manyに於いて' do\r
+ before do\r
+ @has_many = @model.my_manifest.associations.has_many\r
+ @names = ['scroll_panels', 'panels']\r
+ end\r
+ it 'これらのモデルを所持している' do\r
+ set_associations? @has_many, @names\r
+ end\r
+ describe 'scroll_panelsに於いて' do\r
+ before do\r
+ @mani = @has_many['scroll_panels']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'scroll_panel'\r
+ expect(@mani.foreign_key).to eq 'scroll_id'\r
+ expect(@mani.through).to be nil\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be false\r
+ expect(@mani.model).to eq ScrollPanel\r
+ end\r
+ end\r
+ describe 'panelsに於いて' do\r
+ before do\r
+ @mani = @has_many['panels']\r
+ end\r
+ it 'マニフェストから設定を取り出している' do\r
+ # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている\r
+ expect(@mani.model_name).to eq 'panel'\r
+ expect(@mani.foreign_key).to eq 'scroll_id'\r
+ expect(@mani.through).to eq 'scroll_panels'\r
+ end\r
+ it 'サポート機能が動作している' do\r
+ # モデルを再現できている, 中間モデルフラグ\r
+ expect(@mani.through?).to be true\r
+ expect(@mani.model).to eq Panel\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe 'attributesに於いて' do\r
+ before do\r
+ @attributes = @model.my_manifest.attributes\r
+ end\r
+ it 'これらのカラムを定義している' do\r
+ set_attributes? @attributes, \r
+ ['id', 'title', 'description', 'visible', 'author_id', \r
+ 'created_at', 'updated_at']\r
+ end\r
+ describe 'titleに於いて' do\r
+ before do\r
+ @attribute = @attributes['title']\r
+ end\r
+ it 'textタイプである' do\r
+ expect(@attribute.type).to eq 'text'\r
+ end\r
+ end\r
+ describe 'descriptionに於いて' do\r
+ before do\r
+ @attribute = @attributes['description']\r
+ end\r
+ it 'textタイプである' do\r
+ expect(@attribute.type).to eq 'text'\r
+ end\r
+ end\r
+ describe 'visibleに於いて' do\r
+ before do\r
+ @attribute = @attributes['visible']\r
+ end\r
+ it 'numberタイプである' do\r
+ expect(@attribute.type).to eq 'number'\r
+ end\r
+ it '選択肢を定数から取得できるように定義している' do\r
+ expect(@attribute.source.type).to eq 'magic_number'\r
+ expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'\r
+ end\r
+ end\r
+ describe 'author_idに於いて' do\r
+ before do\r
+ @attribute = @attributes['author_id']\r
+ end\r
+ it 'numberタイプである' do\r
+ expect(@attribute.type).to eq 'number'\r
+ end\r
+ end\r
+ end\r
+ \r
+ end\r
+ \r
+end\r