Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Commit

Permalink
defining
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Sep 2, 2010
1 parent 031a3ba commit 55c83b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/extra/extra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ module Extra
class Extra
include Candy::Piece

class << self
alias_method :'!', :new
end

def self.source opts={}
opts[:host] ||= "localhost"
Candy.host = opts[:host]
opts[:port] ||= 27017
Candy.port = opts[:port]
end

end
end
9 changes: 8 additions & 1 deletion spec/extra_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@

describe "#source" do
it "should exist" do
Extra::Extra.source
Extra::Extra.respond_to?(:source).should == true
end

it "should set Candy.host and Candy.port" do
Candy.should_receive(:host=).with("localhost")
Candy.should_receive(:port=).with(1337)
Extra::Extra.source :host => "localhost", :port => 1337
end
end

describe "self#!" do
it "should call #new" do
#this doesn't work. ideas?
#Extra::Extra.should_receive(:new)
#Extra::Extra::!
end
end
end

0 comments on commit 55c83b1

Please sign in to comment.