Skip to content

Commit

Permalink
Make test less hack-ish by using mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Nov 21, 2010
1 parent 132d9b5 commit 99774a1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions spec/server_spec.rb
Expand Up @@ -75,14 +75,11 @@
it "should raise an exception if boot timeout is exceeded" do
@slow_app = proc { |env| sleep(1); [200, {}, "Hello Slow Server!"] }

# HACK: Capybara::Server does Kernel#exit on timeout, which makes it difficult
# to test. This makes it easier.
TestableServer = Class.new(Capybara::Server) do
def exit; :timeout; end
end

Capybara.server_boot_timeout = 0.5
TestableServer.new(@slow_app).boot.should == :timeout
server = Capybara::Server.new(@slow_app)
server.stub(:exit).and_return(:timeout)
server.stub(:puts)
server.boot.should == :timeout
end

end

0 comments on commit 99774a1

Please sign in to comment.