Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 67 lines (57 sloc) 1.758 kb
db72fb5 @paulcarey Initial revision
authored
1 begin
2 require 'spec'
3 rescue LoadError
4 require 'rubygems'
5 gem 'rspec'
6 require 'spec'
7 end
8
9 $:.unshift(File.dirname(__FILE__) + '/../lib')
10 require 'relaxdb'
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
11
d398ea0 @paulcarey Added minimal support for data migrations.
authored
12 class RdbFormatter; def call(sv, time, progname, msg); puts msg; end; end
13
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
14 def setup_test_db
78f8ed8 @paulcarey Exploring inheritance support.
authored
15 # RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc", :logger => Logger.new(STDOUT)
d398ea0 @paulcarey Added minimal support for data migrations.
authored
16 # RelaxDB.logger.formatter = RdbFormatter.new
17
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
18 RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc"
19
20 RelaxDB.delete_db "relaxdb_spec" rescue "ok"
21 RelaxDB.use_db "relaxdb_spec"
22 begin
23 RelaxDB.replicate_db "relaxdb_spec_base", "relaxdb_spec"
78f8ed8 @paulcarey Exploring inheritance support.
authored
24 RelaxDB.enable_view_creation
6eb9681 @paulcarey Keep up to date with CouchDB head in anticipation of 0.9 (some tests fai...
authored
25 rescue => e
26 puts "\n===== Run rake create_base_db before the first spec run ====="
27 puts
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
28 exit!
29 end
30 end
31
73a3663 @paulcarey Moved all-by-class-name view so it's now created (if necessary) when a c...
authored
32 def create_test_db params = {}
33 defaults = {:host => "localhost", :port => 5984, :design_doc => "spec_doc"}
34 RelaxDB.configure defaults.merge(params)
35
36 RelaxDB.delete_db "relaxdb_spec" rescue "ok"
37 RelaxDB.use_db "relaxdb_spec"
78f8ed8 @paulcarey Exploring inheritance support.
authored
38 RelaxDB.enable_view_creation
73a3663 @paulcarey Moved all-by-class-name view so it's now created (if necessary) when a c...
authored
39 end
40
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
41 def create_base_db
42 RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc"
5a0735e @paulcarey Change identifying class property from class to relaxdb_class.
authored
43 RelaxDB.delete_db "relaxdb_spec_base" rescue "ok"
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
44 RelaxDB.use_db "relaxdb_spec_base"
78f8ed8 @paulcarey Exploring inheritance support.
authored
45 RelaxDB.enable_view_creation
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
46 require File.dirname(__FILE__) + '/spec_models.rb'
6c6fcd4 @paulcarey Modified view creation so all views are uploaded in a single request.
authored
47 RelaxDB::View.design_doc.save
1901592 @paulcarey Doc specs run on replicated db to ensure all views are pre-created. Also...
authored
48 puts "Created relaxdb_spec_base"
49 end
ecd8c0d @paulcarey Added support for updated_at.
authored
50
51 def roll_clock_forward(distance)
52 Time.meta_class.instance_eval do
53 define_method(:future_now) do
54 standard_now + distance
55 end
56 alias_method :standard_now, :now
57 alias_method :now, :future_now
58 begin
59 yield
60 rescue => e
61 raise e
62 ensure
63 alias_method :now, :standard_now
64 end
65 end
66 end
Something went wrong with that request. Please try again.