Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cucumber paths made human-readable and more consistent. eg "When I go…

… to the snippets admin page". Steps and features updated
  • Loading branch information...
commit d33234585d23e943870196f4c965239205a35994 1 parent bff6b96
@will-r will-r authored
View
4 features/admin/content_negotiation.feature
@@ -6,13 +6,13 @@ Feature: Proper content negotiation
Scenario: Default to HTML format
Given I am logged in as "admin"
When I send an "Accept" header of "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
- And I go to admin:pages
+ And I go to the "pages" admin page
Then I should not see "Missing template"
Scenario: Requesting XML format via file-extension
Given I am logged in as "admin"
When I send an "Accept" header of "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
- And I go to admin:pages as xml
+ And I go to the "pages" admin page as xml
Then I should see an xml document
Scenario: Requesting children via Ajax
View
12 features/admin/pages_management.feature
@@ -5,20 +5,20 @@ Feature: Managing pages
Scenario: Listing pages
Given I am logged in as "existing"
- When I go to admin:pages
+ When I go to the "pages" admin page
Then I should see "Pages"
And I should see "Home"
Scenario: No pages
Given I am logged in as "existing"
Given there are no pages
- When I go to admin:pages
+ When I go to the "pages" admin page
Then I should see "No Pages"
Scenario: Creating a homepage
Given I am logged in as "existing"
Given there are no pages
- When I go to admin:pages
+ When I go to the "pages" admin page
And I follow "New Homepage"
Then I should see "New Page"
And there should be a "body" part
@@ -38,7 +38,7 @@ Feature: Managing pages
Scenario: Creating child pages
Given I am logged in as "existing"
And there is a homepage
- When I go to admin:pages
+ When I go to the "pages" admin page
And I follow "Add child"
Then I should see "New Page"
And there should be a "body" part
@@ -52,12 +52,12 @@ Feature: Managing pages
And I press "Save and Continue Editing"
Then I should see "Edit Page"
And I should see "Under Construction"
- When I go to my-child
+ When I go to the new child page
Then I should see "Under Construction"
Scenario: Delete page
Given I am logged in as "existing"
- When I go to admin:pages
+ When I go to the "pages" admin page
And I follow "remove page"
Then I should see "permanently remove"
When I press "Delete Pages"
View
14 features/admin/user_permissions.feature
@@ -4,7 +4,7 @@ Feature: User authentication and permissions
users should be given different access permissions
Scenario Outline: Authentication-login
- When I go to admin:login
+ When I go to the login page
And I fill in "Username" with "<username>"
And I fill in "Password" with "password"
And I press "Login"
@@ -31,7 +31,7 @@ Feature: User authentication and permissions
Scenario Outline: All users can edit pages
Given I am logged in as "<username>"
And I should see "Pages"
- When I go to admin:pages
+ When I go to the "pages" admin page
And I follow "Home"
Then I should see "Edit Page"
And I should see "Pages"
@@ -73,7 +73,7 @@ Feature: User authentication and permissions
Scenario Outline: Ordinary users cannot edit layouts
Given I am logged in as "<username>"
And I should not see "Design"
- When I go to admin:layouts
+ When I go to the "layouts" admin page
Then I should see "You must have designer privileges"
Examples:
@@ -84,7 +84,7 @@ Feature: User authentication and permissions
Scenario Outline: Ordinary users cannot edit snippets
Given I am logged in as "<username>"
And I should not see "Design"
- When I go to admin:snippets
+ When I go to the "snippets" admin page
Then I should see "You must have designer privileges"
Examples:
@@ -103,7 +103,7 @@ Feature: User authentication and permissions
Scenario Outline: Non-admins cannot see or edit users
Given I am logged in as "<username>"
And I should not see "Users"
- When I go to admin:users
+ When I go to the "users" admin page
Then I should see "You must have administrative privileges"
Examples:
@@ -135,7 +135,7 @@ Feature: User authentication and permissions
Given I am logged in as "<username>"
When I follow "Settings"
And I should not see "Extensions"
- When I go to admin:extensions
+ When I go to the "extensions" admin page
Then I should see "You must have administrative privileges"
Examples:
@@ -146,7 +146,7 @@ Feature: User authentication and permissions
Scenario Outline: Anyone can export YAML
Given I am logged in as "<username>"
- When I go to admin:export
+ When I go to the export page
Then I should see "id:"
Examples:
View
2  features/admin/users_management.feature
@@ -4,7 +4,7 @@ Feature: Managing users
Background:
Given I am logged in as "admin"
- And I go to admin:users
+ And I go to the "users" admin page
Scenario: Listing users
Then I should see "Admin"
And I should see "Designer"
View
16 features/page_serving.feature
@@ -7,36 +7,36 @@ Feature: Serving pages from front-end
Given the page cache is clear
Scenario: Basic page rendering
- When I go to page:first
+ When I go to the first page
Then I should get a 200 response code
And I should see "First body."
Scenario: Rendering deeply nested page
- When I go to page:parent/child/grandchild/great-grandchild
+ When I go to the great-grandchild page
Then I should get a 200 response code
And I should see "Great Grandchild body."
Scenario: Apache/lighttpd acceleration
Given I have turned on X-Sendfile headers
- When I go to page:first
- And I go to page:first
+ When I go to the first page
+ And I go to the first page
Then I should get an "X-Sendfile" header in the response
Scenario: nginx acceleration
Given I have turned on X-Accel-Redirect headers
- When I go to page:first
- And I go to page:first
+ When I go to the first page
+ And I go to the first page
Then I should get an "X-Accel-Redirect" header in the response
Scenario: page caching enabled
Given I have page caching on
- When I go to page:first
+ When I go to the first page
Then I should get an "ETag" header in the response
And The "Cache-Control" header should be "public"
Scenario: page caching disabled
Given I have page caching off
- When I go to page:first
+ When I go to the first page
Then I should not get an "ETag" header in the response
And The "Cache-Control" header should be "private"
View
66 features/support/paths.rb
@@ -5,47 +5,55 @@ module NavigationHelpers
#
# step definition in web_steps.rb
#
- def path_to(page_name)
- case page_name
-
+ def path_to(page_name, format=nil)
+ case normalize_page_name(page_name)
+ when /^\/(.*)/
+ $1
when /the home\s?page/
'/'
-
- # Add more mappings here.
- # Here is an example that pulls values out of the Regexp:
- #
- # when /^(.*)'s profile page$/i
- # user_profile_path(User.find_by_login($1))
- when /the homepage/
- root_path
+ when /the (\S+) (|admin )page as (\w+)/
+ path_to($1, $3)
+ when /the (\S+) ($:|admin )page/
+ path_to($1)
+ when /first/
+ '/first'
+ when /new child/
+ '/my-child'
+ when /great-grandchild/
+ '/parent/child/grandchild/great-grandchild'
when /sitemap/i
- admin_pages_path
+ admin_pages_path(:format => format)
when /login/i
- login_path
+ login_path(:format => format)
when /preferences/i
- edit_admin_preferences_path
+ edit_admin_preferences_path(:format => format)
when /snippets/i
- admin_snippets_path
+ admin_snippets_path(:format => format)
when /login/i
- login_path
- when /users/
- admin_users_path
- when /admin:(.*) as xml/i
- "/admin/#{$1}.xml"
- when /admin:(.*)/i
- "/admin/#{$1}"
- when "my-child"
- "/my-child"
- when "page:parent/child/grandchild/great-grandchild"
- "/parent/child/grandchild/great-grandchild"
- when "page:first"
- "/first"
-
+ login_path(:format => format)
+ when /users/i
+ admin_users_path(:format => format)
+ when /pages/i
+ admin_pages_path(:format => format)
+ when /layouts/i
+ admin_layouts_path(:format => format)
+ when /snippets/i
+ admin_snippets_path(:format => format)
+ when /users/i
+ admin_users_path(:format => format)
+ when /extensions/i
+ admin_extensions_path(:format => format)
+ when /export/i
+ export_path(:format => format)
else
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
"Now, go and add a mapping in #{__FILE__}"
end
end
+
+ def normalize_page_name(page_name)
+ page_name.gsub(/^["']+(.*?)["']+$/,'\1')
+ end
end
World(NavigationHelpers)
Please sign in to comment.
Something went wrong with that request. Please try again.