hi there, I have a Rails model A, that has_one model B, model A have a method called save_nested_b that: * context 'invalid B params' ** context 'no nested B exists' => do nothing ** context 'nested B exists' => remove it
* context 'valid B params' ** context 'no nested B exists' => create it ** context 'nested B exists' => remove it and create new one (or edit attributes linking to A) the save_nested_b method implementation should not be problematic. My question is: on A specs I want to make sure all above on the list happens but not having to repeat all B validations on making 'invalid B params' examples, because B have its own specs, and also the A specs for save_nested_b will be brittle when B validations change (not to mention the combinations of invalid fields can be long) how would you do this? would you do a loose thing like: context 'invalid B params' do .. a.save_nested_b nil a.should have_no_b .. end giving it a more thought after writing this email I guess I would go for this approach, what do you think? greetings, joaquin -- www.least-significant-bit.com
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users