basecamp = mock("basecamp api",;projects => <<whatever you
expect to
get from the projects call>>)
Basecamp.stub!(:new).and_return(basecamp)
So for the projects one, you could return an array, or a bunch of
mocks, or a string. Just make it match how the Basecamp API is behaving.
On Jan 31, 2008, at 6:31 AM, desaperados wrote:
>
> I realise that this is kind of a basic question but I''m new to
rspec
> and
> still trying to work out how to do things. I''m working on a rails
> project
> that requires basecamp integration via the api, which is fairly
> trivial to
> use via the basecamp.rb wrapper:
>
> Connection:
> basecamp = Basecamp.new(APP_CONFIG[''api_host''],
> APP_CONFIG[''api_username''],
> APP_CONFIG[''api_pwd''])
>
> And to retrieve a list of Projects:
> puts "Projects: #{basecamp.projects}"
>
> I know how to make this work in the model, I''m just having trouble
> working
> out how to create a usable mock for this in rspec. I can''t work
out
> to mock
> ''basecamp.projects'' with an object which can then be used
in the
> tests.
>
> Sorry if this is a stupid question but I''m just a bit stuck with
it.
>
>
>
>
>
> --
> View this message in context:
http://www.nabble.com/RSpec-and-the-Basecamp-API-tp15205668p15205668.html
> Sent from the rspec-users mailing list archive at Nabble.com.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
James Deville
http://devillecompanies.org
james.deville at gmail.com
rspec r3172
rspec_on_rails r3172
rails r8331