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

Set server port using Jasmine config #202

Merged
merged 5 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
((nil . ((enh-ruby-indent-level . 2)
(ruby-indent-level . 2)
(js-indent-level . 2)
(js2-basic-offset . 2)
(prelude-clean-whitespace-on-save . nil)
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: ruby
bundler_args: --without development
rvm:
- 2.2.5
- 2.3.1
- 2.3
- 2.4
- 2.5
- jruby-9.0.5.0
- rbx
matrix:
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,28 @@ Given your configuration, you could also need to set:

* the server url in the command line: `bundle exec guard-jasmine -u http://localhost:8888/`


## Notes

Rails 5 ships with a puma configuration that may conflict with Guard Jasmine if they're both running concurrently.

To work around this, the `tmp_restart` plugin in config/puma.rb needs to be disabled for development mode.

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

To:

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

Thanks to `quolpr` for investigating and suggesting the fix in: https://github.com/guard/guard-jasmine/issues/199#issuecomment-292648860


## Alternatives

There are many ways to get your Jasmine specs run within a headless environment. If Guard::Jasmine isn't for you,
Expand Down
2 changes: 1 addition & 1 deletion guard-jasmine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|

s.add_dependency 'guard', '~> 2.14'
s.add_dependency 'guard-compat', '~> 1.2'
s.add_dependency 'jasmine', '~> 2.4'
s.add_dependency 'jasmine', '~> 3.1'
s.add_dependency 'multi_json', '~> 1.12'
s.add_dependency 'childprocess', '~> 0.5'
s.add_dependency 'thor', '~> 0.19'
Expand Down
3 changes: 3 additions & 0 deletions lib/guard/jasmine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def initialize(options = {})

self.last_run_failed = false
self.last_failed_paths = []
::Jasmine.configure do |config|
config.server_port = options[:port] if options[:port]
end
@runner = Runner.new(options.merge(run_all_options))
end

Expand Down
2 changes: 1 addition & 1 deletion lib/guard/jasmine/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def start_unicorn_server(port, options)
#
def start_rake_server(port, task, options)
Compat::UI.info "Guard::Jasmine starts Jasmine Gem test server on port #{port}."
execute(options, ['rake', task, "JASMINE_PORT=#{port}"])
execute(options, ['rake', task])
end

# Builds a child process with the given command and arguments
Expand Down
8 changes: 8 additions & 0 deletions spec/guard/jasmine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
expect(guard.options[:port]).to eql 9999
end

it 'port can be set' do
mock_config = OpenStruct.new
expect(::Jasmine).to receive(:configure).and_yield mock_config
guard = Guard::Jasmine.new(port: 12345)
expect(guard.options[:port]).to eql 12345
expect(mock_config.server_port).to eql 12345
end

it 'sets a default :rackup_config option' do
expect(guard.options[:rackup_config]).to eql nil
end
Expand Down