Changeset 5278 for platform/tdiary/spec

Show
Ignore:
Timestamp:
01/22/08 16:42:56 (10 months ago)
Author:
hsbt
Message:

platform/tdiary/spec/account_ad_spec.rb: add include_description_about_with.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/spec/account_ad_spec.rb

    r5178 r5278  
    11$:.unshift(File.dirname(__FILE__)) 
    22require 'spec_helper' 
     3require 'time' 
    34 
    45describe "account_ad plugin w/" do 
    5         def setup_account_ad_plugin(service, name) 
     6        def setup_account_ad_plugin(service, name, mode) 
    67                fake_plugin(:account_ad) { |plugin| 
    7                         plugin.mode = 'latest' 
     8                        plugin.mode = mode 
    89                        plugin.conf['account.service'] = service 
    910                        plugin.conf['account.name'] = name 
    1011                        plugin.conf['base_url'] = 'http://www.hsbt.org/diary/' 
     12                        plugin.date = Time.parse("20070120") 
    1113                } 
    1214        end 
    1315 
    14         describe "Hatena" do 
     16        describe "Hatena in day mode" do 
    1517                before do 
    16                         plugin = setup_account_ad_plugin('Hatena', 'hsbt') 
     18                        plugin = setup_account_ad_plugin('Hatena', 'hsbt', 'day') 
    1719                        @header_snippet = plugin.header_proc 
    1820                end 
     21 
     22                it { @header_snippet.should include_description_about_with( 
     23                                :permalink => 'http://www.hsbt.org/diary/?date=20070120')} 
    1924 
    2025                it { @header_snippet.should include_account_service_with( 
     
    2328                it { @header_snippet.should include_account_name_with( 
    2429                                :name => 'hsbt')} 
     30        end 
    2531 
     32        describe "Hatena in latest mode" do 
     33                before do 
     34                        plugin = setup_account_ad_plugin('Hatena', 'hsbt', 'latest') 
     35                        @header_snippet = plugin.header_proc 
     36                end 
     37                 
     38                it { @header_snippet.should include_description_about_with( 
     39                                :permalink => 'http://www.hsbt.org/diary/')} 
     40 
     41                it { @header_snippet.should include_account_service_with( 
     42                                :service => 'http://www.hatena.ne.jp/')} 
     43 
     44                it { @header_snippet.should include_account_name_with( 
     45                                :name => 'hsbt')}                
     46        end 
     47 
     48        def include_description_about_with(options) 
     49                msg = "include #{options[:permalink]}" 
     50                expected = %|<rdf:Description rdf:about="#{options[:permalink]}">| 
     51                        Spec::Matchers::SimpleMatcher.new(msg) do |actual| 
     52                        actual.include?(expected) 
     53                end 
    2654        end 
    2755