我是使用 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'