OSDN Git Service

add mani test
[pettanr/pettanr.git] / spec / local_manifests / scroll_spec.rb
diff --git a/spec/local_manifests/scroll_spec.rb b/spec/local_manifests/scroll_spec.rb
new file mode 100644 (file)
index 0000000..cf0f231
--- /dev/null
@@ -0,0 +1,515 @@
+# -*- encoding: utf-8 -*-
+require 'spec_helper'
+#スクロールマニフェスト
+
+describe Scroll do
+  before do
+    @model = Scroll
+  end
+  
+  describe 'ファイラーに於いて' do
+    before do
+      @my_local_manifest = LocalManifest.manifest.filers[@model.item_name]
+    end
+    it ' 項はない' do
+      expect(@my_local_manifest.item_class).to eq @model
+      expect(@my_local_manifest.item_name).to eq @model.item_name
+      expect(@my_local_manifest.filer_name).to eq @model.item_name
+    end
+    describe 'symbolに於いて' do
+      before do
+        @symbol = @my_local_manifest.symbol
+      end
+      it 'type' do
+        expect(@symbol.type).to eq 'default'
+      end
+      it 'type' do
+        expect(@symbol.visible?).to be true
+      end
+      describe 'faceに於いて' do
+        before do
+          @face = @symbol.face
+        end
+        it 'type' do
+          expect(@face.type).to eq 'image'
+        end
+        it 'type' do
+          expect(@face.url).to eq '/images/scroll.gif'
+        end
+      end
+      describe 'linkに於いて' do
+        before do
+          @link = @symbol.link
+        end
+        it 'type' do
+          expect(@link.type).to eq 'action'
+        end
+        it 'type' do
+          expect(@link.action_name).to eq 'show'
+        end
+        it 'type' do
+          expect(@link.action_path).to eq '/scrolls/'
+        end
+      end
+    end
+    describe 'captionに於いて' do
+      before do
+        @caption = @my_local_manifest.caption
+      end
+      it 'type' do
+        expect(@caption.type).to eq 'default'
+      end
+      it 'type' do
+        expect(@caption.visible?).to be true
+      end
+      describe 'faceに於いて' do
+        before do
+          @face = @caption.face
+        end
+        it 'type' do
+          expect(@face.type).to eq 'column'
+        end
+        it 'type' do
+          expect(@face.column_name).to eq 'title'
+        end
+      end
+      describe 'linkに於いて' do
+        before do
+          @link = @caption.link
+        end
+        it 'type' do
+          expect(@link.type).to eq 'action'
+        end
+        it 'type' do
+          expect(@link.action_name).to eq 'play'
+        end
+        it 'type' do
+          expect(@link.action_path).to eq '/scrolls/play/'
+        end
+      end
+    end
+    describe 'summaryに於いて' do
+      before do
+        @summary = @my_local_manifest.summary
+      end
+      it 'type' do
+        expect(@summary.type).to eq 'template'
+      end
+      it 'type' do
+        expect(@summary.template_name).to eq 'summary'
+      end
+    end
+    describe 'iconに於いて' do
+      before do
+        @icon = @my_local_manifest.icon
+      end
+      it 'type' do
+        expect(@icon.type).to eq 'default'
+      end
+      it 'type' do
+        expect(@icon.visible?).to be true
+      end
+    end
+    describe 'dateに於いて' do
+      before do
+        @date = @my_local_manifest.date
+      end
+      it 'type' do
+        expect(@date.type).to eq 'default'
+      end
+      it 'type' do
+        expect(@date.visible?).to be true
+      end
+    end
+    describe 'editに於いて' do
+      before do
+        @edit = @my_local_manifest.edit
+      end
+      it 'type' do
+        expect(@edit.type).to eq 'default'
+      end
+      it 'type' do
+        expect(@edit.visible?).to be true
+      end
+    end
+  end
+  
+  describe 'プロファイラーに於いて' do
+    before do
+      @my_local_manifest = LocalManifest.manifest.profilers[@model.item_name]
+    end
+    it ' 項はない' do
+      expect(@my_local_manifest.item_name).to eq @model.item_name
+    end
+    describe 'columnsに於いて' do
+      before do
+        @columns = @my_local_manifest.columns
+      end
+      it 'type' do
+        expect(@columns.size).to eq 4 + 3
+        expect(@columns.keys).to include 'title'
+        expect(@columns.keys).to include 'description'
+        expect(@columns.keys).to include 'visible'
+        expect(@columns.keys).to include 'author_id'
+      end
+      describe 'titleに於いて' do
+        before do
+          @column = @columns['title']
+        end
+        it 'type' do
+          expect(@column.type).to eq 'default'
+        end
+        it 'type' do
+          expect(@column.item_name).to eq 'scroll'
+        end
+      end
+      describe 'descriptionに於いて' do
+        before do
+          @column = @columns['description']
+        end
+        it 'type' do
+          expect(@column.type).to eq 'default'
+        end
+        it 'type' do
+          expect(@column.item_name).to eq 'scroll'
+        end
+      end
+      describe 'visibleに於いて' do
+        before do
+          @column = @columns['visible']
+        end
+        it 'type' do
+          expect(@column.type).to eq 'source'
+        end
+        it 'type' do
+          expect(@column.item_name).to eq 'scroll'
+        end
+      end
+      describe 'author_idに於いて' do
+        before do
+          @column = @columns['author_id']
+        end
+        it 'type' do
+          expect(@column.type).to eq 'default'
+        end
+        it 'type' do
+          expect(@column.item_name).to eq 'scroll'
+        end
+      end
+    end
+    describe 'column_namesに於いて' do
+      before do
+        @column_names = @my_local_manifest.column_names
+      end
+      it 'type' do
+        expect(@column_names.size).to eq 4 + 3
+      end
+      it 'type' do
+        expect(@column_names).to eq ['id', 'title', 'description', 'visible', 'author_id', 'created_at', 'updated_at']
+      end
+    end
+    describe 'extend_settingsに於いて' do
+      before do
+        @extend_settings = @my_local_manifest.extend_settings
+      end
+      it 'type' do
+        expect(@extend_settings).to be_empty
+      end
+    end
+    describe 'listsに於いて' do
+      before do
+        @lists = @my_local_manifest.lists
+      end
+      it 'type' do
+        expect(@lists).to be_empty
+      end
+    end
+    describe 'associationsに於いて' do
+      before do
+        @associations = @my_local_manifest.associations
+      end
+      describe 'belongs_toに於いて' do
+        before do
+          @belongs_to = @associations.belongs_to
+        end
+        describe 'authorに於いて' do
+          before do
+            @mani = @belongs_to[0]
+          end
+          it 'type' do
+            expect(@mani.name).to eq 'author'
+            expect(@mani.model_name).to eq 'author'
+          end
+          it 'type' do
+            expect(@mani.model).to eq Author
+          end
+        end
+      end
+      describe 'has_manyに於いて' do
+        before do
+          @has_many = @associations.has_many
+        end
+        describe 'scroll_panelsに於いて' do
+          before do
+            @mani = @has_many[0]
+          end
+          it 'type' do
+            expect(@mani.name).to eq 'scroll_panels.by_scroll'
+            expect(@mani.model_name).to eq 'scroll_panel'
+            expect(@mani.list_name).to eq 'by_scroll'
+          end
+          it 'type' do
+            expect(@mani.model).to eq ScrollPanel
+          end
+        end
+        describe 'panels.by_scrollに於いて' do
+          before do
+            @mani = @has_many[1]
+          end
+          it 'type' do
+            expect(@mani.name).to eq 'panels.by_scroll'
+            expect(@mani.model_name).to eq 'panel'
+            expect(@mani.list_name).to eq 'by_scroll'
+          end
+          it 'type' do
+            expect(@mani.model).to eq Panel
+          end
+        end
+      end
+    end
+  end
+  
+  describe 'リストグループに於いて' do
+    before do
+      @my_local_manifest = LocalManifest.manifest.list_groups[@model.item_name]
+    end
+    it ' 項はない' do
+      expect(@my_local_manifest.item_name).to eq @model.item_name
+    end
+    describe 'listsに於いて' do
+      before do
+        @lists = @my_local_manifest.lists
+      end
+      it 'type' do
+        expect(@lists.size).to eq 4
+        expect(@lists.keys).to include 'public'
+        expect(@lists.keys).to include 'private'
+        expect(@lists.keys).to include 'by_author'
+        expect(@lists.keys).to include 'by_panel'
+      end
+      describe 'publicに於いて' do
+        before do
+          @mani = @lists['public']
+        end
+        it 'type' do
+          expect(@mani.type).to eq 'public'
+          expect(@mani.model).to eq Scroll
+        end
+        it 'base' do
+          expect(@mani.has_id?).to eq true
+          expect(@mani.pre_id?).to eq false
+          expect(@mani.item_name).to eq @model.item_name
+        end
+        describe 'whereに於いて' do
+          before do
+            @where = @mani.where
+          end
+          it 'type' do
+            expect(@where.type).to eq 'auto'
+            expect(@where.item_name).to eq @model.item_name
+            expect(@where.list_name).to eq 'public'
+            expect(@where.model).to eq Scroll
+          end
+          it 'type' do
+            expect(@where.method_name).to eq 'public_list_where'
+          end
+        end
+        describe 'includesに於いて' do
+          before do
+            @includes = @mani.includes
+          end
+          it 'type' do
+            expect(@includes.type).to eq 'auto'
+            expect(@includes.item_name).to eq @model.item_name
+            expect(@includes.list_name).to eq 'public'
+            expect(@includes.model).to eq Scroll
+          end
+          it 'type' do
+            expect(@includes.includes).to eq {}
+          end
+        end
+        describe 'orderに於いて' do
+          before do
+            @order = @mani.order
+          end
+          it 'type' do
+            expect(@order.type).to eq 'auto'
+            expect(@order.item_name).to eq @model.item_name
+            expect(@order.list_name).to eq 'public'
+            expect(@order.model).to eq Scroll
+          end
+          it 'type' do
+            expect(@order.order).to eq 'list_order'
+          end
+        end
+      end
+    end
+  end
+  
+  describe '入力フォームに於いて' do
+    before do
+      @my_local_manifest = LocalManifest.manifest.forms[@model.item_name]
+    end
+    it ' 項はない' do
+      expect(@my_local_manifest.name).to eq @model.item_name
+    end
+    describe 'fieldsに於いて' do
+      before do
+        @fields = @my_local_manifest.fields
+      end
+      it 'type' do
+        expect(@fields.size).to eq 5
+        expect(@fields.keys).to include 'title'
+        expect(@fields.keys).to include 'description'
+        expect(@fields.keys).to include 'visible'
+        expect(@fields.keys).to include 'id'
+        expect(@fields.keys).to include 'author_id'
+      end
+    end
+    describe 'field_namesに於いて' do
+      before do
+        @field_names = @my_local_manifest.field_names
+      end
+      it 'type' do
+        expect(@field_names.size).to eq 5
+      end
+    end
+    describe 'ordered_fieldsに於いて' do
+      before do
+        @ordered_fields = @my_local_manifest.ordered_fields
+      end
+      it 'type' do
+        expect(@ordered_fields.size).to eq 5
+      end
+      describe 'titleに於いて' do
+        before do
+          @field = @ordered_fields[0]
+        end
+        it 'type' do
+          expect(@field.name).to eq 'title'
+          expect(@field.row_break).to be true
+        end
+        it 'type' do
+          expect(@field.part?).to be false
+          expect(@field.form_name).to eq @model.item_name
+          expect(@field.column_name).to eq 'title'
+          expect(@field.model_name).to eq @model.item_name
+        end
+        describe 'labelに於いて' do
+          before do
+            @label = @field.label
+          end
+          it 'type' do
+            expect(@label.type).to eq 'default'
+            expect(@label.row_break).to be true
+          end
+          it 'type' do
+            expect(@label.form_name).to eq @model.item_name
+            expect(@label.field_name).to eq 'title'
+            expect(@label.model_name).to eq @model.item_name
+            expect(@label.column_name).to eq 'title'
+          end
+        end
+        describe 'tagに於いて' do
+          before do
+            @tag = @field.tag
+          end
+          it 'type' do
+            expect(@tag.type).to eq 'text'
+            expect(@tag.options).to_not be_empty
+            expect(@tag.options['size']).to eq 20
+          end
+          it 'type' do
+            expect(@tag.form_name).to eq @model.item_name
+            expect(@tag.field_name).to eq 'title'
+          end
+        end
+      end
+      describe 'descriptionに於いて' do
+        before do
+          @field = @ordered_fields[1]
+        end
+        it 'type' do
+          expect(@field.name).to eq 'description'
+          expect(@field.row_break).to be true
+        end
+        it 'type' do
+          expect(@field.part?).to be false
+          expect(@field.form_name).to eq @model.item_name
+          expect(@field.column_name).to eq 'description'
+          expect(@field.model_name).to eq @model.item_name
+        end
+      end
+      describe 'visibleに於いて' do
+        before do
+          @field = @ordered_fields[2]
+        end
+        it 'type' do
+          expect(@field.name).to eq 'visible'
+          expect(@field.row_break).to be true
+        end
+        it 'type' do
+          expect(@field.part?).to be false
+          expect(@field.form_name).to eq @model.item_name
+          expect(@field.column_name).to eq 'visible'
+          expect(@field.model_name).to eq @model.item_name
+        end
+      end
+      describe 'idに於いて' do
+        before do
+          @field = @ordered_fields[3]
+        end
+        it 'type' do
+          expect(@field.name).to eq 'id'
+          expect(@field.row_break).to be true
+        end
+        it 'type' do
+          expect(@field.part?).to be false
+          expect(@field.form_name).to eq @model.item_name
+          expect(@field.column_name).to eq 'id'
+          expect(@field.model_name).to eq @model.item_name
+        end
+      end
+      describe 'author_idに於いて' do
+        before do
+          @field = @ordered_fields[4]
+        end
+        it 'type' do
+          expect(@field.name).to eq 'author_id'
+          expect(@field.row_break).to be true
+        end
+        it 'type' do
+          expect(@field.part?).to be false
+          expect(@field.form_name).to eq @model.item_name
+          expect(@field.column_name).to eq 'author_id'
+          expect(@field.model_name).to eq @model.item_name
+        end
+      end
+    end
+  end
+  
+  describe 'bucketに於いて' do
+    before do
+      @my_local_manifest = LocalManifest.manifest.buckets[@model.item_name]
+    end
+    it ' 項はない' do
+      expect(@my_local_manifest.members).to be_empty
+      expect(@my_local_manifest.form_field_names).to be_empty
+    end
+    it ' 項はない' do
+      expect(@my_local_manifest.has_member?).to be false
+      expect(@my_local_manifest.item_name).to eq @model.item_name
+    end
+  end
+  
+end