Skip to content

Instantly share code, notes, and snippets.

@lithtle
Created June 26, 2012 09:12
Show Gist options
  • Save lithtle/2994589 to your computer and use it in GitHub Desktop.
Save lithtle/2994589 to your computer and use it in GitHub Desktop.
rspec の練習
http://d.hatena.ne.jp/t-wada/20100228/p1 より
#! /usr/bin/ruby
# -*- coding:utf-8 -*-
class MessageFilter
def initialize(word)
@word = word
end
def detect?(text)
text.include?(@word)
end
end
#! /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