我是使用Rails创建API的新手,我正在尝试创建一个测试。
require "spec_helper"
describe "/api/v1/iosapps", :type => :api do
context "view all apps" do
let(:url) { "/api/v1/iosapps" }
it "json" do
get "#{url}.json"
iosapps_json = Iosapp.all.to_json
last_response.body.should eql(iosapps_json)
last_response.status.should eql(200)
iosapps = JSON.parse(last_response.body)
iosapps.any? do |p|
p["name"] == iosapp.name
end.should be_true
end
end
end
我在下面说错了。关于如何解决这个问题的任何建议?
Failure/Error: get "#{url}.json"
ActiveRecord::StatementInvalid:
Could not find table 'iosapps'
答案 0 :(得分:1)
测试数据库尚未就绪。你需要运行
rake db:migrate
rake db:test:prepare