Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisroos/4cf5f57914b5df966c6c to your computer and use it in GitHub Desktop.
Save chrisroos/4cf5f57914b5df966c6c to your computer and use it in GitHub Desktop.
[
: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