Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created August 8, 2008 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agibralter/4636 to your computer and use it in GitHub Desktop.
Save agibralter/4636 to your computer and use it in GitHub Desktop.
Story: viewing lists
As a participant
I want view lists
So that blah blah blah
Scenario: viewing the list of ListViews as an anonymous user
Given nothing
When someone requests '/list_views.xml'
Then they should see a list of lists containing 'List 1'
And they should see a list of lists containing 'List 2'
And they should not see a list of lists containing 'List 3'
Scenario: viewing the list of ListViews as a logged in user
Given a User with no email, login 'bob', and password 'password'
And 'bob' logged in with password 'password' # THIS PASSES BUT CAUSES THE FAILS BELOW
When 'bob' requests '/list_views.xml'
Then they should see a list of lists containing 'List 1' # FAIL
And they should see a list of lists containing 'List 2' # FAIL
And they should see a list of lists containing 'List 3' # FAIL
steps_for(:viewing) do
When("$agent requests '/list_views.xml'") do |agent|
get '/list_views.xml'
# This is displaying correctly for both scenarios
puts "<pre>#{response.body}</pre>"
end
Then("they should see a list of lists containing '$list_name'") do |list_name|
response.should have_tag('list-views>list-view>name', list_name)
end
Then("they should not see a list of lists containing '$list_name'") do |list_name|
response.should_not have_tag('list-views>list-view>name', list_name)
end
end
steps_for(:user) do
Given("a User with no email, login '$login', and password '$password'") do |login, password|
Factory(:user, :email => nil, :login => login, :password => password, :password_confirmation => password)
end
Given("'$login_or_email' logged in with password '$password'") do |login_or_email, password|
post '/session', { :login_or_email => login_or_email, :password => password }
response.should be_redirect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment