Sha256: f4d2434f3f7e297b2b0866bcae2513b1a68818c22bbc251f85fa16846c6c0ac7

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

require 'spec_helper'

describe Yema::Validator, "#errors" do

  subject { validator.errors }

  let(:validator) { described_class.new(resource, rule) }
  let(:resource)  { stub('resource', foo: 'bar')        }
  let(:rule)      { stub('rule', attribute_name: :foo)  }

  before do
    rule.should_receive(:matches?).and_return(valid)
  end

  context "when the attribute is valid" do
    let(:valid) { true }
    it_should_behave_like "valid resource"
  end

  context "when the attribute is invalid" do
    let(:valid) { false }
    it_should_behave_like "invalid resource"
    specify { subject.first.should be_kind_of(Yema::Error) }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yema-0.0.3 spec/unit/validator/errors_spec.rb
yema-0.0.2 spec/unit/validator/errors_spec.rb