#85 open
Tom Macklin

failed expectation not flunking spec

Reported by Tom Macklin | December 29th, 2011 @ 04:51 PM

Ruby: MRI 1.9.2p290
mocha: 0.10.0
tests: minitest/spec

I have (essentially) the following tests that is are not failing. Both are simplified a bit.

require 'mocha'
require 'minitest/spec'
require 'minitest/autorun'
require 'myapp'

describe "My App" do

include Mocha::API

it "implements the 'retr' command" do

 @svr.expects(:params_and_cmd_from_client).returns("cmd_retr", "somefile.txt") 
 @svr.set_thread_var(:socket, mock(:gets => "retr", :closed? => true))
 @svr.expects(:this_method_doesnt_exist)
 @svr.client_loop

end

it "does something else" do

th = mock
th.expects(:doesnt_get_called_ever)
@svr.do_something_with_th(th)

end

end

These tests don't fail when the test runs, event though the last expectation is never met.

I have been a long time mocha user, but I switched to minitest/spec only recently (from test/spec).

Apologies if I am overlooking something in the docs.

Thanks for mocha!

Comments and changes to this ticket

  • James Mead

    James Mead December 29th, 2011 @ 10:08 PM

    • State changed from “new” to “open”

    Hi Tom. Thanks for reporting this. Can you tell me what version of MiniTest you are using? Is it the version built-in to Ruby v1.9.2 or are you using it as a gem? Could you do me a favour and run the tests with the following environment variable set and post the output here? Thanks, James.

    MOCHA_OPTIONS=debug
    
  • Tom Macklin

    Tom Macklin January 3rd, 2012 @ 02:56 PM

    Sorry for the delay, I've been unplugged for the holidays. I am pretty sure I am using the built-in minitest/spec with MRI 1.9.2 as I am never bringing in the minitest-spec gem explicitly. That said, I do have the minitest-spec gem loaded (why? I am not sure).

    I exported the variable:

    tomm$ set |grep MOCHA
    MOCHA_OPTIONS=debug

    Here is the output:

    tomm$ rake test (in /Users/tomm/projects/gateway) Loaded suite /usr/local/lib/ruby/1.9.1/rake/rake_test_loader
    Started
    ..........................S........ Finished in 0.124953 seconds.

    1) Skipped: (GatewaySpec) [test/gateway_test.rb:101]: Reevaluate the merit of puking in this condition.

    35 tests, 32 assertions, 0 failures, 0 errors, 1 skips

    Test run options: --seed 14031

    Doesn't seem too helpful though. The skipped test isn't relevant, I just included it for completeness sake.

  • James Mead

    James Mead January 24th, 2012 @ 07:52 PM

    Sorry for the slow response. Can you try using the following command line :-

    MOCHA_OPTIONS=debug rake test
    

    And paste the output here. Also can you see whether the latest version of Mocha v0.10.3 fixes your problem?

    Thanks, James.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

A mocking & stubbing library for Ruby.

* <a href="http://github.com/floehopper/mocha">GitHub repository</a>
* <a href="http://mocha.rubyforge.org">Documentation</a>
* <a href="http://groups.google.com/group/mocha-developer">Mailing List</a>

People watching this ticket

Tags

Pages