default: &default
adapter: postgresql
encoding: unicode
user: postgres
password:
pool: 5
development:
<<: *default
database: decastore_development
host: <%= ENV['DECASTORE_DATABASE_HOST'] %>
test:
<<: *default
database: decastore_test
host: <%= ENV['DECASTORE_DATABASE_HOST'] %>
production:
<<: *default
host: <%= ENV['DECASTORE_DATABASE_HOST'] %>
database: XXXX
username: XXXXX
password: <%= ENV['DECASTORE_DATABASE_PASSWORD'] %>
mystore:
adapter: oracle_enhanced
host: <%= ENV['mystore_db_host']%>
port: <%= ENV['mystore_db_port']%>
database: <%= ENV['mystore_db_name']%>
username: <%= ENV['mystore_db_user']%>
password: <%= ENV['mystore_db_password']%>--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/f723fd63-26b2-4ff7-a9ff-b8a3a69567f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
unless Rails.env.test?module MystoreMigration
class MystoreModel < ActiveRecord::Base
self.abstract_class = true
establish_connection(:mystore) unless Rails.env.test?
end
endTo view this discussion on the web visit https://groups.google.com/d/msgid/rspec/b5fa5aad-7a2a-4b53-875f-8bda30682c1d%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "rspec" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rspec/sbRqzLR_Lug/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/74587C34A93D431CB66AE4B35D84EC2B%40jonrowe.co.uk.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CAJGQ%3DvbsA2GkxtTuUCqKSChAe8YRf-Yeafv68qgSFvQ5X8qCXw%40mail.gmail.com.
> Sure, I'd like to write some tests and I had an impression that when accessing a class that used mystore connection, RSpec tried to use the default connection defined in test group of database.yml. Is the way I'm truing to do that in testing correct ?No, RSpec doesn’t do *any* database configuration, Rails will use the environment named configuration by default, but `establish_connection` *should* override it.If it’s not behaving as you expect you might want to check that Rails is loading your files correctly (as until `establish_connection` is called you won’t have configured the other database).
establish_connection(:mystore) unless Rails.env.test?ORA-12162: TNS:net service name is incorrectly specified
On Wednesday, 27 June 2018 16:26:36 UTC+2, Jon Rowe wrote:> Sure, I'd like to write some tests and I had an impression that when accessing a class that used mystore connection, RSpec tried to use the default connection defined in test group of database.yml. Is the way I'm truing to do that in testing correct ?No, RSpec doesn’t do *any* database configuration, Rails will use the environment named configuration by default, but `establish_connection` *should* override it.If it’s not behaving as you expect you might want to check that Rails is loading your files correctly (as until `establish_connection` is called you won’t have configured the other database).Finally, it does not work as expected when usingestablish_connection(:mystore) unless Rails.env.test?If I use justestablish_connection(:mystore)I have another error when calling new on one of the mystore DB models:ORA-12162: TNS:net service name is incorrectly specifiedDoes RSpec tries to access mystore_test table ?
Sorry, I meant mystore_test database. Thank you.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/4b796b81-d1ce-4109-827f-efccf085d743%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/2EDF7B26264448B5BE512774CA7A042F%40jonrowe.co.uk.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CAJGQ%3DvY8y2mYyC44DTTm2qppoCzCw11LvDv7%3DdC6eVyRJG%3DeMw%40mail.gmail.com.
Without knowing the specifics of the figaro gem I would wager yes, as they would appear to be blank.
module MystoreMigration
class MystoreModel < ApplicationRecord
establish_connection(:mystore) unless Rails.env.test?
end
endrequire 'rails_helper'
RSpec.describe MystoreMigration::StoreMigrator do
let(:shop) { build(:shop) }
let(:store) { double(MystoreMigration::StoreInfo)}
let(:store_migrator) { MystoreMigration::StoreMigrator.new([store]) }
describe 'initialization' do
it 'should have stores initialized' do
expect(store_migrator.stores).not_to be_empty
end
endrequire_relative 'store_schedule_period'
require_relative 'store_welcome'
module MystoreMigration
class StoreMigrator
MIGRATOR = 'mystore.store.migrator'.freeze
DEFAULT_SHOP_CATEGORY = 'decathlon'.freeze
attr_reader :stores
def initialize(stores = [])
@stores = stores
endTo view this discussion on the web visit https://groups.google.com/d/msgid/rspec/11fa1aa7-249a-429b-8cf5-ec94a4a30b57%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/27419AEAC05B43C9A90C257B0D4A458D%40jonrowe.co.uk.