У меня проблема с огурцом, когда в методе обратного вызова модели есть ссылка на себя.
Пример кода ниже.Ошибка выглядит так: Ожидается лицо (# 26738680), получено лицо (# 29003170) (ActiveRecord :: AssociationTypeMismatch)
class Person < ActiveRecord::Base
has_one :person_profile
accepts_nested_attributes_for : person_profile
after_create :new_person_profile
private
def new_person_profile
person_profile = PersonProfile.new(
...,
:person => self # <--- this causes the error in cucumber
)
self.person_profile.save
end
Сценарий сбоя выглядит так:
Scenario: Student logs in for the first time
Given I am a valid Student
Инеудачные шаги:
Before do
include Authlogic::TestCase
activate_authlogic
end
def valid_person
@current_person = Factory.create(:valid_person, :person_profile => new_person_profile('Kelly','Hope'))
end
Given /^I am a valid Student$/ do
valid_student
end
Спасибо, Адам