I'm using Shoulda, Mocha, and Test::Unit for testing. I have the following controller and test:
class FoosController < ApplicationController
caches_action :show
def show
@foo = requested_foo
end
private
def requested_foo
Foo.find(params[:id])
end
end
class FoosCachingTest < ActionController::IntegrationTest
def s...
I'm developing a application that uses the twitter API. I'm currently using rspec with mocha, but I found it to be cumbersome and I cannot reuse the mocking that I create for a give method. Is there a way that you can have for a give call, return something, and for another call return something else? Or it needs to be by each method?
...
I'm attempting the following functional test on the controller. I'm using the following
RSpec2
Rails 3
Shoudla
Mocha
Here's the test
context "POST on create should be successful" do
before(:each) do
Model.any_instance.expects(:save).returns(true).once
Model.any_instance.stubs(:id).returns(1)
post :create, :model => {}...
I'm fairly new to RoR and recently started learning BDD/Rspec for testing my application. I've been looking for a way to spec an AJAX request, but so far I haven't found much documentation on this at all.
Anyone know how to do this? I'm using rails 2.3.8, rspec 1.3.0 and mocha 0.9.8 for my stubs (which I'm also in the process of le...
I need to mock the following:
Class User
def facebook
#returns an instance of a facebook gem
end
end
So in my User tests, to access the User's facebook info I need to call user.facebook.me.info to retrieve its info. If I want to mock this, I'm currently using the following:
@user = Factory(:user)
facebook = mock()
me = mock()...
Is it possible to stub an entire chain using Mocha? For example, I want to stub:
User.first.posts.find(params[:id])
such that it returns a predefined post instance instead of accessing the database. Ideally, I'd want to do something like:
@post = Post.new
User.any_instance.stubs(:posts,:find).returns(@post)
As you can see, I'm stub...
For a test suite that's already using mocha for mocking, can new tests be written with rspec mocking? maybe turn that on before(:all) and turn it back to mocha after(:all)
I tried changing the Spec::Runner configuration at run-time and that didn't seem to work with mocking
...