NameError: undefined local variable or method `stub'

Please find the text as below from my terminal window.

devtaa:rails chetanm$ rake test --trace
(in /Users/chetanm/workspace/Mortar/Labs/RnD/rails)
** Invoke test (first_time)
** Execute test
(in /Users/chetanm/workspace/Mortar/Labs/RnD/rails/activesupport)
rake aborted!
Malformed version number string 3.0.pre
/Users/chetanm/workspace/Mortar/Labs/RnD/rails/activesupport/Rakefile:
51
(See full trace by running task with --trace)
(in /Users/chetanm/workspace/Mortar/Labs/RnD/rails/actionpack)
rake aborted!
Malformed version number string 3.0.pre
/Users/chetanm/workspace/Mortar/Labs/RnD/rails/actionpack/Rakefile:106
(See full trace by running task with --trace)
(in /Users/chetanm/workspace/Mortar/Labs/RnD/rails/actionmailer)
rake aborted!
Malformed version number string 3.0.pre
/Users/chetanm/workspace/Mortar/Labs/RnD/rails/actionmailer/Rakefile:
56
(See full trace by running task with --trace)
(in /Users/chetanm/workspace/Mortar/Labs/RnD/rails/activemodel)
/usr/local/bin/ruby -I"/Users/chetanm/workspace/Mortar/Labs/RnD/rails/
activemodel/lib" -I"/Users/chetanm/workspace/Mortar/Labs/RnD/rails/
activemodel/test" "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/
rake/rake_test_loader.rb" "test/cases/naming_test.rb" "test/cases/
observing_test.rb" "test/cases/serializeration/
json_serialization_test.rb" "test/cases/serializeration/
xml_serialization_test.rb" "test/cases/state_machine/event_test.rb"
"test/cases/state_machine/machine_test.rb" "test/cases/state_machine/
state_test.rb" "test/cases/state_machine/state_transition_test.rb"
"test/cases/state_machine_test.rb" "test/cases/validations/
acceptance_validation_test.rb" "test/cases/validations/
conditional_validation_test.rb" "test/cases/validations/
confirmation_validation_test.rb" "test/cases/validations/
exclusion_validation_test.rb" "test/cases/validations/
format_validation_test.rb" "test/cases/validations/
i18n_generate_message_validation_test.rb" "test/cases/validations/
i18n_validation_test.rb" "test/cases/validations/
inclusion_validation_test.rb" "test/cases/validations/
length_validation_test.rb" "test/cases/validations/
numericality_validation_test.rb" "test/cases/validations/
presence_validation_test.rb" "test/cases/validations_test.rb"
Loaded suite /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/
rake_test_loader
Started
........................EE..................................EEEE....EE..EE..EE..EE..EE..EE..EEEE..EE..E..EE..EE..EE....................................................................E........EEE.................EEEEEEE.EE...............EEEEE..........EEEEEE.EEE...............................
Finished in 0.793663 seconds.

  1) Error:
test_should_return_the_state_of_the_first_matching_transition_it_finds
(EventBeingFiredTest):
NameError: undefined local variable or method `stub' for
#<EventBeingFiredTest:0x19c9590>
    ./test/cases/state_machine/event_test.rb:44:in
`test_should_return_the_state_of_the_first_matching_transition_it_finds'
    /Users/chetanm/workspace/Mortar/Labs/RnD/rails/activemodel/test/
cases/../../lib/../../activesupport/lib/active_support/testing/
setup_and_teardown.rb:62:in `__send__'
    /Users/chetanm/workspace/Mortar/Labs/RnD/rails/activemodel/test/
cases/../../lib/../../activesupport/lib/active_support/testing/
setup_and_teardown.rb:62:in `run'

  2) Error:
test_should_create_StateTransitions(EventTest):
NoMethodError: undefined method `expects' for
ActiveModel::StateMachine::StateTransition:Class

___________________ some text is cut to keep this message short

Iirc you have to update RubyGems to accept those weird version
strings. A warning would be nice though, or a normal version string…

Eloy

My first guess on this one would be that you don't have the current mocha gem installed.

Your other issue can be, as Eloy said, solved by updating to latest RubyGems.

Potentially helpful resources:

http://guides.rubyonrails.org/contributing_to_rails.html
http://wiki.railsbridge.org/projects/railsbridge/wiki/Pre-flight_Checklist

Also the #rails-contrib channel on Freenode IRC can usually get you pretty quick help for this sort of thing.

Mike

Thanks for your reply guys!

I installed mocha as suggested by Mike.

- Chetan.