Permalink
Browse files

Added infrastructure for integration tests

  • Loading branch information...
1 parent 2ae9de2 commit 6adebbf1370addba1b6bdb3e69e088c3000bccee @karmi committed Feb 7, 2011
View
@@ -16,6 +16,11 @@ namespace :test do
test.pattern = 'test/unit/*_test.rb'
test.verbose = true
end
+ Rake::TestTask.new(:integration) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/integration/*_test.rb'
+ test.verbose = true
+ end
end
# Generate documentation
@@ -0,0 +1 @@
+{"title" : "One", "tags" : ["ruby"]}
@@ -0,0 +1 @@
+{"title" : "Two", "tags" : ["ruby", "python"]}
@@ -0,0 +1 @@
+{"title" : "Three", "tags" : ["java"]}
@@ -0,0 +1 @@
+{"title" : "Four", "tags" : ["erlang"]}
@@ -0,0 +1 @@
+{"title" : "Five", "tags" : ["javascript", "java"]}
View
@@ -1,9 +1,40 @@
-$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
-
require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'mocha'
require 'turn' unless ENV["TM_FILEPATH"]
+require 'pathname'
require 'slingshot'
+
+class Test::Unit::TestCase
+
+ def fixtures_path
+ Pathname( File.expand_path( 'fixtures', File.dirname(__FILE__) ) )
+ end
+
+ def fixture_file(path)
+ File.read File.expand_path( path, fixtures_path )
+ end
+
+end
+
+module Test::Integration
+ URL = "http://localhost:9200"
+
+ def setup
+ ::RestClient.delete "#{URL}/articles-test" rescue nil
+ ::RestClient.post "#{URL}/articles-test", ''
+ fixtures_path.join('articles').entries.each do |f|
+ filename = f.to_s
+ next if filename =~ /^\./
+ ::RestClient.put "#{URL}/articles-test/article/#{File.basename(filename, '.*')}",
+ fixtures_path.join('articles').join(f).read
+ end
+ ::RestClient.post "#{URL}/articles-test/_refresh", ''
+ end
+
+ def teardown
+ ::RestClient.delete "#{URL}/articles-test" rescue nil
+ end
+end

0 comments on commit 6adebbf

Please sign in to comment.