FactoryGirl screws up rake db:migrate process

I think you need to have factory girl definition like that in Gemfile: gem ‘factory_girl_rails’, :require => false And then you just require it in your spec_helper.rb like that: require ‘factory_girl_rails’ This is the way I’m always using this gem. You don’t need to require it in other places than spec_helper.rb. Your current desired approach … Read more

Pass parameter in setting attribute on association in FactoryGirl

The association helper in factory_girl can’t take dynamic property arguments, but you can use a dynamic attribute to instantiate the association however you want: factory :tx_link do units “9.99” factory :link_red_to_sub do transient do sub 0 red 0 end units { red } giver { create(:transaction, units: sub) } taker { create(:redemption, units: red) } … Read more

How to write an RSpec test for a simple PUT update?

You forgot to .reload your @article, and on update action your response most likely perform redirect, so RSpec 2: describe “PUT update/:id” do let(:attr) do { :title => ‘new title’, :content => ‘new content’ } end before(:each) do put :update, :id => @article.id, :article => attr @article.reload end it { response.should redirect_to(@article) } it { … Read more

Using factory_girl_rails with Rspec on namespaced models

I have a minimal working example here, maybe you could use it to pinpoint where your problem is. The comment you left on dmarkow’s answer suggests to me that you have an error someplace else. app/models/bar/foo.rb class Bar::Foo < ActiveRecord::Base end *db/migrate/20110614204536_foo.rb* class Foo < ActiveRecord::Migration def self.up create_table :foos do |t| t.string :name end … Read more

How to specify the association with factory_bot?

You should use explicit associations instead of implicit ones: #spec/factories/post.rb FactoryBot.define do factory :post do association :user # <<<— here the change body Faker::Movie.quote posted_at “2018-04-03 13:33:05” end end #spec/factories/user.rb FactoryBot.define do factory :user do first_name ‘Jake’ end end https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)