Skip to content

Commit

Permalink
Renamed project to interface_enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonh committed Aug 13, 2012
1 parent 5e66d36 commit f831a5b
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 79 deletions.
10 changes: 5 additions & 5 deletions README.md
@@ -1,5 +1,5 @@
interface\_enforcer interface\_enforcement
=================== =====================


*WARNING* This software does not represent an opinion. It is not a call to *WARNING* This software does not represent an opinion. It is not a call to
do things a certain way. It is an exploration of the forces and concerns at do things a certain way. It is an exploration of the forces and concerns at
Expand Down Expand Up @@ -50,7 +50,7 @@ test (the test subject).
Demo Demo
---- ----


The file [demo/subscriber\_spec.rb](/sheldonh/interface_enforcer/tree/master/demo/subscriber_spec.rb) The file [demo/subscriber\_spec.rb](/sheldonh/interface_enforcement/tree/master/demo/subscriber_spec.rb)
demonstrates the risk present in isolated testing in a loosely typed language, demonstrates the risk present in isolated testing in a loosely typed language,
using a contrived example of an obvious mistake that nobody would make. What is using a contrived example of an obvious mistake that nobody would make. What is
being demonstrated is the mechanism of elective test interface enforcement, not being demonstrated is the mechanism of elective test interface enforcement, not
Expand All @@ -66,8 +66,8 @@ double that does not behave like the object it stands in for.


The PublisherInterface would be written by the author of the Publisher, and The PublisherInterface would be written by the author of the Publisher, and
would be used by the authors of both the Publisher and the subscriber. It is would be used by the authors of both the Publisher and the subscriber. It is
defined in terms of the TestInterface::Enforcer for readability, because the defined in terms of the InterfaceEnforcement::Enforcer for readability, because the
in situ use of TestInterface::Enforcer is more ugly. in situ use of InterfaceEnforcement::Enforcer is more ugly.


Background Background
---------- ----------
Expand Down
4 changes: 2 additions & 2 deletions demo/subscriber_spec.rb
Expand Up @@ -29,7 +29,7 @@ def gets
################ ################


require 'spec_helper' require 'spec_helper'
require 'test_interface' require 'interface_enforcement'


module PublisherInterface module PublisherInterface


Expand All @@ -41,7 +41,7 @@ module PublisherInterface
} }


def self.wrap(subject) def self.wrap(subject)
TestInterface::Interface.new(CONTRACT).proxy(subject) InterfaceEnforcement::Interface.new(CONTRACT).proxy(subject)
end end


end end
Expand Down
4 changes: 4 additions & 0 deletions lib/interface_enforcement.rb
@@ -0,0 +1,4 @@
require 'interface_enforcement/constraint'
require 'interface_enforcement/interface'
require 'interface_enforcement/method_contract'
require 'interface_enforcement/violation'
@@ -1,4 +1,4 @@
module TestInterface module InterfaceEnforcement


class AccessControl class AccessControl


Expand Down
@@ -1,7 +1,7 @@
require 'test_interface/enforcer' require 'interface_enforcement/enforcer'
require 'test_interface/violation' require 'interface_enforcement/violation'


module TestInterface module InterfaceEnforcement


class AliasedEnforcer < Enforcer class AliasedEnforcer < Enforcer


Expand Down
@@ -1,10 +1,10 @@
require 'test_interface/constraint/enumeration' require 'interface_enforcement/constraint/enumeration'
require 'test_interface/constraint/none' require 'interface_enforcement/constraint/none'
require 'test_interface/constraint/open' require 'interface_enforcement/constraint/open'
require 'test_interface/constraint/rule' require 'interface_enforcement/constraint/rule'
require 'test_interface/constraint/type' require 'interface_enforcement/constraint/type'


module TestInterface module InterfaceEnforcement


module Constraint module Constraint


Expand Down
@@ -1,4 +1,4 @@
module TestInterface module InterfaceEnforcement


module Constraint module Constraint


Expand Down
@@ -1,4 +1,4 @@
module TestInterface module InterfaceEnforcement


module Constraint module Constraint


Expand Down
@@ -1,4 +1,4 @@
module TestInterface module InterfaceEnforcement


module Constraint module Constraint


Expand Down
@@ -1,4 +1,4 @@
module TestInterface module InterfaceEnforcement


module Constraint module Constraint


Expand Down
@@ -1,4 +1,4 @@
module TestInterface module InterfaceEnforcement


module Constraint module Constraint


Expand Down
@@ -1,7 +1,7 @@
require 'test_interface/access_control' require 'interface_enforcement/access_control'
require 'test_interface/violation' require 'interface_enforcement/violation'


module TestInterface module InterfaceEnforcement


class Enforcer class Enforcer


Expand Down
@@ -1,7 +1,7 @@
require 'sender' require 'sender'
require 'test_interface/aliased_enforcer' require 'interface_enforcement/aliased_enforcer'


