Last active
March 10, 2016 21:52
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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