I’m following Michael H.'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:
FactoryGirl.define do
factory :user do
name “John S.”
sequence :email do |n|
“person-#{n}@factory.com”
end
password “foobar”
password_confirmation “foobar”
end
end
Here’s the relevant section of my users_controller_spec.rb:
require ‘spec_helper’
describe UsersController do
.
.
describe “GET ‘index’” do
.
.
describe “for signed-in users” do
before(:each) do
@user = test_sign_in(FactoryGirl.create(:user))
second = FactoryGirl.create(:user,
:email => “[email protected]”)
third = FactoryGirl.create(:user,
:email => “[email protected]”)
@users = [@user, second, third]
30.times do
@users << FactoryGirl.create(:user,
:email => FactoryGirl.generate(:email))
end
end
it "should have the right title" do
get :index
response.should have_selector("title", :content => "All users")
end
.
.
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…