Sha256: 433f08828083776645b3ef47795eb60c48ecdeb6492a69ec2d47b88934e0c5ee

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

module PostcodeAnywhere
  module EmailValidation

    describe Validator do

      subject { ::ValidatedClass.new }

      context 'blank email' do
        it 'is not valid' do
          PostcodeAnywhere::EmailValidation.should_not_receive(:valid?)
          expect(subject).to_not be_valid
        end
      end

      context 'Using Postcode Anywhere' do
        before { subject.email = 'an_email' }

        it 'is valid if service returns true' do
          PostcodeAnywhere::EmailValidation.should_receive(:valid?).with('an_email').and_return false
          expect(subject).to_not be_valid
        end

        it 'is invalid if service returns false' do
          PostcodeAnywhere::EmailValidation.should_receive(:valid?).with('an_email').and_return true
          expect(subject).to be_valid
        end
      end

      describe 'RSpec Matcher' do
        context 'with default attribute' do
          it { should validate_email_with_postcode_anywhere }
        end
        context 'with custom attribute' do
          it { should validate_email_with_postcode_anywhere.on_attribute(:email) }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
postcode_anywhere-email_validation-0.0.4 spec/lib/postcode_anywhere/email_validation/validator_spec.rb