Sha256: d3feef8fd9fe9ebbbf906162b60bf072844ec53a318e89809294ff130c33c65d

Contents?: true

Size: 892 Bytes

Versions: 6

Compression:

Stored size: 892 Bytes

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" }

  describe "#port" do
    subject(:port) { described_class.new(host, command, log_path).port }

    it { is_expected.to be_open_port }
  end

  describe "#start" do
    subject(:server) { described_class.new(host, command, log_path) }

    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

    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

6 entries across 6 versions & 1 rubygems

Version Path
cypress_rails-0.5.0 spec/cypress_rails/server_spec.rb
cypress_rails-0.4.2 spec/cypress_rails/server_spec.rb
cypress_rails-0.4.1 spec/cypress_rails/server_spec.rb
cypress_rails-0.4.0 spec/cypress_rails/server_spec.rb
cypress_rails-0.3.0 spec/cypress_rails/server_spec.rb
cypress_rails-0.2.0 spec/cypress_rails/server_spec.rb