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:
FactoryGirl.define do
  factory :user do
    name "John Smith"
    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 => "anot...@example.com")
          third = FactoryGirl.create(:user,
                   :email => "anot...@example.net")
          @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..

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9a737f95223c556c8f2296079c82b59f%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to