Skip to content

Instantly share code, notes, and snippets.

@ohta-rh
Created May 9, 2012 08:15
Show Gist options
  • Select an option

  • Save ohta-rh/2642895 to your computer and use it in GitHub Desktop.

Select an option

Save ohta-rh/2642895 to your computer and use it in GitHub Desktop.
Rspec sample
#sample code
class Hoge
def say(message=nil)
message ||= "hoge"
return message
end
end
#rspec
describe Hoge do
describe "#say" do
context "when argument is nil" do
subject { Hoge.new }
its(:say) { should == 'hoge' }
end
context "when argument is 'fuga'" do
subject{
hoge = Hoge.new
hoge.say('fuga')
}
it { should == 'fuga' }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment