lib/pundit/rspec.rb in pundit-1.0.1 vs lib/pundit/rspec.rb in pundit-1.1.0

- old
+ new

@@ -5,27 +5,33 @@ module Matchers extend ::RSpec::Matchers::DSL matcher :permit do |user, record| match_proc = lambda do |policy| - @violating_permissions = permissions.find_all { |permission| not policy.new(user, record).public_send(permission) } + @violating_permissions = permissions.find_all do |permission| + not policy.new(user, record).public_send(permission) + end @violating_permissions.empty? end match_when_negated_proc = lambda do |policy| - @violating_permissions = permissions.find_all { |permission| policy.new(user, record).public_send(permission) } + @violating_permissions = permissions.find_all do |permission| + policy.new(user, record).public_send(permission) + end @violating_permissions.empty? end failure_message_proc = lambda do |policy| was_were = @violating_permissions.count > 1 ? "were" : "was" - "Expected #{policy} to grant #{permissions.to_sentence} on #{record} but #{@violating_permissions.to_sentence} #{was_were} not granted" + "Expected #{policy} to grant #{permissions.to_sentence} on \ + #{record} but #{@violating_permissions.to_sentence} #{was_were} not granted" end failure_message_when_negated_proc = lambda do |policy| was_were = @violating_permissions.count > 1 ? "were" : "was" - "Expected #{policy} not to grant #{permissions.to_sentence} on #{record} but #{@violating_permissions.to_sentence} #{was_were} granted" + "Expected #{policy} not to grant #{permissions.to_sentence} on \ + #{record} but #{@violating_permissions.to_sentence} #{was_were} granted" end if respond_to?(:match_when_negated) match(&match_proc) match_when_negated(&match_when_negated_proc) @@ -45,11 +51,11 @@ end end module DSL def permissions(*list, &block) - describe(list.to_sentence, :permissions => list, :caller => caller) { instance_eval(&block) } + describe(list.to_sentence, permissions: list, caller: caller) { instance_eval(&block) } end end module PolicyExampleGroup include Pundit::RSpec::Matchers @@ -63,16 +69,16 @@ end end RSpec.configure do |config| if RSpec::Core::Version::STRING.split(".").first.to_i >= 3 - config.include(Pundit::RSpec::PolicyExampleGroup, { - :type => :policy, - :file_path => /spec\/policies/, - }) + config.include(Pundit::RSpec::PolicyExampleGroup, + type: :policy, + file_path: %r{spec/policies} + ) else - config.include(Pundit::RSpec::PolicyExampleGroup, { - :type => :policy, - :example_group => { :file_path => /spec\/policies/ } - }) + config.include(Pundit::RSpec::PolicyExampleGroup, + type: :policy, + example_group: { file_path: %r{spec/policies} } + ) end end