OSDN Git Service

add mani test
[pettanr/pettanr.git] / spec / manifests / scroll_spec.rb
index 1e18386..af004e0 100644 (file)
@@ -4,39 +4,266 @@ require 'spec_helper'
 
 describe Scroll do
   before do
+    @model = Scroll
   end
   
   describe 'ペタナイズに於いて' do
-    context 'オーソドックスなデータのとき' do
-      it 'スクコマを閉じるためのバインダーである' do
-        expect(@item.is_a?(Peta::Binder)).to be true
-      end
+    it 'スクコマを閉じるためのバインダーである' do
+      expect(@model.ancestors.include?(Peta::Binder)).to eq true
+    end
+    it ' 項はない' do
+      expect(@model.my_peta.parent_model_name).to be_blank
+    end
+    describe 'ブーストに於いて' do
       it 'ブースト特筆すべき注意事項はない' do
-        expect(self.class.my_peta.boost.keys).to be true
+        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 'scroll'
+    end
     describe 'actionに於いて' do
-      it 'スクコマを閉じるためのバインダーである' do
-        expect(@item.is_a?(Peta::Binder)).to be true
+      before do
+        @actions = @controller.actions
       end
-      it 'ブースト特筆すべき注意事項はない' do
-        expect(self.class.my_peta.boost.keys).to be true
+      it 'はない' do
+        expect(@actions.keys.size).to eq 13
+        expect(@actions.keys).to include 'index'
+        expect(@actions.keys).to include 'by_author'
+        expect(@actions.keys).to include 'by_panel'
+        expect(@actions.keys).to include 'play'
+        expect(@actions.keys).to include 'show'
+        expect(@actions.keys).to include 'count'
+        expect(@actions.keys).to include 'count_by_author'
+        expect(@actions.keys).to include 'count_by_panel'
+        expect(@actions.keys).to include 'new'
+        expect(@actions.keys).to include 'edit'
+        expect(@actions.keys).to include 'create'
+        expect(@actions.keys).to include 'update'
+        expect(@actions.keys).to include 'destroy'
+      end
+      describe 'index actionに於いて' do
+        before do
+          @action = @actions['index']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'list'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+          expect(@action.list_name).to eq 'public'
+        end
+      end
+      describe 'by_author actionに於いて' do
+        before do
+          @action = @actions['by_author']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'list'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+          expect(@action.list_name).to eq 'by_author'
+        end
+      end
+      describe 'count actionに於いて' do
+        before do
+          @action = @actions['count']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'count'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+          expect(@action.list_name).to eq 'public'
+        end
+      end
+      describe 'new actionに於いて' do
+        before do
+          @action = @actions['new']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'new'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+        end
+      end
+      describe 'edit actionに於いて' do
+        before do
+          @action = @actions['edit']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'edit'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+        end
+      end
+      describe 'create actionに於いて' do
+        before do
+          @action = @actions['create']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'create'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+        end
+      end
+      describe 'update actionに於いて' do
+        before do
+          @action = @actions['update']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'update'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+        end
+      end
+      describe 'destroy actionに於いて' do
+        before do
+          @action = @actions['destroy']
+        end
+        it 'type' do
+          expect(@action.type).to eq 'destroy'
+        end
+        it 'type' do
+          expect(@action.item_name).to eq 'scroll'
+        end
       end
     end
     
   end
   
   describe 'モデルに於いて' do
-    context 'オーソドックスなデータのとき' do
-      it 'スクコマを閉じるためのバインダーである' do
-        expect(@item.is_a?(Peta::Binder)).to be true
+    describe 'associationsに於いて' do
+      describe 'belongs_toに於いて' do
+        before do
+          @belongs_to = @model.my_manifest.associations.belongs_to
+        end
+        it ' である' do
+          expect(@belongs_to.keys).to include 'author'
+        end
+        describe 'authorに於いて' do
+          before do
+            @mani = @belongs_to['author']
+          end
+          it 'type' do
+            expect(@mani.model_name).to eq 'author'
+            expect(@mani.id_column).to eq 'author_id'
+          end
+          it 'type' do
+            expect(@mani.model).to eq Author
+          end
+        end
       end
-      it 'ブースト特筆すべき注意事項はない' do
-        expect(self.class.my_peta.boost.keys).to be true
+      describe 'has_manyに於いて' do
+        before do
+          @has_many = @model.my_manifest.associations.has_many
+        end
+        it ' である' do
+          expect(@has_many.keys).to include 'scroll_panels'
+          expect(@has_many.keys).to include 'panels'
+        end
+        describe 'scroll_panelsに於いて' do
+          before do
+            @mani = @has_many['scroll_panels']
+          end
+          it 'type' do
+            expect(@mani.model_name).to eq 'scroll_panel'
+            expect(@mani.foreign_key).to eq 'scroll_id'
+            expect(@mani.through).to be nil
+          end
+          it 'type' do
+            expect(@mani.through?).to be false
+            expect(@mani.model).to eq ScrollPanel
+          end
+        end
+        describe 'panelsに於いて' do
+          before do
+            @mani = @has_many['panels']
+          end
+          it 'type' do
+            expect(@mani.model_name).to eq 'panel'
+            expect(@mani.foreign_key).to eq 'scroll_id'
+            expect(@mani.through).to eq 'scroll_panels'
+          end
+          it 'type' do
+            expect(@mani.through?).to be true
+            expect(@mani.model).to eq Panel
+          end
+        end
+      end
+    end
+    
+    describe 'attributesに於いて' do
+      before do
+        @attributes = @model.my_manifest.attributes
+      end
+      it ' である' do
+        expect(@attributes.keys).to include 'id'
+        expect(@attributes.keys).to include 'title'
+        expect(@attributes.keys).to include 'description'
+        expect(@attributes.keys).to include 'visible'
+        expect(@attributes.keys).to include 'author_id'
+        expect(@attributes.keys).to include 'created_at'
+        expect(@attributes.keys).to include 'updated_at'
+      end
+      describe 'titleに於いて' do
+        before do
+          @attribute = @attributes['title']
+        end
+        it 'type' do
+          expect(@attribute.type).to eq 'text'
+        end
+      end
+      describe 'descriptionに於いて' do
+        before do
+          @attribute = @attributes['description']
+        end
+        it 'type' do
+          expect(@attribute.type).to eq 'text'
+        end
+      end
+      describe 'visibleに於いて' do
+        before do
+          @attribute = @attributes['visible']
+        end
+        it 'type' do
+          expect(@attribute.type).to eq 'number'
+        end
+        it 'source' do
+          expect(@attribute.source.type).to eq 'magic_number'
+          expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
+        end
+      end
+      describe 'author_idに於いて' do
+        before do
+          @attribute = @attributes['author_id']
+        end
+        it 'type' do
+          expect(@attribute.type).to eq 'number'
+        end
+      end
+    end
+    
+    describe 'shortcutに於いて' do
+      before do
+        @my_manifest = @model.my_manifest
+      end
+      it 'type' do
+        expect(@my_manifest.model_name).to eq 'scroll'
+        expect(@my_manifest.classify).to eq @model
+        expect(@my_manifest.table_name).to eq 'scrolls'
       end
     end