开发者

I've monkey patched after_commit so it works with my test, but it doesn't work on Jenkins

开发者 https://www.devze.com 2023-04-07 02:15 出处:网络
I use an after_commit filter in several places in my code. In order to get my cucumber tests working, I had to use a patch - http://outofti.me/post/4777884779/test-after-commit-hooks-with-transactiona

I use an after_commit filter in several places in my code. In order to get my cucumber tests working, I had to use a patch - http://outofti.me/post/4777884779/test-after-commit-hooks-with-transactional-fixtures

It works fine locally both when run standalone or under Autotest. I also try to run the tests under Jenkins but almost all the tests fail with the following error message.

can't dump File (TypeError)
  /var/lib/jenkins/.rvm/rubies/ree-开发者_JS百科1.8.7-2011.03/lib/ruby/1.8/monitor.rb:242:in `synchronize'
  ./features/support/after_commit_monkey_patch.rb:20:in `transaction'
  ./features/support/after_commit_monkey_patch.rb:18:in `transaction'

Can anyone help me figure out what's going on? I'm confused why the same code works in one situation but not another. The environments are as identical as possible using RVM etc.

Thanks, Graeme


After a bit of searching (and thanks to Andy for the clue) it didn't have anything to do with the monkey-patch - it was just reporting the problem.

I had the cache for testing set to ...

config.cache_store = nil

I changed it to ...

config.cache_store = :dalli_store, { :namespace => "TEST" }

... instead and it works without fault now. It still doesn't explain why my tests work locally but didn't under Jenkins with a nil cache.


turned this patch into a gem test after_commit to have a common ground for improvements and to add tests to see it works on all rails versions

0

精彩评论

暂无评论...
验证码 换一张
取 消