Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Commit

Permalink
Added infrastructure for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karmi committed Feb 7, 2011
1 parent 2ae9de2 commit 6adebbf
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Rakefile
Expand Up @@ -16,6 +16,11 @@ namespace :test do
test.pattern = 'test/unit/*_test.rb' test.pattern = 'test/unit/*_test.rb'
test.verbose = true test.verbose = true
end end
Rake::TestTask.new(:integration) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/integration/*_test.rb'
test.verbose = true
end
end end


# Generate documentation # Generate documentation
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/articles/1.json
@@ -0,0 +1 @@
{"title" : "One", "tags" : ["ruby"]}
1 change: 1 addition & 0 deletions test/fixtures/articles/2.json
@@ -0,0 +1 @@
{"title" : "Two", "tags" : ["ruby", "python"]}
1 change: 1 addition & 0 deletions test/fixtures/articles/3.json
@@ -0,0 +1 @@
{"title" : "Three", "tags" : ["java"]}
1 change: 1 addition & 0 deletions test/fixtures/articles/4.json
@@ -0,0 +1 @@
{"title" : "Four", "tags" : ["erlang"]}
1 change: 1 addition & 0 deletions test/fixtures/articles/5.json
@@ -0,0 +1 @@
{"title" : "Five", "tags" : ["javascript", "java"]}
35 changes: 33 additions & 2 deletions test/test_helper.rb
@@ -1,9 +1,40 @@
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'rubygems' require 'rubygems'
require 'test/unit' require 'test/unit'
require 'shoulda' require 'shoulda'
require 'mocha' require 'mocha'
require 'turn' unless ENV["TM_FILEPATH"] require 'turn' unless ENV["TM_FILEPATH"]
require 'pathname'


require 'slingshot' 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.