Sha256: cf2049dc3ee1530ddf10095979851562cd61875818a78f0bc2355f8a00194f9e

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 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
    # this causes issues with building and saving
    # @survey_section.survey_id = nil
    # @survey_section.should have(1).error_on(:survey)
  end
end

describe SurveySection, "with questions" do
  before(:each) do
    @survey_section = Factory(:survey_section, :title => "Rhymes", :display_order => 4)
    @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

6 entries across 6 versions & 1 rubygems

Version Path
surveyor-0.18.1 spec/models/survey_section_spec.rb
surveyor-0.18.0 spec/models/survey_section_spec.rb
surveyor-0.17.0 spec/models/survey_section_spec.rb
surveyor-0.16.1 spec/models/survey_section_spec.rb
surveyor-0.16.0 spec/models/survey_section_spec.rb
surveyor-0.15.0 spec/models/survey_section_spec.rb