Sha256: 4976383ff6759d121f8177f9ea5f83091aa2550b22c7e3dd749c57d10e653a90

Contents?: true

Size: 1.65 KB

Versions: 18

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'
require 'sneakers'
require 'sneakers/cli'
require 'sneakers/runner'

describe Sneakers::CLI do
  describe "#work" do
    before do
      any_instance_of(Sneakers::Runner) do |runner|
        stub(runner).run{ true }
      end
    end

    describe 'with dirty class loading' do
      after do
        # require cleanup
        Object.send(:remove_const, :TitleScraper)
      end

      it "should perform a run" do
        any_instance_of(Sneakers::Runner) do |runner|
          mock(runner).run{ true }
        end
        out = capture_io{ Sneakers::CLI.start [
          'work',
          "TitleScraper",
          "--require=#{File.expand_path('../fixtures/require_worker.rb', File.dirname(__FILE__))}"
        ]}.join ''

        out.must_match(/Workers.*:.*TitleScraper.*/)

      end

      it "should be able to run as front-running process" do
        out = capture_io{ Sneakers::CLI.start [
          'work',
          "TitleScraper",
          "--require=#{File.expand_path('../fixtures/require_worker.rb', File.dirname(__FILE__))}"
        ]}.join ''

        out.must_match(/Log.*Console/)
      end

      it "should be able to run as daemonized process" do
        out = capture_io{ Sneakers::CLI.start [
          'work',
          "TitleScraper",
          "--daemonize",
          "--require=#{File.expand_path('../fixtures/require_worker.rb', File.dirname(__FILE__))}"
        ]}.join ''

        out.must_match(/sneakers.log/)
      end
    end

    it "should fail when no workers found" do
      out = capture_io{ Sneakers::CLI.start ['work', 'TitleScraper'] }.join ''
      out.must_match(/Missing workers: TitleScraper/)
    end

  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
sneakers-2.3.2 spec/sneakers/cli_spec.rb
sneakers-2.3.1 spec/sneakers/cli_spec.rb
sneakers-2.3.0 spec/sneakers/cli_spec.rb
sneakers-2.2.1 spec/sneakers/cli_spec.rb
sneakers-2.2.0 spec/sneakers/cli_spec.rb
sneakers-2.1.0 spec/sneakers/cli_spec.rb
sneakers-1.1.2 spec/sneakers/cli_spec.rb
sneakers-1.1.1 spec/sneakers/cli_spec.rb
sneakers-1.1.0 spec/sneakers/cli_spec.rb
sneakers_custom_bunny-1.0.4 spec/sneakers/cli_spec.rb
sneakers-1.0.4 spec/sneakers/cli_spec.rb
sneakers-1.0.3 spec/sneakers/cli_spec.rb
sneakers-1.0.2 spec/sneakers/cli_spec.rb
sneakers-1.0.1 spec/sneakers/cli_spec.rb
sneakers-1.0.0 spec/sneakers/cli_spec.rb
sneakers-0.1.1.pre spec/sneakers/cli_spec.rb
sneakers-0.1.0.pre spec/sneakers/cli_spec.rb
sneakers-0.0.7 spec/sneakers/cli_spec.rb