Sha256: 3ed3b2da67fc62198ba23f70ac3a6d9ebd457b348685d1b0c4259b909e23f231
Contents?: true
Size: 1009 Bytes
Versions: 3
Compression:
Stored size: 1009 Bytes
Contents
require 'spec_helper' describe Yema::Rule::Length, '#errors' do subject { rule.errors(resource) } let(:rule) { described_class.new(attribute, options) } let(:resource) { stub('resource', attribute => value) } let(:attribute) { :foo } let(:options) { { length: 5 } } it_behaves_like "valid resource", "asdfg" it_behaves_like "invalid resource", "longer_string" it_behaves_like "invalid resource", "" [ nil, false, true, 10000, ].each do |value| context "with invalid value: #{value.inspect}" do let(:value) { value } specify { expect{subject}.to raise_error(ArgumentError) } end end context "when options is a range" do let(:options) { { length: 3..6 } } [ "abc", "abcabc", ].each do |value| it_behaves_like "valid resource", value end it_behaves_like "invalid resource", "abcabca" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yema-0.0.3 | spec/integration/rule/length_spec.rb |
yema-0.0.2 | spec/integration/rule/length_spec.rb |
yema-0.0.1 | spec/integration/rule/length_spec.rb |