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-0.9.3.2 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.9.5 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.9.4 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.9.3 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.9.2 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.9.1 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.9 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.8.1 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.8 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.7 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.6.2 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.6.1 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.6 lib/cantango/rspec/matchers/be_allowed_to.rb
cantango-0.8.5.1 lib/cantango/rspec/matchers/be_allowed_to.rb