OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / spec / manifests / panel_picture_spec.rb
diff --git a/spec/manifests/panel_picture_spec.rb b/spec/manifests/panel_picture_spec.rb
new file mode 100644 (file)
index 0000000..f09fc4b
--- /dev/null
@@ -0,0 +1,289 @@
+# -*- encoding: utf-8 -*-
+require 'spec_helper'
+#コマ絵
+describe PanelPicture do
+  include ManifestsMacros
+  before do
+    @model = PanelPicture
+  end
+  
+  describe 'ペタナイズに於いて' do
+    it 'パネルの要素として利用されるエレメントである' do
+      expect(@model.ancestors.include?(Peta::Element)).to eq true
+    end
+    it '親モデルはパネルである' do
+      expect(@model.my_peta.parent_model_name).to eq 'panel'
+    end
+    describe 'ブーストに於いて' do
+      it '特筆すべき注意事項はない' do
+        expect(@model.my_peta.boost.keys).to be_empty
+      end
+    end
+    
+  end
+  
+  describe 'コントローラに於いて' do
+    before do
+      @controller = @model.my_controller
+    end
+    it 'コマ絵のためのコントローラである' do
+      expect(@model.item_name).to eq 'panel_picture'
+    end
+    describe 'actionに於いて' do
+      before do
+        @actions = @controller.actions
+        @actions_names = ['index', 'by_author', 'by_panel', 'show', 
+          'count', 'count_by_author', 'count_by_panel', 
+          'new', 'edit']
+      end
+      it 'これらのアクションが定義されている' do
+        set_actions? @actions, @actions_names
+      end
+      describe 'baseに於いて' do
+      end
+      describe 'indexに於いて' do
+        before do
+          @action = @actions['index']
+        end
+        it 'listタイプのアクションである' do
+          expect(@action.type).to eq 'list'
+        end
+        it 'マニフェストから設定を取り出している' do
+          # コマ絵の公開リストを返すように定義している
+          set_list_action? @action, 'panel_picture', 'public'
+        end
+      end
+      describe 'by_authorに於いて' do
+        before do
+          @action = @actions['by_author']
+        end
+        it 'listタイプのアクションである' do
+          expect(@action.type).to eq 'list'
+        end
+        it 'マニフェストから設定を取り出している' do
+          # コマ絵の作家フィルタリストを返すように定義している
+          set_list_action? @action, 'panel_picture', '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, 'panel_picture', 'by_panel'
+        end
+      end
+      describe 'showに於いて' do
+        before do
+          @action = @actions['show']
+        end
+        it 'showタイプのアクションである' do
+          expect(@action.type).to eq 'show'
+        end
+      end
+      describe 'countに於いて' do
+        before do
+          @action = @actions['count']
+        end
+        it 'countタイプのアクションである' do
+          expect(@action.type).to eq 'count'
+        end
+        it 'マニフェストから設定を取り出している' do
+          #コマ絵の公開リストのカウントを返すように定義している
+          set_list_action? @action, 'panel_picture', 'public'
+        end
+      end
+      describe 'count_by_authorに於いて' do
+        before do
+          @action = @actions['count_by_author']
+        end
+        it 'countタイプのアクションである' do
+          expect(@action.type).to eq 'count'
+        end
+        it 'マニフェストから設定を取り出している' do
+          # コマ絵の作家フィルタリストのカウントを返すように定義している
+          set_list_action? @action, 'panel_picture', '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, 'panel_picture', 'by_panel'
+        end
+      end
+      describe 'newに於いて' do
+        before do
+          @action = @actions['new']
+        end
+        it 'newタイプのアクションである' do
+          expect(@action.type).to eq 'new'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'panel_picture'
+        end
+      end
+      describe 'editに於いて' do
+        before do
+          @action = @actions['edit']
+        end
+        it 'editタイプのアクションである' do
+          expect(@action.type).to eq 'edit'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'panel_picture'
+        end
+      end
+    end
+    
+  end
+  
+  describe 'モデルに於いて' do
+    before do
+      @my_manifest = @model.my_manifest
+    end
+    it 'サポート機能が動作している' do
+      expect(@my_manifest.model_name).to eq 'panel_picture'
+      expect(@my_manifest.classify).to eq @model
+      expect(@my_manifest.table_name).to eq 'panel_pictures'
+    end
+    
+    describe 'associationsに於いて' do
+      describe 'belongs_toに於いて' do
+        before do
+          @belongs_to = @my_manifest.associations.belongs_to
+          @names = ['panel']
+        end
+        it 'これらのモデルに所属している' do
+          set_associations? @belongs_to, @names
+        end
+        describe 'panelに於いて' do
+          before do
+            @mani = @belongs_to['panel']
+          end
+          it 'マニフェストから設定を取り出している' do
+            # モデル名と外部キーが定義あるいはデフォルト値補充されている
+            expect(@mani.model_name).to eq 'panel'
+            expect(@mani.id_column).to eq 'panel_id'
+          end
+          it 'サポート機能が動作している' do
+            # モデルを再現できている
+            expect(@mani.model).to eq Panel
+          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
+      before do
+        @attributes = @model.my_manifest.attributes
+      end
+      it 'これらのカラムを定義している' do
+        set_attributes? @attributes, 
+          ['id', 'panel_id', 'picture_id', 'caption', 'x', 'y', 'width', 'height', 
+          'link', 'z', 't', 
+          'created_at', 'updated_at']
+      end
+      describe 'panel_idに於いて' do
+        before do
+          @attribute = @attributes['panel_id']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      describe 'picture_idに於いて' do
+        before do
+          @attribute = @attributes['picture_id']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      describe 'captionに於いて' do
+        before do
+          @attribute = @attributes['caption']
+        end
+        it 'textタイプである' do
+          expect(@attribute.type).to eq 'text'
+        end
+      end
+      describe 'xに於いて' do
+        before do
+          @attribute = @attributes['x']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      describe 'yに於いて' do
+        before do
+          @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 'linkに於いて' do
+        before do
+          @attribute = @attributes['link']
+        end
+        it 'textタイプである' do
+          expect(@attribute.type).to eq 'text'
+        end
+      end
+      describe 'zに於いて' do
+        before do
+          @attribute = @attributes['z']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+      describe 'tに於いて' do
+        before do
+          @attribute = @attributes['t']
+        end
+        it 'numberタイプである' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+    end
+    
+  end
+  
+end