I have the following tests:
Creating this action: the user responds first Once a post 'login_ass user #actionmileer goes above two because the user who created the topic is a post together. # Post an email for post creation, second post reply to Assert_difference (['postcount', 'action mileer :: base. Deliveries.size'], 2) Post: create, topic_id: topic.id, post: {body : 'Creating a post for the first time.' } End Email = Action Mailer :: Base. Deliveries email.first.to.must_equal [user.email] email.subject.must_equal 'Post successfully created' must_redirect_to topic_path (topic.id) email.last.to.must_equal [user] .email]] Email.subject.must_equal will send 'reply sent reply' i_redirect_to topic_path (topic.id) end
due to the assert_difference
block in the code Test Breaks Up To pass this exam I need to increase from 1 to postcount, and after that, ActionMailer :: Base.deliveries.size
will be increased by 2. This scenario will pass the test pass. I have tried to rewrite the code in this second type of test.
Creating this action: A user first responds to the posting 'Login User's Postcount' Login User, 1) Post: Create, topic_id: topic.id, Posted: {Body: 'Creating a Post for the First Time. '} End # ActionMiler goes above two because the user who created the topic is a post together. # Email for post creation, second for post reply. Assert_difference ('ActionMailer :: Base.deliveries.size', 2) Post: Make, topic_id: topic.id, post: {body: 'Creating a post for the first time.' } End Email = Action Mailer :: Base. Deliveries email.first.to.must_equal [user.email] email.subject.must_equal 'Post successfully created' must_redirect_to topic_path (topic.id) email.last.to.must_equal [user] .email]] Email.subject.must_equal 'Answer has sent the answer' end of the must_redirect_to topic_path (topic.id)
This second instance is for me, but not enough. The problem with this code is that it will create a post object twice due to making a call in the assert_difference
block I have seen that the code in the Rail API guide and API dock looked at the code assert_difference
I want something like this:
Assert_difference ['postcount', 'action mileer :: base. Deliveries.size'], 1,2 do # End the post app
Is there a way to implement it?
You can nest them, like:
assert_difference ("post."), 1) assert_difference ("Action mileer :: base. Deliveries.size", 2) Do # Create Term
No comments:
Post a Comment