0.0
No commit activity in last 3 years
No release in over 3 years
From within your tests, if you can't understand what's going on, maybe you need to dump your data to your development database and use it from there?
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

DataDumper

Installation

  1. Gemfile
    gem “data_dumper”, :group => [:development, :test]

Usage

You’re knee deep in a debugger session, and you can’t understand why something’s wrong. You wish you could fire up your application against the test database, but sadly, the process which is running the tests is within a transaction, and thus the actual data is opaque. What can you do?

# Somewhere deep in your tests
test "the frobble touches the widget" do
  assert_equal 42, frobble.widget_id
end

You’ve been on this assert_equal call for the past hour wondering. Frustration’s been mounting, because you don’t understand why the frobble doesn’t touch the widget. Clearly, there’s something wrong with the fixtures, but you can’t understand what it is. Time to fire up the debugger and dump the data:

[814, 823] in test/unit/widget_test.rb
   814          frobble.save!
   815        end
   816
   817        test "the frobble touches the widget" do
   818          debugger
=> 819          assert_equal 42, frobble.widget_id
   820        end
   821
   822        test "the widget touched the frobble in turn" do
   823          assert widget.touched_by_frobble?
test/unit/widget_test.rb:819
=> 819          assert_equal 42, frobble.widget_id
(rdb:112)

Since the data_dumper gem is already declared in your Gemfile (if not, declare it, bundle install, then run your tests again), type:

(rdb:112) File.mkdir(Rails.root + "dump")
(rdb:113) DataDumper.dump(Rails.root + "dump")

Then, quit your failing tests, and from the trusty command line:

$ rails console
> DataDumper.load(Rails.root + "dump")
> exit

$ rails server

Any and all data from your test database will be loaded in your development environment. You can now explore your model with your trusty application, to find out what’s really going on.

Caveats

This tool is known to work with Rails 2.3.5, PostgreSQL 8.4 and REE 1.8.7 2011.03. Anything else is up for you to test.

LICENSE

(The MIT License)

Copyright © 2011 François Beausoleil (francois@teksol.info)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
‘Software’), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.