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

Version Path
cantango-core-0.1.9.3 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.9.2 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.9.1 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.9 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.8 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.7 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.6 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.5 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.4 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.3 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.2 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.1 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-core-0.1.0 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.9.4.7 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.9.4.6 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.9.4.5 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.9.4.3 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.9.4.2 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.9.4.1 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.9.4 lib/cantango/rspec/matchers/be_allowed_to.rb