module TestInterface module InterfaceEnforcement


class Injector class Injector


Expand Down
@@ -1,8 +1,8 @@
require 'test_interface/injector' require 'interface_enforcement/injector'
require 'test_interface/method_contract' require 'interface_enforcement/method_contract'
require 'test_interface/proxy' require 'interface_enforcement/proxy'


module TestInterface module InterfaceEnforcement


class Interface class Interface


Expand All @@ -14,11 +14,11 @@ def initialize(contract)
end end


def proxy(subject) def proxy(subject)
TestInterface::Proxy.new(self, subject) InterfaceEnforcement::Proxy.new(self, subject)
end end


def inject(subject) def inject(subject)
TestInterface::Injector.new(self).inject(subject) InterfaceEnforcement::Injector.new(self).inject(subject)
end end


def method_contract(method) def method_contract(method)
Expand Down
@@ -1,6 +1,6 @@
require 'test_interface/constraint' require 'interface_enforcement/constraint'


module TestInterface module InterfaceEnforcement


class MethodContract class MethodContract


Expand Down
@@ -1,7 +1,7 @@
require 'sender' require 'sender'
require 'test_interface/enforcer' require 'interface_enforcement/enforcer'


module TestInterface module InterfaceEnforcement


class Proxy class Proxy


Expand Down
@@ -1,4 +1,4 @@
module TestInterface module InterfaceEnforcement


class Violation < RuntimeError; end class Violation < RuntimeError; end
class MethodViolation < Violation; end class MethodViolation < Violation; end
Expand Down
4 changes: 0 additions & 4 deletions lib/test_interface.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/spec_helper.rb
@@ -1,6 +1,6 @@
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')


require 'test_interface' require 'interface_enforcement'


Dir.glob(File.join(File.dirname(__FILE__), 'support', '**', '*.rb')).each do |f| Dir.glob(File.join(File.dirname(__FILE__), 'support', '**', '*.rb')).each do |f|
require f require f
Expand Down
6 changes: 3 additions & 3 deletions spec/support/rspec_sugar.rb
@@ -1,6 +1,6 @@
require 'test_interface' require 'interface_enforcement'


module TestInterface module InterfaceEnforcement
module RspecSugar module RspecSugar


class Enforcement class Enforcement
Expand All @@ -18,7 +18,7 @@ def inject(subject)
end end


def interface(contract) def interface(contract)
interface = TestInterface::Interface.new(contract) interface = InterfaceEnforcement::Interface.new(contract)
Enforcement.new(interface) Enforcement.new(interface)
end end
end end
Expand Down
6 changes: 3 additions & 3 deletions spec/test_interface/constraint_spec.rb
@@ -1,16 +1,16 @@
require 'spec_helper' require 'spec_helper'


describe TestInterface::Constraint do describe InterfaceEnforcement::Constraint do


describe ".build(specification, *strategies)" do describe ".build(specification, *strategies)" do


it "raises ArgumentError for an unknown strategy" do it "raises ArgumentError for an unknown strategy" do
expect { TestInterface::Constraint.build(String, :none, :rubbish, :any) } expect { InterfaceEnforcement::Constraint.build(String, :none, :rubbish, :any) }
.to raise_error ArgumentError, /unknown.*strategy/ .to raise_error ArgumentError, /unknown.*strategy/
end end


it "raises ArgumentError if all strategies gave up" do it "raises ArgumentError if all strategies gave up" do
expect { TestInterface::Constraint.build(:rubbish, :any) }.to raise_error ArgumentError, /all strategies gave up/ expect { InterfaceEnforcement::Constraint.build(:rubbish, :any) }.to raise_error ArgumentError, /all strategies gave up/
end end


end end
Expand Down
8 changes: 4 additions & 4 deletions spec/test_interface/injector_spec.rb
Expand Up @@ -30,9 +30,9 @@ def private_method
end end
end end


describe TestInterface::Injector do describe InterfaceEnforcement::Injector do


include TestInterface::RspecSugar include InterfaceEnforcement::RspecSugar


describe "method invocation" do describe "method invocation" do


Expand All @@ -43,10 +43,10 @@ def private_method
subject.get.should eq("new knowledge") subject.get.should eq("new knowledge")
end end


it "raises a TestInterface::MethodViolation if uncontracted" do it "raises a InterfaceEnforcement::MethodViolation if uncontracted" do
subject = Subject.new subject = Subject.new
interface(:set => :allowed).inject(subject) interface(:set => :allowed).inject(subject)
expect { subject.get }.to raise_error TestInterface::MethodViolation expect { subject.get }.to raise_error InterfaceEnforcement::MethodViolation
end end


context "nonexistent methods" do context "nonexistent methods" do
Expand Down

0 comments on commit f831a5b

Please sign in to comment.