|
| 1 | +describe MultipleChoiceSubmittable do |
| 2 | + it { should have_one(:question) } |
| 3 | +end |
| 4 | + |
1 | 5 | describe MultipleChoiceSubmittable, '#breakdown' do |
2 | 6 | it 'returns a percentage breakdown' do |
3 | 7 | survey = create(:survey) |
|
6 | 10 | options_texts: %w(Blue Red), |
7 | 11 | survey: survey |
8 | 12 | ) |
9 | | - submittable = MultipleChoiceSubmittable.new(question) |
| 13 | + submittable = MultipleChoiceSubmittable.new(question: question) |
10 | 14 | taker = AnswerCreator.new(survey) |
11 | 15 | taker.answer question, 'Red' |
12 | 16 | taker.answer question, 'Blue' |
|
19 | 23 | describe MultipleChoiceSubmittable, '#options_for_form' do |
20 | 24 | it 'adds empty options when none are present' do |
21 | 25 | question = build_stubbed(:multiple_choice_question, options: []) |
22 | | - submittable = MultipleChoiceSubmittable.new(question) |
| 26 | + submittable = MultipleChoiceSubmittable.new(question: question) |
23 | 27 | submittable.options_for_form.count.should == 3 |
24 | 28 | end |
25 | 29 |
|
26 | 30 | it 'leaves existing options alone' do |
27 | 31 | options = [Option.new(text: 'hey'), Option.new(text: 'hello')] |
28 | 32 | question = build_stubbed(:multiple_choice_question, options: options) |
29 | | - submittable = MultipleChoiceSubmittable.new(question) |
| 33 | + submittable = MultipleChoiceSubmittable.new(question: question) |
30 | 34 | submittable.options_for_form.map(&:text).should match_array(['hey', 'hello']) |
31 | 35 | end |
32 | 36 | end |
33 | 37 |
|
34 | 38 | describe MultipleChoiceSubmittable, '#score' do |
35 | 39 | it 'returns the score for the option with the given text' do |
36 | 40 | question = build_stubbed(:multiple_choice_question) |
37 | | - submittable = MultipleChoiceSubmittable.new(question) |
| 41 | + submittable = MultipleChoiceSubmittable.new(question: question) |
38 | 42 | question.options.target.stubs(score: 2) |
39 | 43 |
|
40 | 44 | result = submittable.score('two') |
|
0 commit comments