Sha256: 33c4053f5cfb31cb76995165534a854cbf2566f26f791c67014b303e15189277
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# encoding: utf-8 describe Policy::Base::Xor do # defines mock builders #valid_policy and #invalid_policy require "support/composer" let(:one) { invalid_policy error: "one" } let(:two) { invalid_policy error: "two" } let(:three) { valid_policy } subject { described_class.new one, two, three } describe ".new" do it "creates a Node" do expect(subject).to be_kind_of Policy::Base::Node end end # new describe "#policies" do it "is initialized" do expect(subject.policies).to contain_exactly one, two, three end end # describe #policies describe "#valid?" do context "when both valid and invalid policies are present" do it "returns true" do expect(subject).to be_valid end it "clears previous errors" do subject.errors.add :base, :subject expect { subject.valid? }.to change { subject.errors.blank? }.to true end end # context context "when all policies are valid" do let(:one) { valid_policy } let(:two) { valid_policy } it "returns false" do expect(subject).not_to be_valid end end # context context "when all policies are invalid" do let(:three) { invalid_policy error: "three" } let!(:result) { subject.valid? } it "returns false" do expect(result).to eq false end it "picks up errors from all policies" do expect(subject.errors).to contain_exactly "one", "two", "three" end end # context end # describe #valid? end # describe Policy::Base::Not
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
policy-2.0.0 | spec/tests/lib/policy/base/xor_spec.rb |