I'm following Michael Hartl's Ruby on Rails 3 Tutorial but I'm using
Rails 3.2.8 and FactoryGirl 4.2.0 and rspec 2.14.1 I'm in chapter 10
trying to generate tests for pagination (using will_paginate 3.2.5 which
works fine in dev)
I can get FactoryGirl to test just fine if I don't use Sequence but I
can't seem to figure out the correct syntax to test pagination using
sequence. Very new to Ruby.
Here's what my factories.rb looks like:
factory :user do
name "John Smith"
sequence :email do |n|
Here's the relevant section of my users_controller_spec.rb:
describe UsersController do
describe "GET 'index'" do
describe "for signed-in users" do
@user = test_sign_in(FactoryGirl.create(:user))
second = FactoryGirl.create(:user,
:email => "email@example.com")
third = FactoryGirl.create(:user,
:email => "firstname.lastname@example.org")
@users = [@user, second, third]
@users << FactoryGirl.create(:user,
:email => FactoryGirl.generate(:email))
it "should have the right title" do
response.should have_selector("title", :content => "All users")
All my "get :index" tests are failing in the "for signed-in users" block
fail. They don't fail if I just manually create a list of 30 users so
something is wrong with how I am trying to sequence or generate.
Thanks for helping this newb..