27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Adding more tags<br />

cannot fill in, no text field, text area or password<br />

field with id, name, or label 'Tags' found<br />

You can fix this by taking these lines from app/views/tickets/_form.html.erb and moving<br />

them into a new partial at app/views/tags/_form.html.erb:<br />

<br />

<br />

<br />

<br />

Replace the code you removed from app/views/tickets/_form.html.erb with this line:<br />

<br />

This new line will render your new tags partial. In order to make the failing step in<br />

your scenario now pass, you re-use this same line inside the authorized? block inside<br />

app/views/comments/_form.html.erb underneath the code you use to render the<br />

State select box.<br />

When you run bin/cucumber features/creating_comments.feature:47, you see<br />

that this step is indeed passing, but now it’s the final step of your scenario that is failing:<br />

Then I should see "bug" within "#ticket #tags"<br />

expected there to be content "bug" in ""<br />

This feature is not seeing the word “bug” within the content for the ticket’s tags<br />

(which is empty), and so the scenario fails. This is because the code to associate a tag<br />

with a ticket isn’t in the create action of CommentsController yet. In the create<br />

action in TicketsController, you use this line to tag the ticket that was created:<br />

@ticket.tag!(params[:tags])<br />

You can use this same method to tag a comment’s ticket. On the line immediately<br />

after if @comment.save in the create action inside CommentsController, you re-use<br />

the tag! line. That’s all you need to get this scenario to pass, right? Run bin/cucumber<br />

features/creating_comments.feature:47 to find out:<br />

1 scenario (1 passed)<br />

15 steps (15 passed)<br />

Boom, that’s passing! Good stuff. Now for the cleanup. Make sure you haven’t broken<br />

anything else by running rake cucumber:ok spec:<br />

55 scenarios (55 passed)<br />

598 steps (598 passed)<br />

# and<br />

27 examples, 1 failure, 10 pending<br />

It would seem your spec/controllers/comments_controller_spec.rb doesn’t want to<br />

play nice.<br />

293

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!