Created
March 8, 2012 03:40
-
-
Save shageman/1998462 to your computer and use it in GitHub Desktop.
The problem of rspec predicate matchers
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
require 'rspec/core' | |
class VeryImportantQuestions | |
def self.really?(answer) | |
answer == 'Yes. I am telling you.' | |
end | |
def self.really_really?(answer) | |
answer == 'Yes. I am telling you.' ? 42 : nil | |
end | |
end | |
describe "really?" do | |
context "using rspec predicate matchers" do | |
context "if someone is telling you" do | |
it "should be really really the case and return true" do | |
VeryImportantQuestions.really?('Yes. I am telling you.').should be_true | |
end | |
end | |
context "if someone is not sure" do | |
it "should return false" do | |
VeryImportantQuestions.really?('I am not sure.').should be_false | |
end | |
end | |
end | |
end | |
describe "really_really?" do | |
context "using rspec predicate matchers" do | |
context "if someone is telling you" do | |
it "should be really really the case and return true" do | |
VeryImportantQuestions.really_really?('Yes. I am telling you.').should be_true | |
end | |
end | |
context "if someone is not sure" do | |
it "should return false" do | |
VeryImportantQuestions.really_really?('I am not sure.').should be_false | |
end | |
end | |
end | |
context "spec'ing the actual output of the method fails" do | |
context "if someone is telling you" do | |
it "should be really really the case and return true" do | |
VeryImportantQuestions.really_really?('Yes. I am telling you.').should == true | |
end | |
end | |
context "if someone is not sure" do | |
it "should return false" do | |
VeryImportantQuestions.really_really?('I am not sure.').should == false | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment