Sha256: 486ae74df78871bdf9833deef32a13dbe3f537d40b0ea91bdd1b3d94c807ee0e

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'rubygems'
require 'minitest/spec'

$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), *%w[.. lib]))
require 'collecta-rb'

MiniTest::Unit.autorun

module MiniTest
  require 'pathname' if MINI_DIR =~ %r{^./}

  module Assertions
    def assert_has_apikey(key, node, msg = nil)
      msg = message(msg) { "Expected #{mu_pp(node)} to have API key #{mu_pp(key)}" }
      assert(node.apikey == key, msg)
    end

    def assert_has_query(query, node, msg = nil)
      msg = message(msg) { "Expected #{mu_pp(node)} to have query #{mu_pp(query)}" }
      assert(node.query.include?(query), msg)
    end

    def assert_has_notify(notify, node, msg = nil)
      msg = message(msg) { "Expected #{mu_pp(node)} to have query #{mu_pp(notify)}" }
      assert(node.notify.include?(notify), msg)
    end
  end
end

class Object
  def must_have_apikey *args
    return MiniTest::Spec.current.assert_has_apikey(args.first, self)
  end

  def must_have_query *args
    return MiniTest::Spec.current.assert_has_query(args.first, self)
  end

  def must_have_notify *args
    return MiniTest::Spec.current.assert_has_notify(args.first, self)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
collecta-rb-0.1.0 spec/spec_helper.rb