Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
143 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
require 'rake_ext' | ||
|
||
project( | ||
project \ | ||
name: "micon", | ||
gem: true, | ||
summary: "Silent killer of dependencies and configs", | ||
|
||
author: "Alexey Petrushin", | ||
homepage: "http://alexeypetrushin.github.com/micon" | ||
) | ||
homepage: "http://alexeypetrushin.github.com/micon" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'spec_helper' | ||
|
||
describe "Managed" do | ||
before{self.micon = Micon::Core.new} | ||
after{remove_constants :Tmp} | ||
|
||
it "scope" do | ||
class Tmp | ||
register_as :an_object | ||
end | ||
|
||
scope = micon.metadata[:an_object] | ||
initializer, dependencies = micon.metadata.initializers[:an_object] | ||
scope.should == :application | ||
initializer.call.should be_a(Tmp) | ||
end | ||
|
||
it "injection" do | ||
class Tmp | ||
inject object: :an_object | ||
|
||
class << self | ||
inject object: :an_object | ||
end | ||
end | ||
|
||
the_object = "An Object" | ||
micon.register(:an_object){the_object} | ||
|
||
Tmp.object.should == the_object | ||
Tmp.new.object.should == the_object | ||
end | ||
|
||
it "outjection" do | ||
class Tmp | ||
class << self | ||
inject object: :an_object | ||
end | ||
end | ||
|
||
the_object = "An Object" | ||
micon.register :an_object | ||
|
||
-> {Tmp.object}.should raise_error(/no initializer/) | ||
Tmp.object = the_object | ||
Tmp.object.should == the_object | ||
end | ||
|
||
it "empty?" do | ||
class Tmp | ||
register_as :an_object | ||
end | ||
|
||
micon.should be_empty | ||
micon[:an_object] | ||
micon.should_not be_empty | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'spec_helper' | ||
|
||
describe "Helpers" do | ||
before{self.micon = Micon::Core.new} | ||
after{remove_constants :Tmp} | ||
|
||
it "register_as" do | ||
class Tmp | ||
micon.should_receive :register do |name, &initializer| | ||
name.should == :an_object | ||
initializer.call.class.should == Tmp | ||
end | ||
|
||
register_as :an_object | ||
end | ||
end | ||
|
||
it "inject" do | ||
class Tmp | ||
inject :an_object | ||
end | ||
tmp = Tmp.new | ||
|
||
micon.should_receive(:[]).with :an_object | ||
tmp.an_object | ||
|
||
micon.should_receive(:[]=).with :an_object, 'An Object' | ||
tmp.an_object = 'An Object' | ||
|
||
micon.should_receive(:include?).with :an_object | ||
tmp.an_object? | ||
|
||
# Another form. | ||
class Tmp | ||
inject other: :other_object | ||
end | ||
micon.should_receive(:[]).with :other_object | ||
tmp.other | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.