Sha256: 0495289f57e47cbf4832e9a610c8919a7bffb760bbb567c1bf72cdf299f35980

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Answer, "when creating a new answer" do
  before(:each) do
    @answer = Factory(:answer, :text => "Red")
  end
  
  it "should be valid" do
    @answer.should be_valid
  end
  
  # this causes issues with building and saving answers to questions within a grid.
  # it "should be invalid without a question_id" do
  #   @answer.question_id = nil
  #   @answer.should_not be_valid
  # end
  
  it "should tell me its css class" do
    @answer.custom_class = "foo bar"
    @answer.css_class.should == "foo bar"
    @answer.is_exclusive = true
    @answer.css_class.should == "exclusive foo bar"
  end
  
  it "should hide the label when hide_label is set" do
    @answer.split_or_hidden_text.should == "Red"
    @answer.hide_label = true
    @answer.split_or_hidden_text.should == ""
  end
  it "should split up pre/post labels" do
    @answer.text = "before|after|extra"
    @answer.split_or_hidden_text(:pre).should == "before"
    @answer.split_or_hidden_text(:post).should == "after|extra"
  end
  it "should delete validation when it is deleted" do
    v_id = Factory(:validation, :answer => @answer).id
    @answer.destroy
    Validation.find_by_id(v_id).should be_nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
surveyor-0.19.3 spec/models/answer_spec.rb
surveyor-0.19.2 spec/models/answer_spec.rb
surveyor-0.19.1 spec/models/answer_spec.rb
surveyor-0.19.0 spec/models/answer_spec.rb