Skip to content

Commit

Permalink
Add basic specs for respond_to, match and == matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 28, 2013
1 parent 9e1caeb commit e4d9f76
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions spec/matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,53 @@
}.to raise_error(Exception)
end
end

describe "respond_to" do
it "matches if actual responds to sym" do
expect("foo").to respond_to(:upcase)
end

it "does not match if actual does not respond to sym" do
expect(Object.new).to_not respond_to(:upcase)
end

it "fails if actual does not respond to sym" do
expect {
expect(Object.new).to respond_to(:upcase)
}.to raise_error(Exception)
end
end

describe "match" do
it "matches if actual matches expected" do
expect("foobar").to match(/ar/)
expect("foobar").to match("oob")
end

it "does not match if actual does not match expected" do
expect("foobar").to_not match(/baz/)
expect("foobar").to_not match("woosh")
end

it "fails unless matcher matches" do
expect {
exprct("hello").to match(/world/)
}.to raise_error(Exception)
end
end

describe "operator ==" do
it "matches if actual == expected" do
"hello".should == "hello"
end

it "does not match when actual does not == expected" do
"hello".should_not == "world"
end

it "fails unless matcher matches" do
expect {
"hello".should == "world"
}.to raise_error(Exception)
end
end

0 comments on commit e4d9f76

Please sign in to comment.