Sha256: 92143ed153a0085add0f3ac4a94b2fe1abe93bfdadce5861bfec1d9f8c4773a8

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

dependencies = %w{
  bacon
  sinatra
  rack/test
  nokogiri
}

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')

module TestHelper
  def rackup(app)
    Rack::Test::Session.new(app)
  end
  
  def body
    last_response.body.to_s
  end

  def instance_of(klass)
    lambda {|obj| obj.is_a?(klass) }
  end

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

end

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

class Should

  def have_element(search, content = nil)
    satisfy "have element matching #{search}" do
      doc = Nokogiri.parse(@object.to_s)
      node_set = doc.search(search)
      if node_set.empty?
        false
      else
        collected_content = node_set.collect {|t| t.content }.join(' ')
        case content
        when Regexp
          collected_content =~ content
        when String
          collected_content.include?(content)
        when nil
          true
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
lenary-ginatra-2.0.2 vendor/vegas/test/test_helper.rb
quirkey-vegas-0.0.4.1 test/test_helper.rb
quirkey-vegas-0.0.4 test/test_helper.rb
ginatra-2.0.2 vendor/vegas/test/test_helper.rb
vegas-0.0.4 test/test_helper.rb
vegas-0.0.4.1 test/test_helper.rb