From jamesmead44 at gmail.com Fri Feb 1 08:03:46 2008 From: jamesmead44 at gmail.com (James Mead) Date: Fri, 1 Feb 2008 13:03:46 +0000 Subject: [mocha-developer] Proxies In-Reply-To: <6a2b4fd00801021255t3c1e792v9c8cfece685e78c9@mail.gmail.com> References: <6a2b4fd00801021255t3c1e792v9c8cfece685e78c9@mail.gmail.com> Message-ID: <1db558f00802010503t122a72b5k8d145926cdfcc79a@mail.gmail.com> On 02/01/2008, Duncan Beevers wrote: > > I really like the idea of Mock Proxies as explained in Brian Takita's post > here: > http://pivots.pivotallabs.com/users/brian/blog/articles/352-introducing-rr > > I posted to this list eariler with an incomplete implementation of > .stops_mocking in the thread "Mocking Time, delegating to original > object." The Mock Proxy pattern would make this simpler. > > Proxy(User).expects(:find).with(99) # Sets expectation, forwards > method invocation to original class > User.expects(:find).with(99).returns(nil).then.proxies # Canned > response, then forwards successive invocations to original class. > > Most of this is just my desire to be lazy and not actually have to > unit-test *trivial* methods explicitly. I also like the idea of using > the Mock Proxy to exercise the behavior of simple private instance > methods of my class which are kind of a pain to test currently, which > leads to my not making anything private. > I've taken the liberty of adding this as a feature request [1] on rubyforge. -- James. http://blog.floehopper.org http://tumble.floehopper.org [1] http://rubyforge.org/tracker/index.php?func=detail&aid=17695&group_id=1917&atid=7480 From duncanbeevers at gmail.com Fri Feb 1 15:05:26 2008 From: duncanbeevers at gmail.com (Duncan Beevers) Date: Fri, 1 Feb 2008 12:05:26 -0800 Subject: [mocha-developer] Proxies In-Reply-To: <1db558f00802010503t122a72b5k8d145926cdfcc79a@mail.gmail.com> References: <6a2b4fd00801021255t3c1e792v9c8cfece685e78c9@mail.gmail.com> <1db558f00802010503t122a72b5k8d145926cdfcc79a@mail.gmail.com> Message-ID: <6a2b4fd00802011205r2e4410dbk16ac600753249fa6@mail.gmail.com> Awesome. Thanks James. On Feb 1, 2008 5:03 AM, James Mead wrote: > On 02/01/2008, Duncan Beevers wrote: > > > > I really like the idea of Mock Proxies as explained in Brian Takita's post > > here: > > http://pivots.pivotallabs.com/users/brian/blog/articles/352-introducing-rr > > > > I posted to this list eariler with an incomplete implementation of > > .stops_mocking in the thread "Mocking Time, delegating to original > > object." The Mock Proxy pattern would make this simpler. > > > > Proxy(User).expects(:find).with(99) # Sets expectation, forwards > > method invocation to original class > > User.expects(:find).with(99).returns(nil).then.proxies # Canned > > response, then forwards successive invocations to original class. > > > > Most of this is just my desire to be lazy and not actually have to > > unit-test *trivial* methods explicitly. I also like the idea of using > > the Mock Proxy to exercise the behavior of simple private instance > > methods of my class which are kind of a pain to test currently, which > > leads to my not making anything private. > > > > I've taken the liberty of adding this as a feature request [1] on rubyforge. > > -- > James. > http://blog.floehopper.org > http://tumble.floehopper.org > > [1] > http://rubyforge.org/tracker/index.php?func=detail&aid=17695&group_id=1917&atid=7480 > > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > From ned.wolpert at gmail.com Tue Feb 5 16:31:00 2008 From: ned.wolpert at gmail.com (Ned Wolpert) Date: Tue, 5 Feb 2008 14:31:00 -0700 Subject: [mocha-developer] New error? Message-ID: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> In the head, I'm getting a new error that does not look like its one of mine... started in rev 251... if it is mine, can anyone tell me where to look? here's the stack: Started /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in `mocha_teardown': You have a nil object when you didn't expect it! (NoMethodError) The error occurred while evaluating nil.teardown from /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in `start_mediator' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in `start' from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in `run' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' from /usr/lib/ruby/1.8/test/unit.rb:278 from test/unit/processor_application_test.rb:21 -- Virtually, Ned Wolpert http://www.codeheadsystems.com/blog/ "Settle thy studies, Faustus, and begin..." --Marlowe From jamesmead44 at gmail.com Tue Feb 5 19:32:48 2008 From: jamesmead44 at gmail.com (James Mead) Date: Wed, 6 Feb 2008 00:32:48 +0000 Subject: [mocha-developer] New error? In-Reply-To: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> Message-ID: <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> Hmm. Can you (a) try updating to HEAD i.e. revision 254; and (b) give me an example test case that gives you the error (ideally the simplest you can make it). Thanks. On 05/02/2008, Ned Wolpert wrote: > > In the head, I'm getting a new error that does not look like its one > of mine... started in rev 251... if it is mine, can anyone tell me > where to look? > > here's the stack: > > > Started > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in > `mocha_teardown': You have a nil object when you didn't expect it! > (NoMethodError) > The error occurred while evaluating nil.teardown from > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in > `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in > `run_suite' > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in > `start_mediator' > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in > `start' > from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in > `run' > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' > from /usr/lib/ruby/1.8/test/unit.rb:278 > from test/unit/processor_application_test.rb:21 > > -- > Virtually, Ned Wolpert > http://www.codeheadsystems.com/blog/ > > "Settle thy studies, Faustus, and begin..." --Marlowe > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > -- James. http://blog.floehopper.org http://tumble.floehopper.org From ned.wolpert at gmail.com Tue Feb 5 22:57:32 2008 From: ned.wolpert at gmail.com (Ned Wolpert) Date: Tue, 5 Feb 2008 20:57:32 -0700 Subject: [mocha-developer] New error? In-Reply-To: <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> Message-ID: <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> In this case, no real code is needed... It looks like the @mockery code isn't getting initialized. I did a test case but its nothing major......here is my test case: mocha_test.rb: ----------------------------------- Cut Here--> require File.dirname(__FILE__) + '/../test_helper' require 'stubba' # It still fails if this line isn't there... class MochaTest < Test::Unit::TestCase # Replace this with your real tests. def test_truth assert true end end ----------------------------------- Cut Here--> Run command: ruby test/unit/mocha_test.rb Output: Started /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in `mocha_teardown': You have a nil object when you didn't expect it! (NoMethodError) The error occurred while evaluating nil.teardown from /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in `start_mediator' from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in `start' from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in `run' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' from /usr/lib/ruby/1.8/test/unit.rb:278 from test/unit/mocha_test.rb:8 On Feb 5, 2008 5:32 PM, James Mead wrote: > Hmm. Can you (a) try updating to HEAD i.e. revision 254; and (b) give me an > example test case that gives you the error (ideally the simplest you can > make it). Thanks. > > > On 05/02/2008, Ned Wolpert wrote: > > > > In the head, I'm getting a new error that does not look like its one > > of mine... started in rev 251... if it is mine, can anyone tell me > > where to look? > > > > here's the stack: > > > > > > Started > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in > > `mocha_teardown': You have a nil object when you didn't expect it! > > (NoMethodError) > > The error occurred while evaluating nil.teardown from > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in > > `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in > > `run_suite' > > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in > > `start_mediator' > > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in > > `start' > > from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in > > `run' > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' > > from /usr/lib/ruby/1.8/test/unit.rb:278 > > from test/unit/processor_application_test.rb:21 > > > > -- > > Virtually, Ned Wolpert > > http://www.codeheadsystems.com/blog/ > > > > "Settle thy studies, Faustus, and begin..." --Marlowe > > _______________________________________________ > > mocha-developer mailing list > > mocha-developer at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mocha-developer > > > > > > -- > James. > http://blog.floehopper.org > http://tumble.floehopper.org > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > -- Virtually, Ned Wolpert http://www.codeheadsystems.com/blog/ "Settle thy studies, Faustus, and begin..." --Marlowe From jamesmead44 at gmail.com Wed Feb 6 03:53:32 2008 From: jamesmead44 at gmail.com (James Mead) Date: Wed, 6 Feb 2008 08:53:32 +0000 Subject: [mocha-developer] New error? In-Reply-To: <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> Message-ID: <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> Hmm. I don't see this problem running Mocha revision 254 as a Rails plugin with Rails 1.2.3. What version of Rails are you running? And have you tried updating to revision 254? I'll try going back to revision 251 when I have some time later today. Thanks. On 06/02/2008, Ned Wolpert wrote: > > In this case, no real code is needed... It looks like the @mockery > code isn't getting initialized. > > I did a test case but its nothing major......here is my test case: > mocha_test.rb: > ----------------------------------- Cut Here--> > require File.dirname(__FILE__) + '/../test_helper' > > require 'stubba' # It still fails if this line isn't there... > > class MochaTest < Test::Unit::TestCase > > # Replace this with your real tests. > def test_truth > assert true > end > end > ----------------------------------- Cut Here--> > > Run command: ruby test/unit/mocha_test.rb > > Output: > Started > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in > `mocha_teardown': You have a nil object when you didn't expect it! > (NoMethodError) > The error occurred while evaluating nil.teardown from > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in > `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in > `run_suite' > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in > `start_mediator' > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in > `start' > from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in > `run' > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' > from /usr/lib/ruby/1.8/test/unit.rb:278 > from test/unit/mocha_test.rb:8 > > > On Feb 5, 2008 5:32 PM, James Mead wrote: > > Hmm. Can you (a) try updating to HEAD i.e. revision 254; and (b) give me > an > > example test case that gives you the error (ideally the simplest you can > > make it). Thanks. > > > > > > On 05/02/2008, Ned Wolpert wrote: > > > > > > In the head, I'm getting a new error that does not look like its one > > > of mine... started in rev 251... if it is mine, can anyone tell me > > > where to look? > > > > > > here's the stack: > > > > > > > > > Started > > > > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in > > > `mocha_teardown': You have a nil object when you didn't expect it! > > > (NoMethodError) > > > The error occurred while evaluating nil.teardown from > > > > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in > > > `run' > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > > from > /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in > > > `run_suite' > > > from > /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in > > > `start_mediator' > > > from > /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in > > > `start' > > > from > /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in > > > `run' > > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' > > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' > > > from /usr/lib/ruby/1.8/test/unit.rb:278 > > > from test/unit/processor_application_test.rb:21 > > > > > > -- > > > Virtually, Ned Wolpert > > > http://www.codeheadsystems.com/blog/ > > > > > > "Settle thy studies, Faustus, and begin..." --Marlowe > > > _______________________________________________ > > > mocha-developer mailing list > > > mocha-developer at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/mocha-developer > > > > > > > > > > > -- > > James. > > http://blog.floehopper.org > > http://tumble.floehopper.org > > _______________________________________________ > > mocha-developer mailing list > > mocha-developer at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mocha-developer > > > > > > -- > Virtually, Ned Wolpert > http://www.codeheadsystems.com/blog/ > > "Settle thy studies, Faustus, and begin..." --Marlowe > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > -- James. http://blog.floehopper.org http://tumble.floehopper.org From ned.wolpert at gmail.com Wed Feb 6 08:17:15 2008 From: ned.wolpert at gmail.com (Ned Wolpert) Date: Wed, 6 Feb 2008 06:17:15 -0700 Subject: [mocha-developer] New error? In-Reply-To: <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> Message-ID: <33cb339b0802060517v681d3124r8221c1f590768457@mail.gmail.com> Yeah, I use the head of Mocha... so my tests auto-update to the lasted and execute on svn checkins. I need to track Mocha back to 251 because after this error, tests just stop... It seems like when my rails environment is loaded (Rails 2.0.2) the mocha_setup doesn't occur so 'mockery' doesn't get built in the mocha_setup. Again, no clue why. Runs fine within just a ruby call and the library without the rails framework... so something isn't playing well there it seems. On Feb 6, 2008 1:53 AM, James Mead wrote: > Hmm. I don't see this problem running Mocha revision 254 as a Rails plugin > with Rails 1.2.3. > > What version of Rails are you running? And have you tried updating to > revision 254? > > I'll try going back to revision 251 when I have some time later today. > > Thanks. > > > On 06/02/2008, Ned Wolpert wrote: > > > > In this case, no real code is needed... It looks like the @mockery > > code isn't getting initialized. > > > > I did a test case but its nothing major......here is my test case: > > mocha_test.rb: > > ----------------------------------- Cut Here--> > > require File.dirname(__FILE__) + '/../test_helper' > > > > require 'stubba' # It still fails if this line isn't there... > > > > class MochaTest < Test::Unit::TestCase > > > > # Replace this with your real tests. > > def test_truth > > assert true > > end > > end > > ----------------------------------- Cut Here--> > > > > Run command: ruby test/unit/mocha_test.rb > > > > Output: > > Started > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in > > `mocha_teardown': You have a nil object when you didn't expect it! > > (NoMethodError) > > The error occurred while evaluating nil.teardown from > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in > > `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > from /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in > > `run_suite' > > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in > > `start_mediator' > > from /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in > > `start' > > from /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in > > `run' > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' > > from /usr/lib/ruby/1.8/test/unit.rb:278 > > from test/unit/mocha_test.rb:8 > > > > > > On Feb 5, 2008 5:32 PM, James Mead wrote: > > > Hmm. Can you (a) try updating to HEAD i.e. revision 254; and (b) give me > > an > > > example test case that gives you the error (ideally the simplest you can > > > make it). Thanks. > > > > > > > > > On 05/02/2008, Ned Wolpert wrote: > > > > > > > > In the head, I'm getting a new error that does not look like its one > > > > of mine... started in rev 251... if it is mine, can anyone tell me > > > > where to look? > > > > > > > > here's the stack: > > > > > > > > > > > > Started > > > > > > > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/standalone.rb:151:in > > > > `mocha_teardown': You have a nil object when you didn't expect it! > > > > (NoMethodError) > > > > The error occurred while evaluating nil.teardown from > > > > > > > > > > /home/wolpert/svn/rubylms/vendor/plugins/mocha/lib/mocha/test_case_adapter.rb:50:in > > > > `run' > > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' > > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' > > > > from /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' > > > > from > > /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in > > > > `run_suite' > > > > from > > /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in > > > > `start_mediator' > > > > from > > /usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in > > > > `start' > > > > from > > /usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in > > > > `run' > > > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run' > > > > from /usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run' > > > > from /usr/lib/ruby/1.8/test/unit.rb:278 > > > > from test/unit/processor_application_test.rb:21 > > > > > > > > -- > > > > Virtually, Ned Wolpert > > > > http://www.codeheadsystems.com/blog/ > > > > > > > > "Settle thy studies, Faustus, and begin..." --Marlowe > > > > _______________________________________________ > > > > mocha-developer mailing list > > > > mocha-developer at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/mocha-developer > > > > > > > > > > > > > > > > -- > > > James. > > > http://blog.floehopper.org > > > http://tumble.floehopper.org > > > _______________________________________________ > > > mocha-developer mailing list > > > mocha-developer at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/mocha-developer > > > > > > > > > > > -- > > Virtually, Ned Wolpert > > http://www.codeheadsystems.com/blog/ > > > > "Settle thy studies, Faustus, and begin..." --Marlowe > > _______________________________________________ > > mocha-developer mailing list > > mocha-developer at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mocha-developer > > > > > > -- > James. > http://blog.floehopper.org > http://tumble.floehopper.org > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > -- Virtually, Ned Wolpert http://www.codeheadsystems.com/blog/ "Settle thy studies, Faustus, and begin..." --Marlowe From jamesmead44 at gmail.com Wed Feb 6 09:34:33 2008 From: jamesmead44 at gmail.com (James Mead) Date: Wed, 6 Feb 2008 14:34:33 +0000 Subject: [mocha-developer] New error? In-Reply-To: <33cb339b0802060517v681d3124r8221c1f590768457@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> <33cb339b0802060517v681d3124r8221c1f590768457@mail.gmail.com> Message-ID: <1db558f00802060634p6ffd1fbat267cbed6ab2cd72b@mail.gmail.com> On 06/02/2008, Ned Wolpert wrote: > > Yeah, I use the head of Mocha... so my tests auto-update to the lasted > and execute on svn checkins. I need to track Mocha back to 251 because > after this error, tests just stop... > > It seems like when my rails environment is loaded (Rails 2.0.2) the > mocha_setup doesn't occur so 'mockery' doesn't get built in the > mocha_setup. Again, no clue why. Runs fine within just a ruby call and > the library without the rails framework... so something isn't playing > well there it seems. > I've just created a fresh Rails project using Rails 2.0.2. I added the Mocha plugin from HEAD (revision 254). I added the following unit test... require File.dirname(__FILE__) + '/../test_helper' class TempTest < Test::Unit::TestCase def test_me assert true end end When I run this test, I get the following output (i.e. the test passes)... $ ruby test/unit/temp_test.rb Loaded suite test/unit/temp_test Started . Finished in 0.025527 seconds. 1 tests, 1 assertions, 0 failures, 0 errors Can you tell me if *anything* I've done sounds different from you? e.g. are you using fixtures? The call to require 'stubba' is not necessary and should make no difference. Running script/about gives the following output... $ script/about About your application's environment Ruby version 1.8.6 (i686-darwin8.10.3) RubyGems version 0.9.4 Rails version 2.0.2 Active Record version 2.0.2 Action Pack version 2.0.2 Active Resource version 2.0.2 Action Mailer version 2.0.2 Active Support version 2.0.2 Application root /Users/jamesmead/projects/temp Environment development Database adapter mysql Settings in test/test_helper.rb are the defaults... self.use_transactional_fixtures = true self.use_instantiated_fixtures = false fixtures :all Thanks. -- James. http://blog.floehopper.org http://tumble.floehopper.org From ned.wolpert at gmail.com Wed Feb 6 10:48:12 2008 From: ned.wolpert at gmail.com (Ned Wolpert) Date: Wed, 6 Feb 2008 08:48:12 -0700 Subject: [mocha-developer] New error? In-Reply-To: <1db558f00802060634p6ffd1fbat267cbed6ab2cd72b@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> <33cb339b0802060517v681d3124r8221c1f590768457@mail.gmail.com> <1db558f00802060634p6ffd1fbat267cbed6ab2cd72b@mail.gmail.com> Message-ID: <33cb339b0802060748r46ff6abeh357a0ca487d7d9c4@mail.gmail.com> After more testing, the problem is the mocha changes conflict with a suggestion made by Ola Bini http://ola-bini.blogspot.com/2007/12/your-ruby-tests-are-memory-leaks.html We added his suggestion (which for some reason actually made the tests run faster) and by removing it causes the latest mocha changes to not fail on our code. Bini's code removes (forceably) all instance variables set during the unit test... so its basically killing the Mocha variables simply because its not referenced in his code-base. So, its not a bug with Mocha, but an assumption of the variables that exist within the TestCase framework that Bini's code makes... I do appreciate your help. I find it difficult to figure out what 'sandboxes' are safe to play in with the Rails project and its plugins... and initial introspection into Bini's code did not seem like a bad thing. Seems like there should be a better 'discovery' technique on necessary variables though. (Side note, this is the first time Mocha added an instance variable to the test case itself, right? It would explain why this just happened recently.) Thanks again. On Feb 6, 2008 7:34 AM, James Mead wrote: > On 06/02/2008, Ned Wolpert wrote: > > > > Yeah, I use the head of Mocha... so my tests auto-update to the lasted > > and execute on svn checkins. I need to track Mocha back to 251 because > > after this error, tests just stop... > > > > It seems like when my rails environment is loaded (Rails 2.0.2) the > > mocha_setup doesn't occur so 'mockery' doesn't get built in the > > mocha_setup. Again, no clue why. Runs fine within just a ruby call and > > the library without the rails framework... so something isn't playing > > well there it seems. > > > > I've just created a fresh Rails project using Rails 2.0.2. I added the Mocha > plugin from HEAD (revision 254). > > I added the following unit test... > > require File.dirname(__FILE__) + '/../test_helper' > > class TempTest < Test::Unit::TestCase > > def test_me > assert true > end > > end > > When I run this test, I get the following output (i.e. the test passes)... > > $ ruby test/unit/temp_test.rb > Loaded suite test/unit/temp_test > Started > . > Finished in 0.025527 seconds. > > 1 tests, 1 assertions, 0 failures, 0 errors > > Can you tell me if *anything* I've done sounds different from you? e.g. are > you using fixtures? > > The call to require 'stubba' is not necessary and should make no difference. > > Running script/about gives the following output... > > $ script/about > About your application's environment > Ruby version 1.8.6 (i686-darwin8.10.3) > RubyGems version 0.9.4 > Rails version 2.0.2 > Active Record version 2.0.2 > Action Pack version 2.0.2 > Active Resource version 2.0.2 > Action Mailer version 2.0.2 > Active Support version 2.0.2 > Application root /Users/jamesmead/projects/temp > Environment development > Database adapter mysql > > Settings in test/test_helper.rb are the defaults... > > self.use_transactional_fixtures = true > self.use_instantiated_fixtures = false > fixtures :all > > Thanks. > -- > > James. > http://blog.floehopper.org > http://tumble.floehopper.org > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > -- Virtually, Ned Wolpert http://www.codeheadsystems.com/blog/ "Settle thy studies, Faustus, and begin..." --Marlowe From jamesmead44 at gmail.com Wed Feb 6 11:28:52 2008 From: jamesmead44 at gmail.com (James Mead) Date: Wed, 6 Feb 2008 16:28:52 +0000 Subject: [mocha-developer] New error? In-Reply-To: <33cb339b0802060748r46ff6abeh357a0ca487d7d9c4@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> <33cb339b0802060517v681d3124r8221c1f590768457@mail.gmail.com> <1db558f00802060634p6ffd1fbat267cbed6ab2cd72b@mail.gmail.com> <33cb339b0802060748r46ff6abeh357a0ca487d7d9c4@mail.gmail.com> Message-ID: <1db558f00802060828w5349e4edve90cfd918b85d0da@mail.gmail.com> On 06/02/2008, Ned Wolpert wrote: > > After more testing, the problem is the mocha changes conflict with a > suggestion made by Ola Bini > http://ola-bini.blogspot.com/2007/12/your-ruby-tests-are-memory-leaks.html > We added his suggestion (which for some reason actually made the tests > run faster) and by removing it causes the latest mocha changes to not > fail on our code. Bini's code removes (forceably) all instance > variables set during the unit test... so its basically killing the > Mocha variables simply because its not referenced in his code-base. > > So, its not a bug with Mocha, but an assumption of the variables that > exist within the TestCase framework that Bini's code makes... I do > appreciate your help. I find it difficult to figure out what > 'sandboxes' are safe to play in with the Rails project and its > plugins... and initial introspection into Bini's code did not seem > like a bad thing. Seems like there should be a better 'discovery' > technique on necessary variables though. (Side note, this is the > first time Mocha added an instance variable to the test case itself, > right? It would explain why this just happened recently.) > > Thanks again. > Wow! Well done for figuring that out. Yes, I think it is the first time Mocha has added an instance variable to the test case - I've been doing some significant refactoring recently. I can probably do without it and perhaps that would be a less invasive approach. I'll give it some more thought. Thanks for being tenacious enough to find the problem :-) -- James. http://blog.floehopper.org http://tumble.floehopper.org From jamesmead44 at gmail.com Thu Feb 7 19:04:37 2008 From: jamesmead44 at gmail.com (James Mead) Date: Fri, 8 Feb 2008 00:04:37 +0000 Subject: [mocha-developer] New error? In-Reply-To: <1db558f00802060828w5349e4edve90cfd918b85d0da@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> <33cb339b0802060517v681d3124r8221c1f590768457@mail.gmail.com> <1db558f00802060634p6ffd1fbat267cbed6ab2cd72b@mail.gmail.com> <33cb339b0802060748r46ff6abeh357a0ca487d7d9c4@mail.gmail.com> <1db558f00802060828w5349e4edve90cfd918b85d0da@mail.gmail.com> Message-ID: <1db558f00802071604q748b0d16l22b2bb78135dd9a0@mail.gmail.com> On 06/02/2008, James Mead wrote: > > I can probably do without it and perhaps that would be a less invasive > approach. I'll give it some more thought. > Just to let you know, I just checked in revision 258 which removes the @mockery instance variable from the TestCase. So you should be able to use the Ola Bini patch safely again. -- James. http://blog.floehopper.org http://tumble.floehopper.org From ned.wolpert at gmail.com Mon Feb 11 13:30:04 2008 From: ned.wolpert at gmail.com (Ned Wolpert) Date: Mon, 11 Feb 2008 11:30:04 -0700 Subject: [mocha-developer] New error? In-Reply-To: <1db558f00802071604q748b0d16l22b2bb78135dd9a0@mail.gmail.com> References: <33cb339b0802051331mdd2600cg11443540bb07fa70@mail.gmail.com> <1db558f00802051632o6ba1d65eu9c9079637612ede2@mail.gmail.com> <33cb339b0802051957n43968c86kd6f95603681a6969@mail.gmail.com> <1db558f00802060053h232624f7if543909cdc3c34bd@mail.gmail.com> <33cb339b0802060517v681d3124r8221c1f590768457@mail.gmail.com> <1db558f00802060634p6ffd1fbat267cbed6ab2cd72b@mail.gmail.com> <33cb339b0802060748r46ff6abeh357a0ca487d7d9c4@mail.gmail.com> <1db558f00802060828w5349e4edve90cfd918b85d0da@mail.gmail.com> <1db558f00802071604q748b0d16l22b2bb78135dd9a0@mail.gmail.com> Message-ID: <33cb339b0802111030w4719bfb0t637c676bec2bb87d@mail.gmail.com> Heh... I added the @mockery instance variable to Ola Bini's "don't touch variable" list... :-) On Feb 7, 2008 5:04 PM, James Mead wrote: > On 06/02/2008, James Mead wrote: > > > > I can probably do without it and perhaps that would be a less invasive > > approach. I'll give it some more thought. > > > > Just to let you know, I just checked in revision 258 which removes the > @mockery instance variable from the TestCase. So you should be able to use > the Ola Bini patch safely again. > > > -- > James. > http://blog.floehopper.org > http://tumble.floehopper.org > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer > -- Virtually, Ned Wolpert http://www.codeheadsystems.com/blog/ "Settle thy studies, Faustus, and begin..." --Marlowe From jamesmead44 at gmail.com Fri Feb 22 04:47:12 2008 From: jamesmead44 at gmail.com (James Mead) Date: Fri, 22 Feb 2008 09:47:12 +0000 Subject: [mocha-developer] Module stubbing methods? Message-ID: <1db558f00802220147m747368f5u2d8f007efe52e996@mail.gmail.com> Hi Ken, Your message got bounced by mailman - I'm guessing it didn't like your p7s attachment, but I'm not really sure. I'm re-posting to the list on your behalf... On 22/02/2008, Ken Collins wrote: > I found myself wondering about this when I needed to stub a helper > method that test weather a rails app is in production mode or not. Has > anyone run into Module stubbing needs at all and or is it a > possibility that Mocha could do some ruby-fu to accomodate an > any_instance style behavior on them? > > General thoughts? > > > - Thanks, > Ken > -- James. http://blog.floehopper.org http://tumble.floehopper.org From jamesmead44 at gmail.com Fri Feb 22 05:07:44 2008 From: jamesmead44 at gmail.com (James Mead) Date: Fri, 22 Feb 2008 10:07:44 +0000 Subject: [mocha-developer] Module stubbing methods? In-Reply-To: <1db558f00802220147m747368f5u2d8f007efe52e996@mail.gmail.com> References: <1db558f00802220147m747368f5u2d8f007efe52e996@mail.gmail.com> Message-ID: <1db558f00802220207h37c885f4h76534a51b05d4cf7@mail.gmail.com> On 22/02/2008, James Mead wrote: > Hi Ken, > > Your message got bounced by mailman - I'm guessing it didn't like your p7s attachment, but I'm not really sure. > > I'm re-posting to the list on your behalf... > > On 22/02/2008, Ken Collins wrote: > > > I found myself wondering about this when I needed to stub a helper > > method that test weather a rails app is in production mode or not. Has > > anyone run into Module stubbing needs at all and or is it a > > possibility that Mocha could do some ruby-fu to accomodate an > > any_instance style behavior on them? > > > > General thoughts? > > > > > > - Thanks, > > Ken > > Oops. Not sure what happened with the font size - sorry. I think you can already do what you want. I've tried to write some explanatory examples [1]. The key is that you need to stub module instance methods directly on the *instance* which extends the module, rather than on the module itself. I hope that helps. -- James. http://blog.floehopper.org http://tumble.floehopper.org [1] http://pastie.caboo.se/155858 From jamesmead44 at gmail.com Mon Feb 25 04:46:31 2008 From: jamesmead44 at gmail.com (James Mead) Date: Mon, 25 Feb 2008 09:46:31 +0000 Subject: [mocha-developer] revision 283 Message-ID: <1db558f00802250146y4e83f77ane37e73707a3f1737@mail.gmail.com> Just in case anyone is using Mocha trunk and has picked up revision 283, please be aware that this may break some tests involving stubbing of methods on ActiveRecord association proxies or stubbing of ActiveRecord attribute methods. The change that caused this has been reversed in revision 284. Cheers, James. -- http://blog.floehopper.org http://tumble.floehopper.org