Sha256: 3df33bd6e8f557b950dd2048be6933ae1f1571a08c97b7583c1fdf09ea214737

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require_relative "spec_helper"

describe "hello world" do
  context "server started in test" do
    it "answers" do
      out = double
      allow(out).to receive(:puts)

      test = Httpotemkin::Test.new(out: out)
      test.add_server("server")

      test.run do |client|
        sleep 2
        client.execute(["curl", "server/hello"])

        expect(client.exit_code).to eq(0)
        expect(client.out).to eq("world\n")
        expect(client.err.empty?).to be(true)
      end
    end
  end

  context "server started before test" do
    before(:all) do
      out = StringIO.new
      @test = Httpotemkin::Test.new(out: out)
      @test.add_server("server")
      @test.up
      @client = @test.start_client
      sleep 2
    end

    it "answers once" do
      @client.execute(["curl", "server/hello"])

      expect(@client.exit_code).to eq(0)
      expect(@client.out).to eq("world\n")
      expect(@client.err.empty?).to be(true)
    end

    it "answers twice" do
      @client.execute(["curl", "server/hello"])

      expect(@client.exit_code).to eq(0)
      expect(@client.out).to eq("world\n")
      expect(@client.err.empty?).to be(true)
    end

    after(:all) do
      @test.down
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
httpotemkin-0.0.2 spec/system/hello_world_spec.rb