Skip to content

@shageman /predicate_matchers.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
The problem of rspec predicate matchers
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
Something went wrong with that request. Please try again.