What is the difference between User.make and User.new?

77 views Asked by At

In Capybara docs, it has

describe "the signin process", :type => :feature do
  before :each do
    User.make(:email => '[email protected]', :password => 'password')
  end    
  it "signs me in" do
    visit '/sessions/new'
    within("#session") do
      fill_in 'Email', :with => '[email protected]'
      fill_in 'Password', :with => 'password'
    end
    click_button 'Sign in'
    expect(page).to have_content 'Success'
  end
end

My question is what is the difference between User.make and User.create; As from this question: Ruby on Rails - what is make method on a model? User.make is a Machnist gem specific method. Why would Capybara include that in it's docs and not just user User.create, is it vital or really useful with testing specs?

1

There are 1 answers

0
Andy Waite On BEST ANSWER

Libraries such as Machinist and FactoryGirl allow you to create entities using a template which has reasonable defaults, so that you only need to specify the properties that are relevant to the test. It's very common to use them in tests, as an alternative to fixtures.