I'm beginning to look at testing a Rails app I've been working on and can't seem to get the default generated tests to even run. I think it has something to do with rails generating unique ids for fixtures.
The test I'm running is simply this: rails test test/controllers/pages_controller_test
Full error message: Error: PagesControllerTest#test_should_get_home: ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: UNIQUE constraint failed: reviews.id: INSERT INTO "reviews" ("created_at", "updated_at", "id") VALUES ('2018-03-26 21:55:24.345073', '2018-03-26 21:55:24.345073', 980190962)
test/controllers/pages_controller_test
require 'test_helper'
class PagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get pages_home_url
assert_response :success
end
end
This is what reviews.yml looks like:
# Read about fixtures at
http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
comment: MyText
star: 1
reservation_id: one
tourist_id: one
guide_id: one
type:
two:
comment: MyText
star: 1
reservation_id: two
tourist_id: two
guide_id: two
type:
Aucun commentaire:
Enregistrer un commentaire