Created
January 15, 2015 09:13
-
-
Save shoyan/0954f9502a0d2c3015cb to your computer and use it in GitHub Desktop.
test of EmailValidator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "EmailValidator" do | |
before do | |
@validator = EmailValidator.new({:attributes => {email: ''}}) | |
@mock = double("Foo") | |
allow(@mock).to receive(:errors).and_return([]) | |
allow(@mock.errors).to receive(:[]).and_return({}) | |
allow(@mock.errors[]).to receive(:<<) | |
end | |
it "should validate valid address" do | |
expect(@mock).not_to receive(:errors) | |
@validator.validate_each(@mock, "email", "[email protected]") | |
end | |
it "should validate invalid address" do | |
expect(@mock.errors[]).to receive(:<<) | |
@validator.validate_each(@mock, "email", "notvalid") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment