Skip to content

Instantly share code, notes, and snippets.

@jldbasa
Created October 11, 2011 02:42
Show Gist options
  • Select an option

  • Save jldbasa/1277143 to your computer and use it in GitHub Desktop.

Select an option

Save jldbasa/1277143 to your computer and use it in GitHub Desktop.
Ripple + Cucumber Issue
require 'riak/test_server'
module Ripple
module TestServer
extend self
# Tweak this to change how your test server is configured
def test_server_config
{
:app_config => {
:riak_kv => {
:js_source_dir => Ripple.config.delete(:js_source_dir),
:map_cache_size => 0, # 0.14
:vnode_cache_entries => 0 # 0.13
},
:riak_core => { :web_port => Ripple.config[:http_port] || 8098 }
},
:bin_dir => Ripple.config.delete(:bin_dir),
:temp_dir => Rails.root + "tmp/riak_test_server"
}
end
# Prepares the subprocess Riak node for the test suite
def setup
unless @test_server
begin
_server = @test_server = Riak::TestServer.new(test_server_config)
@test_server.prepare!
@test_server.start
at_exit { _server.cleanup }
rescue => e
warn "Can't run tests with Riak::TestServer. Specify the location of your Riak installation in the config/ripple.yml #{Rails.env} environment."
warn e.inspect
@test_server = nil
end
end
end
# Clear the data after each test run
def clear
@test_server.recycle if @test_server
end
end
end
Ripple::TestServer.setup
After do
Ripple::TestServer.clear
end
# Configure Riak connections for the Ripple library.
development:
http_port: 8098
pb_port: 8087
host: localhost
# The test environment has additional keys for configuring the
# Riak::TestServer for your test/spec suite:
#
# * bin_dir specifies the path to the "riak" script that you use to
# start Riak (just the directory)
# * js_source_dir specifies where your custom Javascript functions for
# MapReduce should be loaded from. Usually app/mapreduce.
#http_port: 9000
#pb_port: 9002
# bin_dir: /usr/local/bin # Default for Homebrew.
test:
http_port: 9000
pb_port: 9002
host: localhost
bin_dir: /usr/sbin
js_source_dir: <%= Rails.root + "app/mapreduce" %>
production:
http_port: 8098
pb_port: 8087
host: localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment