Sha256: f5412f3f72019ecbf769add56f6d9224effc6246e986e8095e7c56df03ec23cf

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 Bytes

Contents

require 'spec_helper'

class NodeWithValidation < ::Rubiks::ValidatedNode
  validates :something

  def something
    errors << 'Something is required'
  end
end

class SubNodeWithValidation < NodeWithValidation
end

class NodeWithAdditionalValidation < NodeWithValidation
  validates :something_else
end




describe NodeWithValidation do
  subject { described_class }

  it 'has a validator' do
    subject.validators.length.should eq 1
  end

  context 'when parsed from an invalid (empty) hash' do
    subject { described_class.new }

    it { should_not be_valid }
  end
end

describe SubNodeWithValidation do
  subject { described_class }

  it 'inherits the validator of the super class' do
    subject.validators.length.should eq 1
  end
end

describe NodeWithAdditionalValidation do
  subject { described_class }

  it 'has 2 validators' do
    subject.validators.length.should eq 2
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubiks-0.0.6 spec/rubiks/nodes/validated_node_spec.rb
rubiks-0.0.5 spec/rubiks/nodes/validated_node_spec.rb
rubiks-0.0.4 spec/rubiks/nodes/validated_node_spec.rb