leshill/resque_spec — pull request #79 by kyanny (2013-11-11 04:23:03+00:00)
Title: Show failure message with actual arguments

Some matchers of ResqueSpec shows expected arguments in failure message but not show actual arguments.
This change adds actual arguments in failure message to make debugging test with ResqueSpec more easier.

Sample code for this change is here. https://github.com/kyanny/resque_spec_test

Before this change, `have_queued` matcher shows these failure messages:

```
$ bundle exec rake spec
/Users/kyanny/.rbenv/versions/2.0.0-p247/bin/ruby -S rspec ./spec/app_spec.rb
Resque::Helpers will be gone with no replacement in Resque 2.0.0.

App
with different args (FAILED - 1)
with no args (FAILED - 2)

Failures:

1) App with different args
Failure/Error: Job.should have_queued('a', 'b', 'c')
expected that Job would have [a, b, c] queued
# ./spec/app_spec.rb:8:in `block (2 levels) in '

2) App with no args
Failure/Error: Job.should have_queued('a', 'b', 'c')
expected that Job would have [a, b, c] queued
# ./spec/app_spec.rb:13:in `block (2 levels) in '

Finished in 0.00171 seconds
2 examples, 2 failures

Failed examples:

rspec ./spec/app_spec.rb:6 # App with different args
rspec ./spec/app_spec.rb:11 # App with no args
/Users/kyanny/.rbenv/versions/2.0.0-p247/bin/ruby -S rspec ./spec/app_spec.rb failed
```

After this change, `have_queued` matcher shows more valuable failure messages: (see the difference in faillure message starts with **but actually ...**)

```
$ bundle exec rake spec
/Users/kyanny/.rbenv/versions/2.0.0-p247/bin/ruby -S rspec ./spec/app_spec.rb
Resque::Helpers will be gone with no replacement in Resque 2.0.0.

App
with different args (FAILED - 1)
with no args (FAILED - 2)

Failures:

1) App with different args
Failure/Error: Job.should have_queued('a', 'b', 'c')
expected that Job would have [a, b, c] queued but actually Job with [1, 2, 3]
# ./spec/app_spec.rb:8:in `block (2 levels) in '

2) App with no args
Failure/Error: Job.should have_queued('a', 'b', 'c')
expected that Job would have [a, b, c] queued but actually Job with [no args]
# ./spec/app_spec.rb:13:in `block (2 levels) in '

Finished in 0.00177 seconds
2 examples, 2 failures

Failed examples:

rspec ./spec/app_spec.rb:6 # App with different args
rspec ./spec/app_spec.rb:11 # App with no args
/Users/kyanny/.rbenv/versions/2.0.0-p247/bin/ruby -S rspec ./spec/app_spec.rb failed
```