spec/pushpop_spec.rb in pushpop-0.2 vs spec/pushpop_spec.rb in pushpop-0.3.1

- old
+ new

@@ -6,10 +6,13 @@ 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) @@ -18,9 +21,36 @@ 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