vendredi 18 décembre 2015

[Rails][Tests] Fixtures run in different context

I'm having a problem when testing a gem. test_helper:

require File.expand_path("../dummy/config/environment.rb",  __FILE__)

(...)
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
  ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end

class ActiveSupport::TestCase
  fixtures :all
end

In test/dummy I have a sample rails app. When I run integration tests they sometimes fail because they try to use fixtures in dummy app context:

NavigationTest#test_index_render_correct_template_and_layout:
Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/(...)/test/dummy/test/fixtures/(...)/tokens.yml

The problem is that happens randomly. I need to add some small features to the gem, but the tests fail. How can I fix the test_helper to always run fixtures in the right context, that is test/fixtures not test/dummy/test/fixtures?

Aucun commentaire:

Enregistrer un commentaire