Skip to content

Instantly share code, notes, and snippets.

@m3talsmith
Created August 26, 2009 21:20
Show Gist options
  • Save m3talsmith/175859 to your computer and use it in GitHub Desktop.
Save m3talsmith/175859 to your computer and use it in GitHub Desktop.
Feature: Manage Users
So that I can manage my user base
As an administrator
I want to be able to list, create, view, update, activate, deactivate, and archive all users
Background: # features/manage_users.feature:6
Given the following users: # features/step_definitions/manage_users_steps.rb:1
| name | login | password | is_admin |
| Test Admin | test_admin | noone | true |
| Basic User | basic_user | loluser | false |
Scenario: List all users # features/manage_users.feature:12
Given an admin # features/step_definitions/admin_common_steps.rb:1
And a current admin session # features/step_definitions/admin_common_steps.rb:5
When I visit "/admin/users" # features/step_definitions/common_steps.rb:1
Then I should see a list of "users" with a length of at least "2" # features/step_definitions/manage_users_steps.rb:14
expected following output to contain a <.user/> tag:
<table class="users">
<thead><tr>
<th> </th>
<th>Name</th>
<th>Login</th>
<th>Administrator</th>
</tr></thead>
<tr class="user">
<td><input id="user_1" name="user_1" type="checkbox" value="none"></td>
<td>Test Admin</td>
<td>test_admin</td>
<td>True</td>
</tr>
<tr class="user">
<td><input id="user_2" name="user_2" type="checkbox" value="none"></td>
<td>Basic User</td>
<td>basic_user</td>
<td>False</td>
</tr>
</table> (Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/manage_users_steps.rb:18:in `__instance_exec0'
./features/step_definitions/manage_users_steps.rb:17:in `/^I should see a list of "([^\"]*)" with a length of at least "([^\"]*)"$/'
features/manage_users.feature:16:in `Then I should see a list of "users" with a length of at least "2"'
--
I'm using cucumber version 0.3.94
Then I should see a list of "users" with a length of at least "2"
<table class="users">
<thead>
<tr>
<th> </th>
<th>Name</th>
<th>Login</th>
<th>Administrator</th>
</tr>
</thead>
<tr class="user">
<td><input id="user_1" name="user_1" type="checkbox" value="none"></td>
<td>Test Admin</td>
<td>test_admin</td>
<td>True</td>
</tr>
<tr class="user">
<td><input id="user_2" name="user_2" type="checkbox" value="none"></td>
<td>Basic User</td>
<td>basic_user</td>
<td>False</td>
</tr>
</table>
Then /^I should see a list of "([^\"]*)" with a length of at least "([^\"]*)"$/ do |list_class, length|
# Because of issues with the :count option, I will be ignoring the length and
# just settling for seeing a plural of a list_class and a singular inside that
response.should have_selector(".#{list_class}") do |inner_selection|
inner_selection.should have_selector(".#{list_class.to_s.singularize}", :count => length)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment