jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

teaspoon-jasmine running in development environment instead of test #504

Closed sujaysudheenda closed 3 years ago

sujaysudheenda commented 7 years ago

I am trying to run teaspoon tests in rails app. instead of running in test environment teaspoon is trying to run on dev environment and asks for missing database migrations.

I have specified ENV['RAILS_ENV'] = 'test' in first line of teaspoon_env.rb file

using gem 'teaspoon-jasmine', '~> 2.3.4'

Error: ActiveRecord::PendingMigrationError:

Migrations are pending. To resolve this issue, run:

 bin/rake db:migrate RAILS_ENV=development
gems/activerecord-4.2.7.1/lib/active_record/migration.rb:392:in `check_pending!'
gems/activerecord-4.2.7.1/lib/active_record/migration.rb:373:in `call'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/reloader.rb:73:in `call'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
gems/railties-4.2.7.1/lib/rails/rack/logger.rb:38:in `call_app'
gems/railties-4.2.7.1/lib/rails/rack/logger.rb:22:in `call'
gems/request_store-1.2.1/lib/request_store/middleware.rb:8:in `call'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
gems/activesupport-4.2.7.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/static.rb:120:in `call'
51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
gems/railties-4.2.7.1/lib/rails/engine.rb:518:in `call'
gems/railties-4.2.7.1/lib/rails/application.rb:165:in `call'
gems/puma-3.6.0/lib/puma/configuration.rb:225:in `call'
gems/puma-3.6.0/lib/puma/server.rb:578:in `handle_request'
gems/puma-3.6.0/lib/puma/server.rb:415:in `process_client'
gems/puma-3.6.0/lib/puma/server.rb:275:in `block in run'
gems/puma-3.6.0/lib/puma/thread_pool.rb:116:in `call'
gems/puma-3.6.0/lib/puma/thread_pool.rb:116:in `block in spawn_thread'
jejacks0n commented 7 years ago

rake db:test:prepare ?


Jeremy Jackson

On Oct 28, 2016, at 1:20 PM, Sujay Sudheendra notifications@github.com wrote:

I am trying to run teaspoon tests in rails app. instead of running in test environment teaspoon is trying to run on dev environment and asks for missing database migrations.

I have specified ENV['RAILS_ENV'] = 'test' in first line of teaspoon_env.rb file

using gem 'teaspoon-jasmine', '~> 2.3.4'

Error: ActiveRecord::PendingMigrationError:

Migrations are pending. To resolve this issue, run:

bin/rake db:migrate RAILS_ENV=development gems/activerecord-4.2.7.1/lib/active_record/migration.rb:392:in check_pending!' gems/activerecord-4.2.7.1/lib/active_record/migration.rb:373:incall' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:29:in block in call' gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:88:inrun_callbacks' gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in _run_call_callbacks' gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:81:inrun_callbacks' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:27:in call' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/reloader.rb:73:incall' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/remote_ip.rb:78:in call' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:incall' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in call' gems/railties-4.2.7.1/lib/rails/rack/logger.rb:38:incall_app' gems/railties-4.2.7.1/lib/rails/rack/logger.rb:22:in call' gems/request_store-1.2.1/lib/request_store/middleware.rb:8:incall' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/request_id.rb:21:in call' 51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:incall' 51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/runtime.rb:18:in call' gems/activesupport-4.2.7.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall' 51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/lock.rb:17:in call' gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/static.rb:120:incall' 51/.rvm/gems/ruby-2.2.3@global/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in call' gems/railties-4.2.7.1/lib/rails/engine.rb:518:incall' gems/railties-4.2.7.1/lib/rails/application.rb:165:in call' gems/puma-3.6.0/lib/puma/configuration.rb:225:incall' gems/puma-3.6.0/lib/puma/server.rb:578:in handle_request' gems/puma-3.6.0/lib/puma/server.rb:415:inprocess_client' gems/puma-3.6.0/lib/puma/server.rb:275:in block in run' gems/puma-3.6.0/lib/puma/thread_pool.rb:116:incall' gems/puma-3.6.0/lib/puma/thread_pool.rb:116:in `block in spawn_thread' — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

sujaysudheenda commented 7 years ago

@jejacks0n I tried doing it before running the teaspoon tests. but it didnt seem to work. I still see the same error.

edit: If I specify rails env explicitly like sh 'RAILS_ENV=test bundle exec teaspoon' then it picks up the right env

sockmonk commented 7 years ago

I have a similar problem: When I run "bin/teaspoon", logging goes to log/development.log. When I run "RAILS_ENV=test bin/teaspoon", logging goes to log/test.log.

I doublechecked, and by default RAILS_ENV is unset, so that isn't the problem. In my Gemfile, teaspoon-jasmine is in the 'development, test' block.
Rails 4.2.7.1, teaspoon 1.1.5, teaspoon-jasmine 2.3.4

jejacks0n commented 7 years ago

It's mentioned in the documentation that teaspoon by default runs in the development env. If you want to change this and not take advantage of the optimizations this provides, by all means do as you wish. Though it's not the default setup, so any issues you come across in the test env are for you to resolve.


Jeremy Jackson

On Nov 26, 2016, at 12:23 PM, Wes Sheldahl notifications@github.com wrote:

I have a similar problem: When I run "bin/teaspoon", logging goes to log/development.log. When I run "RAILS_ENV=test bin/teaspoon", logging goes to log/test.log.

I doublechecked, and by default RAILS_ENV is unset, so that isn't the problem. In my Gemfile, teaspoon-jasmine is in the 'development, test' block. Rails 4.2.7.1, teaspoon 1.1.5, teaspoon-jasmine 2.3.4

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ameykelkar commented 7 years ago

@sujaysudheenda Instead of setting environment variable as ENV['RAILS_ENV'] = 'test', you could try setting the rails environment by specifying Rails.env = 'test' in first line of teaspoon_env.rb