public
Created

Using Mocha's state machines

  • Download Gist
test.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
class FakeResource # fake RestClient::Resource
attr_reader :path
def initialize(path = "/")
@path = Mocha::Mockery.instance.new_state_machine("location").starts_as(path)
end
def [](path)
tap { @path.become(path) }
end
end
 
describe "Github::Client" do
before(:each) do
@resource = FakeResource.new
@client = Github::Client.new(@resource)
end
describe "#get" do
it "performs a GET request to /some/path on the resource" do
@resource.expects(:get).when @resource.path.is("/some/path")
@client.get("/some/path")
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.