Sha256: 87fa3f0dda4958fc5edfef61ca28f7d79054075c509ff6e8d8f7d65ef672ff24
Contents?: true
Size: 1.21 KB
Versions: 25
Compression:
Stored size: 1.21 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe SurveySection, "when saving a survey_section" do before(:each) do @valid_attributes={:title => "foo", :survey_id => 2, :display_order => 4} @survey_section = SurveySection.new(@valid_attributes) end it "should be invalid without title" do @survey_section.title = nil @survey_section.should have(1).error_on(:title) end it "should have a parent survey" do @survey_section.survey_id = nil @survey_section.should have(1).error_on(:survey) end end describe SurveySection, "with questions" do before(:each) do @survey = mock_model(Survey) @valid_attributes={:title => "Rhymes", :survey => @survey, :display_order => 4} @survey_section = SurveySection.create(@valid_attributes) @q1 = @survey_section.questions.create(:text => "Peep", :display_order => 3) @q2 = @survey_section.questions.create(:text => "Little", :display_order => 1) @q3 = @survey_section.questions.create(:text => "Bo", :display_order => 2) end it "should return questions sorted in display order" do @survey_section.questions.should have(3).questions @survey_section.questions.should == [@q2,@q3,@q1] end end
Version data entries
25 entries across 25 versions & 2 rubygems