I am new in ruby on rails and I want to write a simple test to check the login functionality of my system. I am following this official documentation http://guides.rubyonrails.org/testing.html#integration-testing
I run the command rails test:integration but this is showing this error
rails aborted!
ActiveRecord::EnvironmentMismatchError: You are attempting to modify a database that was last run in `development` environment.
You are running in `test` environment. If you are sure you want to continue, first set the environment using:
bin/rails db:environment:set RAILS_ENV=test
Why I should I switch to test environment to test my application? If i switch to test environment all the configurations will be different. Is this strange that we develop in development/production mode and then test in testing mode?
This is my testing db
default: &default
adapter: postgresql
encoding: unicode
host: <%= ENV.fetch("DATABASE_HOST") { "localhost" } %>
username: <%= ENV.fetch("DATABASE_USER") {"vagrant"} %>
password: <%= ENV.fetch("DATABASE_PASS") {"vagrant"} %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: fanshub_development
socket: <%= ENV["DATABASE_SOCKET"] %>
test:
<<: *default
database: fanshub_test
socket: <%= ENV["DATABASE_SOCKET"] %>
production:
<<: *default
database: fanshub_production
<% if ENV["DATABASE_URL"] %>
host: <%= ENV.fetch("DATABASE_URL", "localhost") %>
<% elsif ENV["DATABASE_SOCKET"] %>
socket: <%= ENV["DATABASE_SOCKET"] %>
<% end %>