How can i unit test a "Delete link" with Ror, cucumber - webrat?
I am currently developing a Rails application, I'm trying to units test it. I chose Cucumber + WebRater. I'd like to test in my backend all delete link.
I tried to go to visit a second argument (the method: delete) without success. (something like : visit my_path, method => :delete)
On my pages I delete some links so the solution click_link ("Delete") is not acceptable.
I appeal to your exp开发者_如何学运维erience in this field.
Thank you in advance
Gaetan.
The method :delete us Javascript to made the good request to you server with a POST and _method='put".
Webrat don't know how interprete the Javascript. If you want that, you need use some backend with it. Capybara or Selenium.
Webrat just needs a simple patch to get it to work with rails3's new unobtrusive JavaScript.
See here for explanation and a link to the patch:
https://webrat.lighthouseapp.com/projects/10503/tickets/365-allow-webrat-to-read-the-data-method-attribute
Worked for me.
精彩评论