Sha256: 9d989d2b8d025b8c9eed7a4a2f59261920571a8496fcf8a7cb4468994eb70ef3

Contents?: true

Size: 1001 Bytes

Versions: 4

Compression:

Stored size: 1001 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_bad_request do
        match do |response|
          response.code.to_s =~ /^4/
        end
      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.1.3 lib/smart_rspec/matchers/be_matchers.rb
smart_rspec-0.1.2 lib/smart_rspec/matchers/be_matchers.rb
smart_rspec-0.1.1 lib/smart_rspec/matchers/be_matchers.rb
smart_rspec-0.1.0 lib/smart_rspec/matchers/be_matchers.rb