Open remotelocal opened 9 years ago
Factoryを定義して、データをぶん回して、テストするみたいな流れがあったはず。
Factoryで作らなきゃいけないデータは? User WorkTime
FactoryGirl.define do factory :user do name "Michael Hartl" email "michael@example.com" password "foobar" password_confirmation "foobar" end end
require 'spec_helper'
describe "User pages" do
subject { page }
describe "profile page" do let(:user) { FactoryGirl.create(:user) } before { visit user_path(user) }
it { should have_content(user.name) } it { should have_title(user.name) }
end
describe "signup page" do before { visit signup_path }
it { should have_content('Sign up') } it { should have_title(full_title('Sign up')) }
end end
config/environments/test.rb SampleApp::Application.configure do . . .
ActiveModel::SecurePassword.min_cost = true end
http://railstutorial.jp/chapters/sign-up?version=4.0#sec-tests_with_factories
Factoryを定義して、データをぶん回して、テストするみたいな流れがあったはず。
Factoryで作らなきゃいけないデータは? User WorkTime
FactoryGirl.define do factory :user do name "Michael Hartl" email "michael@example.com" password "foobar" password_confirmation "foobar" end end
require 'spec_helper'
describe "User pages" do
subject { page }
describe "profile page" do let(:user) { FactoryGirl.create(:user) } before { visit user_path(user) }
end
describe "signup page" do before { visit signup_path }
end end
config/environments/test.rb SampleApp::Application.configure do . . .
bcrypt'のコスト関数を下げることでテストの速度を向上させる。
ActiveModel::SecurePassword.min_cost = true end
http://railstutorial.jp/chapters/sign-up?version=4.0#sec-tests_with_factories