Sha256: 11a348475d3c25b854667d590ac97eab533511e570c7f5cbf1c442ae8ff2e35f

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 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).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

4 entries across 4 versions & 1 rubygems

Version Path
jstd-runner-0.0.7 spec/jstd-runner/runner_spec.rb
jstd-runner-0.0.6 spec/jstd-runner/runner_spec.rb
jstd-runner-0.0.5 spec/jstd-runner/runner_spec.rb
jstd-runner-0.0.4 spec/jstd-runner/runner_spec.rb