私は RSpec と FactoryGirl にかなり慣れていないので、RSpec のファクトリを使用するときにテストに合格しようとしています。
次のような spec/controllers/shares_controller_spec.rb 仕様があります。
require 'spec_helper'
describe SharesController do
let(:user) do
user = FactoryGirl.create(:user)
user
end
let(:share) do
share = FactoryGirl.create(:share)
share
end
context "standard users" do
it "cannot remove other person's shares" do
sign_in(:user, user)
send('delete', 'destroy', :id => share.id)
response.should redirect_to shares_path
flash[:alert].should eql('You must be the author to delete this share.')
end
end
end
そしてspec/factories.rb:
FactoryGirl.define do
factory :user do
sequence(:email) {|n| "user-#{n}@qwerty.com"}
password "password"
password_confirmation "password"
end
factory :share do
title "Test"
content "Test"
user FactoryGirl.create(:user)
end
end
私が走るとき
rspec 仕様/コントローラー/shares_controller_spec.rb私のテストは合格しましたが、どういうわけかCucumberを壊します:
$キュウリのすくい:OK レーキが中止されました! 検証に失敗しました: メールは既に取得されています タスク: TOP => cucumber:ok => db:test:prepare => db:abort_if_pending_migrations => 環境 ( --trace を指定してタスクを実行すると、完全なトレースが表示されます)
私は何を間違っていますか?前もって感謝します。