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
18 changed files
with
590 additions
and
22 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
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
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,55 @@ | ||
require "#{File.dirname(__FILE__)}/../helpers.rb" | ||
|
||
describe "Object#cache_method_missing" do | ||
|
||
before do | ||
class A; end | ||
end | ||
|
||
after do | ||
Object.instance_eval { remove_const(:A) if const_defined?(:A) } | ||
end | ||
|
||
it "defines the missing method" do | ||
A.module_eval do | ||
def method_missing(name, *args) | ||
cache_method_missing name, "'hi'", *args | ||
end | ||
end | ||
A.new.bar | ||
A.new.should.respond_to :bar | ||
end | ||
|
||
it "passes along the args" do | ||
A.module_eval do | ||
def method_missing(name, *args, &block) | ||
cache_method_missing name, "args.join('-')", *args | ||
end | ||
end | ||
|
||
A.new.bar(1, 2, 3).should == "1-2-3" | ||
end | ||
|
||
it "passes along the block" do | ||
A.module_eval do | ||
def method_missing(name, *args, &block) | ||
cache_method_missing name, "block.call", *args, &block | ||
end | ||
end | ||
|
||
A.new.bar { 'bye' }.should == 'bye' | ||
end | ||
|
||
end | ||
|
||
describe "Object#instance_exec" do | ||
|
||
before do | ||
@block = lambda { |guy| "Howdy, #{guy}!" } | ||
end | ||
|
||
it "works like instance_eval, but it takes args and gives them to the block" do | ||
instance_exec( "Steve", &@block ).should == "Howdy, Steve!" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require "#{File.dirname(__FILE__)}/../helpers.rb" | ||
|
||
describe "Waves::Ext::String" do | ||
it "defines / as syntactic sugar for File.join" do | ||
( "lib" / "utilities" ).should == File.join( "lib", "utilities" ) | ||
( "lib" / :utilities ).should == File.join( "lib", "utilities" ) | ||
( "lib" / 3 ).should == File.join( "lib", "3" ) | ||
end | ||
end | ||
|
||
describe "A monkeypatch to Symbol" do | ||
|
||
it "defines / as syntactic sugar for File.join" do | ||
( :lib / :utilities ).should == File.join( "lib", "utilities") | ||
end | ||
|
||
end | ||
|
||
describe "Waves::Ext::Hash" do | ||
|
||
it "adds a non-destructive method for converting all hash keys to strings" do | ||
h = { :a => 1, 'b' => 2, 3 => 3} | ||
h.stringify_keys.should == { 'a' => 1, 'b' => 2, '3' => 3} | ||
h.should == { :a => 1, 'b' => 2, 3 => 3} | ||
end | ||
|
||
it "adds a destructive method for converting hash keys to symbols" do | ||
h = { "two" => 2, :three => 3} | ||
h.symbolize_keys! | ||
h.should == { :two => 2, :three => 3 } | ||
end | ||
|
||
end | ||
|
||
describe "Waves::Ext::Integer" do | ||
|
||
it "has an absolutely pedantic amount of helpers" do | ||
1.kilobytes.should == "1_024".to_i | ||
1.megabytes.should == "1_048_576".to_i | ||
1.gigabytes.should == "1_073_741_824".to_i | ||
1.terabytes.should == "1_099_511_627_776".to_i | ||
1.petabytes.should == "1_125_899_906_842_624".to_i | ||
1.exabytes.should == "1_152_921_504_606_846_976".to_i | ||
1.zettabytes.should == "1_180_591_620_717_411_303_424".to_i | ||
1.yottabytes.should == "1_208_925_819_614_629_174_706_176".to_i | ||
end | ||
|
||
end | ||
|
||
describe "Waves::Ext::Module" do | ||
|
||
before do | ||
module Eenie; module Meenie; module Miney; end; end ; end | ||
end | ||
|
||
it "defines a basename method" do | ||
Eenie::Meenie.basename.should == "Meenie" | ||
Eenie::Meenie::Miney.basename.should == "Miney" | ||
end | ||
|
||
it "defines [] for easy access to namespaced constants" do | ||
Eenie[:Meenie].should == Eenie::Meenie | ||
end | ||
|
||
it "defines a method for obtaining the outermost constant name" do | ||
Eenie::Meenie::Miney.rootname.should == "Eenie" | ||
end | ||
|
||
it "defines a method for obtaining the outermost constant" do | ||
Eenie::Meenie::Miney.root.should == Eenie | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ | |
alias_method :specification, :describe | ||
alias_method :feature, :it | ||
end | ||
|
||
Bacon.summary_on_exit |
Oops, something went wrong.