Created
June 26, 2012 09:12
-
-
Save lithtle/2994589 to your computer and use it in GitHub Desktop.
rspec 練習 (http://d.hatena.ne.jp/t-wada/20100228/p1 より)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rspec の練習 | |
http://d.hatena.ne.jp/t-wada/20100228/p1 より |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
# -*- coding:utf-8 -*- | |
class MessageFilter | |
def initialize(word) | |
@word = word | |
end | |
def detect?(text) | |
text.include?(@word) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby -Ku | |
# -*- coding:utf-8 -*- | |
require "rubygems" | |
require "rspec" | |
require "message_filter" | |
describe MessageFilter, "with argument 'foo'" do | |
subject { MessageFilter.new("foo") } | |
it { should be_detect("hello from foo") } | |
it { should_not be_detect("hello, world") } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment