Sha256: 20e5cd21ef9458ac51194b351441d3e7670926ca6c901fc86f4559105b9cf1f0

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe 'job' do
  it 'has a name' do
    job 'foo-main' do end
    expect(Pushpop.jobs.first.name).to eq('foo-main')
  end
end

describe Pushpop do
  before(:each) do
    Pushpop.web.instance_variable_set(:@routes, [])    
  end

  describe 'add_job' do
    it 'adds a job to the list' do
      empty_proc = Proc.new {}
      Pushpop.add_job('foo', &empty_proc)
      expect(Pushpop.jobs.first.name).to eq('foo')
    end
  end

  describe 'random_name' do
    it 'is 8 characters and alphanumeric' do
      expect(Pushpop.random_name).to match(/^\w{8}$/)
    end
  end

  describe 'clock' do
    it 'starts clock in a thread' do
      t = Pushpop.start_clock
      expect(t.class).to be(Thread)

      t.exit
    end
  end

  describe 'web' do
    it 'gets or creates an instance of Web' do
      expect(Pushpop.web.class).to be(Pushpop::Web)
    end

    it 'does not start the web app if no routes are defined' do
      expect(Pushpop.start_webserver).to be_falsey
    end

    it 'starts the web app in a thread' do
      Pushpop.web.add_route('/test', Proc.new{})
      t = Pushpop.start_webserver
      expect(t.class).to be(Thread)

      t.exit
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pushpop-0.4.0 spec/pushpop_spec.rb
pushpop-0.3.3 spec/pushpop_spec.rb
pushpop-0.3.2 spec/pushpop_spec.rb
pushpop-0.3.1 spec/pushpop_spec.rb