When trying to run Chris samples I get error: /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/smart_test_case.rb:3: uninitialized constant Test (NameError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' from /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/mocha.rb:1 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:33:in `require'' from spam_cannon_test.rb:2 So i figure there might be some problem with the mocha gem and its dependency upon Test::Unit, so I tried installing from SVN, but there doesn''t seems to be a install/setup.rb there. All, thats is there is, init.rb, which is for rails plugin. I am trying to use mocha for testing a three tier networking app. That accepts connections from clients, and in turn requests some external servers and returns back the data to the client. In between it does, some caching, session validation and stuff. I am having a hard time, unit testing this app, so though I can give mocha spin. -- gnufied ----------- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary.
On 15/12/06, hemant <gethemant at gmail.com> wrote:> When trying to run Chris samples I get error:What exactly is "Chris samples"? Sorry I''m probably missing something obvious.> /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/smart_test_case.rb:3: > uninitialized constant Test (NameError) > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require'' > from /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/mocha.rb:1 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:33:in > `require'' > from spam_cannon_test.rb:2Can you give a small snippet of code which generates this exception? It''s hard to give more help without a context. However, the most likely issue is that you need to require ''test/unit'' before you require ''mocha'' to use the 0.3.2 gem.> So i figure there might be some problem with the mocha gem and its > dependency upon Test::Unit, so I tried installing from SVN, but there > doesn''t seems to be a install/setup.rb there.There is a run-time dependency on Test::Unit. Do you specifically not want to use Test::Unit? If not, what test framework are you using? There is no specific mechanism (install.rb/setup.rb) to install Mocha as a library. You can checkout from svn into a lib directory within your application if you want. Otherwise it''s probably simpler to use the gem or the Rails plugin.> All, thats is there is, init.rb, which is for rails plugin.You are correct - init.rb is for the Rails plugin.> I am trying to use mocha for testing a three tier networking app. That > accepts connections from clients, and in turn requests some external > servers and returns back the data to the client. In between it does, > some caching, session validation and stuff. > > I am having a hard time, unit testing this app, so though I can give mocha spin.I hope you get it working and that it helps you with your unit testing. -- James. http://blog.floehopper.org
On 12/15/06, James Mead <jamesmead44 at gmail.com> wrote:> On 15/12/06, hemant <gethemant at gmail.com> wrote: > > When trying to run Chris samples I get error: > > What exactly is "Chris samples"? Sorry I''m probably missing something obvious.No, Sorry for being a little vague: I meant this: http://errtheblog.com/post/40> > > /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/smart_test_case.rb:3: > > uninitialized constant Test (NameError) > > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `require'' > > from /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/mocha.rb:1 > > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:33:in > > `require'' > > from spam_cannon_test.rb:2 > > Can you give a small snippet of code which generates this exception? > It''s hard to give more help without a context. However, the most > likely issue is that you need to require ''test/unit'' before you > require ''mocha'' to use the 0.3.2 gem.I ran his code verbatim, to get a feel, how mocha works outside rails.> > > So i figure there might be some problem with the mocha gem and its > > dependency upon Test::Unit, so I tried installing from SVN, but there > > doesn''t seems to be a install/setup.rb there. > > There is a run-time dependency on Test::Unit. Do you specifically not > want to use Test::Unit? If not, what test framework are you using?Hell no, I want to use Test::Unit.> There is no specific mechanism (install.rb/setup.rb) to install Mocha > as a library. You can checkout from svn into a lib directory within > your application if you want. Otherwise it''s probably simpler to use > the gem or the Rails plugin. >Ok.... this not such a big problem. I solved it using $.unshift trick.> > > I am trying to use mocha for testing a three tier networking app. That > > accepts connections from clients, and in turn requests some external > > servers and returns back the data to the client. In between it does, > > some caching, session validation and stuff. > > > > I am having a hard time, unit testing this app, so though I can give mocha spin. > > I hope you get it working and that it helps you with your unit testing.Thanks -- gnufied ----------- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary.
I''m glad you got it working. There are some examples on the Mocha website which might be useful... http://mocha.rubyforge.org/examples/mocha.html http://mocha.rubyforge.org/examples/stubba.html http://mocha.rubyforge.org/examples/misc.html -- James. http://blog.floehopper.org