I'll give another way to test, but, using the rspec matcher have_received because it seems more readable. See the example below using have_received matcher and tell me what do you think, ok? =)
it"creates a record"do##### Setupattrs={name: "P1",description: "Super Product"}allow(store).toreceive(:create)##### ExecutionCatalog.add_product(attrs,store)##### Expectationexpect(store).tohave_received(:create).with(attrs)end
Nice post!!! That's unit test!! =DD
I'll give another way to test, but, using the rspec matcher
have_received
because it seems more readable. See the example below usinghave_received
matcher and tell me what do you think, ok? =)see more about have_received matcher
Thanks for reply. Here my main focus is how to run validation code while testing.
I'm a new comer for rspec so I cannot say too much about it.