How to test posts in Rails / Capybara / Cucumber or Rspec -
i'm using rspec, cucumber , capybara , i'm looking way test malicious user can't hack form post url he/she doesn't have permission to. have permissions set in cancan such "should" work, however, way can test hacking form myself.
how can automate sort of testing? webrat in unit test rspec
put :update, :user_id => @user.id, :id => @user_achievement.id response.should contain("error, don't have permission access that!")
in capybara, however, visit get's seems. can't find way this, i've googled everwhere.
any appreciated, thanks
i think can rack-test https://github.com/brynary/rack-test
in gemfile:
gem 'rack-test'
in env.rb file
module capybaraapp def app; capybara.app; end end world(capybaraapp) world(rack::test::methods)
step defintions somewhere:
when /^i send post request "([^"]*)"$/ |path| post path end
most of learned came here: http://www.anthonyeden.com/2010/11/testing-rest-apis-with-cucumber-and-rack-test
update: think can skip changes env.rb file newer versions of rails and/or cucumber (not sure which, don't part on newer projects , works fine)
Comments
Post a Comment