Sha256: b4f2c945716f5ce2a9222fad621a3d5f97d11b62ab60f141d33b0409f81991d1

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

# http://solnic.eu/2011/01/14/custom-rspec-2-matchers.html


RSpec::Matchers.define :be_allowed_to do |action, objects|
  chain :with_options do |options|
    @options = options
  end
  
  match do |subject|
    @options ? subject.can?(action, objects, @options) : subject.can?(action, objects)
  end

  failure_message_for_should do |subject|
    "expected that #{subject} could a #{action} the #{objects}"
  end

  failure_message_for_should_not do |actual|
    "did not expect that #{subject} could a #{action} the #{objects}"
  end

  description do
    "be allowed to #{action} the #{objects}"
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-0.8.0 lib/cantango/rspec/matchers/be_allowed_to.rb