Reputation: 5132
I am new to creating an API with Rails and am trying to create a test.
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
I get an error saying the below. Any advice on how to fix this?
Failure/Error: get "#{url}.json"
ActiveRecord::StatementInvalid:
Could not find table 'iosapps'
Upvotes: 0
Views: 63
Reputation: 24815
Test db is not ready. You need to run
rake db:migrate
rake db:test:prepare
Upvotes: 1