Changeset 6635 for platform/tdiary/spec

Show
Ignore:
Timestamp:
02/13/08 18:42:11 (10 months ago)
Author:
hsbt
Message:

platform/tdiary/spec: merge from spec_with_rspec-fixture.

Location:
platform/tdiary/spec
Files:
7 modified

Legend:

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

    r4983 r6635  
    33 
    44describe "google_video plugin" do 
    5         def expected_html_snippet(options) 
    6                 doc_id = options[:doc_id] 
    7                 w = options[:width] 
    8                 h = options[:height] 
    9                 <<-EXPECTED 
    10    <object class="googlevideo" width="#{w}" height="#{h}"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=#{doc_id}&hl=en"></param 
    11    ><embed src="http://video.google.com/googleplayer.swf?docId=#{doc_id}&hl=en" type="application/x-shockwave-flash" width="#{w}" height="#{h}" 
    12    ></embed></object> 
    13                 EXPECTED 
    14         end 
    15  
    165        DUMMY_VIDEO_ID = 1234567890 
    176 
    18         before do 
    19                 @plugin = fake_plugin(:google_video) 
    20         end 
     7  with_fixtures [:width, :height] => :expected do 
     8    it 'should render :width x :height object tag' do |input, expected| 
     9      plugin = fake_plugin(:google_video) 
     10      snippet = plugin.google_video(DUMMY_VIDEO_ID, "#{input[:width]}x#{input[:height]}") 
     11      snippet.should == expected 
     12    end 
    2113 
    22         it "should render 425x320 object tag" do 
    23                 snippet = @plugin.google_video(DUMMY_VIDEO_ID) 
    24                 snippet.should == expected_html_snippet( 
    25                         :doc_id => DUMMY_VIDEO_ID, 
    26                         :width => 425, :height => 320) 
    27         end 
     14    filters({ 
     15      :expected => lambda {|val| 
     16        width, height = *val 
     17        doc_id = DUMMY_VIDEO_ID 
    2818 
    29         it "should render 212x160 object tag" do 
    30                 snippet = @plugin.google_video(DUMMY_VIDEO_ID, "212x160") 
    31                 snippet.should == expected_html_snippet( 
    32                         :doc_id => DUMMY_VIDEO_ID, 
    33                         :width => 212, :height => 160) 
    34         end 
     19       %|<object class="googlevideo" width="#{width}" height="#{height}"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=#{doc_id}&hl=en"></param><embed src="http://video.google.com/googleplayer.swf?docId=#{doc_id}&hl=en" type="application/x-shockwave-flash" width="#{width}" height="#{height}"></embed></object>| 
     20      }, 
     21    }) 
     22 
     23    set_fixtures([ 
     24      [ [212, 160] => [212, 160] ], 
     25      [ [425, 320] => [425, 320] ], 
     26    ]) 
     27  end 
    3528end 
  • platform/tdiary/spec/jdate_spec.rb

    r5402 r6635  
    44 
    55describe "jdate plugin" do 
    6         def setup_jdate_plugin(date) 
    7                 fake_plugin(:jdate) { |plugin| 
    8                         plugin.date = date 
    9                 } 
    10         end 
    116 
    12         describe "for monday" do 
    13                 before do 
    14                         @date = Time.parse('20080121'); 
    15                         @plugin = setup_jdate_plugin(@date) 
    16                 end 
     7        with_fixtures :date => :jwday do 
     8    def setup_jdate_plugin(date) 
     9      fake_plugin(:jdate) { |plugin| 
     10        plugin.date = date 
     11      } 
     12    end 
    1713 
    18                 it { @plugin.date.strftime("%J").should  == "月" } 
    19         end 
     14    filters({ 
     15      :date => lambda {|val| Time.parse(val) }, 
     16    }) 
    2017 
    21         describe "for tuesday" do 
    22                 before do 
    23                         @date = Time.parse('20080122'); 
    24                         @plugin = setup_jdate_plugin(@date) 
    25                 end 
     18    it ':jwday' do |date, jwday| 
     19      setup_jdate_plugin(date).date.strftime('%J').should == jwday 
     20    end 
    2621 
    27                 it { @plugin.date.strftime("%J").should  == "火" } 
    28         end 
    29  
    30         describe "for wednesday" do 
    31                 before do 
    32                         @date = Time.parse('20080123'); 
    33                         @plugin = setup_jdate_plugin(@date) 
    34                 end 
    35  
    36                 it { @plugin.date.strftime("%J").should  == "水" } 
    37         end 
    38  
    39         describe "for thursday" do 
    40                 before do 
    41                         @date = Time.parse('20080124'); 
    42                         @plugin = setup_jdate_plugin(@date) 
    43                 end 
    44  
    45                 it { @plugin.date.strftime("%J").should  == "木" } 
    46         end 
    47  
    48         describe "for friday" do 
    49                 before do 
    50                         @date = Time.parse('20080125'); 
    51                         @plugin = setup_jdate_plugin(@date) 
    52                 end 
    53  
    54                 it { @plugin.date.strftime("%J").should  == "金" } 
    55         end 
    56  
    57         describe "for saturday" do 
    58                 before do 
    59                         @date = Time.parse('20080126'); 
    60                         @plugin = setup_jdate_plugin(@date) 
    61                 end 
    62  
    63                 it { @plugin.date.strftime("%J").should  == "土" } 
    64         end 
    65  
    66         describe "for sunday" do 
    67                 before do 
    68                         @date = Time.parse('20080127'); 
    69                         @plugin = setup_jdate_plugin(@date) 
    70                 end 
    71  
    72                 it { @plugin.date.strftime("%J").should  == "日" } 
     22    set_fixtures([ 
     23      [ '20080121' => '月'], 
     24      [ '20080122' => '火'], 
     25      [ '20080123' => '水'], 
     26      [ '20080124' => '木'], 
     27      [ '20080125' => '金'], 
     28      [ '20080126' => '土'], 
     29      [ '20080127' => '日'], 
     30    ]) 
    7331        end 
    7432end 
     33 
  • platform/tdiary/spec/jmonth_spec.rb

    r5405 r6635  
    44 
    55describe "jmonth plugin" do 
    6         def setup_jmonth_plugin(date) 
    7                 fake_plugin(:jmonth) { |plugin| 
    8                         plugin.date = date 
    9                 } 
    10         end 
     6  with_fixtures :date => :jmonth do 
     7    def setup_jmonth_plugin(date) 
     8      fake_plugin(:jmonth) { |plugin| 
     9        plugin.date = date 
     10      } 
     11    end 
    1112 
    12         describe "in Janu" do 
    13                 before do 
    14                         @date = Time.parse('20070101'); 
    15                         @plugin = setup_jmonth_plugin(@date) 
    16                 end 
     13    filters({ 
     14      :date => lambda {|val| Time.parse(val) } 
     15    }) 
    1716 
    18                 it { @plugin.date.strftime("%i").should  == "睦月" } 
    19         end 
     17    it 'in :jmonth' do |date, jmonth| 
     18      setup_jmonth_plugin(date).date.strftime('%i').should == jmonth 
     19    end 
    2020 
    21         describe "in " do 
    22                 before do 
    23                         @date = Time.parse('20070201'); 
    24                         @plugin = setup_jmonth_plugin(@date) 
    25                 end 
    26  
    27                 it { @plugin.date.strftime("%i").should  == "如月" } 
    28         end 
    29  
    30         describe "in " do 
    31                 before do 
    32                         @date = Time.parse('20070301'); 
    33                         @plugin = setup_jmonth_plugin(@date) 
    34                 end 
    35  
    36                 it { @plugin.date.strftime("%i").should  == "弥生" } 
    37         end 
    38  
    39         describe "in Janu" do 
    40                 before do 
    41                         @date = Time.parse('20070401'); 
    42                         @plugin = setup_jmonth_plugin(@date) 
    43                 end 
    44  
    45                 it { @plugin.date.strftime("%i").should  == "卯月" } 
    46         end 
    47  
    48         describe "in " do 
    49                 before do 
    50                         @date = Time.parse('20070501'); 
    51                         @plugin = setup_jmonth_plugin(@date) 
    52                 end 
    53  
    54                 it { @plugin.date.strftime("%i").should  == "皐月" } 
    55         end 
    56  
    57         describe "in " do 
    58                 before do 
    59                         @date = Time.parse('20070601'); 
    60                         @plugin = setup_jmonth_plugin(@date) 
    61                 end 
    62  
    63                 it { @plugin.date.strftime("%i").should  == "水無月" } 
    64         end 
    65  
    66         describe "in Janu" do 
    67                 before do 
    68                         @date = Time.parse('20070701'); 
    69                         @plugin = setup_jmonth_plugin(@date) 
    70                 end 
    71  
    72                 it { @plugin.date.strftime("%i").should  == "文月" } 
    73         end 
    74  
    75         describe "in " do 
    76                 before do 
    77                         @date = Time.parse('20070801'); 
    78                         @plugin = setup_jmonth_plugin(@date) 
    79                 end 
    80  
    81                 it { @plugin.date.strftime("%i").should  == "葉月" } 
    82         end 
    83  
    84         describe "in " do 
    85                 before do 
    86                         @date = Time.parse('20070901'); 
    87                         @plugin = setup_jmonth_plugin(@date) 
    88                 end 
    89  
    90                 it { @plugin.date.strftime("%i").should  == "長月" } 
    91         end 
    92  
    93         describe "in Janu" do 
    94                 before do 
    95                         @date = Time.parse('20071001'); 
    96                         @plugin = setup_jmonth_plugin(@date) 
    97                 end 
    98  
    99                 it { @plugin.date.strftime("%i").should  == "神無月" } 
    100         end 
    101  
    102         describe "in " do 
    103                 before do 
    104                         @date = Time.parse('20071101'); 
    105                         @plugin = setup_jmonth_plugin(@date) 
    106                 end 
    107  
    108                 it { @plugin.date.strftime("%i").should  == "霜月" } 
    109         end 
    110  
    111         describe "in " do 
    112                 before do 
    113                         @date = Time.parse('20071201'); 
    114                         @plugin = setup_jmonth_plugin(@date) 
    115                 end 
    116  
    117                 it { @plugin.date.strftime("%i").should  == "師走" } 
    118         end 
     21    set_fixtures([ 
     22      [ '2007/01/01' => '睦月'] , 
     23      [ '2007/02/01' => '如月'] , 
     24      [ '2007/03/01' => '弥生'] , 
     25      [ '2007/04/01' => '卯月'] , 
     26      [ '2007/05/01' => '皐月'] , 
     27      [ '2007/06/01' => '水無月' ] , 
     28      [ '2007/07/01' => '文月'] , 
     29      [ '2007/08/01' => '葉月'] , 
     30      [ '2007/09/01' => '長月'] , 
     31      [ '2007/10/01' => '神無月'], 
     32      [ '2007/11/01' => '霜月'] , 
     33      [ '2007/12/01' => '師走'] , 
     34    ])  
     35  end 
    11936end 
  • platform/tdiary/spec/jyear_spec.rb

    r5516 r6635  
    44 
    55describe "jyear plugin" do 
    6         def setup_jyear_plugin(date) 
    7                 fake_plugin(:jyear) { |plugin| 
    8                         plugin.date = date 
    9                 } 
    10         end 
     6  with_fixtures :date => :jyear do 
     7    def setup_jyear_plugin(date) 
     8      fake_plugin(:jyear) { |plugin| 
     9        plugin.date = date 
     10      } 
     11    end 
    1112 
    12         describe "in 1925/01/01" do 
    13                 before do 
    14                         @date = Time.parse('19250101'); 
    15                         @plugin = setup_jyear_plugin(@date) 
    16                 end 
     13    it 'in :date' do |date, jyear| 
     14      setup_jyear_plugin(date).date.strftime('%K').should == jyear 
     15    end 
    1716 
    18                 it { @plugin.date.strftime("%K").should  == "昔々" } 
    19         end 
     17    filters({ 
     18      :date => lambda {|val| Time.parse(val) }, 
     19    }) 
    2020 
    21         describe "in 1926/12/25" do 
    22                 before do 
    23                         @date = Time.parse('19261225'); 
    24                         @plugin = setup_jyear_plugin(@date) 
    25                 end 
    26  
    27                 it { @plugin.date.strftime("%K").should  == "昭和元年" } 
    28         end 
    29  
    30         describe "in 1927/01/01" do 
    31                 before do 
    32                         @date = Time.parse('19270101'); 
    33                         @plugin = setup_jyear_plugin(@date) 
    34                 end 
    35  
    36                 it { @plugin.date.strftime("%K").should  == "昭和2" } 
    37         end 
    38  
    39         describe "in 1981/01/08" do 
    40                 before do 
    41                         @date = Time.parse('19890108'); 
    42                         @plugin = setup_jyear_plugin(@date) 
    43                 end 
    44  
    45                 it { @plugin.date.strftime("%K").should  == "平成元年" } 
    46         end 
    47  
    48         describe "in 1990/01/01" do 
    49                 before do 
    50                         @date = Time.parse('19900101'); 
    51                         @plugin = setup_jyear_plugin(@date) 
    52                 end 
    53  
    54                 it { @plugin.date.strftime("%K").should  == "平成2" } 
    55         end 
    56  
     21    set_fixtures([ 
     22      ['1925/01/01' => '昔々'], 
     23      ['1926/12/25' => '昭和元年'], 
     24      ['1927/01/01' => '昭和2' ], 
     25      ['1989/01/08' => '平成元年' ], 
     26      ['1990/01/01' => '平成2' ], 
     27    ]) 
     28  end 
    5729end 
  • platform/tdiary/spec/openid_spec.rb

    r5948 r6635  
    1111        end 
    1212 
    13  
    1413        describe "Hatena" do 
    1514                before do 
  • platform/tdiary/spec/spec_helper.rb

    r5409 r6635  
    11$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "plugin"))) 
     2require 'rubygems' 
     3require 'spec' 
     4require 'spec/fixture' 
    25require 'erb' 
    36 
  • platform/tdiary/spec/youtube_spec.rb

    r5344 r6635  
    55        DUMMY_YOUTUBE_VIDEO_ID = 1234567890 
    66 
    7         before do 
    8                 @cgi = CGIFake.new 
    9                 @plugin = fake_plugin(:youtube) 
    10         end 
     7  with_fixtures :user_agent => :expected do 
     8    it 'should render object tag in :user_agent' do |user_agent, expected| 
     9      cgi = CGIFake.new 
     10      plugin = fake_plugin(:youtube) 
     11      cgi.user_agent = user_agent 
     12      plugin.conf.cgi = cgi 
     13      plugin.youtube(DUMMY_YOUTUBE_VIDEO_ID).should == expected 
     14    end 
    1115 
    12         it "should render object tag in mobile agent" do 
    13                 @cgi.user_agent = "DoCoMo" 
    14                 @plugin.conf.cgi = @cgi 
    15                 snippet = @plugin.youtube(DUMMY_YOUTUBE_VIDEO_ID) 
    16                 snippet.should == %Q|<div class="youtube"><a href="http://www.youtube.com/watch?v=#{DUMMY_YOUTUBE_VIDEO_ID}">YouTube (#{DUMMY_YOUTUBE_VIDEO_ID})</a></div>| 
    17         end 
    18  
    19         it "should render object tag in iPhone/iPod" do 
    20                 @cgi.user_agent = "iPhone" 
    21                 @plugin.conf.cgi = @cgi 
    22                 snippet = @plugin.youtube(DUMMY_YOUTUBE_VIDEO_ID) 
    23                 snippet.should == %Q|<div class="youtube"><a href="youtube:#{DUMMY_YOUTUBE_VIDEO_ID}">YouTube (#{DUMMY_YOUTUBE_VIDEO_ID})</a></div>| 
    24         end 
    25  
    26         it "should render object tag" do 
    27                 @cgi.user_agent = "Mozilla" 
    28                 @plugin.conf.cgi = @cgi 
    29                 snippet = @plugin.youtube(DUMMY_YOUTUBE_VIDEO_ID) 
    30                 snippet.should == <<-TAG 
    31                 <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/#{DUMMY_YOUTUBE_VIDEO_ID}"></param><embed src="http://www.youtube.com/v/#{DUMMY_YOUTUBE_VIDEO_ID}" type="application/x-shockwave-flash" width="425" height="350"></embed></object> 
    32                 TAG 
    33         end 
     16    set_fixtures([ 
     17      ['DoCoMo'  =>  
     18          %|<div class="youtube"><a href="http://www.youtube.com/watch?v=#{DUMMY_YOUTUBE_VIDEO_ID}">YouTube (#{DUMMY_YOUTUBE_VIDEO_ID})</a></div>|  
     19      ], 
     20      ['iPhone'  =>  
     21          %|<div class="youtube"><a href="youtube:#{DUMMY_YOUTUBE_VIDEO_ID}">YouTube (#{DUMMY_YOUTUBE_VIDEO_ID})</a></div>| 
     22      ], 
     23      ["Mozilla" =>  
     24          %|\t\t<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/#{DUMMY_YOUTUBE_VIDEO_ID}"></param><embed src="http://www.youtube.com/v/#{DUMMY_YOUTUBE_VIDEO_ID}" type="application/x-shockwave-flash" width="425" height="350"></embed></object> 
     25| 
     26      ], 
     27    ]) 
     28  end 
    3429end 
    3530