Sha256: e1e0ce15530cdf83e6067c0dd250ae25a034a265faf5f831b41b86948320d450

Contents?: true

Size: 597 Bytes

Versions: 4

Compression:

Stored size: 597 Bytes

Contents

require "active_support/test_case"

class ActiveSupport::TestCase
  def cmd(name, env={}, as="someone")
    post "/cogy/cmd/#{name}", env.merge("COG_CHAT_HANDLE" => as)
  end

  def fetch_inventory
    get "/cogy/inventory"
    YAML.load(response.body)
  end

  def with_config(opts={})
    old = {}

    opts.each do |k, v|
      old[k] = Cogy.send(k)
      Cogy.send("#{k}=", v)
    end

    yield fetch_inventory

    old.each do |k, v|
      Cogy.send("#{k}=", v)
    end
  end

  def without_commands
    old = Cogy.commands
    Cogy.commands = {}
    yield
    Cogy.commands = old
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cogy-0.5.2 test/support/helpers.rb
cogy-0.5.1 test/support/helpers.rb
cogy-0.5.0 test/support/helpers.rb
cogy-0.4.0 test/support/helpers.rb