Skip to content

Instantly share code, notes, and snippets.

@sheldonh
Created August 14, 2012 11:54
Show Gist options
  • Select an option

  • Save sheldonh/3348651 to your computer and use it in GitHub Desktop.

Select an option

Save sheldonh/3348651 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe InterfaceEnforcement::Constraint::Type do
context "for a class" do
subject { InterfaceEnforcement::Constraint::Type.new(Set) }
it 'allows the class' do
subject.allows?(Set.new).should be_true
end
it 'allows its subclasses' do
subject.allows?(SortedSet.new).should be_true
end
it 'does not allow its ancestors' do
subject.allows?(Object.new).should be_false
end
it 'does not allow unrelated classes' do
subject.allows?(String.new).should be_false
end
end
context "for a module" do
subject { InterfaceEnforcement::Constraint::Type.new(Enumerable) }
it 'allows objects that include the module' do
subject.allows?(Array.new).should be_true
end
it 'does not allow objects that do not include the module' do
subject.allows?(Object.new).should be_false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment