0
我正在做一些模块化的Sinatra应用程序,并使用rspec和水豚进行测试。问题是,当我试图访问一个页面时,我总是得到“未找到”错误404。当我使用命令'bundle exec rackup'并转到相同的URL但在浏览器中一切正常。这里是我的规格:水豚访问总是给我错误404
require "spec_helper"
require_relative '../../routes/user_routes'
set :environment, :test
RSpec.describe RubyPlay, type: :feature do
include Rack::Test::Methods
def app
RubyPlay # this defines the active application for this test
end
before { visit '/' }
it "should allow accessing the home page" do
p page.html # prints Not found
p page.status_code # 404
expect(page).to have_content 'Ruby Play'
end
end
束的exec rspec的:
RubyPlay should allow accessing the home page
Failure/Error: expect(page).to have_content 'Ruby Play'
expected to find text "Ruby Play" in "Not Found"
我从来没有做过的西纳特拉测试,不知道什么可能是错误的... :)
是的 - 没有设置应用程序水豚不知道加载/运行什么 - 当您包括水豚/铁轨时,所有处理的铁轨 - 但与您需要做Sinatra它手动 –