Sha256: d484fdb9edd28aafa4b3725b215d0d9dd2b07f6dd9e2372584eb5a213783bca7

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

# The variable file should be renamed to something better - starbelly
shared_examples_for "a web server" do |plugin, file, bind_str = nil|
    plugin = plugin.to_sym unless plugin.is_a? Symbol

    if plugin == :unicorn && RUBY_PLATFORM == "java"
      before { skip("until unicorn supports jruby") }
    end

    abs_file = Object.send("#{plugin}_path", file)
    instance = nil
    args = { plugin => abs_file}
    args[:bind] = bind_str unless bind_str.nil?

    it "returns an instance" do
      instance = Excon::Test::Server.new(args)
      expect(instance).to be_instance_of Excon::Test::Server
    end
 
    it 'starts the server' do
      expect(instance.start).to be true
    end

    it 'stops the server' do
      expect(instance.stop).to be true
    end
end

describe Excon::Test::Server do
  context 'when webrick' do
    it_should_behave_like "a web server", :webrick, 'basic.ru'
  end

  context 'when unicorn' do
    it_should_behave_like "a web server", :unicorn, 'streaming.ru'
  end

  context "when unicorn is given a unix socket uri" do
    socket_uri = 'unix:///tmp/unicorn.socket'
    it_should_behave_like "a web server", :unicorn, 'streaming.ru', socket_uri
  end

  context 'when puma' do
    it_should_behave_like "a web server", :puma, 'streaming.ru'
  end

  context 'when executable' do
    it_should_behave_like "a web server", :exec, 'good.rb' 
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
excon-0.52.0 spec/excon_test_server_spec.rb