Skip to content

Instantly share code, notes, and snippets.

@adam-phillipps
Last active March 10, 2016 21:52
Show Gist options
  • Save adam-phillipps/53810b1b52a745aed4f5 to your computer and use it in GitHub Desktop.
Save adam-phillipps/53810b1b52a745aed4f5 to your computer and use it in GitHub Desktop.
moved a couple things around to make the expectations a bit more readable
# in the spec
it 'should cycle in either direction blah blah blah' do
# a better way is to set up contexts for each direction you want to cycle
# and test the crap out of it that way but you get the idea, no?
[next, prev].each do |direction|
expect(students_cycle_correctly? cycle_list(direction)).to be true
end
end
# in the helper
def cycle_list(direction)
current_index =
@students.index(@students.find { |l| l.name == f(selectedStudent).text })
f(direction).click
direction
end
def list_cycles_correctly?(&block)
given_direction = block.call
check(given_direction)
end
def check(direction)
comparison_index = direction =~ /next/ ? -1 : 1
studentXofXstring = "Student #{new_index + 1} of #{@students.length}"
f(selectedStudent).text.include?(@students[comparison_index].name) &&
f(studentXofXlabel).text.include?(studentXofXstring)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment