Sha256: 2bfa163e53c0c4d096325a50c00df9b09b11fc22060afb577d4b8745c471aa67

Contents?: true

Size: 620 Bytes

Versions: 9

Compression:

Stored size: 620 Bytes

Contents

require 'pork/executor'

module Kernel
  def should *args, &block
    stat = Thread.current.group.list.find{ |t| t[:pork_stat] }[:pork_stat]
    Pork::Expect.new(stat, self, *args, &block)
  end
end

module Pork
  module Should
    def execute mode, stat=Stat.new, *args
      thread = Thread.current
      original_group, group = thread.group, ThreadGroup.new
      original_stat = thread[:pork_stat]
      group.add(thread)
      thread[:pork_stat] = stat
      super(mode, stat, *args)
    ensure
      thread[:pork_stat] = original_stat
      original_group.add(thread)
    end
  end

  Executor.extend(Should)
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pork-1.5.0 lib/pork/more/should.rb
pork-1.4.4 lib/pork/more/should.rb
pork-1.4.3 lib/pork/more/should.rb
pork-1.4.2 lib/pork/more/should.rb
pork-1.4.1 lib/pork/more/should.rb
pork-1.4.0 lib/pork/more/should.rb
pork-1.3.1 lib/pork/more/should.rb
pork-1.3.0 lib/pork/more/should.rb
pork-1.2.4 lib/pork/more/should.rb