Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 333015 - dev-ruby/mocha-0.9.2 broke on Ruby 1.8.7 due to compability patch for Ruby 1.9.2.
Summary: dev-ruby/mocha-0.9.2 broke on Ruby 1.8.7 due to compability patch for Ruby 1....
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-16 15:40 UTC by Thomas Nyman
Modified: 2010-08-22 06:15 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Example test case illustrating the problem. (example_test.rb,180 bytes, text/plain)
2010-08-16 15:42 UTC, Thomas Nyman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Nyman 2010-08-16 15:40:45 UTC
Trying to run rails unit tests using dev-ruby/mocha mockup library causes "NameError: uninitialized constant Mocha::Mockery::Mock". 

The culprit seems to be the mocha-0.9.8+ruby-1.9.2.patch added by the mocha ebuild. As far as I understand the problems seems to lie with the removal of the "require mocha/mock" line from /usr/lib/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/mockery.rb. Excerpt from patch below:

diff --git a/lib/mocha/mockery.rb b/lib/mocha/mockery.rb
index 6fd5e5a..3b847db 100644
--- a/lib/mocha/mockery.rb
+++ b/lib/mocha/mockery.rb
@@ -1,5 +1,4 @@
 require 'mocha/central'
-require 'mocha/mock'
 require 'mocha/names'
 require 'mocha/state_machine'
 require 'mocha/logger'


Reproducible: Always

Steps to Reproduce:
1. Emerge dev-lang/ruby-1.8.7_p249 and dev-ruby/mocha-0.9.8
2. Ensure ruby18 profile is selected with eselect ruby.
3. Run attached example test case: "ruby example_test.rb"
Actual Results:  
Running test fails with NameError.

Loaded suite example_test
Started
E
Finished in 0.000319 seconds.

  1) Error:
test_call_to_mock_causes_name_error(ExampleTest):
NameError: uninitialized constant Mocha::Mockery::Mock
    /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/mockery.rb:25:in `named_mock'
    /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/api.rb:43:in `mock'
    example_test.rb:8:in `test_call_to_mock_causes_name_error'
    /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `__send__'
    /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run'

1 tests, 0 assertions, 0 failures, 1 errors

Expected Results:  
Expected the tests to run successfully.

Loaded suite example_test
Started
.
Finished in 0.000321 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

As a workaround disabling the mocha-0.9.8+ruby-1.9.2 patch results in a working Mocha in Ruby 1.8.7.
Comment 1 Thomas Nyman 2010-08-16 15:42:35 UTC
Created attachment 243229 [details]
Example test case illustrating the problem.

Attached trivial test case using the Mocha library.
Comment 2 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-08-16 22:17:49 UTC
This is my fault for trusting upstream blindly.
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-08-16 22:41:41 UTC
Thanks for reporting, fixed with -r3.

And I'll write 100 times on the blackboard "don't export upstream patches when you can do the same with a sed".
Comment 4 Thomas Nyman 2010-08-17 06:31:32 UTC
Thank you for the quick response and fix.

However it seems that the SRC_URI in the ebuild was not updated to point to the new patch, resulting in emerge failure due to missing patchfile (mocha-0.9.8+ruby-1.9.2-r2.patch.bz2).

Downloaded patch manually to /usr/portage/distfiles as a workaround and mocha works like a charm now.