Permalink
Browse files

makes conditional ending string/int id agnostic

  • Loading branch information...
1 parent 2e97a2a commit 91928fcab9050d8a8f802888023ce332da004c7c @Najaf Najaf committed Mar 4, 2013
Showing with 5 additions and 5 deletions.
  1. +2 −2 lib/dumb-answers/conditional_ending.rb
  2. +3 −3 spec/conditional_ending_spec.rb
@@ -15,8 +15,8 @@ def to_ending(history)
private
def text_for(history)
applicable_endings = @conditional_texts.select do |conditional_text|
- conditional_text['conditions'].each_pair.all? do |pair|
- history.include? pair
+ conditional_text['conditions'].each_pair.all? do |(question_id, answer_code)|
+ history.include? [question_id.to_s, answer_code.to_s]
end
end
@@ -16,9 +16,9 @@
describe '#to_ending' do
before do
@conditional_ending = ConditionalEnding.new('id' => 'to-ending-test-id', 'conditional_texts' => [
- { 'conditions' => { '1' => 'a', '2' => 'a', '3' => 'a' }, 'text' => 'All as' },
- { 'conditions' => { '1' => 'a', '2' => 'b', '3' => 'a' }, 'text' => 'Mix' },
- { 'conditions' => { '1' => 'b', '2' => 'b', '3' => 'b' }, 'text' => 'All bs' }
+ { 'conditions' => { 1 => 'a', 2 => 'a', 3 => 'a' }, 'text' => 'All as' },
+ { 'conditions' => { 1 => 'a', 2 => 'b', 3 => 'a' }, 'text' => 'Mix' },
+ { 'conditions' => { 1 => 'b', 2 => 'b', 3 => 'b' }, 'text' => 'All bs' }
])
@valid_history = [ %w(1 a), %w(2 b), %w(3 a) ]

0 comments on commit 91928fc

Please sign in to comment.