spec/tests/validations_spec.rb in attestor-0.3.0 vs spec/tests/validations_spec.rb in attestor-0.4.0

- old
+ new

@@ -4,19 +4,18 @@ describe Attestor::Validations do let(:validators_class) { Attestor::Validations::Validators } let(:validator_class) { Attestor::Validations::Validator } - let(:follower_class) { Attestor::Validations::Follower } - let(:collection_class) { Attestor::Validations::Validators } + let(:delegator_class) { Attestor::Validations::Delegator } let(:item_class) { Attestor::Validations::Item } let(:message_class) { Attestor::Validations::Message } let(:invalid_error) { Attestor::InvalidError } let(:test_class) { Class.new.send(:include, described_class) } - before { Test = test_class } - after { Object.send :remove_const, :Test } + before { Test = test_class } + after { Object.send :remove_const, :Test } subject { test_class.new } describe ".validators" do @@ -36,11 +35,11 @@ before { test_class.validate :foo } it "registers a validator" do expect(test_class.validators.map(&:name)).to eq [:foo] - expect(test_class.validators.first).not_to be_kind_of follower_class + expect(test_class.validators.first).not_to be_kind_of delegator_class end end # context context "with restrictions" do @@ -55,36 +54,36 @@ end # context end # describe .validate - describe ".follow_policy" do + describe ".validates" do context "without options" do - before { test_class.follow_policy :foo } + before { test_class.validates :foo } - it "registers a follower" do + it "registers a delegator" do expect(test_class.validators.map(&:name)).to eq [:foo] - expect(test_class.validators.first).to be_kind_of follower_class + expect(test_class.validators.first).to be_kind_of delegator_class end end # context context "with restrictions" do - before { test_class.follow_policy :foo, only: %w(bar baz), except: "bar" } + before { test_class.validates :foo, only: %w(bar baz), except: "bar" } it "uses options" do expect(test_class.validators.map(&:name)).to eq [:foo] expect(test_class.validators.set(:baz).map(&:name)).to eq [:foo] expect(test_class.validators.set(:bar).map(&:name)).to eq [] end end # context - end # describe .follow_policy + end # describe .validates describe "#invalid" do shared_examples "raising an error" do |name, options = {}| @@ -124,12 +123,12 @@ end # invalid describe "#validate" do before do - test_class.validate :foo - test_class.validate :bar, only: :all - test_class.follow_policy :baz, only: :foo + test_class.validate :foo + test_class.validate :bar, only: :all + test_class.validates :baz, only: :foo allow(subject).to receive(:foo) allow(subject).to receive(:bar) allow(subject).to receive(:baz) { valid_policy } end