Using FlexMock in a rails functional test.
- by dagda1
Hi,
I have the following index action:
class ExpensesController < ApplicationController
def index()
@expenses = Expense.all
end
end
I want to mock the call to all in a functional test. I am using flexmock and have written the following test:
require 'test_helper'
require 'flexmock'
require 'flexmock/test_unit'
class ExpensesControllerTest < ActionController::TestCase
test "should render index" do
flexmock(Expense).should_receive(:all).and_return([])
get :index
assert_response :success
assert_template :index
assert_equal [], assigns(:presentations)
end
end
The problem is the the last assertion fais with the following error message:
<[] expected but was nil
I am confused what I am doing wrong. Should this not work?
Cheers
Paul