Skip to content

Commit

Permalink
fix warnings about expectations of :success? on nil
Browse files Browse the repository at this point in the history
It's not right to mock $?.success?, because $? can be nil at the
time the expectation is set, resulting in errors like:

    An expectation of :success? was set on nil. Called from /home/adam/.GIT/3rd-party/capistrano-unicorn/spec/config_spec.rb:36:in `block

Instead we simply ensure that $? is set to an appropriate value.

This may or may not fix the failures that some people have been seeing
(mentioned in sosedoff#70).
  • Loading branch information
Adam Spiers committed Sep 17, 2013
1 parent a4c7f49 commit 649ebde
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

it "should default to a sensible pid file when auto-detection failed" do
@configuration.should_receive(shell).with(/unicorn -c /).and_return('') do |cmd|
$?.should_receive(:success?).and_return(false)
`false` # Simulate failure by setting $?
end
@configuration.logger.stub(:important)
@configuration.fetch(:unicorn_pid).should == app_path + "/tmp/pids/unicorn.pid"
Expand All @@ -53,7 +53,7 @@
tmpfile = $~[1]
tmpfile.should include("tmp")
File.read(tmpfile).should include(%!config_file = "#{config_file}"!)
$?.should_receive(:success?).and_return(true)
`true` # Simulate success by setting $?
pid_file
end
@configuration.fetch(:unicorn_pid).should == pid_file
Expand Down

0 comments on commit 649ebde

Please sign in to comment.