你要測試的是,當用戶在填寫表單並按下「提交」,該應用程序不會根據提交的信息正確的事, 對?
假設你正在使用標準的黃瓜+ Webrat組合一個Rails應用程序的工作,你可以這樣做:
Background: Login, go to really long form
Given the user "Fred exists" # Factory a user into existance, something like @user = Factory(:user, :username => "Fred"
And I am on the "Really long form" page # map "Really long form page" in /features/supposrt/paths.rb
Scenario: Succesfully fill in really long form
When I fill in the following: # This is defined in Webrat steps
| field 1 | response 1 |
| field 2 | response 2 |
...
| field 19 | response 19 |
| field 20 | response 20 |
And I press "Save"
Then I should see a "success" message # assert there is a div with the calss success. Could be an error message
And "Fred" should have a valid set of attributes # because you defined @user, you can call whatever assertions you like here i.e. assert equal @user.username, "Fred" (I forget the correct syntax for doing this, but you get the idea).
這是否幫助?