Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaked the sorting features to work with new sorting method

  • Loading branch information...
commit c084cba076cc6028ac45fb38e7d62ce1dbf0ce14 1 parent 85b3d9f
David Davis authored
View
26 features/problem_sorting.feature
@@ -2,30 +2,32 @@ Feature: Sort problems
In order to find problems to solve more easily
a user wants to sort problems by various columns
+ @javascript
Scenario: An external user sorts problems by title
Given the following problems:
- | title | difficulty |
- | Test 4 | 1 |
- | Test 3 | 1 |
- | Test 2 | 1 |
- | Test 1 | 1 |
+ | title | difficulty | approved |
+ | Test 4 | 1 | true |
+ | Test 3 | 1 | true |
+ | Test 2 | 1 | true |
+ | Test 1 | 1 | true |
When I go to the problems page
- And I sort by title
+ And I sort by "Title"
Then I should see problems in this order:
| Test 1 | Easy |
| Test 2 | Easy |
| Test 3 | Easy |
| Test 4 | Easy |
+ @javascript
Scenario: An external user sorts problems by difficulty
Given the following problems:
- | title | difficulty |
- | Test 1 | 3 |
- | Test 2 | 2 |
- | Test 3 | 1 |
- | Test 4 | 0 |
+ | title | difficulty | approved |
+ | Test 1 | 3 | true |
+ | Test 2 | 2 | true |
+ | Test 3 | 1 | true |
+ | Test 4 | 0 | true |
When I go to the problems page
- And I sort by difficulty
+ And I sort by "Difficulty"
Then I should see problems in this order:
| Test 4 | Elementary |
| Test 3 | Easy |
View
10 features/step_definitions/problem_steps.rb
@@ -1,5 +1,7 @@
When /I go to the problems page/ do
visit problems_path
+ #debugger
+ 1
end
Given /^the following problems:$/ do |table|
@@ -10,8 +12,8 @@
end
end
-When /^I sort by (.+)$/ do |column|
- click_link column.titleize
+When /^I sort by "([^"]*)"$/ do |column|
+ page.find(:xpath, "//table[@id='problems']//th[contains(., '#{column}')]").click
end
Then /^I should see problems in this order:$/ do |table|
@@ -20,8 +22,8 @@
rows = page.all('tr.problem')
rows.each do |row|
- # We just want the second and fourth td in our cells array
- cells = row.all('td').select.with_index { |element, index| [1, 3].include? index }
+ # We just want the first and third td in our cells array
+ cells = row.all('td').select.with_index { |element, index| [0, 2].include? index }
actual_order << cells.map { |cell| cell.text }
end
Please sign in to comment.
Something went wrong with that request. Please try again.