Pergunta

I installed Comfortable Mexican Sofa on a Rails 4 app and the visit function of my rspec tests was unable to find the CMS pages. I found two remedies: 1) the following bash commands

pg_dump harvey_development > db.dump
psql harvey_test < db.dump

2) Adding the following to spec_helper.rb:

ENV["RAILS_ENV"] = 'development'

I suspect that a better solution would be to configure something such that rspec always used the development db to serve CMS content and used test db for everything else. My question is: What is the best solution to this problem? And how do I implement it? Thanks in advance for any help at all, even as little as a vague gesture in the right direction.

Foi útil?

Solução

Take a look here: https://github.com/comfy/comfortable-mexican-sofa/wiki/Docs:-CMS-Seeds#using-cms-seeds-in-tests

Also, depending on how you structure your tests, you can hit the fixture importer directly: ComfortableMexicanSofa::Fixture::Importer.new(from, to, :force).import! Where from is the folder name and to is the identifier of the site.

Rake task works pretty good as it loads cms content only once for the duration of the entire test run. Also it doesn't get triggered if you're running focused tests. At least when using TestUnit, I don't like RSpec personally.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top