Closed ShPakvel closed 10 years ago
I don't really understand what the job is supposed to be doing. Are you testing to see if database cleaner works properly?
Output of the log/test.log
would be more helpful for debugging this.
Also, what version of Rspec are you using?
It is just example for simplisity.
BTW, I've corrected it (there should be before
block instead of let
).
My Rspec version from Gemfile.lock
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.4)
rspec-support (~> 3.0.0)
rspec-rails (3.0.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
The main problem for me right now is that code inside my job do not see any record in database created in spec before block.
If you give me a github URL of the app, I can take a look. Also, the test.log
output for the job would help.
@brandonhilkert I've figured out what was the problem.
In my rails_helper.rb
file (could be spec_helper.rb
) there was not comment line with transactional fixtures.
config.use_transactional_fixtures = true
It explains everything. And after comment it the job code works properly (see data in database created in spec). I don't know how it's happened (how I forgot to comment it). :blush: Silly me. But maybe someone will have the same problem. So maybe it would be nice to have note about that case in readme. What do you think about it?
Thanks for your support!
Makes sense. Can you send a PR?
On Tuesday, October 28, 2014, Pavel Shpak notifications@github.com wrote:
@brandonhilkert https://github.com/brandonhilkert I've figured out what was the problem. In my rails_helper.rb file (could be spec_helper.rb) there was not comment line with transactional fixtures.
config.use_transactional_fixtures = true
It explains everything. And after comment it the job code works properly (see data in database created in spec). I don't know how it's happened (how I forgot to comment it). [image: :blush:] Silly me. But maybe someone will have the same problem. So maybe it would be nice to have note about that case in readme. What do you think about it?
Thanks for your support!
— Reply to this email directly or view it on GitHub https://github.com/brandonhilkert/sucker_punch/issues/81#issuecomment-60783459 .
_The Build a Ruby Gem guide is available! http://brandonhilkert.com/books/build-a-ruby-gem/?utm_source=gmail-sig&utm_medium=email&utm_campaign=gem-config_
Ok, I will send it a couple hours later...
Hi, Brandon! I have problem with testing job. I use
database_cleaner
and follow your instruction from cleaning-test-data-transactions. But when I execute spec I have strange result. Data prepared before job code execution is not reachable from database. It seems like transaction/threads issue or I don't know what it is. Can you help me to solve this? Here is example code