Sha256: 293ef5424913a3be1d97c30fc898839f2d1748427726fb8c0be143508f12b9f1

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

require "spec_helper"

module JstdRunner
  describe Runner do
    let(:runner) { Runner.new }

    before {
      EM.stub!(:run).and_yield
      runner.stub!(:at_exit)
      runner.stub!(:trap)
    }

    it "runs and watches the server" do
      browser = mock(Browser, :capture => nil).as_null_object
      runner.stub!(:browser).and_return(browser)

      server = mock(Server, :host => "localhost", :port => 4224)
      Server.should_receive(:new).with(4224, nil).and_return(server)
      server.should_receive(:start)
      server.should_receive(:monitor).with(10)

      runner.run
    end

    it "runs, captures and watches the browser" do
      server = mock(Server, :host => "localhost", :port => 1234).as_null_object
      runner.stub!(:server).and_return(server)

      browser = mock(Browser)
      Browser.should_receive(:new).with(:firefox).and_return(browser)
      browser.should_receive(:start)
      browser.should_receive(:capture).with("localhost", 1234)
      browser.should_receive(:monitor).with(10)

      runner.run
    end

    it "sets up restarts" do
      browser = mock(Browser).as_null_object
      server = mock(Server, :host => "localhost", :port => 1234).as_null_object

      runner.stub!(:browser).and_return browser
      runner.stub!(:server).and_return server

      EM.should_receive(:daily).with("01:15").and_yield
      runner.options[:restart_at] = "01:15"

      server.should_receive(:restart)
      browser.should_receive(:restart)
      browser.should_receive(:capture).with("localhost", 1234).twice

      runner.run
    end

    # TODO: more specs here
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jstd-runner-0.0.9 spec/jstd-runner/runner_spec.rb
jstd-runner-0.0.8 spec/jstd-runner/runner_spec.rb