Skip to content

Commit

Permalink
Make server set up and tear down automatic.
Browse files Browse the repository at this point in the history
  • Loading branch information
lowjoel committed Jul 10, 2016
1 parent 176e43d commit a583355
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: ruby
rvm:
- 2.1.7
- 2.2.4
- 2.3.0
before_install: gem install bundler -v 1.11.2
- 2.1.9
- 2.2.5
- 2.3.1
before_install: gem update bundler
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ MessageBus::Client.poll_interval = 15 # seconds
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to
run the tests.

If you are running Windows, Ruby is not able to kill the server process. Run it separately using
`rake server` before running the specs.

## Contributing

Bug reports and pull requests are welcome on GitHub at
Expand Down
13 changes: 12 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :server do
pid = 0
Bundler.with_clean_env do
sh "bundle exec puma 'spec/chat_server.ru'"
pid = spawn "bundle exec puma 'spec/chat_server.ru'"
end

at_exit do
$stderr.puts "Killing pid #{pid}"
Process.kill('KILL', pid)
Process.wait(pid)
end

sleep 3
end

task :spec => :server

task default: :spec

0 comments on commit a583355

Please sign in to comment.