ARID (ActiveResourceIntegrationDsl) version 0.3 is released for your testing pleasure. Yes Cliff, that's a nested acronym. You know you love it! This one isn't a major update. I added some more documentation to the README, and fixed a bug that wouldn't allow tests to access the index action on controllers. I'm using this plugin quite extensively on a project at the day job now.

On Sunday, as we were getting ready for the Euchre Tournament to start, I was chatting with Cliff. He was a little fuzzy about what ARID did, which isn't surprising. My explanations so far admittedly haven't been all that clear. But hey, it's only at version 0.3, so give me a break.

Anyway, I thought a couple WITH and WITHOUT examples might do a better job. So, how's this for explaining what ARID does for your Integration tests?

New User Signing Up
With ARID
new_session do |guest|
  guest.creates_user({:user => {:username => 'george', :password => 'curious'}})
end
Without ARID
open_session do |sess| 
  sess.get new_user_path
  sess.assert_response :success
  sess.assert_select "form[action='/users'][method='post']" do
    sess.assert_select "input[name='user[username]']"
    sess.assert_select "input[name='user[password]']"
  end
  sess.post users_path, {:user => {:username => 'george', :password => 'curious'}}
  sess.assert_response :redirect
  sess.follow_redirect!
  sess.assert_response :success
end
Updating a User
With ARID
new_session_as('jonnyg','testing123') do |jon|
  jon.updates_user(42,{:user => {:username => 'newname', :password => 'newpass'}})
end
Without ARID
open_session do |sess|
  #Load Login Page and Check the Form
  sess.get new_session_path
  sess.assert_response :success
  sess.assert_select "form[action='/sessions'][method='post']" do
    sess.assert_select "input[name='user[username]']"
    sess.assert_select "input[name='user[password]']"
  end

  #Login
  sess.post sessions_path, {:user => {:username => 'jonnyg', :password => 'testing123'}}
  sess.assert_response :redirect
  sess.follow_redirect!
  sess.assert_response :success

  #Get Edit User Page and Check the Form
  sess.get edit_user_path(42)
  sess.assert_response :success
  sess.assert_select "form[action='/users/42'][method='post']" do
    sess.assert_select "input[type='hidden'][name='_method'][value='put']"
    sess.assert_select "input[name='user[username]']"
    sess.assert_select "input[name='user[password]']"
  end
  
  #Update User
  sess.put user_path(42) {:user => {:username => 'newname', :password => 'newpass'}}
  sess.assert_response :redirect
  sess.follow_redirect!
  sess.assert_response :success
  
  #Log Out
  sess.delete session_path('current')
  sess.assert_resonse :redirect
  sess.follow_redirect!
  sess.assert_response :success
end

Note that these are pretty minimalistic tests. They don't check to see that the user actually got created or updated. Since your controller may, or may not, have a 1 to 1 correlation with a model in the back end, and what you actually expect to happen to that model may change from controller to controller, I'll leave it to you to check that your app works the way you expect it to. Also, note that you can pass a block to any of the provided methods to do additional assertions on the generated page. See the README for additional details on that.

Comments: [add comment]