OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / manifests / sheet_spec.rb
index 1ef6d52..ec16c16 100644 (file)
@@ -9,8 +9,8 @@ describe Sheet do
   end
   
   describe 'ペタナイズに於いて' do
-    it 'ã\82¹ã\82¯ã\82³ã\83\9eã\82\92é\96\89ã\81\98ã\82\8bã\81\9fã\82\81ã\81®ã\83\90ã\82¤ã\83³ã\83\80ã\83¼である' do
-      expect(@model.ancestors.include?(Peta::Binder)).to eq true
+    it 'ã\83«ã\83¼ã\83\88である' do
+      expect(@model.ancestors.include?(Peta::Root)).to eq true
     end
     it '親モデルは持たない' do
       expect(@model.my_peta.parent_model_name).to be_blank
@@ -27,14 +27,14 @@ describe Sheet 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 'sheet'
     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', 
+        @actions_names = ['index', 'by_story', 'by_author', 'by_panel', 'play', 'show', 
+          'count', 'count_by_story', 'count_by_author', 'count_by_panel', 
           'new', 'edit', 'create', 'update', 'destroy']
       end
       it 'これらのアクションが定義されている' do
@@ -50,8 +50,20 @@ describe Sheet do
           expect(@action.type).to eq 'list'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールの公開リストを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
+          # 用紙の公開リストを返すように定義している
+          set_list_action? @action, 'sheet', 'public'
+        end
+      end
+      describe 'by_storyに於いて' do
+        before do
+          @action = @actions['by_story']
+        end
+        it 'listタイプのアクションである' do
+          expect(@action.type).to eq 'list'
+        end
+        it 'マニフェストから設定を取り出している' do
+          # 用紙のストーリーフィルタリストを返すように定義している
+          set_list_action? @action, 'sheet', 'by_story'
         end
       end
       describe 'by_authorに於いて' do
@@ -62,8 +74,8 @@ describe Sheet do
           expect(@action.type).to eq 'list'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールの作家フィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
+          # 用紙の作家フィルタリストを返すように定義している
+          set_list_action? @action, 'sheet', 'by_author'
         end
       end
       describe 'by_panelに於いて' do
@@ -74,8 +86,16 @@ describe Sheet do
           expect(@action.type).to eq 'list'
         end
         it 'マニフェストから設定を取り出している' do
-          #スクロールのコマフィルタリストを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
+          #用紙のコマフィルタリストを返すように定義している
+          set_list_action? @action, 'sheet', '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
@@ -86,8 +106,20 @@ describe Sheet do
           expect(@action.type).to eq 'count'
         end
         it 'マニフェストから設定を取り出している' do
-          #スクロールの公開リストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'public'
+          #用紙の公開リストのカウントを返すように定義している
+          set_list_action? @action, 'sheet', 'public'
+        end
+      end
+      describe 'count_by_storyに於いて' do
+        before do
+          @action = @actions['count_by_story']
+        end
+        it 'countタイプのアクションである' do
+          expect(@action.type).to eq 'count'
+        end
+        it 'マニフェストから設定を取り出している' do
+          # 用紙のストーリーフィルタリストのカウントを返すように定義している
+          set_list_action? @action, 'sheet', 'by_story'
         end
       end
       describe 'count_by_authorに於いて' do
@@ -98,8 +130,8 @@ describe Sheet do
           expect(@action.type).to eq 'count'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールの作家フィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_author'
+          # 用紙の作家フィルタリストのカウントを返すように定義している
+          set_list_action? @action, 'sheet', 'by_author'
         end
       end
       describe 'count_by_panelに於いて' do
@@ -110,8 +142,8 @@ describe Sheet do
           expect(@action.type).to eq 'count'
         end
         it 'マニフェストから設定を取り出している' do
-          # スクロールのコマフィルタリストのカウントを返すように定義している
-          set_list_action? @action, 'scroll', 'by_panel'
+          # 用紙のコマフィルタリストのカウントを返すように定義している
+          set_list_action? @action, 'sheet', 'by_panel'
         end
       end
       describe 'newに於いて' do
@@ -122,7 +154,7 @@ describe Sheet do
           expect(@action.type).to eq 'new'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'sheet'
         end
       end
       describe 'editに於いて' do
@@ -133,7 +165,7 @@ describe Sheet do
           expect(@action.type).to eq 'edit'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'sheet'
         end
       end
       describe 'createに於いて' do
@@ -144,7 +176,7 @@ describe Sheet do
           expect(@action.type).to eq 'create'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'sheet'
         end
       end
       describe 'updateに於いて' do
@@ -155,7 +187,7 @@ describe Sheet do
           expect(@action.type).to eq 'update'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'sheet'
         end
       end
       describe 'destroyに於いて' do
