OSDN Git Service

fix peta spec
[pettanr/pettanr.git] / spec / peta / template_spec.rb
index 7c51e06..9ec76e4 100644 (file)
@@ -9,33 +9,74 @@ describe SpeechBalloonTemplate do
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @circle = FactoryGirl.create :speech_balloon_template_circle_with_system_picture
+    @plain = FactoryGirl.create :speech_balloon_template_plain_with_system_picture
+    @square = FactoryGirl.create :speech_balloon_template_square_with_system_picture
+    @test = FactoryGirl.create :speech_balloon_template_test_with_system_picture
   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 'enable_listに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(SpeechBalloonTemplate.enable_list).to_not be_empty
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(SpeechBalloonTemplate).to receive(:enable?).and_return(false)
+      expect(SpeechBalloonTemplate.enable_list).to be_empty
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(@circle).to receive(:enable?).and_return(false)
+      expect(SpeechBalloonTemplate.enable_list.size).to eq 3
+    end
+    
+  end
+  
+  describe 'enable?に於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(SpeechBalloonTemplate).to receive(:template_manifest).and_return(nil)
+      expect(@circle.enable?).to be false
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@circle.enable?).to be true
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@test.enable?).to be false
+    end
+  end
+  
+  describe 'template_moduleに於いて' do
+    before do
     end
     
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@circle.template_module).to eq CircleSpeechBalloon
+      expect(@square.template_module).to eq SquareSpeechBalloon
+    end
   end
   
-  describe 'boostに於いて' do
+  describe 'template_path_nameに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@circle.template_path_name).to eq 'circle_speech_balloon'
+      expect(@square.template_path_name).to eq 'square_speech_balloon'
     end
   end
   
@@ -44,37 +85,76 @@ end
 describe LicenseGroup do
   include TemplateMacros
   before do
-    @admin =FactoryGirl.create :admin
+    @admin = FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @cc = FactoryGirl.create :license_group_cc
+    @pc = FactoryGirl.create :license_group_pc
+    @test = FactoryGirl.create :license_group_test
   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 'enable_listに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(LicenseGroup.enable_list).to_not be_empty
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(LicenseGroup).to receive(:enable?).and_return(false)
+      expect(LicenseGroup.enable_list).to be_empty
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(LicenseGroup.enable_list.size).to eq 2
     end
     
   end
   
-  describe 'boostに於いて' do
+  describe 'enable?に於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      allow(LicenseGroup).to receive(:template_manifest).and_return(nil)
+      expect(@cc.enable?).to be false
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@cc.enable?).to be true
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@test.enable?).to be false
+    end
+  end
+  
+  describe 'template_moduleに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@cc.template_module).to eq PettanrCreativeCommonsV30Licenses
+      expect(@pc.template_module).to eq PettanrPettanCommonsV01Licenses
+    end
+  end
+  
+  describe 'template_path_nameに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@cc.template_path_name).to eq 'pettanr_creative_commons_v30_licenses'
+      expect(@pc.template_path_name).to eq 'pettanr_pettan_commons_v01_licenses'
     end
   end
   
@@ -83,36 +163,75 @@ end
 describe WritingFormat do
   include TemplateMacros
   before do
-    @admin =FactoryGirl.create :admin
+    @admin = FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
     @author_yas =  @user_yas.author
+    
+    @test = FactoryGirl.create :writing_format_test_with_system_picture
+    @simple = FactoryGirl.create :writing_format_simple_format_with_system_picture
   end
   
   describe '生成メソッドに於いて' do
     before do
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ComicStory]
-      end
+  end
+  
+  describe 'enable_listに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(WritingFormat.enable_list).to_not be_empty
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ComicStory]
-      end
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(WritingFormat).to receive(:enable?).and_return(false)
+      expect(SpeechBalloonTemplate.enable_list).to be_empty
     end
     
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(@simple).to receive(:enable?).and_return(false)
+      expect(WritingFormat.enable_list.size).to eq 2
+    end
+    
+  end
+  
+  describe 'enable?に於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow(WritingFormat).to receive(:template_manifest).and_return(nil)
+      expect(@simple.enable?).to be false
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@simple.enable?).to be true
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      allow_any_instance_of(WritingFormat).to receive(:module_name).and_return('excluded')
+      expect(@test.enable?).to be false
+    end
+  end
+  
+  describe 'template_moduleに於いて' do
+    before do
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@simple.template_module).to eq PettanrSimpleFormat
+    end
   end
   
-  describe 'boostに於いて' do
+  describe 'template_path_nameに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
     it 'ブーストメッセージをリーフに伝搬する' do
+      expect(@simple.template_path_name).to eq 'pettanr_simple_format'
     end
   end