From 4394520aeecbf380391b0779ee7f96ecb4730cd6 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Tue, 22 Jul 2014 11:13:12 +0900 Subject: [PATCH] fix spec --- app/views/top/ap.html.erb | 2 +- config/environment.rb | 1 - lib/ar_helper.rb | 77 -- lib/local_manifest/form/field/tag/base.rb | 2 +- lib/local_manifest/list_group/list/base.rb | 3 + .../list_group/list/includes/base.rb | 2 +- lib/local_manifest/list_group/list/order/base.rb | 2 +- lib/local_manifest/list_group/list/where/base.rb | 2 +- .../profiler/association/belongs_to.rb | 2 +- .../profiler/association/has_many.rb | 4 +- lib/local_manifest/profiler/association/has_one.rb | 2 +- lib/peta/item.rb | 8 + spec/local_manifests/scroll_spec.rb | 198 ++--- spec/manifests/scroll_spec.rb | 188 +++-- spec/models/scroll_spec.rb | 802 +++------------------ spec/peta/binder_spec.rb | 56 +- spec/peta/content_spec.rb | 80 ++ spec/peta/element_spec.rb | 110 +++ spec/peta/item_spec.rb | 127 ++++ spec/peta/leaf_spec.rb | 67 ++ spec/peta/owner_spec.rb | 80 ++ spec/peta/root_spec.rb | 80 ++ spec/peta/system_resource_spec.rb | 80 ++ spec/peta/template_spec.rb | 119 +++ spec/support/binder_macros.rb | 127 ---- spec/support/local_manifests_macros.rb | 32 + spec/support/manifests_macros.rb | 32 + spec/support/peta_macros.rb | 240 ++++++ 28 files changed, 1413 insertions(+), 1112 deletions(-) delete mode 100644 lib/ar_helper.rb create mode 100644 spec/peta/content_spec.rb create mode 100644 spec/peta/element_spec.rb create mode 100644 spec/peta/item_spec.rb create mode 100644 spec/peta/leaf_spec.rb create mode 100644 spec/peta/owner_spec.rb create mode 100644 spec/peta/root_spec.rb create mode 100644 spec/peta/system_resource_spec.rb create mode 100644 spec/peta/template_spec.rb delete mode 100644 spec/support/binder_macros.rb create mode 100644 spec/support/local_manifests_macros.rb create mode 100644 spec/support/manifests_macros.rb create mode 100644 spec/support/peta_macros.rb diff --git a/app/views/top/ap.html.erb b/app/views/top/ap.html.erb index 405081d8..d1a4cf8d 100644 --- a/app/views/top/ap.html.erb +++ b/app/views/top/ap.html.erb @@ -50,7 +50,7 @@ <&= file_item.edit.render_column().el.innerHTML &> diff --git a/config/environment.rb b/config/environment.rb index 0fb7a64b..4c91c760 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -6,7 +6,6 @@ require 'rest_client' require 'picture_io' require 'pettan_imager' -require 'ar_helper' require 'operator' require 'import_result' require 'common' diff --git a/lib/ar_helper.rb b/lib/ar_helper.rb deleted file mode 100644 index 8a8be927..00000000 --- a/lib/ar_helper.rb +++ /dev/null @@ -1,77 +0,0 @@ - -module ActiveRecord - class Base - module ActiveRecordHelper - def self.included(base) - base.extend(ClassMethods) - base.__send__ :include, InstanceMethods - end - - module ClassMethods - def get_author_from_roles roles - roles.each do |role| - return role if role.is_a?(Author) - return role.author if role.is_a?(User) - return role.author if role.is_a?(Artist) and role.author - end - nil - end - - def get_artist_from_roles roles - roles.each do |role| - return role.artist if role.is_a?(Author) and role.artist - return role.author.artist if role.is_a?(User) and role.author and role.author.artist - return role if role.is_a?(Artist) - end - nil - end - - def get_admin_from_roles roles - roles.each do |role| - return role if role.is_a?(Admin) - end - nil - end - - end - - module InstanceMethods - private - - public - - def guest_role_check roles - true - end - - def reader_role_check roles - roles = [roles] unless roles.respond_to?(:each) - roles.each do |role| - return true if role.is_a?(Author) or role.is_a?(Artist) or role.is_a?(Admin) or role.is_a?(User) - end - false - end - - def resource_reader_role_check roles - roles = [roles] unless roles.respond_to?(:each) - roles.each do |role| - return true if role.is_a?(Author) or role.is_a?(Artist) or role.is_a?(Admin) or role.is_a?(User) or role.is_a?(DemandUser) - end - false - end - - def admin_role_check roles - roles = [roles] unless roles.respond_to?(:each) - roles.each do |role| - return true if role.is_a?(Admin) - end - false - end - - end - - end - include ActiveRecordHelper - end -end - diff --git a/lib/local_manifest/form/field/tag/base.rb b/lib/local_manifest/form/field/tag/base.rb index 4b05a69a..d0cdcc7b 100644 --- a/lib/local_manifest/form/field/tag/base.rb +++ b/lib/local_manifest/form/field/tag/base.rb @@ -20,7 +20,7 @@ module LocalManifest end def field_name - @parent.field_name + @parent.name end end diff --git a/lib/local_manifest/list_group/list/base.rb b/lib/local_manifest/list_group/list/base.rb index 71921023..4fc88f71 100644 --- a/lib/local_manifest/list_group/list/base.rb +++ b/lib/local_manifest/list_group/list/base.rb @@ -30,6 +30,9 @@ module LocalManifest @type =~ /filter/ end + # url format + # true: /path/id/action + # nil: /path/action/id def pre_id? if @name =~ /^by_/ false diff --git a/lib/local_manifest/list_group/list/includes/base.rb b/lib/local_manifest/list_group/list/includes/base.rb index 65242c92..157e1c9a 100644 --- a/lib/local_manifest/list_group/list/includes/base.rb +++ b/lib/local_manifest/list_group/list/includes/base.rb @@ -17,7 +17,7 @@ module LocalManifest end def list_name - @parent.list_name + @parent.name end def model diff --git a/lib/local_manifest/list_group/list/order/base.rb b/lib/local_manifest/list_group/list/order/base.rb index 21455943..fa1a60a5 100644 --- a/lib/local_manifest/list_group/list/order/base.rb +++ b/lib/local_manifest/list_group/list/order/base.rb @@ -17,7 +17,7 @@ module LocalManifest end def list_name - @parent.list_name + @parent.name end def model diff --git a/lib/local_manifest/list_group/list/where/base.rb b/lib/local_manifest/list_group/list/where/base.rb index b09f4f45..b84cae24 100644 --- a/lib/local_manifest/list_group/list/where/base.rb +++ b/lib/local_manifest/list_group/list/where/base.rb @@ -17,7 +17,7 @@ module LocalManifest end def list_name - @parent.list_name + @parent.name end def model diff --git a/lib/local_manifest/profiler/association/belongs_to.rb b/lib/local_manifest/profiler/association/belongs_to.rb index b150350d..0e520ddb 100644 --- a/lib/local_manifest/profiler/association/belongs_to.rb +++ b/lib/local_manifest/profiler/association/belongs_to.rb @@ -18,7 +18,7 @@ module LocalManifest end def association_name - @parent.name + @parent.profiler_name end end diff --git a/lib/local_manifest/profiler/association/has_many.rb b/lib/local_manifest/profiler/association/has_many.rb index 2d5cf6e9..2a239893 100644 --- a/lib/local_manifest/profiler/association/has_many.rb +++ b/lib/local_manifest/profiler/association/has_many.rb @@ -2,7 +2,7 @@ module LocalManifest module ProfilerModule module AssociationModule class HasMany < ManifestBase::Names - attr :model_name, :list_name + attr :model_name, :list_name, :table_name def set_default super @@ -34,7 +34,7 @@ module LocalManifest end def association_name - @parent.association_name + @parent.profiler_name end def profiler diff --git a/lib/local_manifest/profiler/association/has_one.rb b/lib/local_manifest/profiler/association/has_one.rb index 86ae8252..f0bdf824 100644 --- a/lib/local_manifest/profiler/association/has_one.rb +++ b/lib/local_manifest/profiler/association/has_one.rb @@ -33,7 +33,7 @@ module LocalManifest end def association_name - @parent.association_name + @parent.profiler_name end def profiler diff --git a/lib/peta/item.rb b/lib/peta/item.rb index 1f2c8f8d..db22a100 100644 --- a/lib/peta/item.rb +++ b/lib/peta/item.rb @@ -152,6 +152,14 @@ module Peta #InstanceMethods + def singular + self.class.singular + end + + def plural + self.class.plural + end + def item_name self.class.item_name end diff --git a/spec/local_manifests/scroll_spec.rb b/spec/local_manifests/scroll_spec.rb index cf0f231e..6a431fab 100644 --- a/spec/local_manifests/scroll_spec.rb +++ b/spec/local_manifests/scroll_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' #スクロールマニフェスト describe Scroll do + include LocalManifestsMacros before do @model = Scroll end @@ -11,7 +12,7 @@ describe Scroll do before do @my_local_manifest = LocalManifest.manifest.filers[@model.item_name] end - it ' 項はない' do + 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 @@ -20,20 +21,20 @@ describe Scroll do before do @symbol = @my_local_manifest.symbol end - it 'type' do + it 'defaultタイプのsymbolである' do expect(@symbol.type).to eq 'default' end - it 'type' do + it 'サポート機能が動作している' do expect(@symbol.visible?).to be true end describe 'faceに於いて' do before do @face = @symbol.face end - it 'type' do + it 'imageタイプのfaceである' do expect(@face.type).to eq 'image' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@face.url).to eq '/images/scroll.gif' end end @@ -41,13 +42,13 @@ describe Scroll do before do @link = @symbol.link end - it 'type' do + it 'actionタイプのlinkである' do expect(@link.type).to eq 'action' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@link.action_name).to eq 'show' end - it 'type' do + it 'サポート機能が動作している' do expect(@link.action_path).to eq '/scrolls/' end end @@ -56,20 +57,20 @@ describe Scroll do before do @caption = @my_local_manifest.caption end - it 'type' do + it 'defaultタイプのsymbolである' do expect(@caption.type).to eq 'default' end - it 'type' do + it 'サポート機能が動作している' do expect(@caption.visible?).to be true end describe 'faceに於いて' do before do @face = @caption.face end - it 'type' do + it 'columnタイプのfaceである' do expect(@face.type).to eq 'column' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@face.column_name).to eq 'title' end end @@ -77,13 +78,13 @@ describe Scroll do before do @link = @caption.link end - it 'type' do + it 'actionタイプのlinkである' do expect(@link.type).to eq 'action' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@link.action_name).to eq 'play' end - it 'type' do + it 'サポート機能が動作している' do expect(@link.action_path).to eq '/scrolls/play/' end end @@ -92,10 +93,10 @@ describe Scroll do before do @summary = @my_local_manifest.summary end - it 'type' do + it 'templateタイプのsymbolである' do expect(@summary.type).to eq 'template' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@summary.template_name).to eq 'summary' end end @@ -103,10 +104,10 @@ describe Scroll do before do @icon = @my_local_manifest.icon end - it 'type' do + it 'defaultタイプのsymbolである' do expect(@icon.type).to eq 'default' end - it 'type' do + it 'サポート機能が動作している' do expect(@icon.visible?).to be true end end @@ -114,10 +115,10 @@ describe Scroll do before do @date = @my_local_manifest.date end - it 'type' do + it 'defaultタイプのsymbolである' do expect(@date.type).to eq 'default' end - it 'type' do + it 'サポート機能が動作している' do expect(@date.visible?).to be true end end @@ -125,10 +126,10 @@ describe Scroll do before do @edit = @my_local_manifest.edit end - it 'type' do + it 'defaultタイプのsymbolである' do expect(@edit.type).to eq 'default' end - it 'type' do + it 'サポート機能が動作している' do expect(@edit.visible?).to be true end end @@ -138,28 +139,25 @@ describe Scroll do before do @my_local_manifest = LocalManifest.manifest.profilers[@model.item_name] end - it ' 項はない' do + it 'マニフェストから設定を取り出している' do expect(@my_local_manifest.item_name).to eq @model.item_name end describe 'columnsに於いて' do before do @columns = @my_local_manifest.columns + @names = ['id', 'title', 'description', 'visible', 'author_id', 'created_at', 'updated_at'] 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' + it 'これらのカラムが定義されている' do + set_columns? @columns, @names end describe 'titleに於いて' do before do @column = @columns['title'] end - it 'type' do + it 'defaultタイプのcolumnである' do expect(@column.type).to eq 'default' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@column.item_name).to eq 'scroll' end end @@ -167,10 +165,10 @@ describe Scroll do before do @column = @columns['description'] end - it 'type' do + it 'defaultタイプのcolumnである' do expect(@column.type).to eq 'default' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@column.item_name).to eq 'scroll' end end @@ -178,10 +176,10 @@ describe Scroll do before do @column = @columns['visible'] end - it 'type' do + it 'sourceタイプのcolumnである' do expect(@column.type).to eq 'source' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@column.item_name).to eq 'scroll' end end @@ -189,10 +187,10 @@ describe Scroll do before do @column = @columns['author_id'] end - it 'type' do + it 'defaultタイプのcolumnである' do expect(@column.type).to eq 'default' end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@column.item_name).to eq 'scroll' end end @@ -201,10 +199,10 @@ describe Scroll do before do @column_names = @my_local_manifest.column_names end - it 'type' do + it '数量が守られている' do expect(@column_names.size).to eq 4 + 3 end - it 'type' do + it '順序が守られている' do expect(@column_names).to eq ['id', 'title', 'description', 'visible', 'author_id', 'created_at', 'updated_at'] end end @@ -212,7 +210,7 @@ describe Scroll do before do @extend_settings = @my_local_manifest.extend_settings end - it 'type' do + it '拡張カラムは無い' do expect(@extend_settings).to be_empty end end @@ -220,7 +218,7 @@ describe Scroll do before do @lists = @my_local_manifest.lists end - it 'type' do + it '無い' do expect(@lists).to be_empty end end @@ -232,15 +230,18 @@ describe Scroll do before do @belongs_to = @associations.belongs_to end + it 'これらの所属モデルを取り扱う' do + expect(@belongs_to.map {|a| a.name}).to eq ['author'] + end describe 'authorに於いて' do before do @mani = @belongs_to[0] end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@mani.name).to eq 'author' expect(@mani.model_name).to eq 'author' end - it 'type' do + it 'サポート機能が動作している' do expect(@mani.model).to eq Author end end @@ -249,16 +250,19 @@ describe Scroll do before do @has_many = @associations.has_many end + it 'これらの所持モデルを取り扱う' do + expect(@has_many.map {|a| a.table_name}).to eq ['scroll_panels', 'panels'] + end describe 'scroll_panelsに於いて' do before do @mani = @has_many[0] end - it 'type' do + it 'マニフェストから設定を取り出している' 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 + it 'サポート機能が動作している' do expect(@mani.model).to eq ScrollPanel end end @@ -266,12 +270,12 @@ describe Scroll do before do @mani = @has_many[1] end - it 'type' do + it 'マニフェストから設定を取り出している' 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 + it 'サポート機能が動作している' do expect(@mani.model).to eq Panel end end @@ -283,44 +287,44 @@ describe Scroll do before do @my_local_manifest = LocalManifest.manifest.list_groups[@model.item_name] end - it ' 項はない' do + 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' + it 'これらのリストを定義している' do + set_lists? @lists, ['public', 'private', 'by_author', 'by_panel'] end describe 'publicに於いて' do before do @mani = @lists['public'] end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@mani.type).to eq 'public' + end + it 'マニフェストから設定を取り出している' do expect(@mani.model).to eq Scroll end - it 'base' do - expect(@mani.has_id?).to eq true - expect(@mani.pre_id?).to eq false + it 'サポート機能が動作している' do + expect(@mani.has_id?).to be nil + expect(@mani.pre_id?).to be true expect(@mani.item_name).to eq @model.item_name end describe 'whereに於いて' do before do @where = @mani.where end - it 'type' do + it 'autoタイプである' do expect(@where.type).to eq 'auto' + end + it 'サポート機能が動作している' do 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 + it 'method_name' do expect(@where.method_name).to eq 'public_list_where' end end @@ -328,27 +332,31 @@ describe Scroll do before do @includes = @mani.includes end - it 'type' do + it 'autoタイプである' do expect(@includes.type).to eq 'auto' + end + it 'サポート機能が動作している' do 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 {} + it 'includes' do + expect(@includes.includes).to be_empty end end describe 'orderに於いて' do before do @order = @mani.order end - it 'type' do + it 'autoタイプである' do expect(@order.type).to eq 'auto' + end + it 'サポート機能が動作している' do 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 + it 'order' do expect(@order.order).to eq 'list_order' end end @@ -360,46 +368,48 @@ describe Scroll do before do @my_local_manifest = LocalManifest.manifest.forms[@model.item_name] end - it ' 項はない' do + 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 + # 細かいチェックは後でやるので、大雑把に数量だけチェックしておく。 + it '数量が守られている' 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 + it '数量が守られている' do expect(@field_names.size).to eq 5 end + it '順序が守られている' do + expect(@field_names).to eq ['title', 'description', 'visible', 'id', 'author_id'] + end end + # 処理順に並べられたフィールドのこと + # 本来fieldsでテストするべき内容だが、並び替えもテストしたいのでこちらで行う。 describe 'ordered_fieldsに於いて' do before do @ordered_fields = @my_local_manifest.ordered_fields + @names = ['title', 'description', 'visible', 'id', 'author_id'] end - it 'type' do - expect(@ordered_fields.size).to eq 5 + it 'これらのフィールドを取り扱う' do + expect(@ordered_fields.map {|f| f.name }).to eq @names end describe 'titleに於いて' do before do @field = @ordered_fields[0] end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@field.name).to eq 'title' expect(@field.row_break).to be true end - it 'type' do + it 'サポート機能が動作している' do expect(@field.part?).to be false expect(@field.form_name).to eq @model.item_name expect(@field.column_name).to eq 'title' @@ -409,11 +419,13 @@ describe Scroll do before do @label = @field.label end - it 'type' do + it 'defaultタイプである' do expect(@label.type).to eq 'default' + end + it 'マニフェストから設定を取り出している' do expect(@label.row_break).to be true end - it 'type' do + it 'サポート機能が動作している' 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 @@ -424,12 +436,14 @@ describe Scroll do before do @tag = @field.tag end - it 'type' do + it 'textタイプである' do expect(@tag.type).to eq 'text' + end + it 'マニフェストから設定を取り出している' do expect(@tag.options).to_not be_empty expect(@tag.options['size']).to eq 20 end - it 'type' do + it 'サポート機能が動作している' do expect(@tag.form_name).to eq @model.item_name expect(@tag.field_name).to eq 'title' end @@ -439,11 +453,11 @@ describe Scroll do before do @field = @ordered_fields[1] end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@field.name).to eq 'description' expect(@field.row_break).to be true end - it 'type' do + it 'サポート機能が動作している' do expect(@field.part?).to be false expect(@field.form_name).to eq @model.item_name expect(@field.column_name).to eq 'description' @@ -454,11 +468,11 @@ describe Scroll do before do @field = @ordered_fields[2] end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@field.name).to eq 'visible' expect(@field.row_break).to be true end - it 'type' do + it 'サポート機能が動作している' do expect(@field.part?).to be false expect(@field.form_name).to eq @model.item_name expect(@field.column_name).to eq 'visible' @@ -469,11 +483,11 @@ describe Scroll do before do @field = @ordered_fields[3] end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@field.name).to eq 'id' expect(@field.row_break).to be true end - it 'type' do + it 'サポート機能が動作している' do expect(@field.part?).to be false expect(@field.form_name).to eq @model.item_name expect(@field.column_name).to eq 'id' @@ -484,11 +498,11 @@ describe Scroll do before do @field = @ordered_fields[4] end - it 'type' do + it 'マニフェストから設定を取り出している' do expect(@field.name).to eq 'author_id' expect(@field.row_break).to be true end - it 'type' do + it 'サポート機能が動作している' do expect(@field.part?).to be false expect(@field.form_name).to eq @model.item_name expect(@field.column_name).to eq 'author_id' @@ -502,11 +516,11 @@ describe Scroll do before do @my_local_manifest = LocalManifest.manifest.buckets[@model.item_name] end - it ' 項はない' do + it 'マニフェストから設定を取り出している' do expect(@my_local_manifest.members).to be_empty expect(@my_local_manifest.form_field_names).to be_empty end - it ' 項はない' do + it 'サポート機能が動作している' do expect(@my_local_manifest.has_member?).to be false expect(@my_local_manifest.item_name).to eq @model.item_name end diff --git a/spec/manifests/scroll_spec.rb b/spec/manifests/scroll_spec.rb index af004e08..b9a8b9ee 100644 --- a/spec/manifests/scroll_spec.rb +++ b/spec/manifests/scroll_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' #スクロールマニフェスト describe Scroll do + include ManifestsMacros before do @model = Scroll end @@ -11,11 +12,11 @@ describe Scroll do it 'スクコマを閉じるためのバインダーである' do expect(@model.ancestors.include?(Peta::Binder)).to eq true end - it ' 項はない' do + it '親モデルは持たない' do expect(@model.my_peta.parent_model_name).to be_blank end describe 'ブーストに於いて' do - it 'ブースト特筆すべき注意事項はない' do + it '特筆すべき注意事項はない' do expect(@model.my_peta.boost.keys).to be_empty end end @@ -26,114 +27,142 @@ describe Scroll do before do @controller = @model.my_controller end - it 'ーである' do + it 'スクロールのためのコントローラである' do expect(@model.item_name).to eq 'scroll' 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', + 'new', 'edit', 'create', 'update', 'destroy'] end - 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' + it 'これらのアクションが定義されている' do + set_actions? @actions, @actions_names end - describe 'index actionに於いて' do + describe 'baseに於いて' do + end + describe 'indexに於いて' do before do @action = @actions['index'] end - it 'type' do + it 'listタイプのアクションである' 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' + it 'マニフェストから設定を取り出している' do + # スクロールの公開リストを返すように定義している + set_list_action? @action, 'scroll', 'public' end end - describe 'by_author actionに於いて' do + describe 'by_authorに於いて' do before do @action = @actions['by_author'] end - it 'type' do + it 'listタイプのアクションである' 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' + it 'マニフェストから設定を取り出している' do + # スクロールの作家フィルタリストを返すように定義している + set_list_action? @action, 'scroll', 'by_author' end end - describe 'count actionに於いて' do + 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, 'scroll', 'by_panel' + end + end + describe 'countに於いて' do before do @action = @actions['count'] end - it 'type' do + it 'countタイプのアクションである' 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' + it 'マニフェストから設定を取り出している' do + #スクロールの公開リストのカウントを返すように定義している + set_list_action? @action, 'scroll', '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, 'scroll', '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, 'scroll', 'by_panel' end end - describe 'new actionに於いて' do + describe 'newに於いて' do before do @action = @actions['new'] end - it 'type' do + it 'newタイプのアクションである' do expect(@action.type).to eq 'new' end it 'type' do expect(@action.item_name).to eq 'scroll' end end - describe 'edit actionに於いて' do + describe 'editに於いて' do before do @action = @actions['edit'] end - it 'type' do + it 'editタイプのアクションである' do expect(@action.type).to eq 'edit' end it 'type' do expect(@action.item_name).to eq 'scroll' end end - describe 'create actionに於いて' do + describe 'createに於いて' do before do @action = @actions['create'] end - it 'type' do + it 'createタイプのアクションである' do expect(@action.type).to eq 'create' end it 'type' do expect(@action.item_name).to eq 'scroll' end end - describe 'update actionに於いて' do + describe 'updateに於いて' do before do @action = @actions['update'] end - it 'type' do + it 'updateタイプのアクションである' do expect(@action.type).to eq 'update' end it 'type' do expect(@action.item_name).to eq 'scroll' end end - describe 'destroy actionに於いて' do + describe 'destroyに於いて' do before do @action = @actions['destroy'] end - it 'type' do + it 'destroyタイプのアクションである' do expect(@action.type).to eq 'destroy' end it 'type' do @@ -145,23 +174,35 @@ describe Scroll do end describe 'モデルに於いて' do + before do + @my_manifest = @model.my_manifest + end + it 'サポート機能が動作している' 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 + describe 'associationsに於いて' do describe 'belongs_toに於いて' do before do - @belongs_to = @model.my_manifest.associations.belongs_to + @belongs_to = @my_manifest.associations.belongs_to + @names = ['author'] end - it ' である' do - expect(@belongs_to.keys).to include 'author' + it 'これらのモデルに所属している' do + set_associations? @belongs_to, @names end describe 'authorに於いて' do before do @mani = @belongs_to['author'] end - it 'type' do + it 'マニフェストから設定を取り出している' do + # モデル名と外部キーが定義あるいはデフォルト値補充されている expect(@mani.model_name).to eq 'author' expect(@mani.id_column).to eq 'author_id' end - it 'type' do + it 'サポート機能が動作している' do + # モデルを再現できている expect(@mani.model).to eq Author end end @@ -169,21 +210,23 @@ describe Scroll do describe 'has_manyに於いて' do before do @has_many = @model.my_manifest.associations.has_many + @names = ['scroll_panels', 'panels'] end - it ' である' do - expect(@has_many.keys).to include 'scroll_panels' - expect(@has_many.keys).to include 'panels' + it 'これらのモデルを所持している' do + set_associations? @has_many, @names end describe 'scroll_panelsに於いて' do before do @mani = @has_many['scroll_panels'] end - it 'type' do + it 'マニフェストから設定を取り出している' 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 + it 'サポート機能が動作している' do + # モデルを再現できている, 中間モデルフラグ expect(@mani.through?).to be false expect(@mani.model).to eq ScrollPanel end @@ -192,12 +235,14 @@ describe Scroll do before do @mani = @has_many['panels'] end - it 'type' 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' end - it 'type' do + it 'サポート機能が動作している' do + # モデルを再現できている, 中間モデルフラグ expect(@mani.through?).to be true expect(@mani.model).to eq Panel end @@ -209,20 +254,16 @@ describe Scroll 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' + it 'これらのカラムを定義している' do + set_attributes? @attributes, + ['id', 'title', 'description', 'visible', 'author_id', + 'created_at', 'updated_at'] end describe 'titleに於いて' do before do @attribute = @attributes['title'] end - it 'type' do + it 'textタイプである' do expect(@attribute.type).to eq 'text' end end @@ -230,7 +271,7 @@ describe Scroll do before do @attribute = @attributes['description'] end - it 'type' do + it 'textタイプである' do expect(@attribute.type).to eq 'text' end end @@ -238,10 +279,10 @@ describe Scroll do before do @attribute = @attributes['visible'] end - it 'type' do + it 'numberタイプである' do expect(@attribute.type).to eq 'number' end - it 'source' do + it '選択肢を定数から取得できるように定義している' do expect(@attribute.source.type).to eq 'magic_number' expect(@attribute.source.select_item_name).to eq 'scroll_visible_items' end @@ -250,23 +291,12 @@ describe Scroll do before do @attribute = @attributes['author_id'] end - it 'type' do + it 'numberタイプである' 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 - end end diff --git a/spec/models/scroll_spec.rb b/spec/models/scroll_spec.rb index 73220ed1..97daf721 100644 --- a/spec/models/scroll_spec.rb +++ b/spec/models/scroll_spec.rb @@ -3,257 +3,104 @@ require 'spec_helper' #スクロール describe Scroll do - include BinderMacros before do - SpeechBalloonTemplate.delete_all - @admin = FactoryGirl.create :admin - @demand_user = FactoryGirl.create :demand_user - @sp = FactoryGirl.create :system_picture - @lg = FactoryGirl.create :license_group - @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id - @user = FactoryGirl.create( :user_yas) - @author = FactoryGirl.create :author, :user_id => @user.id - @artist = FactoryGirl.create :artist_yas, :author_id => @author.id - @other_user = FactoryGirl.create( :user_yas) - @other_author = FactoryGirl.create :author, :user_id => @other_user.id - @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id - end - - describe 'ペタナイズに於いて' do - it 'スクコマを閉じるためのバインダーである' do - expect(@item.is_a?(Peta::Binder)).to be true - end - it 'ブースト特筆すべき注意事項はない' do - expect(self.class.my_peta.boost.keys).to be true - end - context 'バインダー' do - it '' do - define_leaf_items? - end - it '' do - define_leafs_items? - end - end - - end - - describe 'マニフェストに於いて' do - context 'オーソドックスなデータのとき' do - it 'スクコマを閉じるためのバインダーである' do - expect(@item.is_a?(Peta::Binder)).to be true - end - it 'ブースト特筆すべき注意事項はない' do - expect(self.class.my_peta.boost.keys).to be true - end - end - - end - - describe 'ローカルマニフェストに於いて' do - context 'ファイラーのとき' do - it 'スクコマを閉じるためのバインダーである' do - expect(@item.is_a?(Peta::Binder)).to be true - end - it 'ブースト特筆すべき注意事項はない' do - expect(self.class.my_peta.boost.keys).to be true - end - end - + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author end describe '検証に於いて' do before do - @scroll = FactoryGirl.build :scroll, :author_id => @author.id + @item = FactoryGirl.build :scroll_hello, author: @author_yas end context 'オーソドックスなデータのとき' do it '下限データが通る' do - @scroll.title = 'a' - @scroll.visible = 0 - @scroll.should be_valid + @item.title = 'a' + @item.visible = 0 + expect(@item).to be_valid end it '上限データが通る' do - @scroll.title = 'a'*100 - @scroll.visible = 1 - @scroll.should be_valid + @item.title = 'a'*100 + @item.visible = 1 + expect(@item).to be_valid end end context 'titleを検証するとき' do it 'nullなら失敗する' do - @scroll.title = nil - @scroll.should_not be_valid + @item.title = nil + expect(@item).to_not be_valid end it '100文字以上なら失敗する' do - @scroll.title = 'a'*101 - @scroll.should_not be_valid + @item.title = 'a'*101 + expect(@item).to_not be_valid end end context 'visibleを検証するとき' do it 'nullなら失敗する' do - @scroll.visible = nil - @scroll.should_not be_valid + @item.visible = nil + expect(@item).to_not be_valid end it '負なら失敗する' do - @scroll.visible = -1 - @scroll.should_not be_valid + @item.visible = -1 + expect(@item).to_not be_valid end it '2以上なら失敗する' do - @scroll.visible = 2 - @scroll.should_not be_valid + @item.visible = 2 + expect(@item).to_not be_valid end end context 'author_idを検証するとき' do it 'nullなら失敗する' do - @scroll.author_id = nil - @scroll.should_not be_valid + @item.author_id = nil + expect(@item).to_not be_valid end it '数値でなければ失敗する' do - @scroll.author_id = 'a' - @scroll.should_not be_valid + @item.author_id = 'a' + expect(@item).to_not be_valid end it '存在する作家でなければ失敗する' do - @scroll.author_id = 0 - @scroll.should_not be_valid - end - end - end - - describe '文字コード検証に於いて' do - before do - @scroll = FactoryGirl.build :scroll, :author_id => @author.id - end - - context 'titleを検証するとき' do - it 'Shift JISなら失敗する' do - @scroll.title = "\x83G\x83r\x83]\x83D" - lambda{ - @scroll.valid_encode - }.should raise_error(Pettanr::BadRequest) - end - end - - context 'descriptionを検証するとき' do - it 'Shift JISなら失敗する' do - @scroll.description = "\x83G\x83r\x83]\x83D" - lambda{ - @scroll.valid_encode - }.should raise_error(Pettanr::BadRequest) + @item.author_id = 0 + expect(@item).to_not be_valid end end end describe 'デフォルト値補充に於いて' do it 'visibleが0になっている' do - @scroll = FactoryGirl.build :scroll, :visible => nil - @scroll.supply_default - @scroll.visible.should eq 0 + @item = FactoryGirl.build :scroll_hello, author: @author_yas + @item.supply_default + expect(@item.visible).to eq 0 end end describe '上書き補充に於いて' do it '作家idが設定されている' do - @scroll = FactoryGirl.build :scroll, :author_id => nil - @scroll.overwrite @author - @scroll.author_id.should eq @author.id - end - end - - describe 'ロールリストからの作家取得に於いて' do - context 'ロールがユーザのとき' do - it 'ユーザから作家を取得して、それを返す' do - r = Scroll.get_author_from_roles([@user]) - r.should eq @author - end - end - context 'ロールが作家のとき' do - it '作家を返す' do - r = Scroll.get_author_from_roles([@author]) - r.should eq @author - end - end - context 'ロールが絵師のとき' do - it '絵師から作家を取得できれば、それをを返す' do - r = Scroll.get_author_from_roles([@artist]) - r.should eq @author - end - it '絵師から作家を取得できないときnilを返す' do - @artist.author_id = nil - @artist.save! - r = Scroll.get_author_from_roles([@artist]) - r.should be_nil - end - end - context 'ロールが管理者のとき' do - it 'nilを返す' do - r = Scroll.get_author_from_roles([@admin]) - r.should be_nil - end - end - end - - describe 'ロールリストからの絵師取得に於いて' do - context 'ロールがユーザのとき' do - it 'ユーザから作家を取得して、そこから絵師を取得できれば、それを返す' do - r = Scroll.get_artist_from_roles([@user]) - r.should eq @artist - end - it '作家から絵師を取得できないときnilを返す' do - @artist.author_id = nil - @artist.save! - r = Scroll.get_artist_from_roles([@user]) - r.should be_nil - end - end - context 'ロールが作家のとき' do - it 'そこから絵師を取得できれば、それを返す' do - r = Scroll.get_artist_from_roles([@author]) - r.should eq @artist - end - it '作家から絵師を取得できないときnilを返す' do - @artist.author_id = nil - @artist.save! - r = Scroll.get_artist_from_roles([@author]) - r.should be_nil - end - end - context 'ロールが絵師のとき' do - it 'それを返す' do - r = Scroll.get_artist_from_roles([@artist]) - r.should eq @artist - end - end - context 'ロールが管理者のとき' do - it 'nilを返す' do - r = Scroll.get_artist_from_roles([@admin]) - r.should be_nil - end + @item = FactoryGirl.build :scroll_hello, author: @author_yas + @item.overwrite @author + expect(@item.author_id).to eq @author.id end end describe '所持判定に於いて' do before do - @scroll = FactoryGirl.build :scroll, :author_id => @author.id - end - context '事前チェックする' do - it '自身にロールリストからの作家取得を依頼している' do - Scroll.should_receive(:get_author_from_roles).with(any_args).exactly(1) - r = @scroll.own?([@author]) - end + @item = FactoryGirl.build :scroll_hello, author: @author_yas end context 'ロール内作家が取得できるとき' do before do end it 'ロール内作家のidが自身の作家idと一致するなら許可する' do Scroll.stub(:get_author_from_roles).with(any_args).and_return(@author) - r = @scroll.own?([@author]) + r = @item.own?([@author]) r.should be_true end it 'ロール内作家のidが自身の作家idと一致しないならno' do Scroll.stub(:get_author_from_roles).with(any_args).and_return(@other_author) - @scroll.own?(@other_author).should be_false + @item.own?(@other_author).should be_false end end context 'ロール内作家が取得できないとき' do @@ -261,93 +108,7 @@ describe Scroll do Scroll.stub(:get_author_from_roles).with(any_args).and_return(nil) end it 'Falseを返す' do - r = @scroll.own?([@author]) - r.should be_false - end - end - end - - describe '読者用ロールチェックに於いて' do - before do - @scroll = FactoryGirl.build :scroll, :author_id => @author.id - end - context 'ロールリストに作家が含まれるとき' do - it 'ロールリストがリストではないとき、リストにする trueを返す' do - r = @scroll.reader_role_check(@author) - r.should be_true - end - it 'trueを返す' do - r = @scroll.reader_role_check([@author]) - r.should be_true - end - end - context 'ロールリストに絵師が含まれるとき' do - it 'trueを返す' do - r = @scroll.reader_role_check([@artist]) - r.should be_true - end - end - context 'ロールリストにユーザが含まれるとき' do - it 'trueを返す' do - r = @scroll.reader_role_check([@user]) - r.should be_true - end - end - context 'ロールリストに管理者が含まれるとき' do - it 'trueを返す' do - r = @scroll.reader_role_check([@admin]) - r.should be_true - end - end - context 'ロールリストにユーザ、管理者、作家、絵師が含まれないとき' do - it 'falseを返す' do - r = @scroll.reader_role_check([nil]) - r.should be_false - end - end - end - - describe '素材読者用ロールチェックに於いて' do - before do - @scroll = FactoryGirl.build :scroll, :author_id => @author.id - end - context 'ロールリストに作家が含まれるとき' do - it 'ロールリストがリストではないとき、リストにする trueを返す' do - r = @scroll.resource_reader_role_check(@author) - r.should be_true - end - it 'trueを返す' do - r = @scroll.resource_reader_role_check([@author]) - r.should be_true - end - end - context 'ロールリストに絵師が含まれるとき' do - it 'trueを返す' do - r = @scroll.resource_reader_role_check([@artist]) - r.should be_true - end - end - context 'ロールリストにユーザが含まれるとき' do - it 'trueを返す' do - r = @scroll.resource_reader_role_check([@user]) - r.should be_true - end - end - context 'ロールリストに管理者が含まれるとき' do - it 'trueを返す' do - r = @scroll.resource_reader_role_check([@admin]) - r.should be_true - end - end - context 'ロールリストに借手が含まれるとき' do - it 'trueを返す' do - r = @scroll.resource_reader_role_check([@demand_user]) - r.should be_true - end - end - context 'ロールリストにユーザ、管理者、作家、絵師、借手が含まれないとき' do - it 'falseを返す' do - r = @scroll.resource_reader_role_check([nil]) + r = @item.own?([@author]) r.should be_false end end @@ -355,398 +116,73 @@ describe Scroll do describe '閲覧許可に於いて' do before do - @scroll = FactoryGirl.build :scroll, :author_id => @author.id + @item = FactoryGirl.build :scroll_hello, author: @author_yas end context 'オープンモードのとき' do before do MagicNumber['run_mode'] = 0 end - it '自身にゲスト用ロールチェックを問い合わせしている' do - Scroll.any_instance.stub(:guest_role_check).and_return(true) - Scroll.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1) - r = @scroll.visible?([@author]) + context 'ゲストのとき' do + it '他人のの非公開スクロールでも許可する' do + end end - it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do - Scroll.any_instance.stub(:guest_role_check).and_return(false) - r = @scroll.visible?([@author]) - r.should be_false + context 'yasのとき' do + it '自分のスクロールなら許可する' do + Scroll.any_instance.stub(:own?).and_return(true) + Scroll.any_instance.stub(:visible).and_return(0) + r = @item.visible?([@author]) + r.should be_true + end + it '他人の非公開スクロールなら許可しない' do + end + it '他人のスクロールでも公開なら許可する' do + end + end + context 'adminのとき' do + it '他人のの非公開スクロールでも許可する' do + end end end context 'クローズドモードのとき' do before do MagicNumber['run_mode'] = 1 end - it '自身に読者用ロールチェックを問い合わせしている' do - Scroll.any_instance.stub(:reader_role_check).and_return(true) - Scroll.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1) - r = @scroll.visible?([@author]) + context 'ゲストのとき' do + it '他人のの非公開スクロールでも許可する' do + end end - it '読者用ロールチェックが失敗したとき、falseを返す' do - Scroll.any_instance.stub(:reader_role_check).and_return(false) - r = @scroll.visible?([@author]) - r.should be_false + context 'yasのとき' do + it '自分のスクロールなら許可する' do + Scroll.any_instance.stub(:own?).and_return(true) + Scroll.any_instance.stub(:visible).and_return(0) + r = @item.visible?([@author]) + r.should be_true + end + it '他人の非公開スクロールなら許可しない' do + end + it '他人のスクロールでも公開なら許可する' do + end end - end - context '事前チェックする' do - before do - MagicNumber['run_mode'] = 1 - Scroll.any_instance.stub(:reader_role_check).and_return(true) - Scroll.any_instance.stub(:own?).and_return(true) - end - it '自身に所持判定を問い合わせしている' do - Scroll.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = @scroll.visible?([@author]) + context 'adminのとき' do + it '他人のの非公開スクロールでも許可する' do + end end end - context 'つつがなく終わるとき' do - before do - MagicNumber['run_mode'] = 1 - Scroll.any_instance.stub(:reader_role_check).and_return(true) - end - it '自分のスクロールなら許可する' do - Scroll.any_instance.stub(:own?).and_return(true) - Scroll.any_instance.stub(:visible).and_return(0) - r = @scroll.visible?([@author]) - r.should be_true - end - it '他人の非公開スクロールなら許可しない' do - Scroll.any_instance.stub(:own?).and_return(false) - Scroll.any_instance.stub(:visible).and_return(0) - r = @scroll.visible?([@author]) - r.should be_false - end - it '他人のスクロールでも公開なら許可する' do - Scroll.any_instance.stub(:own?).and_return(false) - Scroll.any_instance.stub(:visible).and_return(1) - r = @scroll.visible?([@author]) - r.should be_true - end - end - end - - describe '一覧取得に於いて' do - before do - @scroll = FactoryGirl.create :scroll, :author_id => @author.id - end - context 'page補正について' do - it '文字列から数値に変換される' do - Scroll.page('8').should eq 8 - end - it 'nilの場合は1になる' do - Scroll.page().should eq 1 - end - it '0以下の場合は1になる' do - Scroll.page('0').should eq 1 - end - end - context 'page_size補正について' do - it '文字列から数値に変換される' do - Scroll.page_size('7').should eq 7 - end - it 'nilの場合はScroll.default_page_sizeになる' do - Scroll.page_size().should eq Scroll.default_page_size - end - it '0以下の場合はScroll.default_page_sizeになる' do - Scroll.page_size('0').should eq Scroll.default_page_size - end - it 'Scroll.max_page_sizeを超えた場合はScroll.max_page_sizeになる' do - Scroll.page_size('1000').should eq Scroll.max_page_size - end - end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Scroll.stub(:list_opt).with(any_args).and_return({}) - Scroll.should_receive(:list_opt).with(any_args).exactly(1) - r = Scroll.list - end - end - it 'リストを返す' do - c = Scroll.list - c.should eq [@scroll] - end - it '非公開スクロールは(自分のスクロールであっても)含んでいない' do - FactoryGirl.create :scroll, :author_id => @author.id, :visible => 0 - c = Scroll.list - c.should eq [@scroll] - end - it '時系列で並んでいる' do - #公開スクロールは(他人のスクロールであっても)含んでいる - v = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100 - c = Scroll.list - c.should eq [v, @scroll] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @scroll2 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100 - @scroll3 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 200 - @scroll4 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 300 - @scroll5 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 400 - Scroll.stub(:default_page_size).and_return(2) - end - it '通常は2件を返す' do - c = Scroll.list - c.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - c = Scroll.list(1) - c.should eq [@scroll5, @scroll4] - end - it 'page=2なら中間2件を返す' do - c = Scroll.list(2) - c.should eq [@scroll3, @scroll2] - end - it 'page=3なら先頭1件を返す' do - c = Scroll.list(3) - c.should eq [@scroll] - end - end - end - - describe '自分のスクロール一覧取得に於いて' do - before do - @scroll = FactoryGirl.create :scroll, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Scroll.stub(:list_opt).with(any_args).and_return({}) - Scroll.should_receive(:list_opt).with(any_args).exactly(1) - r = Scroll.mylist @author - end - end - it 'リストを返す' do - c = Scroll.mylist @author - c.should eq [@scroll] - end - it '時系列で並んでいる' do - nc = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100 - cl = Scroll.mylist @author - cl.should eq [nc, @scroll] - end - it '他人のスクロールは公開でも含まない' do - nc = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 1 - cl = Scroll.mylist @author - cl.should eq [@scroll] - end - it '自分のスクロールは非公開でも含んでいる' do - nc = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100 - cl = Scroll.mylist @author - cl.should eq [nc, @scroll] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @scroll2 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 100 - @scroll3 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 200 - @scroll4 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 300 - @scroll5 = FactoryGirl.create :scroll, :author_id => @author.id, :updated_at => Time.now + 400 - end - it '通常は2件を返す' do - c = Scroll.mylist @author, 1, 2 - c.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - c = Scroll.mylist(@author, 1, 2) - c.should eq [@scroll5, @scroll4] - end - it 'page=2なら中間2件を返す' do - c = Scroll.mylist(@author, 2, 2) - c.should eq [@scroll3, @scroll2] - end - it 'page=3なら先頭1件を返す' do - c = Scroll.mylist(@author, 3, 2) - c.should eq [@scroll] - end - end - end - - describe '他作家のスクロール一覧取得に於いて' do - before do - @scroll = FactoryGirl.create :scroll, :author_id => @author.id - @other_scroll = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 1 - end - context 'つつがなく終わるとき' do - it '一覧取得オプションを利用している' do - Scroll.stub(:list_opt).with(any_args).and_return({}) - Scroll.should_receive(:list_opt).with(any_args).exactly(1) - r = Scroll.himlist @other_author - end - end - it '指定した作家のリストを返す' do - r = Scroll.himlist @other_author - r.should eq [@other_scroll] - end - it '時系列で並んでいる' do - nc = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100 - r = Scroll.himlist @other_author - r.should eq [nc, @other_scroll] - end - it '公開スクロールに限る ' do - hidden = FactoryGirl.create :scroll, :author_id => @other_author.id, :visible => 0 - r = Scroll.himlist @other_author - r.should eq [@other_scroll] - end - context 'DBに5件あって1ページの件数を2件に変えたとして' do - before do - @other_scroll2 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 100 - @other_scroll3 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 200 - @other_scroll4 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 300 - @other_scroll5 = FactoryGirl.create :scroll, :author_id => @other_author.id, :updated_at => Time.now + 400 - end - it '通常は2件を返す' do - c = Scroll.himlist @other_author, 1, 2 - c.should have(2).items - end - it 'page=1なら末尾2件を返す' do - #時系列で並んでいる - c = Scroll.himlist(@other_author, 1, 2) - c.should eq [@other_scroll5, @other_scroll4] - end - it 'page=2なら中間2件を返す' do - c = Scroll.himlist(@other_author, 2, 2) - c.should eq [@other_scroll3, @other_scroll2] - end - it 'page=3なら先頭1件を返す' do - c = Scroll.himlist(@other_author, 3, 2) - c.should eq [@other_scroll] - end - end - end - - describe 'スクロール一覧ページ制御に於いて' do - before do - Scroll.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Scroll.list_paginate - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it 'スクロール一覧の取得条件を利用している' do - Scroll.stub(:list_where).with(any_args).and_return('') - Scroll.should_receive(:list_where).with(any_args).exactly(1) - r = Scroll.list_paginate - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Scroll.list_paginate 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '自分のスクロール一覧ページ制御に於いて' do - before do - Scroll.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Scroll.mylist_paginate @author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it '自分のスクロール一覧の取得条件を利用している' do - Scroll.stub(:mylist_where).with(any_args).and_return('') - Scroll.should_receive(:mylist_where).with(any_args).exactly(1) - r = Scroll.mylist_paginate @author - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Scroll.mylist_paginate @author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '他作家のスクロール一覧ページ制御に於いて' do - before do - Scroll.stub(:count).with(any_args).and_return(100) - end - it 'ページ制御を返す' do - r = Scroll.himlist_paginate @other_author - r.is_a?(Kaminari::PaginatableArray).should be_true - end - it '他作家のスクロール一覧の取得条件を利用している' do - Scroll.stub(:himlist_where).with(any_args).and_return('') - Scroll.should_receive(:himlist_where).with(any_args).exactly(1) - r = Scroll.himlist_paginate @other_author - end - it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do - r = Scroll.himlist_paginate @other_author, 3, 10 - r.limit_value.should eq 10 - r.offset_value.should eq 20 - end - end - - describe '一覧取得オプションに於いて' do - it '2つの項目を含んでいる' do - r = Scroll.list_opt - r.should have(2).items - end - it 'スクコマを含んでいる' do - r = Scroll.list_opt - r.has_key?(:scroll_panels).should be_true - end - it 'スクコマはコマを含んでいる' do - r = Scroll.list_opt - r[:scroll_panels].has_key?(:panel).should be_true - end - it '作家を含んでいる' do - r = Scroll.list_opt - r.has_key?(:author).should be_true - end - end - describe 'json一覧出力オプションに於いて' do - before do - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template - @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id - end - it 'スクコマを含んでいる' do - r = Scroll.list.to_json Scroll.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('scroll_panels').should be_true - end - it 'スクコマはコマを含んでいる' do - r = Scroll.list.to_json Scroll.list_json_opt - j = JSON.parse r - i = j.first - s = i['scroll_panels'].first - s.has_key?('panel').should be_true - end - it '作家を含んでいる' do - r = Scroll.list.to_json Scroll.list_json_opt - j = JSON.parse r - i = j.first - i.has_key?('author').should be_true - end end describe '単体取得に於いて' do before do - @scroll = FactoryGirl.create :scroll, :author_id => @author.id - end - context 'つつがなく終わるとき' do - it '単体取得オプションを利用している' do - Scroll.stub(:show_opt).with(any_args).and_return({}) - Scroll.should_receive(:show_opt).with(any_args).exactly(1) - r = Scroll.show @scroll.id, @author - end - it '閲覧許可を問い合わせている' do - Scroll.any_instance.stub(:visible?).with(any_args).and_return(true) - Scroll.any_instance.should_receive(:visible?).with(any_args).exactly(1) - r = Scroll.show @scroll.id, @author - end + @item = FactoryGirl.create :scroll, :author_id => @author.id end it '指定のスクロールを返す' do - c = Scroll.show @scroll.id, @author - c.should eq @scroll + c = Scroll.show @item.id, @author + c.should eq @item end context '閲覧許可が出なかったとき' do it '403Forbidden例外を返す' do Scroll.any_instance.stub(:visible?).and_return(false) lambda{ - Scroll.show @scroll.id, @author + Scroll.show @item.id, @author }.should raise_error(ActiveRecord::Forbidden) end end @@ -761,30 +197,30 @@ describe Scroll do describe '編集取得に於いて' do before do - @scroll = FactoryGirl.create :scroll, :author_id => @author.id + @item = FactoryGirl.create :scroll, :author_id => @author.id end context 'つつがなく終わるとき' do it '単体取得オプションを利用している' do Scroll.stub(:show_opt).with(any_args).and_return({}) Scroll.should_receive(:show_opt).with(any_args).exactly(1) - r = Scroll.edit @scroll.id, @author + r = Scroll.edit @item.id, @author end it '所持判定を問い合わせている' do Scroll.any_instance.stub(:own?).with(any_args).and_return(true) Scroll.any_instance.should_receive(:own?).with(any_args).exactly(1) - r = Scroll.edit @scroll.id, @author + r = Scroll.edit @item.id, @author end end it '指定のスクロールを返す' do Scroll.any_instance.stub(:own?).and_return(true) - c = Scroll.edit @scroll.id, @author.id - c.should eq @scroll + c = Scroll.edit @item.id, @author.id + c.should eq @item end context '他人のスクロールを開こうとしたとき' do it '403Forbidden例外を返す' do Scroll.any_instance.stub(:own?).and_return(false) lambda{ - Scroll.edit @scroll.id, @author + Scroll.edit @item.id, @author }.should raise_error(ActiveRecord::Forbidden) end end @@ -796,86 +232,34 @@ describe Scroll do end end end - describe '単体取得オプションに於いて' do - it 'includeキーを含んでいる' do - r = Scroll.show_opt - r.has_key?(:include).should be_true - end - it '2つの項目を含んでいる' do - r = Scroll.show_opt[:include] - r.should have(2).items - end - it '作家を含んでいる' do - r = Scroll.show_opt[:include] - r.has_key?(:author).should be_true - end - it 'スクコマを含んでいる' do - r = Scroll.show_opt[:include] - r.has_key?(:scroll_panels).should be_true - end - it 'スクコマはコマを含んでいる' do - r = Scroll.show_opt[:include] - r[:scroll_panels].has_key?(:panel).should be_true - end - end - describe 'json単体出力オプションに於いて' do - before do - @op = FactoryGirl.create :original_picture, :artist_id => @artist.id - @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id - @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id - @sbt = FactoryGirl.create :speech_balloon_template - @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1 - @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id - end - it 'スクコマを含んでいる' do - r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt - j = JSON.parse r - i = j - i.has_key?('scroll_panels').should be_true - end - it 'スクコマはコマを含んでいる' do - r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt - j = JSON.parse r - i = j - s = i['scroll_panels'].first - s.has_key?('panel').should be_true - end - it '作家を含んでいる' do - r = Scroll.show(@scroll.id, @author).to_json Scroll.show_json_opt - j = JSON.parse r - i = j - i.has_key?('author').should be_true - end - end describe '削除に於いて' do before do - @scroll = FactoryGirl.create :scroll, :author_id => @author.id + @item = FactoryGirl.create :scroll, :author_id => @author.id @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 - @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id + @item_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @item.id, :panel_id => @panel.id @other_scroll = FactoryGirl.create :scroll, :author_id => @author.id @other_scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @other_scroll.id, :panel_id => @panel.id end context 'つつがなく終わるとき' do it '自身を削除する' do lambda { - r = @scroll.destroy_with_scroll_panel + r = @item.destroy_with_scroll_panel }.should change(Scroll, :count).by(-1) lambda { - r = Scroll.find @scroll.id + r = Scroll.find @item.id }.should raise_error end it '自身にリンクしているスクコマをすべて削除する' do lambda { - r = @scroll.destroy_with_scroll_panel + r = @item.destroy_with_scroll_panel }.should change(ScrollPanel, :count).by(-1) lambda { - r = ScrollPanel.find @scroll_panel.id + r = ScrollPanel.find @item_panel.id }.should raise_error end it 'Trueを返す' do - r = @scroll.destroy_with_scroll_panel + r = @item.destroy_with_scroll_panel r.should be_true end end @@ -884,15 +268,15 @@ describe Scroll do ScrollPanel.any_instance.stub(:destroy).with(any_args).and_return(false) end it 'Falseを返す' do - r = @scroll.destroy_with_scroll_panel + r = @item.destroy_with_scroll_panel r.should be_false end it 'ロールバックしている' do lambda { - r = @scroll.destroy_with_scroll_panel + r = @item.destroy_with_scroll_panel }.should_not change(Scroll, :count) lambda { - r = @scroll.destroy_with_scroll_panel + r = @item.destroy_with_scroll_panel }.should_not change(ScrollPanel, :count) end end diff --git a/spec/peta/binder_spec.rb b/spec/peta/binder_spec.rb index 498d3d17..bb172967 100644 --- a/spec/peta/binder_spec.rb +++ b/spec/peta/binder_spec.rb @@ -3,43 +3,63 @@ require 'spec_helper' #スクロール describe Scroll do + include BinderMacros before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author end - describe '文字コード検証に於いて' do + describe '生成メソッドに於いて' do before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas end - context 'titleを検証するとき' do - it 'Shift JISなら失敗する' do - expect(Scroll.new.respond_to?(:leafs_items)).to be true + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] end end - context 'titleを検証するとき' do - it 'Shift JISなら失敗する' do - expect(Scroll.new.respond_to?(:leafs_)).to be true + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] end end end + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + end + describe Comic do + include BinderMacros before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author end - describe '文字コード検証に於いて' do - before do - end - - context 'titleを検証するとき' do - it 'Shift JISなら失敗する' do - @scroll.title = 'a' - @scroll.should be_valid - end - end - +end + +describe Story do + include BinderMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author end end + diff --git a/spec/peta/content_spec.rb b/spec/peta/content_spec.rb new file mode 100644 index 00000000..23a4abaf --- /dev/null +++ b/spec/peta/content_spec.rb @@ -0,0 +1,80 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe Scroll do + include ContentMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end + +describe Comic do + include BinderMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ComicStory] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ComicStory] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end diff --git a/spec/peta/element_spec.rb b/spec/peta/element_spec.rb new file mode 100644 index 00000000..ac1afd20 --- /dev/null +++ b/spec/peta/element_spec.rb @@ -0,0 +1,110 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe Scroll do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + +end + +describe SheetPanel do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe PanelPicture do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe SpeechBalloon do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe Balloon do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe Speech do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe GroundPicture do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe GroundColor do + include ElementMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end diff --git a/spec/peta/item_spec.rb b/spec/peta/item_spec.rb new file mode 100644 index 00000000..82e744f1 --- /dev/null +++ b/spec/peta/item_spec.rb @@ -0,0 +1,127 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe Scroll do + include ItemMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + + @model = Scroll + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe '生成メソッドに於いて' do + before do + end + + describe '文字コード検証に於いて' do + it 'Shift JISなら失敗する' do + @text_column_names = ['title', 'description'] + valid_encode? @item, @text_column_names + end + end + + describe 'child_modelsに於いて' do + it 'すべてのリーフを取得できる' do + define_child_models? @model, [ScrollPanel] + end + end + + describe 'child_element_namesに於いて' do + it 'すべてのリーフを取得できる' do + define_child_element_names? @model, ['scroll_panels'] + end + end + + end + + describe 'myに於いて' do + it '自分のマニフェストを取得するためのショートカットが設定できている' do + define_my_manifest? @model + end + + it 'アイテムの種別を判定するためのフラグが設定できている' do + @subjects = { + :item? => true, + :content? => true, + :element? => false, + :root? => false, + } + set_name? @model, @subjects + end + + it '名前の活用に於いて' do + @subjects = { + :singular => 'Scroll', + :plural => 'Scrolls', + :item_name => 'scroll', + #:model_name => 'Scroll', + :path_name => 'scrolls', + :table_name => 'scrolls', + :pickup_item_name => 'scroll', + :pickup_column_name => 'id', + } + # クラスメソッドで名前の活用ができているか + set_name? @model, @subjects + # インスタンスメソッドからクラスメソッドを呼び出すショートカットが利用できるか + set_name? @item, @subjects + end + end + + describe 'listに於いて' do + it 'list' do + expect(@model.parent_model).to be nil + expect(@model.list_where).to be_blank + expect(@model.list_order).to eq 'scrolls.updated_at desc' + end + end + + describe 'extendに於いて' do + before do + end + + it 'それぞれのカラムは拡張カラムなのか' do + @subjects = { + :title => false, + :description => false, + :visible => false, + :author_id => false, + } + set_extend_column? @model, @subjects + set_extend_column? @item, @subjects + end + + it 'カラム名からブーストマニフェストを取得できている' do + @subjects = { + } + set_extend_column? @model, @subjects + end + + it 'Postレベルでブーストしてブースターを確認する' do + @names = [] + set_boosters? @item, @names + end + + it '拡張データを畳み込める' do + @extend_column_names = [] + @attr = {} + fold_extend_settings? @model, @attr, @extend_column_names + end + + end + + describe 'めんどいからチェックしない機能に於いて' do + it 'とりあえず呼び出すところまでは確認しておく' do + define_test @item + end + # + # list_opt, list_json_opt, show_opt, show_json_opt, form_template, form_name + # supply_default, overwrite, visible? + end + +end + diff --git a/spec/peta/leaf_spec.rb b/spec/peta/leaf_spec.rb new file mode 100644 index 00000000..fde33c1e --- /dev/null +++ b/spec/peta/leaf_spec.rb @@ -0,0 +1,67 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe ScrollPanel do + include LeafMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + +end + +describe SheetPanel do + include LeafMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe ComicStory do + include LeafMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + +describe StorySheet do + include LeafMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + +end + diff --git a/spec/peta/owner_spec.rb b/spec/peta/owner_spec.rb new file mode 100644 index 00000000..439e2dac --- /dev/null +++ b/spec/peta/owner_spec.rb @@ -0,0 +1,80 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe Author do + include OwnerMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end + +describe Artist do + include OwnerMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ComicStory] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ComicStory] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end diff --git a/spec/peta/root_spec.rb b/spec/peta/root_spec.rb new file mode 100644 index 00000000..34354e45 --- /dev/null +++ b/spec/peta/root_spec.rb @@ -0,0 +1,80 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe Sheet do + include RootMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end + +describe Panel do + include RootMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ComicStory] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ComicStory] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end diff --git a/spec/peta/system_resource_spec.rb b/spec/peta/system_resource_spec.rb new file mode 100644 index 00000000..013e817b --- /dev/null +++ b/spec/peta/system_resource_spec.rb @@ -0,0 +1,80 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe License do + include SystemResourceMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end + +describe SystemPicture do + include SystemResourceMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ComicStory] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ComicStory] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end diff --git a/spec/peta/template_spec.rb b/spec/peta/template_spec.rb new file mode 100644 index 00000000..7c51e067 --- /dev/null +++ b/spec/peta/template_spec.rb @@ -0,0 +1,119 @@ +# -*- encoding: utf-8 -*- +require 'spec_helper' +#スクロール + +describe SpeechBalloonTemplate do + include TemplateMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end + +describe LicenseGroup do + include TemplateMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ScrollPanel] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ScrollPanel] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end + +describe WritingFormat do + include TemplateMacros + before do + @admin =FactoryGirl.create :admin + @user_yas = FactoryGirl.create :user_yas_with_owner + @user_rom = FactoryGirl.create :user_rom + @author_yas = @user_yas.author + end + + describe '生成メソッドに於いて' do + before do + end + + describe 'leaf_itemsに於いて' do + it 'ぶら下がるそれぞれのリーフを取得できる' do + define_leaf_items? @item, [ComicStory] + end + end + + describe 'leafs_itemsに於いて' do + it 'すべてのリーフを取得できる' do + define_leafs_items? @item, [ComicStory] + end + end + + end + + describe 'boostに於いて' do + before do + @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas + end + + it 'ブーストメッセージをリーフに伝搬する' do + end + end + +end diff --git a/spec/support/binder_macros.rb b/spec/support/binder_macros.rb deleted file mode 100644 index afa12901..00000000 --- a/spec/support/binder_macros.rb +++ /dev/null @@ -1,127 +0,0 @@ -module BinderMacros - def define_leaf_items? - # ステータス OKを返す - expect(response).to be_success - end - - def render_json? - # jsonデータを返す - expect {JSON.parse(response.body)}.not_to raise_error - end - - def render_filer? - # filerテンプレートを描画する - expect(response).to render_template("templates/r/filer/filer") - end - - def render_profiler? - # profilerテンプレートを描画する - expect(response).to render_template("templates/r/profiler/profiler") - end - - def render_form? - # formテンプレートを描画する - expect(response).to render_template("templates/r/form/form") - end - - def redirect? url - # html形式: ステータスコード302 Foundを返す - expect(response.status).to eq(302) - expect(response).to redirect_to url - end - - # ゲストがapiからコンテンツにアクセスしようとした時の動作を確認する - def render_unauthorized? - # json形式: ステータスコード401 Unauthorizedを返す - expect(response.status).to eq(401) - expect(response.message).to match(/Unauthorized/) - end - - # 処理不能を返す - def render_unprocessable? - expect(response.status).to eq(422) - expect(response.message).to match(/Unprocessable/) - end - - def render_complated? - expect(response.message).to match /./ - end - - def set_model? model_class, var_name = :my_model_class - expect(assigns(var_name)).to be model_class - end - - def set_list_model? model_class, var_name = :my_list_model_class - expect(assigns(var_name)).to be model_class - end - - def set_list? item_name, list_name, var_name = :list - expect(assigns(var_name).item_name).to eq(item_name) - expect(assigns(var_name).list_name).to eq(list_name) - end - - def set_play_list? model_class - expect(assigns(:items).size).to be >= 3 - expect(assigns(:count)).to be >= 3 - expect(assigns(:pager)).not_to be nil - expect(assigns(:items).first.class).to be model_class - end - - def let_filer? var_name = :filer - expect(assigns(var_name).class).to eq(Locmare::Filer) - end - - def let_profiler? var_name = :profiler - expect(assigns(var_name).class).to eq(Locmare::Profiler) - end - - def set_bucket? item, var_name = :form - # @filerにファイラーを取得している - expect(assigns(var_name).item).to eq(item) - expect(assigns(var_name).mounted).to eq(true) - expect(assigns(var_name).submit).to eq(true) - end - - def boost? names, var_name = :item - if names.empty? - assigns(var_name).boosters.empty? - else - names.each do |boost_name| - expect(assigns(var_name).boosters[boost_name]).to_not be nil - end - end - end - - # 作家活動していないユーザーがAPIから創作活動をしようとしたとき、例外を発生させる。 - # 暫定的な仕様なので、良い方法があれば変えるかもしれない。メンテしやすいように切り分けてある。 - # リクエストして例外が発生したところとらえるので、リクエストと検証を同時に行う - def announce_regist_author_for_json method, params = {}, action = :create - expect {__send__(method, action, params.merge(:format => :json))}.to raise_error(ActiveRecord::Forbidden) - end - - # 保存処理を成功したことにしてスキップする - def allow_save my_model_class - allow_any_instance_of(my_model_class).to receive(:save).and_return(true) - end - - # 保存処理を失敗したことにしてスキップする - def reject_save my_model_class - allow_any_instance_of(my_model_class).to receive(:save).and_return(false) - end - - # 削除処理を成功したことにしてスキップする - def allow_destroy my_model_class - allow_any_instance_of(my_model_class).to receive(:destroy).and_return(true) - end - - # 削除処理を失敗したことにしてスキップする - def reject_destroy my_model_class - allow_any_instance_of(my_model_class).to receive(:destroy).and_return(false) - end - - def factory_contents factory_name, author, count = 5 - FactoryGirl.create_list(factory_name, count, author: author) - end - -end - diff --git a/spec/support/local_manifests_macros.rb b/spec/support/local_manifests_macros.rb new file mode 100644 index 00000000..a112ac5b --- /dev/null +++ b/spec/support/local_manifests_macros.rb @@ -0,0 +1,32 @@ +module LocalManifestsMacros + # プロファイラーのカラムのマニフェストが期待通りに記述されているか。数量と名称でチェックする。 + def set_columns? columns, names + expect(columns.keys.size).to eq names.size + names.each do |name| + expect(columns.keys).to include name + end + end + + # プロファイラーのassociationのマニフェストが期待通りに記述されているか。数量と名称でチェックする。 + def set_associations? association, names + expect(association.map {|a| a.association_name}).to eq names + end + + # リストグループのlistsのマニフェストが期待通りに記述されているか。数量と名称でチェックする。 + def set_lists? lists, names + expect(lists.keys.size).to eq names.size + names.each do |name| + expect(lists.keys).to include name + end + end + + # 入力フォームのフィールドのマニフェストが期待通りに記述されているか。数量と名称でチェックする。 + def set_fields? fields, names + expect(fields.keys.size).to eq names.size + names.each do |name| + expect(fields.keys).to include name + end + end + +end + diff --git a/spec/support/manifests_macros.rb b/spec/support/manifests_macros.rb new file mode 100644 index 00000000..52aa7f34 --- /dev/null +++ b/spec/support/manifests_macros.rb @@ -0,0 +1,32 @@ +module ManifestsMacros + # コントローラのアクションのマニフェストが期待通りに記述されているか。数量と名称でチェックする。 + def set_actions? actions, names + expect(actions.keys.size).to eq names.size + names.each do |name| + expect(actions.keys).to include name + end + end + + def set_list_action? action, item_name, list_name + expect(action.item_name).to eq item_name + expect(action.list_name).to eq list_name + end + + # モデルのassociationのマニフェストが期待通りに記述されているか。数量と名称でチェックする。 + def set_associations? association, names + expect(association.keys.size).to eq names.size + names.each do |name| + expect(association.keys).to include name + end + end + + # モデルのカラムのマニフェストが期待通りに記述されているか。数量と名称でチェックする。 + def set_attributes? attributes, names + expect(attributes.keys.size).to eq names.size + names.each do |name| + expect(attributes.keys).to include name + end + end + +end + diff --git a/spec/support/peta_macros.rb b/spec/support/peta_macros.rb new file mode 100644 index 00000000..f2b8b79c --- /dev/null +++ b/spec/support/peta_macros.rb @@ -0,0 +1,240 @@ +module ItemMacros + # 文字コード検証 + def valid_encode? item, text_column_names + text_column_names.each do |name| + expect(item.class.valid_encode_columns).to include name + item.attributes[name] = "\x83G\x83r\x83]\x83D" + # バージョンが上がって問題なくなったかもしれない + #expect { item.valid_encode }.to raise_error(Pettanr::BadRequest) + end + end + + def define_child_models? model, models + expect(model.child_models.size).to eq models.size + models.each do |m| + expect(model.child_models).to include m + end + end + + def define_child_element_names? model, item_names + expect(model.child_models.size).to eq item_names.size + item_names.each do |m| + expect(model.child_element_names).to include m + end + end + + def define_my_manifest? model + expect(model.my_peta).to eq Manifest.manifest.items[model.item_name] + expect(model.my_controller).to eq Manifest.manifest.controllers[model.table_name] + expect(model.my_manifest).to eq Manifest.manifest.models[model.item_name] + end + + # マニフェストを取得するためのショートカット + def define_my_manifest? model + expect(model.my_peta).to eq Manifest.manifest.items[model.item_name] + expect(model.my_controller).to eq Manifest.manifest.controllers[model.table_name] + expect(model.my_manifest).to eq Manifest.manifest.models[model.item_name] + end + + # 名前の活用が正しく変化していることを確認している + def set_name? item, subjects + subjects.each do |name, value| + expect(item.__send__(name)).to eq value + end + end + + # 拡張カラムなのかを確認している + def set_extend_column? model, subjects + subjects.each do |name, value| + expect(model.extend_column?(name)).to eq value + end + end + + # ブースターが用意されているか、名前だけでも確認する + def set_boosters? item, names + item.boosts 'post' + item.boosters.keys.each do |name| + expect(name).to include names + end + end + + # 拡張データを畳み込めるか確認する + def fold_extend_settings? model, attr, extend_column_names + model.fold_extend_settings attr + extend_column_names.each do |name| + expect(attr[name]).to be_kind_of String + end + end + + def define_test item + expect {expect(item.dom_id)}.not_to raise_error + expect {expect(item.editize?)}.not_to raise_error + expect {expect(item.dom_pool_type)}.not_to raise_error + expect {expect(item.merge_dom_item_id({}))}.not_to raise_error + expect {expect(item.tag_attributes)}.not_to raise_error + expect {expect(item.field_tag_attributes(:hoge))}.not_to raise_error + expect {expect(item.post_attribute_key)}.not_to raise_error + end + +end + +module ContentMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + +module BinderMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + +module LeafMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + +module RootMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + +module ElementMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + +module OwnerMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + +module SystemResourceMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + +module TemplateMacros + # ぶら下がるそれぞれのリーフを取得 + def define_leaf_items? item, leaf_models + expect(item.respond_to?(:leaf_items)).to be true + leaf_models.each do |model| + expect(item.leaf_items(model)).to_not be_empty + expect(item.leaf_items(model).first.class).to eq model + end + end + + def define_leafs_items? item, leaf_models + expect(item.respond_to?(:leafs_items)).to be true + expect(item.leafs_items).to_not be_empty + item.leafs_items.map {|i| i.class }.each do |model| + expect(leaf_models).to include model + end + end + +end + -- 2.11.0