add be_able_to matcher

This commit is contained in:
David Chelimsky
2010-04-13 21:02:39 +08:00
committed by Ryan Bates
parent 35c4864de4
commit cf49c5b9de
3 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
require "spec_helper"
describe "be_able_to" do
it "delegates to can?" do
object = Object.new
mock(object).can?(:read, 123) { true }
object.should be_able_to(:read, 123)
end
it "reports a nice failure message for should" do
object = Object.new
mock(object).can?(:read, 123) { false }
expect do
object.should be_able_to(:read, 123)
end.should raise_error('expected to be able to :read 123')
end
it "reports a nice failure message for should not" do
object = Object.new
mock(object).can?(:read, 123) { true }
expect do
object.should_not be_able_to(:read, 123)
end.should raise_error('expected not to be able to :read 123')
end
end