I'm using rails 4.2, minitest 5.11.3, and minitest-rails 2.2.1
My test class has some problem when I want to exploit hstore field from postgresql into fixture.
Here my test class WelcomeMailerTest when running test is ok:
require 'test_helper'
class WelcomeMailerTest < ActionMailer::TestCase
describe 'user_mail_test' do
let(:user) {users(:anthony)}
let(:email) {WelcomeMailer.user(user.id)}
def test_email_to
assert_equal [user.email], email.to
end
end
end
My fixture user in the users.yml file:
anthony:
username: anthony-mattiocco
first_name: Anthony
last_name: Mattiocco
email: [email protected]
token: token
slug: antho
When I use a new fixture coutries.yml with key/value field (hstore), the test failed.
Here my new fixture coutries.yml :
us:
alpha2: US
slugs: <%= {:slug_en => 'test'}.to_yaml.inspect %>
nationality: 'American'
currency: 'USD'
and my updated WelcomeMailerTest class :
require 'test_helper'
class WelcomeMailerTest < ActionMailer::TestCase
describe 'user_mail_test' do
let(:country) {countries(:us)}
puts("countries : " + country.inspect)
let(:user) {users(:anthony)}
let(:email) {WelcomeMailer.user(user.id)}
def test_email_to
assert_equal [user.email], email.to
end
end
end
When I execute :
rake test
I got the following error :
Error: user_mail_test#test_email_to: ActiveRecord::StatementInvalid: PG::InternalError: ERROR: Syntax error near ':' at position 4 LINE 1: ..., "currency", "created_at", "updated_at") VALUES ('US', '--- ^ : INSERT INTO "countries" ("alpha2", "slugs", "nationality", "currency", "created_at", "updated_at") VALUES ('US', '--- :slug_en: test ', 'American', 'USD', '2019-11-14 23:02:06', '2019-11-14 23:02:06')
Thanks in advance for your help