Created
April 23, 2009 21:43
-
-
Save btakita/100781 to your computer and use it in GitHub Desktop.
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
class Daemon | |
def initialize(run_now = true) | |
run if run_now | |
end | |
def run | |
raise "dont call me" | |
# loop do | |
# puts "running!" | |
# end | |
end | |
end | |
describe Daemon do | |
describe "#initialize" do | |
it "should run by default on start up" do | |
mock(Daemon).new(true) do |arg| | |
daemon = Daemon.allocate | |
mock(daemon).run.once | |
daemon.send(:initialize, arg) | |
daemon | |
end | |
Daemon.new(true) | |
end | |
it "should not run if false is the first argument" do | |
mock(Daemon).new(false) do |arg| | |
daemon = Daemon.allocate | |
dont_allow(daemon).run | |
daemon.send(:initialize, arg) | |
daemon | |
end | |
Daemon.new(false) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment