I have a sinatra app working on my computer and am trying to get the tests to run on Codeship. I've reduced it to a tiny subset to see if I can sort out the problem I am having. I would greatly appreciate another pair of eyes...
Here are the key files:
Rakefile:
require 'sinatra/activerecord/rake'
require 'rake/testtask'
require_relative "demo_app"
Rake::TestTask.new do |t|
t.pattern = "test/*_test.rb"
end
database.yml
development:
adapter: sqlite3
database: db/development.sqlite3
test:
adapter: sqlite3
database: db/test.sqlite3
production:
url: <%= ENV['DATABASE_URL'] %>
demo_app.rb:
require 'sinatra/activerecord'
require './models/event'
require './models/person'
require './models/registration'
require 'pry-byebug'
migrations:
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string :name
t.date :date
end
end
end
test_helper.rb:
ENV['RACK_ENV'] = "test"
ENV["SINATRA_ENV"] = "test"
require_relative '../demo_app'
require 'minitest/autorun'
require 'rack/test'
ActiveRecord::Migration.maintain_test_schema!
event_test.rb:
require_relative './test_helper.rb'
describe Event do
it "can add events" do
Event.create(name: "An Event")
Event.create(name: "Another Event")
Event.all.size.must_equal 2
end
end
So, with that context I setup Codeship. Here are the key settings there:
Setup commands:
rvm use 2.2.2
bundle install
RACK_ENV=test bundle exec rake db:migrate
Test Pipeline (1 of 1)
rake test
And now when I push to git, and codeship picks it up I get this error on line 1 of demo_app.rb which is a require to sinatra/activerecord
:
rake aborted!
Database URL cannot be empty
.....
It seems that for some reason, it is not paying attention to the fact that I am running in test mode and so it should use the test clause of database.yml.
Thoughts?