describe 'test example of struct' dolet!(:subscription) { Sub = Struct.new(:canceled_at) ; Sub.new(canceled_at: 2.weeks.from_now) }it 'behaves okay with no expectation set' dovalue = 2.weeks.agosubscription.canceled_at = valueputs subscription.inspectexpect(subscription.canceled_at).to eq valueendit 'misbehaves if I place an expecation on the element' doexpect(subscription).to receive(:canceled_at)value = 2.weeks.agosubscription.canceled_at = valueputs subscription.inspectexpect(subscription.canceled_at).to eq valueendend
Run options: include {:locations=>{"./spec/models/user/stripe_customer_spec.rb"=>[362]}}
#<struct Sub canceled_at=Thu, 11 Feb 2021 21:24:19 UTC +00:00>
./Users/jackrg/Documents/Novelty-Stats/spec/models/user/stripe_customer_spec.rb:363: warning: already initialized constant Sub
/Users/jackrg/Documents/Novelty-Stats/spec/models/user/stripe_customer_spec.rb:363: warning: previous definition of Sub was here
#<struct Sub canceled_at=Thu, 11 Feb 2021 21:24:19 UTC +00:00>
F
Failures:
1) User::StripeCustomer test example of struct misbehaves if I place an expecation on the element
Failure/Error: expect(subscription.canceled_at).to eq value
expected: 2021-02-11 21:24:19.601491000 +0000
got: nil
(compared using ==)
# ./spec/models/user/stripe_customer_spec.rb:377:in `block (3 levels) in <top (required)>'
Finished in 0.0432 seconds (files took 7.91 seconds to load)
2 examples, 1 failure