require 'spec_helper' describe Yema::Rule::Inclusion, '#errors' do subject { rule.errors(resource) } let(:rule) { described_class.new(attribute, options) } let(:resource) { stub('resource', attribute => value) } let(:attribute) { :foo } context "with range options" do let(:options) { { within: 3..6 } } [3, 5].each do |value| it_behaves_like "valid resource", value end it_behaves_like "invalid resource", 2 end context "with array options" do let(:options) { { within: ["a", "b"] } } it_behaves_like "valid resource", "a" it_behaves_like "invalid resource", "c" end end