vendredi 3 juillet 2015

FactoryGirl fabrications does not apply in feature tests

So this is my Factory:

    FactoryGirl.define do
     factory :member do       
       email 'admin@admin.com'
       password 'rootroot'    
       first_name 'Rinholds'  
       last_name 'Jordan'     
       expiration Time.local(2015, 6, 21, 15, 13, 0)
       start_date Time.local(2015, 4, 21, 15, 13, 0)
       role 2                 
     end
  end

This is my spec:

   require 'rails_helper'

   describe DashboardController, type: :controller do

     it 'should display chart', js: true do
       member = create(:member)  
       member.save!           
       member.confirm         

       binding.pry            
       visit '/'              

     end
   end 

This is my root_path():

     body
       = yield
     = Member.first.email
~            

When i run spec it returns undefined method `email' for nil:NilClass in view.

When i put binding pry in view, and run Member.all it returns empty array!

How is that posible? How to force factorygirl to create real database data?!?

-- edit -- This is the controller, althout it doesnt even get there, because of devise login page authorized_member!

   class DashboardController < ApplicationController
     before_filter :authenticate_member!

     def index
       day_statistics = Statistics::DayStatistics.new(current_member)
       @charts = day_statistics.domain_charts
     end
   end

Then i add Member.all to my layout file and it shows [], FACTORY GIRL IS NOT WORKING!

Aucun commentaire:

Enregistrer un commentaire