При запуске теста poll_spec.rb
, появляется ошибка:
ArgumentError: Factory not registered: vote_option
Здесь мой код.
factories.rb:
FactoryGirl.define do
factory :user do
email "[email protected]"
password "foobarrr"
password_confirmation "foobarrr"
end
factory :poll do
topic "What your name?"
trait :vote_option1 do
association :vote_option, title: "Dima"
end
trait :vote_option2 do
association :vote_option, title: "Sasha"
end
end
end
poll_spec.rb:
require 'rails_helper'
RSpec.describe Poll, type: :model do
let(:user) { FactoryGirl.create(:user) }
#subject { @poll }
#it { should respond_to(:topic) }
#it {should be_valid}
describe "wrong information" do
describe "less than or equal 1 vote option" do
before do
FactoryGirl.create(:poll, :vote_option1)
end
it { should_not be_valid }
end
end
end
гем файл:
...........................
group :test do
gem 'capybara', '~> 2.4.4'
gem 'selenium-webdriver', '~> 2.46.2'
gem 'factory_girl_rails', '~> 4.5.0'
end
Подскажите, пожалуйста, где ошибка?