Sha256: d5c14b447386be0277548fcbd50ddf2cfb42f11016b07835c5295c27a00e5d03

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

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

describe Validation do
  before(:each) do
    @validation = Factory(:validation)
  end
  
  it "should be valid" do
    @validation.should be_valid
  end
  
  it "should be invalid without a rule" do
    @validation.rule = nil
    @validation.should have(2).errors_on(:rule)
    @validation.rule = " "
    @validation.should have(1).errors_on(:rule)
  end

  it "should be invalid without a answer_id" do
    @validation.answer_id = nil
    @validation.should have(1).error_on(:answer_id)
  end

  it "should be invalid unless rule composed of only references and operators" do
    @validation.rule = "foo"
    @validation.should have(1).error_on(:rule)
    @validation.rule = "1 to 2"
    @validation.should have(1).error_on(:rule)
    @validation.rule = "a and b"
    @validation.should have(1).error_on(:rule)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
surveyor-0.8.0 spec/models/validation_spec.rb