I'm a newbie to Rails. Therefore, apologies in advance if this is a dumb question. I have gone through Michael Heartl's book and tried coding an app myself.
I have written a few basic tests, but when trying to test the app with
$bundle exec rake test
I get the following message on the terminal
Web Console is activated in the test environment, which is
usually a mistake. To ensure it's only activated in development
mode, move it to the development group of your Gemfile:
gem 'web-console', group: :development
If you still want to run it the test environment (and know
what you are doing), put this in your Rails application
configuration:
config.web_console.development_only = false
When I add the above to development.rb it still doesn't make a difference.
Please help me understand what I'm doing wrong.
What you need to do is make sure that in your Gemfile the line gem 'web-console'
is only loaded in the group development.
Can you maybe post your Gemfile? This way we can see if that is what's causing it.
In your Gemfile it should either be:
gem 'web-console', group: :development
or
group :development do
gem 'web-console'
end
In the Gem file if you have this line
gem 'web-console', '~> 2.0'
Remove it.
Then run
$ gem install bundler
$ bundle install --without production
I've gone through Michael Hartl's course as well. I know the Gemfile states that you should have it the way you have it but it brings up that message. If you don't want to change the Gemfile and leave it as the way in the book, you can go to config > environments > test.rb and add in the line below.
config.web_console.development_only = false
Save this and you're good to go.
I'm also studying ROR with Michael Heartl's book and faced the same problem!
The thing that helped me is adding a 'guard' gem to the app's Gemfile.
So the parts of Gemfile look like so:
group :development do
gem 'sqlite3'
gem 'byebug'
gem 'spring'
gem 'web-console', '~> 2.0'
end
group :test do
gem 'minitest-reporters'
gem 'mini_backtrace'
gem 'guard'
gem 'guard-minitest'
end
Also run the following command after changing the code:
bundle install --without production
After these manipulations the tests are executed by the command:
bundle exec rake test