factory-bot

Create users in Factory Girl with OmniAuth?

空扰寡人 提交于 2020-01-14 10:16:17
问题 I am currently creating an application that uses OmniAuth to create and authenticate users. I am encountering problems during testing due to Factory Girl being unable to generate users without OmniAuth. I have several different ways to get factory girl to create users with omniauth but none have been successful. I have added the following 2 lines to my spec_helper file OmniAuth.config.test_mode = true \\ allows me to fake signins OmniAuth.config.add_mock(:twitter, { :uid => '12345', :info =>

Create users in Factory Girl with OmniAuth?

自作多情 提交于 2020-01-14 10:14:30
问题 I am currently creating an application that uses OmniAuth to create and authenticate users. I am encountering problems during testing due to Factory Girl being unable to generate users without OmniAuth. I have several different ways to get factory girl to create users with omniauth but none have been successful. I have added the following 2 lines to my spec_helper file OmniAuth.config.test_mode = true \\ allows me to fake signins OmniAuth.config.add_mock(:twitter, { :uid => '12345', :info =>

Create users in Factory Girl with OmniAuth?

时间秒杀一切 提交于 2020-01-14 10:14:11
问题 I am currently creating an application that uses OmniAuth to create and authenticate users. I am encountering problems during testing due to Factory Girl being unable to generate users without OmniAuth. I have several different ways to get factory girl to create users with omniauth but none have been successful. I have added the following 2 lines to my spec_helper file OmniAuth.config.test_mode = true \\ allows me to fake signins OmniAuth.config.add_mock(:twitter, { :uid => '12345', :info =>

Populating an association with children in factory_girl

给你一囗甜甜゛ 提交于 2020-01-09 12:21:17
问题 I have a model Foo that has_many 'Bar'. I have a factory_girl factory for each of these objects. The factory for Bar has an association to Foo; it will instantiate a Foo when it creates the Bar. I'd like a Factory that creates a Foo that contains a Bar. Ideally this Bar would be created through the :bar factory, and respect the build strategy (create/build) used to create the Foo. I know I could just call the :bar factory and then grab the Foo reference from the new Bar. I'd like to avoid

Populating an association with children in factory_girl

主宰稳场 提交于 2020-01-09 12:17:10
问题 I have a model Foo that has_many 'Bar'. I have a factory_girl factory for each of these objects. The factory for Bar has an association to Foo; it will instantiate a Foo when it creates the Bar. I'd like a Factory that creates a Foo that contains a Bar. Ideally this Bar would be created through the :bar factory, and respect the build strategy (create/build) used to create the Foo. I know I could just call the :bar factory and then grab the Foo reference from the new Bar. I'd like to avoid

rspec association test only works in one direction

一世执手 提交于 2020-01-07 03:37:07
问题 I upgraded to Rails 3 and RSpec 2 and one of my RSpec tests stopped working: # Job.rb class Job < ActiveRecord::Base has_one :location belongs_to :company validates_associated :location end # Location.rb class Location < ActiveRecord::Base belongs_to :job end # job_spec.rb describe Job, "location" do it "should have a location" do job = Factory(:job) location = Factory(:location, :job_id => job.id) location.job.should == job #true job.location.should == location #false end end job.location

Rspec not logging me in

扶醉桌前 提交于 2020-01-06 14:13:09
问题 I was looking at this answer to see how to test a session controller and wrote something like this: require 'spec_helper' describe SessionsController do context "We should login to the system and create a session" do let :credentials do {:user_name => "MyString", :password => "someSimpleP{ass}"} end let :user do FactoryGirl.create(:user, credentials) end before :each do post :create , credentials end it "should create a session" do puts user.inspect puts session[:user_id] #session[:user_id]

Rspec not logging me in

╄→尐↘猪︶ㄣ 提交于 2020-01-06 14:12:08
问题 I was looking at this answer to see how to test a session controller and wrote something like this: require 'spec_helper' describe SessionsController do context "We should login to the system and create a session" do let :credentials do {:user_name => "MyString", :password => "someSimpleP{ass}"} end let :user do FactoryGirl.create(:user, credentials) end before :each do post :create , credentials end it "should create a session" do puts user.inspect puts session[:user_id] #session[:user_id]

RSpec without rails not loading files in spec/support

心已入冬 提交于 2020-01-05 09:36:27
问题 In the file spec/support/factory_girl.rb I have fail "At least this file is being required" RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods end and I have in some spec code require 'pmc_article' require 'pmc_article_parser' require 'factory_girl' require_relative './factories/pmc_article_factory' RSpec.describe PMCArticle do let(:pmc_article) do build(:pmc_article) end it 'parses pmid' do expect(pmc_article.article_id_pmid).to eq '123456' end end but when I run bundle

RSpec without rails not loading files in spec/support

走远了吗. 提交于 2020-01-05 09:36:25
问题 In the file spec/support/factory_girl.rb I have fail "At least this file is being required" RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods end and I have in some spec code require 'pmc_article' require 'pmc_article_parser' require 'factory_girl' require_relative './factories/pmc_article_factory' RSpec.describe PMCArticle do let(:pmc_article) do build(:pmc_article) end it 'parses pmid' do expect(pmc_article.article_id_pmid).to eq '123456' end end but when I run bundle