@@ -166,7 +198,7 @@ describe Sheet do
           expect(@action.type).to eq 'destroy'
         end
         it 'type' do
-          expect(@action.item_name).to eq 'scroll'
+          expect(@action.item_name).to eq 'sheet'
         end
       end
     end
@@ -178,9 +210,9 @@ describe Sheet do
       @my_manifest = @model.my_manifest
     end
     it 'サポート機能が動作している' do
-      expect(@my_manifest.model_name).to eq 'scroll'
+      expect(@my_manifest.model_name).to eq 'sheet'
       expect(@my_manifest.classify).to eq @model
-      expect(@my_manifest.table_name).to eq 'scrolls'
+      expect(@my_manifest.table_name).to eq 'sheets'
     end
     
     describe 'associationsに於いて' do
@@ -210,25 +242,57 @@ describe Sheet do
       describe 'has_manyに於いて' do
         before do
           @has_many = @model.my_manifest.associations.has_many
-          @names = ['scroll_panels', 'panels']
+          @names = ['story_sheets', 'panels', 'sheet_panels', 'panels']
         end
         it 'これらのモデルを所持している' do
           set_associations? @has_many, @names
         end
-        describe 'scroll_panelsに於いて' do
+        describe 'story_sheetsに於いて' do
           before do
-            @mani = @has_many['scroll_panels']
+            @mani = @has_many['story_sheets']
           end
           it 'マニフェストから設定を取り出している' do
             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
-            expect(@mani.model_name).to eq 'scroll_panel'
-            expect(@mani.foreign_key).to eq 'scroll_id'
+            expect(@mani.model_name).to eq 'story_sheet'
+            expect(@mani.foreign_key).to eq 'sheet_id'
             expect(@mani.through).to be nil
           end
           it 'サポート機能が動作している' do
             # モデルを再現できている, 中間モデルフラグ
             expect(@mani.through?).to be false
-            expect(@mani.model).to eq ScrollPanel
+            expect(@mani.model).to eq StorySheet
+          end
+        end
+        describe 'storiesに於いて' do
+          before do
+            @mani = @has_many['stories']
+          end
+          it 'マニフェストから設定を取り出している' do
+            # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
+            expect(@mani.model_name).to eq 'story'
+            expect(@mani.foreign_key).to eq 'sheet_id'
+            expect(@mani.through).to eq 'story_sheets'
+          end
+          it 'サポート機能が動作している' do
+            # モデルを再現できている, 中間モデルフラグ
+            expect(@mani.through?).to be true
+            expect(@mani.model).to eq Story
+          end
+        end
+        describe 'sheet_panelsに於いて' do
+          before do
+            @mani = @has_many['sheet_panels']
+          end
+          it 'マニフェストから設定を取り出している' do
+            # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
+            expect(@mani.model_name).to eq 'sheet_panel'
+            expect(@mani.foreign_key).to eq 'sheet_id'
+            expect(@mani.through).to be nil
+          end
+          it 'サポート機能が動作している' do
+            # モデルを再現できている, 中間モデルフラグ
+            expect(@mani.through?).to be false
+            expect(@mani.model).to eq SheetPanel
           end
         end
         describe 'panelsに於いて' do
@@ -238,8 +302,8 @@ describe Sheet do
           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.foreign_key).to eq 'sheet_id'
+            expect(@mani.through).to eq 'sheet_panels'
           end
           it 'サポート機能が動作している' do
             # モデルを再現できている, 中間モデルフラグ
@@ -256,23 +320,31 @@ describe Sheet do
       end
       it 'これらのカラムを定義している' do
         set_attributes? @attributes, 
-          ['id', 'title', 'description', 'visible', 'author_id', 
+          ['id', 'caption', 'width', 'height', 'visible', 'author_id', 
           'created_at', 'updated_at']
       end
-      describe 'titleに於いて' do
+      describe 'captionに於いて' do
         before do
-          @attribute = @attributes['title']
+          @attribute = @attributes['caption']
         end
         it 'textタイプである' do
           expect(@attribute.type).to eq 'text'
         end
       end
-      describe 'descriptionに於いて' do
+      describe 'widthに於いて' do
         before do
-          @attribute = @attributes['description']
+          @attribute = @attributes['width']
         end
-        it 'textタイプである' do
-          expect(@attribute.type).to eq 'text'
+        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 'visibleに於いて' do
@@ -284,7 +356,7 @@ describe Sheet do
         end
         it '選択肢を定数から取得できるように定義している' do
           expect(@attribute.source.type).to eq 'magic_number'
-          expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
+          expect(@attribute.source.select_item_name).to eq 'sheet_visible_items'
         end
       end
       describe 'author_idに於いて' do