X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;ds=sidebyside;f=spec%2Fmanifests%2Fauthor_spec.rb;fp=spec%2Fmanifests%2Fauthor_spec.rb;h=b4fbad5ae8d89be110b3117f34676c1070efdb5c;hb=c0f332effbcf231d77e8b301af8857729553f271;hp=0000000000000000000000000000000000000000;hpb=b6bb1b9ee93769f9e6e12146e12c185e75587571;p=pettanr%2Fpettanr.git diff --git a/spec/manifests/author_spec.rb b/spec/manifests/author_spec.rb new file mode 100644 index 00000000..b4fbad5a --- /dev/null +++ b/spec/manifests/author_spec.rb @@ -0,0 +1,276 @@ +# -*- encoding: utf-8 -*- +#作家 +require 'spec_helper' + +describe Author do + include ManifestsMacros + before do + @model = Author + end + + describe 'ペタナイズに於いて' do + it 'オーナーである' do + expect(@model.ancestors.include?(Peta::Owner)).to eq true + end + it '親モデルは持たない' do + expect(@model.my_peta.parent_model_name).to be_blank + end + describe 'ブーストに於いて' do + it '特筆すべき注意事項はない' do + expect(@model.my_peta.boost.keys).to be_empty + end + end + + end + + describe 'コントローラに於いて' do + before do + @controller = @model.my_controller + end + it '作家のためのコントローラである' do + expect(@model.item_name).to eq 'author' + end + describe 'actionに於いて' do + before do + @actions = @controller.actions + @actions_names = ['index', 'show', + 'count', + 'new', 'edit', 'create', 'update', 'destroy'] + end + it 'これらのアクションが定義されている' do + set_actions? @actions, @actions_names + end + describe 'baseに於いて' do + end + describe 'indexに於いて' do + before do + @action = @actions['index'] + end + it 'listタイプのアクションである' do + expect(@action.type).to eq 'list' + end + it 'マニフェストから設定を取り出している' do + # 作家の公開リストを返すように定義している + set_list_action? @action, 'author', 'public' + end + end + describe 'showに於いて' do + before do + @action = @actions['show'] + end + it 'showタイプのアクションである' do + expect(@action.type).to eq 'show' + end + end + describe 'countに於いて' do + before do + @action = @actions['count'] + end + it 'countタイプのアクションである' do + expect(@action.type).to eq 'count' + end + it 'マニフェストから設定を取り出している' do + #作家の公開リストのカウントを返すように定義している + set_list_action? @action, 'author', 'public' + end + end + describe 'newに於いて' do + before do + @action = @actions['new'] + end + it 'newタイプのアクションである' do + expect(@action.type).to eq 'new' + end + it 'type' do + expect(@action.item_name).to eq 'author' + end + end + describe 'editに於いて' do + before do + @action = @actions['edit'] + end + it 'editタイプのアクションである' do + expect(@action.type).to eq 'edit' + end + it 'type' do + expect(@action.item_name).to eq 'author' + end + end + describe 'createに於いて' do + before do + @action = @actions['create'] + end + it 'createタイプのアクションである' do + expect(@action.type).to eq 'create' + end + it 'type' do + expect(@action.item_name).to eq 'author' + end + end + describe 'updateに於いて' do + before do + @action = @actions['update'] + end + it 'updateタイプのアクションである' do + expect(@action.type).to eq 'update' + end + it 'type' do + expect(@action.item_name).to eq 'author' + end + end + describe 'destroyに於いて' do + before do + @action = @actions['destroy'] + end + it 'destroyタイプのアクションである' do + expect(@action.type).to eq 'destroy' + end + it 'type' do + expect(@action.item_name).to eq 'author' + end + end + end + + end + + describe 'モデルに於いて' do + before do + @my_manifest = @model.my_manifest + end + it 'サポート機能が動作している' do + expect(@my_manifest.model_name).to eq 'author' + expect(@my_manifest.classify).to eq @model + expect(@my_manifest.table_name).to eq 'authors' + end + + describe 'associationsに於いて' do + describe 'belongs_toに於いて' do + before do + @belongs_to = @my_manifest.associations.belongs_to + @names = [] + end + it 'これらのモデルに所属している' do + set_associations? @belongs_to, @names + end + end + describe 'has_manyに於いて' do + before do + @has_many = @model.my_manifest.associations.has_many + @names = ['scrolls', 'comics', 'stories', 'sheets', 'panels'] + end + it 'これらのモデルを所持している' do + set_associations? @has_many, @names + end + describe 'scrollsに於いて' do + before do + @mani = @has_many['scrolls'] + end + it 'マニフェストから設定を取り出している' do + # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'scroll' + expect(@mani.foreign_key).to eq 'author_id' + expect(@mani.through).to be nil + end + it 'サポート機能が動作している' do + # モデルを再現できている, 中間モデルフラグ + expect(@mani.through?).to be false + expect(@mani.model).to eq Scroll + end + end + describe 'comicsに於いて' do + before do + @mani = @has_many['comics'] + end + it 'マニフェストから設定を取り出している' do + # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'comic' + expect(@mani.foreign_key).to eq 'author_id' + expect(@mani.through).to be nil + end + it 'サポート機能が動作している' do + # モデルを再現できている, 中間モデルフラグ + expect(@mani.through?).to be false + expect(@mani.model).to eq Comic + end + end + describe 'storiesに於いて' do + before do + @mani = @has_many['stories'] + end + it 'マニフェストから設定を取り出している' do + # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'story' + expect(@mani.foreign_key).to eq 'author_id' + expect(@mani.through).to be nil + end + it 'サポート機能が動作している' do + # モデルを再現できている, 中間モデルフラグ + expect(@mani.through?).to be false + expect(@mani.model).to eq Story + end + end + describe 'sheetsに於いて' do + before do + @mani = @has_many['sheets'] + end + it 'マニフェストから設定を取り出している' do + # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'sheet' + expect(@mani.foreign_key).to eq 'author_id' + expect(@mani.through).to be nil + end + it 'サポート機能が動作している' do + # モデルを再現できている, 中間モデルフラグ + expect(@mani.through?).to be false + expect(@mani.model).to eq Sheet + end + end + describe 'panelsに於いて' do + before do + @mani = @has_many['panels'] + end + it 'マニフェストから設定を取り出している' do + # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている + expect(@mani.model_name).to eq 'panel' + expect(@mani.foreign_key).to eq 'author_id' + expect(@mani.through).to be nil + end + it 'サポート機能が動作している' do + # モデルを再現できている, 中間モデルフラグ + expect(@mani.through?).to be false + expect(@mani.model).to eq Panel + end + end + end + end + + describe 'attributesに於いて' do + before do + @attributes = @model.my_manifest.attributes + end + it 'これらのカラムを定義している' do + set_attributes? @attributes, + ['id', 'name', 'user_id', + 'created_at', 'updated_at'] + end + describe 'nameに於いて' do + before do + @attribute = @attributes['name'] + end + it 'textタイプである' do + expect(@attribute.type).to eq 'text' + end + end + describe 'author_idに於いて' do + before do + @attribute = @attributes['user_id'] + end + it 'numberタイプである' do + expect(@attribute.type).to eq 'number' + end + end + end + + end + +end