Sha256: c0653e46226f1a2b755eca93cf498d5a2f51b17eca70393aa0e3c66824a98868

Contents?: true

Size: 878 Bytes

Versions: 4

Compression:

Stored size: 878 Bytes

Contents

module SmartRspec
  module Matchers
    module BeMatchers
      extend RSpec::Matchers::DSL

      matcher :be_ascending do
        match { |actual| actual == actual.sort  }
      end

      matcher :be_a_list_of do |klass|
        match do |collection|
          collection.all? { |e| e.is_a?(klass) }
        end
      end

      matcher :be_boolean do
        match { |actual| [true, false].include?(actual) }
      end

      matcher :be_descending do
        match do |actual|
          actual.each_cons(2).all? { |i, j| i >= j  }
        end
      end

      matcher :be_email do
        match { |actual| actual =~ build_regex(:email) }
      end

      matcher :be_image_url do |*types|
        match { |actual| actual =~ build_regex(:image, types) }
      end

      matcher :be_url do
        match { |actual| actual =~ build_regex(:uri) }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_rspec-0.2.0 lib/smart_rspec/matchers/be_matchers.rb
smart_rspec-0.1.6 lib/smart_rspec/matchers/be_matchers.rb
smart_rspec-0.1.5 lib/smart_rspec/matchers/be_matchers.rb
smart_rspec-0.1.4 lib/smart_rspec/matchers/be_matchers.rb