Top Level Namespace

Includes:
Predicated

Defined Under Namespace

Modules: CanonicalIntegrationCases, CanonicalTransformCases, Kernel, Predicated, Sickill, Wrong Classes: Color, Fixnum, Float, Module, Object, Ruby2Ruby, Sexp

Constant Summary

Constants included from Predicated

Predicated::ALL_PREDICATE_CLASSES, Predicated::VERSION

Instance Method Summary collapse

Methods included from Predicated

#Predicate, #SimpleTemplatedPredicate, require_gem_version

Instance Method Details

#get_from_db_using_predicate(predicate) ⇒ Object



12
13
14
15
16
# File 'lib/predicated/test_integration/arel_integration_test.rb', line 12

def get_from_db_using_predicate(predicate)
  Table(:widget).where(predicate.to_arel(Table(:widget))).select.
    collect{|r|r.tuple}.
    collect{|d|d.first}
end

#get_from_solr(path) ⇒ Object



18
19
20
# File 'lib/predicated/test_integration/solr_integration_test.rb', line 18

def get_from_solr(path)
  open("http://localhost:8983#{path}").read
end

#get_from_solr_using_predicate(predicate) ⇒ Object

download and unpack solr place (overwrite) schema.xml in the solr conf directory start solr (java -jar start.jar)



14
15
16
# File 'lib/predicated/test_integration/solr_integration_test.rb', line 14

def get_from_solr_using_predicate(predicate)
  eval(get_from_solr("/solr/select?q=#{URI.escape(predicate.to_solr)}&wt=ruby"))
end

#post_to_solr(body) ⇒ Object



22
23
24
25
26
27
# File 'lib/predicated/test_integration/solr_integration_test.rb', line 22

def post_to_solr(body)
  request = Net::HTTP::Post.new("/solr/update", {'Content-Type' =>'text/xml'})
  request.body = body
  response = Net::HTTP.new("localhost", 8983).start {|http| http.request(request) }
  raise "Response #{response.code}\n#{response.body}" unless response.code=="200"
end

#run_suite(wildcard) ⇒ Object



26
27
28
29
30
31
# File 'lib/predicated/test/test_helper.rb', line 26

def run_suite(wildcard)
  #simple way to make sure requires are isolated
  result = Dir[wildcard].collect{|test_file| system("ruby #{test_file}") }.uniq == [true]
  puts "suite " + (result ? "passed" : "FAILED")
  exit(result ? 0 : 1)
end