Sha256: e83536fe99b9f3b96a4f02007d083687caa0a2a39917974660784934abad6fbc

Contents?: true

Size: 1.88 KB

Versions: 12

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe Jasmine::Server do
  describe "rack ~> 1.0" do
    before do
      Jasmine::Dependencies.stub(:legacy_rack?).and_return(true)
    end

    it "should run the handler with the application" do
      server = double(:server)
      port = 1234
      application = double(:application)
      Rack::Handler.should_receive(:get).with("webrick").and_return(server)
      server.should_receive(:run).with(application, hash_including(:Port => port))
      Jasmine::Server.new(port, application).start
    end
  end

  describe "rack >= 1.1" do
    before do
      Jasmine::Dependencies.stub(:legacy_rack?).and_return(false)
      if !Rack.constants.include?(:Server)
        Rack::Server = double("Rack::Server")
      end
    end

    it "should create a Rack::Server with the correct port when passed" do
      port = 1234
      Rack::Server.should_receive(:new).with(hash_including(:Port => port)).and_return(double(:server).as_null_object)
      Jasmine::Server.new(port, double(:app)).start
    end

    it "should start the server" do
      server = double(:server)
      Rack::Server.should_receive(:new) { server.as_null_object }
      server.should_receive(:start)
      Jasmine::Server.new('8888', double(:app)).start
    end

    it "should set the app as the instance variable on the rack server" do
      app = double('application')
      server = double(:server)
      Rack::Server.should_receive(:new) { server.as_null_object }
      Jasmine::Server.new(1234, app).start
      server.instance_variable_get(:@app).should == app
    end

    it "should pass rack options when starting the server" do
      app = double('application')
      server = double(:server)
      Rack::Server.should_receive(:new).with(hash_including(:Port => 1234, :foo => 'bar')).and_return(double(:server).as_null_object)
      Jasmine::Server.new(1234, app, {:foo => 'bar', :Port => 4321}).start
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
tdiary-5.0.2 vendor/bundle/gems/jasmine-2.4.0/spec/server_spec.rb
jasmine-2.5.1 spec/server_spec.rb
jasmine-2.5.0 spec/server_spec.rb
tdiary-5.0.1 vendor/bundle/gems/jasmine-2.4.0/spec/server_spec.rb
jasmine-2.4.0 spec/server_spec.rb
jasmine-2.3.1 spec/server_spec.rb
jasmine-2.3.0 spec/server_spec.rb
jasmine-2.2.0 spec/server_spec.rb
jasmine-2.1.0 spec/server_spec.rb
jasmine-2.0.3 spec/server_spec.rb
jasmine-2.0.2 spec/server_spec.rb
jasmine-2.0.1 spec/server_spec.rb