forked from rspec/rspec-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- def classes/modules in RSpec::Rails::Matchers instead of RSpec::Matchers - less opening classes/more includuing modules
- Loading branch information
1 parent
ffd6c07
commit 5af9d7d
Showing
7 changed files
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
require 'active_support/core_ext/module/aliasing' | ||
require 'rspec/matchers/have' | ||
|
||
module RSpec | ||
module Matchers | ||
class Have | ||
# @api private | ||
# | ||
# Enhances the failure message for `should have(n)` matchers | ||
def failure_message_for_should_with_errors_on_extensions | ||
return "expected #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}, got #{@actual}" if @collection_name == :errors_on | ||
return "expected #{relativities[@relativity]}#{@expected} error on :#{@args[0]}, got #{@actual}" if @collection_name == :error_on | ||
return failure_message_for_should_without_errors_on_extensions | ||
end | ||
alias_method_chain :failure_message_for_should, :errors_on_extensions | ||
module RSpec::Rails::Matchers | ||
module HaveExtensions | ||
extend ActiveSupport::Concern | ||
|
||
# @api private | ||
# | ||
# Enhances the failure message for `should have(n)` matchers | ||
def failure_message_for_should_with_errors_on_extensions | ||
return "expected #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}, got #{@actual}" if @collection_name == :errors_on | ||
return "expected #{relativities[@relativity]}#{@expected} error on :#{@args[0]}, got #{@actual}" if @collection_name == :error_on | ||
return failure_message_for_should_without_errors_on_extensions | ||
end | ||
|
||
# @api private | ||
# | ||
# Enhances the description for `should have(n)` matchers | ||
def description_with_errors_on_extensions | ||
return "have #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}" if @collection_name == :errors_on | ||
return "have #{relativities[@relativity]}#{@expected} error on :#{@args[0]}" if @collection_name == :error_on | ||
return description_without_errors_on_extensions | ||
end | ||
# @api private | ||
# | ||
# Enhances the description for `should have(n)` matchers | ||
def description_with_errors_on_extensions | ||
return "have #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}" if @collection_name == :errors_on | ||
return "have #{relativities[@relativity]}#{@expected} error on :#{@args[0]}" if @collection_name == :error_on | ||
return description_without_errors_on_extensions | ||
end | ||
|
||
included do | ||
alias_method_chain :failure_message_for_should, :errors_on_extensions | ||
alias_method_chain :description, :errors_on_extensions | ||
end | ||
end | ||
end | ||
|
||
RSpec::Matchers::Have.class_eval do | ||
include RSpec::Rails::Matchers::HaveExtensions | ||
end |
This file contains 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
This file contains 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
This file contains 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