[PATCH] Call Rails' TestCase callbacks
Reported by Jon | March 15th, 2008 @ 09:06 PM | in 1.1.5
I've been trying to migrate an existing TestCase-based rails project over to RSpec, and ran into a few problems.
First off was that TestCase tests lost their fixtures. Edge Rails adds class-level setup & teardown callbacks, which are used to call setup_fixtures & teardown_fixtures. RSpec's TestCase runner doesn't call these callback methods.
How about something along the lines of a1f0ebead, at http://github.com/jdelStrother/r... ?
Comments and changes to this ticket
-

-

Jon July 12th, 2008 @ 12:37 PM
- → Assigned user changed from to David Chelimsky
- → Tag cleared.
I've updated http://github.com/jdelStrother/r... with an updated version that applies cleanly against rspec-rails' master, and passes the full pre_commit suite.
-
David Chelimsky July 12th, 2008 @ 06:37 PM
- → State changed from new to open
Hey Jon - I got these errors against 2.1:
1) 'Running TestCase tests should call the teardown callbacks' FAILED expected: 1, got: 0 (using ==) ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:51: 2) 'Running TestCase tests should call the setup callbacks' FAILED expected: 1, got: 0 (using ==) ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:45: Finished in 18.983645 seconds 410 examples, 2 failures, 3 pendingI'm running ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] on a Mac. You?
-
David Chelimsky July 12th, 2008 @ 04:08 PM
- → Milestone changed from to 1.1.5
-

Jon July 12th, 2008 @ 06:18 PM
Hmph, really? I'm running ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0], and can't reproduce that.
How are you running the spec? Neither running by hand (ruby ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb) or running 'rake pre_commit' in rspec-dev show any problems for me.
I did spot one problem where the TestUnitTesting testcase could get run twice - once where I explicitly call TestUnitTesting.run in my spec, and once from the magic that runs TestCase tests on exit. That's fixed in http://github.com/jdelStrother/r..., but I doubt that'll fix the problem you're seeing.
-
David Chelimsky July 12th, 2008 @ 06:36 PM
The errors I got before were from running rake from rspec-dev. If I run it manually, I get this (which is, sadly, different):
ruby ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb ... 1) 'Running TestCase tests should call the setup callbacks' FAILED expected: 1, got: 0 (using ==) ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:45: ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:39: 2) 'Running TestCase tests should still only call the normal setup method once' FAILED expected: 1, got: 2 (using ==) ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:48: ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:39: 3) 'Running TestCase tests should call the teardown callbacks' FAILED expected: 1, got: 0 (using ==) ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:51: ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:39: 4) 'Running TestCase tests should still only call the normal teardown method once' FAILED expected: 1, got: 2 (using ==) ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:54: ./vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb:39: -
David Chelimsky July 12th, 2008 @ 06:39 PM
Actually - w/ the most recent update from your repo I get the same results (2 failures) regardless of how it's run.
-

Jon July 12th, 2008 @ 07:05 PM
Curious. I'll try it on the machine at work on Monday, see if it makes any difference.
Is there an easy way of getting your patchlevel of ruby on a mac? MacPorts only seems to have 111 - was yours compiled from scratch?
-
-

Jon July 12th, 2008 @ 07:30 PM
Mm, yeah, it did. And having installed that, I still can't reproduce your problem. Will investigate more with a fresh machine on Monday.
-

Jon July 17th, 2008 @ 06:50 PM
I still can't reproduce the failing tests. Do you think you could double-check your results if you get chance?
If any else could try this on their setup and post the results, that'd be incredibly useful.
-

-
David Chelimsky July 18th, 2008 @ 01:55 AM
- → State changed from open to resolved
Hey Jon - I have NO idea what changed in the world, but I just grabbed your changes and everything ran fine.
Applied to http://github.com/dchelimsky/rsp....
Cheers,
David
-

Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Behaviour Driven Development for Ruby.
