Sha256: bd5eb36257d54429fee323d9704ed3ea288b28da1f87b0ad53475ce1de57c77a
Contents?: true
Size: 1.77 KB
Versions: 17
Compression:
Stored size: 1.77 KB
Contents
require "spec_helper" describe Shamu::Security::PolicyRule do describe "#match?" do let( :klass ) { Class.new } let( :instance ) { klass.new } let( :rule ) do Shamu::Security::PolicyRule.new( [ :read, :write ], klass, :yes, nil ) end it "is true for matching action" do expect( rule ).to be_match :read, instance, nil end it "is false for unmatched action" do expect( rule ).not_to be_match :examine, instance, nil end it "is true for Class match" do expect( rule ).to be_match :read, klass, nil end it "is true for instance of Class match" do expect( rule ).to be_match :read, instance, nil end it "is true for instance match" do rule = Shamu::Security::PolicyRule.new( [ :read, :write ], instance, :yes, nil ) expect( rule ).to be_match :read, instance, nil end it "is false for Class mismatch" do expect( rule ).not_to be_match :read, Class.new, nil end it "is false for instance of Class mismatch" do expect( rule ).not_to be_match :read, Class.new.new, nil end it "is false for instance mismatch" do rule = Shamu::Security::PolicyRule.new( [ :read, :write ], instance, :yes, nil ) expect( rule ).not_to be_match :read, klass.new, nil end context "with block" do it "invokes block if present" do expect do |b| Shamu::Security::PolicyRule.new( [ :read, :write ], klass, :yes, b.to_proc ).match?( :read, instance, nil ) end.to yield_control end it "does not invoke block if resource is a Module" do expect do |b| Shamu::Security::PolicyRule.new( [ :read, :write ], klass, :yes, b.to_proc ).match?( :read, klass, nil ) end.not_to yield_control end end end end
Version data entries
17 entries across 17 versions & 1 rubygems