Created
July 28, 2015 15:34
-
-
Save chrisroos/4cf5f57914b5df966c6c to your computer and use it in GitHub Desktop.
This file contains 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
[ | |
:how_old_are_you?, | |
:how_old_were_you? | |
].each do |age_question_name| | |
context "for #{age_question_name}" do | |
setup do | |
@question = @flow.questions.find { |question| question.name == age_question_name } | |
@state = SmartAnswer::State.new(@question) | |
end | |
should 'not accept ages less than or equal to 0' do | |
assert_raise(SmartAnswer::InvalidResponse) do | |
@question.transition(@state, '0') | |
end | |
end | |
should 'not accept ages greater than 200' do | |
assert_raise(SmartAnswer::InvalidResponse) do | |
@question.transition(@state, '201') | |
end | |
end | |
should 'accept ages between 1 and 200' do | |
new_state = @question.transition(@state, '1') | |
assert_equal 1, new_state.age | |
new_state = @question.transition(@state, '200') | |
assert_equal 200, new_state.age | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment