Permalink
Browse files

Shape of tests to come

  • Loading branch information...
1 parent a0e7828 commit 481a496d6d10924b23ca8a9edf6ca625c65231c3 @sreeix committed Mar 8, 2011
Showing with 73 additions and 0 deletions.
  1. +8 −0 Rakefile
  2. +23 −0 spec/commands/map_spec.rb
  3. 0 spec/couchup_spec.rb
  4. +37 −0 spec/spec_helper.rb
  5. +5 −0 spec/specs.opts
View
@@ -1,2 +1,10 @@
require 'bundler'
Bundler::GemHelper.install_tasks
+
+require 'rspec/core/rake_task'
+
+RSpec::Core::RakeTask.new(:spec) do |r|
+ r.rspec_opts = ["--color", "--format", "progress"]
+end
+
+task :default => :spec
View
@@ -0,0 +1,23 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+module Couchup
+ module Commands
+ describe Map do
+ before(:all) do
+ ddoc = {
+ "_id" => "_design/Rider",
+ "views" => {
+ "all" => {
+ "map" => "function(doc){emit(doc['_id'], 1)}",
+ "reduce" => "_sum"
+ }
+ }
+ }
+ database.save_doc(ddoc)
+ end
+
+ it "Runs a simple map" do
+ Map.new.run("Rider/all")
+ end
+ end
+ end
+end
View
No changes.
View
@@ -0,0 +1,37 @@
+require 'rubygems'
+require 'bundler/setup'
+
+require 'json'
+ROOT = File.expand_path("../..", __FILE__)
+$LOAD_PATH.unshift(File.join(ROOT, "lib"))
+require 'couchup'
+
+
+# Spec stuff
+require 'awesome_print'
+require 'couchrest'
+
+HOST = ENV['HOST'] || "127.0.0.1"
+PORT = ENV['PORT'] || "5984"
+
+TEST_DATABASE = 'couchup_test'
+
+def database
+ @db ||= CouchRest.database("http://#{HOST}:#{PORT}/#{TEST_DATABASE}")
+end
+
+RSpec.configure do |config|
+ config.before(:all) do
+ begin
+ database.delete!
+ database.create!
+ Couchup::Couchup.host = HOST
+ Couchup::Couchup.port = PORT
+ Couchup::Couchup.database = TEST_DATABASE
+ rescue
+ ap "Looks like the couch db does not exist. Use HOST and or PORT env param to set the couchdb server"
+ end
+ end
+end
+
+
View
@@ -0,0 +1,5 @@
+--colour
+--format
+progress
+--loadby
+mtime

0 comments on commit 481a496

Please sign in to comment.