Sha256: 2fae7ffa9896c251285ae04153ccb03406daefe4384720e88f648752ce66da0d

Contents?: true

Size: 951 Bytes

Versions: 2

Compression:

Stored size: 951 Bytes

Contents

require 'spec_helper'
require 'em-dextras/extension/object/deferrable'

describe "EventMachine::Deferrable extensions"  do
  context "when the deferrable is succeeded" do
    it 'returns a new one deferrable with a yielded value' do
      EM.run do
        deferrable = EventMachine::DefaultDeferrable.new

        result_deferrable = deferrable.map do |parameter|
          "transformed-#{parameter}"
        end

        deferrable.succeed('from-succeed')

        result_deferrable.should succeed_with('transformed-from-succeed')
      end
    end
  end

  context "when the deferrable fails" do
    it 'returns a new one failed deferrable' do
      EM.run do
        deferrable = EventMachine::DefaultDeferrable.new

        result_deferrable = deferrable.map do |parameter|
          "transformed-#{parameter}"
        end

        deferrable.fail('from-fail')

        result_deferrable.should fail_with('from-fail')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-dextras-0.4.0 spec/em-dextras/extension/object/deferrable_spec.rb
em-dextras-0.3.0 spec/em-dextras/extension/object/deferrable_spec.rb