Permalink
Browse files

Changing cucumber steps to use tabular form where possible

  • Loading branch information...
1 parent 1a30cd5 commit 8325882ea251f6aae0f06edb7d33ed4f3fe352c3 @devendram devendram committed Aug 22, 2012
@@ -1,8 +1,10 @@
@javascript
Feature: Blocking a user from the stream
Background:
- Given a user named "Bob Jones" with email "bob@bob.bob"
- And a user named "Alice Smith" with email "alice@alice.alice"
+ Given following users exist:
+ | username | email |
+ | Bob Jones | bob@bob.bob |
+ | Alice Smith | alice@alice.alice |
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
And Alice has a post mentioning Bob
And I sign in as "bob@bob.bob"
@@ -18,8 +18,10 @@ Feature: Close Account
And I should see a flash message containing "Invalid email or password"
Scenario: post display should not throw error when mention is removed for the user whose account is closed
- Given a user named "Bob Jones" with email "bob@bob.bob"
- And a user named "Alice Smith" with email "alice@alice.alice"
+ Given following users exist:
+ | username | email |
+ | Bob Jones | bob@bob.bob |
+ | Alice Smith | alice@alice.alice |
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
And Alice has a post mentioning Bob
@@ -5,8 +5,10 @@ Feature: commenting
I want to comment on her post
Background:
- Given a user named "Bob Jones" with email "bob@bob.bob"
- And a user named "Alice Smith" with email "alice@alice.alice"
+ Given following users exist:
+ | username | email |
+ | Bob Jones | bob@bob.bob |
+ | Alice Smith | alice@alice.alice |
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
When "alice@alice.alice" has posted a status message with a photo
@@ -2,9 +2,11 @@
Feature: following and being followed
Background:
- Given a user with email "bob@bob.bob"
- And a user with email "alice@alice.alice"
-
+ Given following users exist:
+ | email |
+ | bob@bob.bob |
+ | alice@alice.alice |
+
When I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page
And I add the person to my "Besties" aspect
@@ -5,8 +5,10 @@ Feature: posting
I want to see what humanity is saying about particular tags
Background:
- Given a user with username "bob"
- And a user with username "alice"
+ Given following users exist:
+ | username |
+ | bob |
+ | alice |
When I sign in as "bob@bob.bob"
And I post a status with the text "I am da #boss"
@@ -4,9 +4,11 @@ Feature: Mentions
I want to mention another user and have a link to them
To show people that this person exsists.
- Scenario: A user mentions another user and it displays correctly
- Given a user named "Bob Jones" with email "bob@bob.bob"
- And a user named "Alice Smith" with email "alice@alice.alice"
+ Scenario: A user mentions another user and it displays correctly
+ Given following users exist:
+ | username | email |
+ | Bob Jones | bob@bob.bob |
+ | Alice Smith | alice@alice.alice |
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
And Alice has a post mentioning Bob
When I sign in as "alice@alice.alice"
@@ -6,13 +6,16 @@ Feature: mentioning a contact from their profile page
Background:
Given I am on the home page
- And a user with username "bob"
- And a user with username "alice"
+ And following users exist:
+ | username |
+ | bob |
+ | alice |
When I sign in as "bob@bob.bob"
And a user with username "bob" is connected with "alice"
- And I have an aspect called "PostingTo"
- And I have an aspect called "NotPostingThingsHere"
+ And I have following aspects:
+ | PostingTo |
+ | NotPostingThingsHere |
And I have user with username "alice" in an aspect called "PostingTo"
And I have user with username "alice" in an aspect called "NotPostingThingsHere"
@@ -2,7 +2,9 @@
Feature: Not safe for work
Scenario: Setting not safe for work
- Given a user named "pr0n king" with email "tommy@pr0n.xxx"
+ Given following users exist:
+ | username | email |
+ | pr0n king | tommy@pr0n.xxx |
And I sign in as "tommy@pr0n.xxx"
When I go to the edit profile page
And I should see the "you are safe for work" message
@@ -5,9 +5,11 @@ Feature: Notifications
I want to get notifications
Background:
- Given a user with email "bob@bob.bob"
- And a user with email "alice@alice.alice"
-
+ Given That following users:
+ | email |
+ | bob@bob.bob |
+ | alice@alice.alice |
+
Scenario: someone shares with me
When I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page
View
@@ -5,7 +5,9 @@ Feature: oembed
I want the links in my posts be replaced by their oEmbed representation
Background:
- Given a user named "Alice Smith" with email "alice@alice.alice"
+ Given following user exists:
+ | username | email |
+ | Alice Smith | alice@alice.alice |
And I have several oEmbed data in cache
When I sign in as "alice@alice.alice"
And I am on the home page
@@ -5,12 +5,15 @@ Feature: posting from the main page
I want to tell the world I am eating a yogurt
Background:
- Given a user with username "bob"
- And a user with username "alice"
+ Given following users exist:
+ | username |
+ | bob |
+ | alice |
And I sign in as "bob@bob.bob"
And a user with username "bob" is connected with "alice"
- And I have an aspect called "PostingTo"
- And I have an aspect called "NotPostingThingsHere"
+ Given I have following aspects:
+ | PostingTo |
+ | NotPostingThingsHere |
And I have user with username "alice" in an aspect called "PostingTo"
And I have user with username "alice" in an aspect called "NotPostingThingsHere"
And I am on the home page
View
@@ -5,8 +5,10 @@ Feature: public repost
I want to reshare my friend's post
Background:
- Given a user named "Bob Jones" with email "bob@bob.bob"
- And a user named "Alice Smith" with email "alice@alice.alice"
+ Given following users exist:
+ | username | email |
+ | Bob Jones | bob@bob.bob |
+ | Alice Smith | alice@alice.alice |
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
# should be covered in rspec, so testing that the post is added to
@@ -5,7 +5,9 @@ Feature: collapsing and expanding long posts
I want long posts to be collapsed and expand on click
Background:
- Given a user with username "bob"
+ Given that following user exists:
+ | username |
+ | bob |
And I sign in as "bob@bob.bob"
And I am on the home page
View
@@ -43,20 +43,23 @@ Feature: new user registration
| user_username | $%&(/&%$&/=)(/ |
And I press "Continue"
- Then the "user_username" field should have a validation error
- And the "user_email" field should have a validation error
- And the "user_password" field should have a validation error
+ Then following fields should have validation errors:
+ | user_username |
+ | user_email |
+ | user_password |
When I fill in the following:
| user_username | valid_user |
| user_email | this is not a valid email $%&/()( |
And I press "Continue"
- Then the "user_email" field should have a validation error
- And the "user_password" field should have a validation error
+ Then following fields should have validation errors:
+ | user_email |
+ | user_password |
When I fill in the following:
| user_email | valid@email.com |
| user_password | 1 |
And I press "Continue"
- Then the "user_password" field should have a validation error
+ Then following field should have validation error:
+ | user_password |
@@ -12,6 +12,13 @@
find_field(field).has_xpath?(".//ancestor::div[contains(@class, 'control-group')]/div[contains(@class, 'field_with_errors')]")
end
+
+Then /^following field[s]? should have validation error[s]?:$/ do |fields|
+ fields.raw.each do |field|
+ step %{the "#{field[0]}" field should have a validation error}
+ end
+end
+
And /^I expand the publisher$/ do
click_publisher
end
@@ -25,6 +25,20 @@
user.profile.update_attributes(:nsfw => true)
end
+
+Given /^(?:|[tT]hat )?following user[s]?(?: exist[s]?)?:$/ do |table|
+ table.hashes.each do |hash|
+ if hash.has_key? "username" and hash.has_key? "email"
+ step %{a user named "#{hash['username']}" with email "#{hash['email']}"}
+ elsif hash.has_key? "username"
+ step %{a user with username "#{hash['username']}"}
+ elsif hash.has_key? "email"
+ step %{a user with email "#{hash['email']}"}
+ end
+ end
+end
+
+
Given /^I have been invited by an admin$/ do
admin = Factory(:user)
admin.invitation_code
@@ -52,6 +66,12 @@
@me.reload
end
+Given /^I have following aspect[s]?:$/ do |fields|
+ fields.raw.each do |field|
+ step %{I have an aspect called "#{field[0]}"}
+ end
+end
+
When /^I have user with username "([^"]*)" in an aspect called "([^"]*)"$/ do |username, aspect|
user = User.find_by_username(username)
contact = @me.reload.contact_for(user.person)
@@ -5,8 +5,10 @@ Feature: Unfollowing
I want to be able to stop following people
Background:
- Given a user with email "bob@bob.bob"
- And a user with email "alice@alice.alice"
+ Given following users:
+ | email |
+ | bob@bob.bob |
+ | alice@alice.alice |
When I sign in as "bob@bob.bob"
And I am on "alice@alice.alice"'s page
And I add the person to my "Besties" aspect

0 comments on commit 8325882

Please sign in to comment.