Sha256: d98b4d5c2d41f9f3183c7c6708d8a18746a151d7fd7680ac41a79c346d06feac
Contents?: true
Size: 653 Bytes
Versions: 34
Compression:
Stored size: 653 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 #{action} the #{objects} #{subject.send :rules}} end failure_message_for_should_not do |actual| %{did not expect that #{subject} could #{action} the #{objects} #{subject.send :rules}} end description do "be allowed to #{action} the #{objects}" end end
Version data entries
34 entries across 34 versions & 2 rubygems