Skip to content

Commit

Permalink
Added question_spec which was missing before
Browse files Browse the repository at this point in the history
Moved webdriver tests to their own dir (out of features/)
  • Loading branch information
armandofox committed Oct 4, 2014
1 parent f67d8b8 commit ce95823
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/models/question_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'spec_helper'

describe Question do
describe 'new' do
before :each do
@q = Question.new :text => 'text', :answers => ['a', '', 'c'], :explanation => 'expl', :correct_answer_index => 1
end
specify 'when valid' do
@q.should be_valid
@q.should have(2).answers
end
specify 'with all blank answers' do
@q.answers = ['', '']
@q.should_not be_valid
@q.should have(1).errors_on(:answers)
end
specify 'with empty text' do
@q.text = ''
@q. should_not be_valid
@q.should have(1).errors_on(:text)
end
specify 'with correct answer index out of range' do
@q.correct_answer_index = 2
@q.should_not be_valid
@q.errors_on(:correct_answer_index).should include('must be less than or equal to 1')
end
end
end
File renamed without changes.

0 comments on commit ce95823

Please sign in to comment.