Sha256: 3fc96348388baf49ff48ee88901ad37fcb58e955152b339d4acc870e97debaf7

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe 'Plain EM, no AMQP' do
  describe EventMachine, " when testing with EventedSpec::SpecHelper" do
    include EventedSpec::SpecHelper

    it "should not require a call to done when #em is not used" do
      1.should == 1
    end

    it "should have timers" do
      start = Time.now
      em do
        EM.add_timer(0.5) {
          (Time.now-start).should be_within(0.1).of(0.5)
          done
        }
      end
    end

    it "should be possible to set spec timeouts as a number of seconds" do
      start = Time.now
      expect {
        em(0.5) do
          EM.add_timer(1) { done }
        end
      }.to raise_error EventedSpec::SpecHelper::SpecTimeoutExceededError
      (Time.now-start).should be_within(0.1).of(0.5)
    end

    it "should be possible to set spec timeout as an option (amqp interface compatibility)" do
      start = Time.now
      expect {
        em(0.5) do
          EM.add_timer(1) { done }
        end
      }.to raise_error EventedSpec::SpecHelper::SpecTimeoutExceededError
      (Time.now-start).should be_within(0.1).of(0.5)
    end
  end

  describe EventMachine, " when testing with EventedSpec::EMSpec" do
    include EventedSpec::EMSpec

    it_should_behave_like 'Spec examples'
  end
end

describe RSPEC, " when running an example group after groups that uses EM specs " do
  it "should work normally" do
    :does_not_hang.should_not be_false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evented-spec-0.4.0 spec/rspec_em_spec.rb