lib/smart_rspec/matchers.rb in smart_rspec-0.0.2 vs lib/smart_rspec/matchers.rb in smart_rspec-0.1.0

- old
+ new

@@ -1,45 +1,12 @@ -require 'rspec/matchers' -require 'rspec/collection_matchers' require 'smart_rspec/support/regexes' +require 'smart_rspec/matchers/be_matchers' +require 'smart_rspec/matchers/other_matchers' module SmartRspec module Matchers - extend RSpec::Matchers::DSL include SmartRspec::Support::Regexes - - matcher :be_boolean do - match { |actual| [true, false].include?(actual) } - end - - matcher :be_email do - match { |actual| actual =~ build_regex(:email) } - end - - matcher :be_url do - match { |actual| actual =~ build_regex(:uri) } - end - - matcher :be_image_url do |*types| - match { |actual| actual =~ build_regex(:image, types) } - end - - matcher :have_error_on do |attr| - match { |actual| actual.errors.keys.include?(attr) } - end - - matcher :include_items do |items| - match { |actual| (items - actual).empty? } - end - - matcher :be_ascending do - match { |actual| actual == actual.sort } - end - - matcher :be_descending do - match do |actual| - actual.each_cons(2).all? { |i, j| i >= j } - end - end + include SmartRspec::Matchers::BeMatchers + include SmartRspec::Matchers::OtherMatchers end end