Changeset 2940 for lang/ruby/ssb

Show
Ignore:
Timestamp:
12/09/07 17:11:51 (13 months ago)
Author:
lchin
Message:

lang/ruby/ssb: introduce flexmock for test mocks

Location:
lang/ruby/ssb/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/ssb/trunk/README

    r2324 r2940  
    1212 - lha (KDDI絵文字アーカイブ解凍) 
    1313 - dust (unit test) 
     14 - flexmock (unit test mocks) 
    1415 
    1516動作確認環境: 
     
    2425 - scrapi 1.2.0 (gem) 
    2526 - dust 0.1.6 (gem) 
    26  
     27 - flexmock 0.8.0 (gem) 
    2728 
    2829How to install: 
  • lang/ruby/ssb/trunk/test/filter_test.rb

    r2695 r2940  
    33require 'ssb/ktai_spec.rb' 
    44require 'ssb.rb' 
    5  
    6 class Term 
    7   def initialize(carrier) 
    8     @carrier = carrier 
    9   end 
    10    
    11   attr_reader :carrier 
    12   alias :get_carrier :carrier 
    13 end 
     5require 'flexmock/test_unit' 
    146 
    157unit_tests do 
    16   def conv(carrier, str) 
    17     SSB::Emoji.emoji_conv(Term.new(carrier), str) 
    18   end 
    19    
    208  test 'filter a tag' do 
    21     assert_equal( 
    22         SSB::Application.filter_html("<a href='/bar'>foo</a>", URI.parse('http://example.com/foo'), Term.new(SSB::KtaiSpec::CARRIER_DOCOMO), ''), 
    23         %Q{<a href=\"./?ssb_q=http%3A%2F%2Fexample.com%3A80%2Fbar\" target=\"_top\" >foo</a>} 
    24     ) 
     9    term = flexmock("term") 
     10    term.should_receive(:get_carrier).and_return(SSB::KtaiSpec::CARRIER_DOCOMO) 
     11    expected = %Q{<a href=\"./?ssb_q=http%3A%2F%2Fexample.com%3A80%2Fbar\" target=\"_top\" >foo</a>} 
     12    filtered = SSB::Application.filter_html("<a href='/bar'>foo</a>", URI.parse('http://example.com/foo'), term, '') 
     13    assert_equal(expected, filtered) 
    2514  end 
    2615end 
    27