Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rails s + guard jasmine fails to run tests #199

Closed
quolpr opened this issue Apr 7, 2017 · 1 comment
Closed

rails s + guard jasmine fails to run tests #199

quolpr opened this issue Apr 7, 2017 · 1 comment

Comments

@quolpr
Copy link

quolpr commented Apr 7, 2017

If I run guard at first:

23:24:52 - DEBUG - Notiffany: gntp not available (Please add "gem 'ruby_gntp'" to your Gemfile and run your app with "bundle exec".).
23:24:52 - DEBUG - Notiffany: growl not available (Unsupported platform "linux-gnu").
23:24:52 - DEBUG - Notiffany: terminal_notifier not available (Unsupported platform "linux-gnu").
23:24:52 - DEBUG - Notiffany: libnotify not available (Please add "gem 'libnotify'" to your Gemfile and run your app with "bundle exec".).
23:24:52 - DEBUG - Command execution: which notify-send
23:24:52 - DEBUG - Command execution: {"ALTERNATE_EDITOR"=>"false"} emacsclient --eval '1'
23:24:52 - DEBUG - Notiffany: emacs not available (Emacs client failed).
23:24:52 - DEBUG - Notiffany: tmux not available (:tmux notifier is only available inside a TMux session.).
23:24:52 - DEBUG - Notiffany: file not available (No :path option given).
23:24:52 - DEBUG - Command execution: which notify-send
23:24:52 - DEBUG - Notiffany is using NotifySend to send notifications.
23:24:52 - DEBUG - Notiffany is using TerminalTitle to send notifications.
23:24:53 - DEBUG - Command execution: hash stty
23:24:53 - DEBUG - Guard starts all plugins
23:24:53 - DEBUG - Hook :start_begin executed for Guard::Jasmine
23:24:53 - INFO - Guard::Jasmine starts Jasmine Gem test server on port 8888.
23:24:56 - INFO - Waiting for Jasmine test runner at http://localhost:8888/
23:24:56 - INFO - Run all Jasmine suites
23:24:58 - INFO - Finished in 1.05 seconds
23:24:58 - INFO - 11 specs, 0 failures
23:24:58 - DEBUG - Command execution: notify-send Jasmine suite passed 11 specs, 0 failures
> [#781bee75cda2] in 1.05 seconds -t 3000 -h int:transient:1 -i /home/quolpr/.rvm/gems/ruby-2.3.3/gems/notiffany-0.1.1/images/success.png -u low

23:24:59 - DEBUG - Hook :start_end executed for Guard::Jasmine
23:24:59 - INFO - Guard is now watching at '/home/quolpr/projects/my_project'
23:24:59 - DEBUG - Start interactor

And then bin/rails s:

=> Booting Puma
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.7.0 (ruby 2.3.3-p222), codename: Snowy Sagebrush
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

I get an error after spec file save:

23:25:20 - DEBUG - Interactor was stopped or killed
23:25:20 - DEBUG - Hook :run_on_modifications_begin executed for Guard::Jasmine
23:25:20 - INFO - Run Jasmine suite spec/javascripts/lib/mention_searcher_spec.coffee
23:25:36 - ERROR - An error occurred: Unable to access Jasmine specs at http://localhost:8888/?spec=MentionSearcher. Connection refused
23:25:36 - DEBUG - Command execution: notify-send Jasmine error An error occurred: Unable to access Jasmine specs at http://localhost:8888/?spec=MentionSearcher. Connection refused -t 3000 -h int:transient:1 -i /home/quolpr/.rvm/gems/ruby-2.3.3/gems/notiffany-0.1.1/images/failed.png -u normal

23:25:36 - DEBUG - Start interactor

If I run bin/rails s at first:

=> Booting Puma
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.7.0 (ruby 2.3.3-p222), codename: Snowy Sagebrush
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

And then guard:

23:29:58 - INFO - Guard::Jasmine starts Jasmine Gem test server on port 8888.
23:30:01 - INFO - Waiting for Jasmine test runner at http://localhost:8888/
23:30:01 - INFO - Run all Jasmine suites
23:30:03 - INFO - Finished in 1.05 seconds
23:30:03 - INFO - 11 specs, 0 failures

23:30:04 - INFO - Guard is now watching at '/home/quolpr/projects/my_project'

Rails got killed:

* Restarting...
=> Booting Puma
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
A server is already running. Check /home/quolpr/projects/my_project/tmp/pids/server.pid.
Exiting

Rails 5.0.1
Guard version 2.14.1
Guard::Jasmine version 2.1.0

Guardfile:

guard :jasmine, console: :always do
  watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
  watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
  watch(%r{spec/javascripts/fixtures/.+$})
  watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{m[1]}_spec.#{m[2]}" }
end

Gemfile:

source 'https://rubygems.org'

ruby '2.3.3'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sassc-rails', '~> 1.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Bootstrap beautiful select
gem 'select2-rails', '~> 4.0'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Authentication system
gem 'devise', '~> 4.2'
# Authorization system
gem 'pundit', '~> 1.1'
# Bootstrap support
gem 'bootstrap-sass', '~> 3.3'
# Forms made easy!
gem 'simple_form', '~> 3.4'
# Make controller more tiny
gem 'responders', '~> 2.3'
# Image processing
gem 'paperclip'
# AWS File storage
gem 'aws-sdk', '~> 2.3'
# Some scss helpers
gem 'bourbon', '~> 4.2'
# A modern JavaScript utility library delivering modularity, performance & extras.
gem 'lodash-rails', '~> 4.17'
# Paginator for Ruby webapps
gem 'kaminari', '~> 1.0'
# PgSearch builds named scopes that take advantage of PostgreSQL's full text search.
gem 'pg_search', '~> 2.0'
# Is needed for seed & testing
gem 'faker', require: false
gem 'factory_girl_rails', require: false

# Date & time pickers
gem 'momentjs-rails', '~> 2.9'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17'

# Geo jquery autocompelete
gem 'geocomplete_rails', '~> 1.7'

# Url validation
gem 'validate_url', '~> 1.0'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri

  # All for testing
  gem 'rspec-rails'
  gem 'database_cleaner'
  gem 'spring-commands-rspec'
  gem 'shoulda-matchers'
  gem 'capybara'
  gem 'ci_reporter_rspec'
  gem 'faker', require: true
  gem 'factory_girl_rails', require: true

  # DB table annotation
  gem 'annotate'

  # Shim to load environment variables from .env into ENV in development.
  gem 'dotenv-rails'

  # Easily switch current user
  gem 'switch_user'

  # A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
  gem 'guard-jasmine'
end

group :development do
  gem 'listen', '~> 3.0'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0'
  # Static analyzer
  gem 'rubocop', '~> 0.47.1', require: false
  gem 'brakeman', require: false
  gem 'scss_lint', require: false
  # Page livereload
  gem 'guard-livereload', '~> 2.5', require: false
  # Help to kill N+1 queries and unused eager loading
  gem 'bullet'
  # Preview email in the default browser instead of sending it
  gem 'letter_opener'
end

group :test do
  # Code coverage
  gem 'simplecov', require: false
  # PhantomJS driver for Capybara
  gem 'poltergeist'
  # Auto open report files generated with specs
  gem 'launchy'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
@quolpr quolpr changed the title rails s + guard jasmine running fails rails 5 severe + guard jasmine fails to run tests Apr 7, 2017
@quolpr quolpr changed the title rails 5 severe + guard jasmine fails to run tests rails s + guard jasmine fails to run tests Apr 7, 2017
@quolpr
Copy link
Author

quolpr commented Apr 7, 2017

With the help of jasmine/jasmine-gem#272 I found the problem:

It looks like this is due to the default Puma configuration that rails writes out. By enabling the tmp_restart plugin, when Jasmine tries to start up another rack server which will detect Puma, it will cause the other server to try to restart, but then detect that another server is running and not start.

Because of this, I don't think there is anything that Jasmine can do to fix this. If you remove (or comment out) the line in your config/puma.rb that enables the tmp_restart plugin, you should no longer see this issue.

Hope this helps. Thanks for using Jasmine!

So I changed config/puma.rb:

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

To:

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart unless ENV['RAILS_ENV'] == 'development'

Maybe it will be a good idea to add this issue to Readme, due to puma is default gem for rails 5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant