Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: d8a0d76fd6
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (37 sloc) 1.514 kb

WARNING: This is just a big hack right now. If you are interested in using this project but I haven't removed this warning yet, please bug me to lessen the hackiness and make it more usable.

RSpec Process Mocks

rspec-process-mocks is an addon to rspec-mocks that provides support for method stubs, fakes, and message expectations within child processes.

Documentation

Setup

Gemfile

gem 'rspec-process-mocks', :git => 'git://github.com/thoughtless/rspec-process-mocks.git'

bundle install

spec/spec_helper.rb

require 'rspec/process_mocks' # This line must be after 'config.mock_with :rspec'

Message Expectations

describe "some action" do
  context "when bad stuff happens" do
    it "logs the error" do
      logger = double('logger')
      doer = Doer.new(logger)
      logger.should_receive_in_child_process(:log)
      doer.do_something_with(:bad_data)
      sleep 0.1 # Leave time for the child process to run.
    end
  end
end

class Doer
  attr_accessor :logger
  def do_something_with(data)
    Process.fork { logger.log(data) }
  end
end

Contribute

See http://github.com/thoughtless/rspec-process-mocks

Also see

Jump to Line
Something went wrong with that request. Please try again.