Sha256: f0869b6fd4e5978f3a5f693bc717dc04709c3deff67982100723d4ef1a053d0b

Contents?: true

Size: 908 Bytes

Versions: 5

Compression:

Stored size: 908 Bytes

Contents

require 'helper'
class ValidationModelTest < ActiveSupport::TestCase
  setup do
    @company = Company.new
  end

  test "should validate step1" do
    @company.my_step = "step1"
    assert !@company.save
    assert_equal @company.errors.messages, { :name=>["can't be blank"] }
  end

  should "validate step 3 and previous steps" do
    @company.my_step = "step3"
    assert !@company.save
    assert_equal @company.errors.messages, { :name => ["can't be blank"],
                                             :code => ["is not a number"],
                                             :city => ["can't be blank"] }
  end

  should "not run method if it doesn't exists" do
    class << @company
      undef_method :validate_step2
    end

    @company.name = "name"
    @company.city = "Kiev"
    @company.my_step = "step3"

    assert_nothing_raised NoMethodError do
      @company.save!
    end
  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stepper-0.2.0 test/models/validation_test.rb
stepper-0.1.0 test/models/validation_test.rb
stepper-0.0.4 test/models/validation_test.rb
stepper-0.0.3 test/models/validation_test.rb
stepper-0.0.1 test/models/validation_test.rb