Skip to content

Commit

Permalink
Switched from mocha to rspec stub
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvanderbyl committed Jul 12, 2012
1 parent a268e19 commit 86ed1cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions spec/cloudist/request_spec.rb
Expand Up @@ -3,8 +3,8 @@
describe Cloudist::Request do
before {
@mq_header = mock("MQ::Header")
@mq_header.stubs(:headers).returns({:published_on=>Time.now.to_i - 60, :event_hash=>"foo", :message_id=>"foo", :ttl=>300})
@mq_header.stub(:headers).and_return({:published_on=>Time.now.to_i - 60, :event_hash=>"foo", :message_id=>"foo", :ttl=>300})

q = Cloudist::JobQueue.new('test.queue')

@request = Cloudist::Request.new(q, Marshal.dump({:bread => 'white'}), @mq_header)
Expand Down
3 changes: 1 addition & 2 deletions spec/cloudist_spec.rb
Expand Up @@ -6,8 +6,7 @@
stub_amqp!
end
it "should start an AMQP instance" do
AMQP.expects(:start).once

AMQP.should_receive(:start).once
Cloudist.start do

end
Expand Down
3 changes: 1 addition & 2 deletions spec/spec_helper.rb
Expand Up @@ -2,13 +2,12 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require "moqueue"
require "mocha"
require 'cloudist'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|
config.mock_with :mocha
config.mock_with :rspec
end
22 changes: 11 additions & 11 deletions spec/support/amqp.rb
@@ -1,16 +1,16 @@
def stub_amqp!
AMQP.stubs(:start)
AMQP.stub(:start)
mock_queue = mock("AMQP::Queue")
mock_queue.stubs(:bind)
mock_queue.stubs(:name).returns("test.queue")
mock_queue.stub(:bind)
mock_queue.stub(:name).and_return("test.queue")

mock_ex = mock("AMQP::Exchange")
mock_ex.stubs(:name).returns("test.queue")
mock_ex.stub(:name).and_return("test.queue")

mock_channel = mock("AMQP::Channel")
mock_channel.stubs(:prefetch).with(1)
mock_channel.stubs(:queue).returns(mock_queue)
mock_channel.stubs(:direct).returns(mock_ex)
AMQP::Channel.stubs(:new).returns(mock_channel)
mock_channel.stub(:prefetch).with(1)
mock_channel.stub(:queue).and_return(mock_queue)
mock_channel.stub(:direct).and_return(mock_ex)

AMQP::Channel.stub(:new).and_return(mock_channel)
end

0 comments on commit 86ed1cc

Please sign in to comment.