Skip to content

Commit

Permalink
made it possible to override subject when using rspec matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
betesh committed Feb 6, 2015
1 parent 22549b2 commit 55347a4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/validates_email_format_of/rspec_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

RSpec::Matchers.define :validate_email_format_of do |attribute|
match do
actual_class_name = subject.is_a?(Class) ? subject : subject.class
actual = actual_class_name.new
actual = subject.is_a?(Class) ? subject.new : subject
actual.send(:"#{attribute}=", "invalid@example.")
expect(actual).to be_invalid
@expected_message ||= ValidatesEmailFormatOf.default_message
Expand Down

0 comments on commit 55347a4

Please sign in to comment.