Skip to content

Instantly share code, notes, and snippets.

@btakita
Created April 23, 2009 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btakita/100781 to your computer and use it in GitHub Desktop.
Save btakita/100781 to your computer and use it in GitHub Desktop.
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