Sha256: f70b531c67961d28f2fe03fac766ddd422665c5e7d5d041343041e59e4da2192

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

require 'spec_helper'

describe Yema::Rule::StrongType, '#errors' do

  subject { rule.errors(resource) }

  let(:rule)      { described_class.new(attribute, options) }
  let(:resource)  { stub('resource', attribute => value)    }
  let(:attribute) { :foo                                    }
  let(:options)   { {type: String}.merge(mode)              }
  let(:mode)      { {}                                      }

  context "allow_nil mode" do
    let(:mode) { {strict: :allow_nil} }

    it_behaves_like "valid resource", nil
    it_behaves_like "invalid resource", 1
    it_behaves_like "valid resource", 'string'
  end

  context "default mode" do
    it_behaves_like "invalid resource", nil
    it_behaves_like "invalid resource", 1
    it_behaves_like "valid resource", 'string'
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yema-0.0.3 spec/integration/rule/strong_type_spec.rb
yema-0.0.2 spec/integration/rule/strong_type_spec.rb
yema-0.0.1 spec/integration/rule/strong_type_spec.rb