rspec-expectations: have_attributes raises error for Dynamic attributes set on monogid objects

For example, ctr is a dynamic attribute set on a model, say, DailyStat. There is no field ctr defined on DailyStat then the expectation fails with a NameError: undefined method 'ctr' for class 'DailyStat'

Usage:

it '...' do
  daily_stat = DailyStat.where(...).first
  expect(daily_stat).to have_attributes('ctr' => 0.5)
end

Can support for dynamic attributes be added in the matcher?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Ok thanks for the clarification! For now I’m gong to close this as the matcher is working as designed and intended. mongoid-rspec could take this further.