To get your local database to the same structure as what you have in production:
First get a local checkout of the branch or tag that's deployed to production.
rake db:test:prepare
rake test # or rake spec
That should clean out your test database, and then recreate it according to your db/schema.rb, which should be the same schema you have in prod. Assuming that you first wrote a failing test, then fixed the bug and watched the test pass, your tests should now be passing.