Sha256: c1095c4f825b0439675a80b8108af3d092b3cc1db916d43ed7b2ad2e0dfece0b

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require "spec_helper"
require "open-uri"
require "cypress_rails/server"

RSpec.describe CypressRails::Server do
  let(:host) { "localhost" }
  let(:command) { "rackup spec/support/dummy_passing/config.ru" }
  let(:log_path) { "/dev/null" }
  let(:server) { described_class.new(host, command, nil, log_path) }

  describe "#port" do
    subject(:port) { server.port }

    it { is_expected.to be_open_port }
  end

  describe "#start" do
    it "starts the server and blocks until it is ready" do
      response = nil
      server.start {
        response = open("http://localhost:#{server.port}")
      }
      expect(response.status).to include "200"
    end

    context "when a healthcheck url is passed" do
      let(:command) { "rackup spec/support/dummy_healthcheck/config.ru" }
      let(:server) { described_class.new(host, command, "http://localhost/foobar", log_path) }

      it "pings the provided url" do
        response = nil
        server.start {
          response = open("http://localhost:#{server.port}/foobar")
        }
        expect(response.status).to include "200"
      end
    end

    it "yields the port number and host into the block" do
      expect { |b| server.start(&b) }.to yield_with_args("localhost", server.port)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cypress_rails-0.9.3 spec/cypress_rails/server_spec.rb
cypress_rails-0.9.2 spec/cypress_rails/server_spec.rb
cypress_rails-0.9.1 spec/cypress_rails/server_spec.rb
cypress_rails-0.9.0 spec/cypress_rails/server_spec.rb
cypress_rails-0.8.0 spec/cypress_rails/server_spec.rb
cypress_rails-0.7.0 spec/cypress_rails/server_spec.rb
cypress_rails-0.6.0 spec/cypress_rails/server_spec.rb