Sha256: 19b2e52bd81cd30a086c09e374d3886663195d9996d2fb6e716039d49c88a650

Contents?: true

Size: 985 Bytes

Versions: 2

Compression:

Stored size: 985 Bytes

Contents

dependencies = %w{
  bacon
  mocha/standalone
  mocha/object
  sinatra
}

begin
  dependencies.each {|f| require f }
rescue LoadError
  require 'rubygems'
  dependencies.each {|f| require f }
end

require File.join(File.dirname(__FILE__), '..', 'lib', 'vegas.rb')
require File.join(File.dirname(__FILE__), 'test_apps.rb')


module TestHelper
  
  def vegas(*args, &block)
    Vegas::Runner.any_instance.stubs(:daemonize!).once
    Rack::Handler::Thin.stubs(:run).once
    @vegas = Vegas::Runner.new(*args, &block)
  end
  
  def body
    last_response.body.to_s
  end

  def instance_of(klass)
    lambda {|obj| obj.is_a?(klass) }
  end
  
  def exist_as_file
    lambda {|obj| File.exist?(obj) }
  end
  
  def have_matching_file_content(content_regex)
    lambda {|obj| 
      File.exist?(obj) && File.read(obj).match(content_regex) 
    }
  end

  def html_body
    body =~ /^\<html/ ? body : "<html><body>#{body}</body></html>"
  end

end

Bacon::Context.send(:include, TestHelper)

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
quirkey-vegas-0.1.0 test/test_helper.rb
vegas-0.1.0 test/test_helper.rb