0
я в настоящее время тест RSpec:RSpec и FactoryGirl
Rspec.describe Some::ServiceClass do
args = ['1', '2']
subject { described_class.new(args) }
describe '#finder_method' do
let(:user_1) { FactorGirl.create(:user) }
it 'returns the right number of users' do
expect(subject.finder_method.count).to eq(1)
end
end
end
Это то, что класс испытываемого выглядит
module Some
class Service
....
# other methods used to identify the resource model
def finder_method
resource.all
end
end
end
Expectation:
- когда
resource.all
называется , Я ожидал, что let(:user_1) FactoryGirl.create(:user)
, в spec test, заселил 1 строку в таблицеusers
(test env)- поэтому, когда оценивается
subject.finder_method
, он будет возвращать один объект AR.
Фактический результат:
- вместо
subject.finder_method
, который просто вызываетall
на объект AR, возвращает#<ActiveRecord::Relation []>
Может кто-нибудь, пожалуйста, объясните, почему это происходит? Где находится user_1
, который был создан FactoryGirl?