我创建了一个炼油厂CMS扩展,其范围为the extension guide和the extension testing guide。如何将页面添加到炼油厂CMS测试虚拟应用程序数据库
某些rspec单元测试通过,并在网页浏览器中加载http://localhost/the_extension
。但现在测试失败,因为虚拟应用程序没有页面(或任何其他数据库表)。
我试图仅仅复制dummy_dev文件dummy_test(和其他东西whoooole一堆),并工作(差不多),因为当我运行虚拟应用程序(cd spec/dummy; rvmsudo rails s -p 80 -e test
)的页面加载在浏览器中,并当我查询页面表(sqlite3 dummy_test 'select * from refinery_pages;
)时,有页面。
但是,每次运行cd vendor/extensions/the_extension; bundle exec rake spec
它都会删除页面表中的所有条目。
我尝试添加这spec/spec_helper.rb
:
# Copy the prototype test database to the test database.
FileUtils.cp File.expand_path('../dummy_test_db_prototype', __FILE__), File.expand_path('../dummy/dummy_test', __FILE__)
但由当时的规范是运行测试数据库已被删除。规格被读入后,数据库被删除,因为如果我把在spec/features/refinery/the_extension/the_extension_spec.rb
底部的分贝仍具有页面如下:
# DEBUG
puts 'Querying test db:'
system "sqlite3 /some_app/vendor/extensions/the_extension/spec/dummy/dummy_test 'select * from refinery_pages;'"
puts 'Done querying.'
如何确保有在测试数据库中的网页时测试跑?
我认为这有效。不幸的是我仍然得到相同的错误:'Capybara :: Webkit :: InvalidResponseError:无法加载URL:http://myapp.com/因为加载错误加载http://myapp.com/:未知错误。这部分是由前端的'window.location.href = target_domain'造成的。我读过我不应该尝试用水豚进行API测试,这是事实。 –