Sha256: 9c6ab0022c00d8425a869792d6581b7fffd62af9c6e2a8f89230428b602a4f22

Contents?: true

Size: 882 Bytes

Versions: 6

Compression:

Stored size: 882 Bytes

Contents

require 'test_helper'

class AnswerTest < ActiveSupport::TestCase

  context "An Answer" do
    
    setup do
      @answer = Factory(:answer)
    end
    
    subject { @answer }

    should_belong_to                :question
    should_belong_to                :user
  
    should_validate_presence_of     :question,
                                    :user
  
    should_allow_mass_assignment_of :data
    
    context "getting formatted data" do
      
      should "format strings" do
        a = Factory(:answer, :question => Factory(:question, :data_type => 'String'), :data => 'abc123')
        assert_equal 'abc123', a.formatted_data
      end
      
      should "format numbers" do
        a = Factory(:answer, :question => Factory(:question, :data_type => 'Number'), :data => '5389')
        assert_equal 5389, a.formatted_data
      end
      
    end
    
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
census-0.5.2 test/models/answer_test.rb
census-0.5.0 test/models/answer_test.rb
census-0.4.4 test/models/answer_test.rb
census-0.4.3 test/models/answer_test.rb
census-0.4.2 test/models/answer_test.rb
census-0.4.1 test/models/answer_test.rb