psyho / bogus

Fake library for Ruby
Other
359 stars 14 forks source link

I'm not able to stub as_json #49

Closed ArturT closed 10 years ago

ArturT commented 10 years ago

I'm not able to stub as_json on ThingsPresenter. I created a method called as_json2 then stub works great. Here is the example app with stack trace of failing spec https://github.com/ArturT/Bogus-Bug-Example

Please look at this spec https://github.com/ArturT/Bogus-Bug-Example/blob/master/spec/controllers/things_controller_spec.rb#L18

Thanks!

allenwyma commented 10 years ago

Did you try this? https://www.relishapp.com/bogus/bogus/docs/configuration/fake-ar-attributes It's not exactly the same, but may be related. Also, why not just stub to_json? I always override to_json instead of as_json. I dont' really know the difference.

ArturT commented 10 years ago

I've already tried fake_ar_attributes but it didn't help. Same problem is with stubbing to_json. We have a lot of presenters with as_json method and right now we are not able to stub it. The only way to stub it is to change as_json/to_json to other name.