mattly-exegesis 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/design_test.rb CHANGED
@@ -21,7 +21,7 @@ class DesignTestDatabase
21
21
  end
22
22
  end
23
23
 
24
- class ExegesisDesignTest < Test::Unit::TestCase
24
+ describe Exegesis::Design do
25
25
 
26
26
  def setup_db(with_doc=true)
27
27
  reset_db
@@ -38,19 +38,19 @@ class ExegesisDesignTest < Test::Unit::TestCase
38
38
  end
39
39
  end
40
40
 
41
- context "design instances" do
41
+ describe "design instances" do
42
42
  before { setup_db }
43
- expect { @db.things.database.will == @db }
43
+ expect { @db.things.database.must_equal @db }
44
44
  end
45
45
 
46
- context "design declarations" do
46
+ describe "design declarations" do
47
47
  before { setup_db }
48
- expect { @db.things.class.will == DesignTestDatabase::ThingsDesign }
49
- expect { @db.things.is_a?(Exegesis::Design).will == true }
50
- expect { @db.things.design_name.will == 'things' }
48
+ expect { @db.things.class.must_equal DesignTestDatabase::ThingsDesign }
49
+ expect { @db.things.must_be_kind_of Exegesis::Design }
50
+ expect { @db.things.design_name.must_equal 'things' }
51
51
  end
52
52
 
53
- context "view declarations" do
53
+ describe "view declarations" do
54
54
  before do
55
55
  setup_db
56
56
  @docs = [
@@ -61,26 +61,26 @@ class ExegesisDesignTest < Test::Unit::TestCase
61
61
  @db.save(@docs)
62
62
  end
63
63
 
64
- context "declared docs" do
64
+ describe "declared docs" do
65
65
  describe "with default key" do
66
66
  before { @response = @db.things.by_tag('foo') }
67
- expect { @response.kind_of?(Exegesis::DocumentCollection).will == true }
68
- expect { @response.size.will == @docs.select{|d| d['tags'].include?('foo')}.size }
69
- expect { @response.documents.all? {|id,d| d.kind_of?(DesignTestDoc) }.will == true }
70
- expect { @response.documents.all? {|id,d| d['tags'].include?('foo') }.will == true }
67
+ expect { @response.must_be_kind_of Exegesis::DocumentCollection }
68
+ expect { @response.size.must_equal @docs.select{|d| d['tags'].include?('foo')}.size }
69
+ expect { @response.documents.each {|id,d| d.must_be_kind_of DesignTestDoc } }
70
+ expect { @response.documents.each {|id,d| d['tags'].must_include 'foo' } }
71
71
  end
72
72
 
73
73
  describe "with multiple keys" do
74
74
  before { @response = @db.things.by_tag :keys => %w(bar bee) }
75
- expect { @response.kind_of?(Exegesis::DocumentCollection).will == true }
76
- expect { @response.size.will == @docs.inject(0){|sum,d| sum+=(d['tags'] & %w(bar bee)).size } }
77
- expect { @response.documents.size.will == @docs.select{|d| (d['tags'] & %w(bar bee)).size > 0}.size }
78
- expect { @response.documents.all? {|id,d| d.kind_of?(DesignTestDoc) }.will == true }
75
+ expect { @response.must_be_kind_of Exegesis::DocumentCollection }
76
+ expect { @response.size.must_equal @docs.inject(0){|sum,d| sum+=(d['tags'] & %w(bar bee)).size } }
77
+ expect { @response.documents.size.must_equal @docs.select{|d| (d['tags'] & %w(bar bee)).size > 0}.size }
78
+ expect { @response.documents.each {|id,d| d.must_be_kind_of DesignTestDoc } }
79
79
  end
80
80
 
81
81
  end
82
82
 
83
- context "declared hashes" do
83
+ describe "declared hashes" do
84
84
  before do
85
85
  @counts = Hash.new(0)
86
86
  @docs.each do |doc|
@@ -94,111 +94,53 @@ class ExegesisDesignTest < Test::Unit::TestCase
94
94
  end
95
95
  end
96
96
  end
97
- expect { @db.things.count.should == @counts }
98
- expect { @db.things.count('foo').should == @counts['foo'] }
97
+ expect { @db.things.count.must_equal @counts }
98
+ expect { @db.things.count('foo').must_equal @counts['foo'] }
99
99
 
100
- context "invalid options" do
101
- expect { lambda{@db.things.count(:group=>false)}.will raise_error(ArgumentError) }
102
- expect { lambda{@db.things.count(:include_docs=>true)}.will raise_error(ArgumentError) }
100
+ describe "invalid options" do
101
+ expect { lambda{@db.things.count(:group=>false)}.must_raise ArgumentError }
102
+ expect { lambda{@db.things.count(:include_docs=>true)}.must_raise ArgumentError }
103
103
  end
104
104
 
105
- context "for views without reduce" do
105
+ describe "for views without reduce" do
106
106
  before { @klass = DesignTestDatabase::StuffDesign }
107
- expect { lambda{@klass.class_eval{hash(:name_count, :view=>:by_name)}}.will raise_error }
107
+ expect { lambda{@klass.class_eval{hash(:name_count, :view=>:by_name)}}.must_raise(ArgumentError) }
108
108
  end
109
109
  end
110
110
  end
111
111
 
112
- context "parsing query options" do
113
- before { setup_db }
114
-
115
- context "with a key as an initial arguemnt" do
116
- expect { @db.things.parse_opts('foo').will == {:key => 'foo'} }
117
- expect { @db.things.parse_opts('foo', :include_docs => true).will == {:key => 'foo', :include_docs => true} }
118
- expect { @db.things.parse_opts('foo', {:stale => 'ok'}, {:include_docs => true}).will == {:key => 'foo', :stale => 'ok', :include_docs => true }}
119
- end
120
-
121
- context "without an implied key" do
122
- expect { @db.things.parse_opts(:key => 'foo').will == {:key => 'foo'} }
123
- expect { @db.things.parse_opts({:key => 'foo'}, nil, {:stale => 'ok'}).will == {:key => 'foo', :stale => 'ok'} }
124
- end
125
-
126
- context "when a keys option is empty" do
127
- expect { @db.things.parse_opts(:keys => []).will == {} }
128
- end
129
-
130
- context "for ranges" do
131
- context "when the key _is_ a range" do
132
- before { @opts = @db.things.parse_opts(:key => 'bar'..'baz') }
133
- expect { @opts.has_key?(:key).will == false }
134
- expect { @opts[:startkey].will == 'bar' }
135
- expect { @opts[:endkey].will == 'baz'}
136
- end
137
-
138
- context "when the key is an array that includes a range" do
139
- before { @opts = @db.things.parse_opts(:key => ['published', '2009'..'2009/04']) }
140
- expect { @opts.has_key?(:key).will == false }
141
- expect { @opts[:startkey].will == ['published', '2009'] }
142
- expect { @opts[:endkey].will == ['published', '2009/04'] }
143
- end
144
-
145
- context "for non inclusive ranges" do
146
- end
147
- context "when descending:true is an option" do
148
- context "and first value is greater than the end value" do
149
- end
150
- end
151
- context "when the first value is greater than the end value" do
152
- end
153
-
154
- context "invalid option configurations" do
155
- expect { lambda {@db.things.parse_opts(:startkey => 'foo')}.will raise_error(ArgumentError) }
156
- end
157
- end
158
-
159
- context "reducing" do
160
- before { @parsing = lambda{|opts| @db.things.parse_opts(opts) } }
161
- expect { @parsing.call(:group => 3).will == {:group_level => 3}}
162
- expect { lambda{@parsing.call(:group => true, :reduce => false)}.will raise_error(ArgumentError) }
163
- expect { lambda{@parsing.call(:group => true, :include_docs => true)}.will raise_error(ArgumentError) }
164
- expect { lambda{@parsing.call(:group => 1, :reduce => false)}.will raise_error(ArgumentError) }
165
- expect { lambda{@parsing.call(:group => 1, :include_docs => true)}.will raise_error(ArgumentError) }
166
- end
112
+ describe "design doc meta declarations" do
113
+ expect { DesignTestDatabase::StuffDesign.design_name.must_equal "things" }
114
+ expect { DesignTestDatabase::StuffDesign.design_directory.must_equal Pathname.new("app/designs/stuff") }
167
115
  end
168
116
 
169
- context "design doc meta declarations" do
170
- expect { DesignTestDatabase::StuffDesign.design_name.will == "things" }
171
- expect { DesignTestDatabase::StuffDesign.design_directory.will == Pathname.new("app/designs/stuff") }
172
- end
173
-
174
- context "the design document" do
117
+ describe "the design document" do
175
118
  before do
176
119
  @canonical = DesignTestDatabase::ThingsDesign.canonical_design
177
120
  end
178
121
 
179
- context "composing the canonical version" do
180
- context "from files" do
181
- expect { @canonical['views']['by_tag']['map'].will == File.read(fixtures_path('designs/things/views/by_tag/map.js')) }
182
- expect { @canonical['views']['by_tag']['reduce'].will == File.read(fixtures_path('designs/things/views/by_tag/reduce.js')) }
122
+ describe "composing the canonical version" do
123
+ describe "from files" do
124
+ expect { @canonical['views']['by_tag']['map'].must_equal File.read(fixtures_path('designs/things/views/by_tag/map.js')) }
125
+ expect { @canonical['views']['by_tag']['reduce'].must_equal File.read(fixtures_path('designs/things/views/by_tag/reduce.js')) }
183
126
  end
184
127
 
185
- context "from class declarations" do
128
+ describe "from class declarations" do
186
129
  # tk
187
130
  end
188
131
  end
189
132
 
190
- context "syncronizing" do
191
- context "when the design_doc doesn't exist in the db yet" do
133
+ describe "syncronizing" do
134
+ describe "when the design_doc doesn't exist in the db yet" do
192
135
  before do
193
136
  setup_db(false)
194
- @db.things
195
137
  end
196
- expect { lambda{@db.get('_design/things')}.wont raise_error }
197
- expect { @db.things['views'].will == @canonical['views'] }
198
- expect { @db.things.rev.will =~ /\d-\d{6,12}/ }
138
+ expect { lambda{@db.get('_design/things')}.must_raise RestClient::ResourceNotFound }
139
+ expect { @db.things['views'].must_equal @canonical['views'] }
140
+ expect { @db.things.rev.must_match /\d-\d{6,12}/ }
199
141
  end
200
142
 
201
- context "when the design_doc exists but is not canonical" do
143
+ describe "when the design_doc exists but is not canonical" do
202
144
  before do
203
145
  # there are no line breaks in the version that setup_db posts
204
146
  setup_db
@@ -206,10 +148,10 @@ class ExegesisDesignTest < Test::Unit::TestCase
206
148
  @db.things
207
149
  end
208
150
 
209
- expect { @db.things.rev.wont == @old['_rev'] }
151
+ expect { @db.things.rev.wont_equal @old['_rev'] }
210
152
  end
211
153
 
212
- context "when the design_doc exists and is canonical" do
154
+ describe "when the design_doc exists and is canonical" do
213
155
  before do
214
156
  setup_db(false)
215
157
  @db.put('_design/things', DesignTestDatabase::ThingsDesign.canonical_design)
@@ -217,18 +159,18 @@ class ExegesisDesignTest < Test::Unit::TestCase
217
159
  @db.things
218
160
  end
219
161
 
220
- expect { @db.things.rev.will == @old['_rev'] }
162
+ expect { @db.things.rev.must_equal @old['_rev'] }
221
163
  end
222
164
  end
223
165
 
224
- context "knowing the views" do
166
+ describe "knowing the views" do
225
167
  before do
226
168
  @klass = DesignTestDatabase::ThingsDesign
227
169
  end
228
170
 
229
- expect { @klass.views.will == @canonical['views'].keys }
230
- expect { @klass.reduceable?('by_tag').will be(true) }
231
- expect { @klass.reduceable?('by_name').will be(false) }
171
+ expect { @klass.views.must_equal @canonical['views'].keys }
172
+ expect { assert @klass.reduceable?('by_tag') }
173
+ expect { refute @klass.reduceable?('by_name') }
232
174
  end
233
175
  end
234
176
 
@@ -4,9 +4,9 @@ class DocCollectionTestDoc
4
4
  include Exegesis::Document
5
5
  end
6
6
 
7
- class ExegesisDocumentCollectionTest < Test::Unit::TestCase
7
+ describe Exegesis::DocumentCollection do
8
8
 
9
- context "when dealing with view response rows" do
9
+ describe "when dealing with view response rows" do
10
10
  before do
11
11
  reset_db
12
12
  @docs = [{'_id' => 'foo'}, {'_id' => 'bar'}, {'_id' => 'bee'}].map {|d| d.update('class' => 'DocCollectionTestDoc') }
@@ -16,14 +16,14 @@ class ExegesisDocumentCollectionTest < Test::Unit::TestCase
16
16
  @collection = Exegesis::DocumentCollection.new(@response_rows, @db)
17
17
  end
18
18
 
19
- expect { @collection.size.will == @rows.size }
20
- expect { @collection.keys.will == @rows.map{|r| r.first}.uniq }
21
- expect { @collection.values.will == @rows.map{|r| r[1]} }
22
- expect { @collection.documents.size.will == @rows.map{|r| r[2]}.uniq.size }
23
- expect { @collection.documents.all? {|id,d| d.kind_of?(DocCollectionTestDoc) }.will == true }
24
- expect { @collection.documents['foo'].id.will == @docs.first['_id'] }
19
+ expect { @collection.size.must_equal @rows.size }
20
+ expect { @collection.keys.must_equal @rows.map{|r| r.first}.uniq }
21
+ expect { @collection.values.must_equal @rows.map{|r| r[1]} }
22
+ expect { @collection.documents.size.must_equal @rows.map{|r| r[2]}.uniq.size }
23
+ expect { @collection.documents.each {|id,d| d.must_be_kind_of DocCollectionTestDoc } }
24
+ expect { @collection.documents['foo'].id.must_equal @docs.first['_id'] }
25
25
 
26
- context "when documents are already in the rows" do
26
+ describe "when documents are already in the rows" do
27
27
  before do
28
28
  # "thing":"foobar" is not in the docs that have been saved to the database
29
29
  @docs.each {|d| d.update('thing' => 'foobar') }
@@ -31,22 +31,22 @@ class ExegesisDocumentCollectionTest < Test::Unit::TestCase
31
31
  @collection = Exegesis::DocumentCollection.new(@response_rows, @db)
32
32
  end
33
33
 
34
- expect { @collection.documents.all?{|id,d| d['thing'] == 'foobar' }.will == true }
34
+ expect { @collection.documents.each {|id,d| d['thing'].must_equal 'foobar' } }
35
35
  end
36
36
 
37
- context "filtering to a specific key" do
37
+ describe "filtering to a specific key" do
38
38
  before do
39
39
  @rows = @rows.select {|r| r[0]=="foo" }
40
40
  @foos = @collection['foo']
41
41
  end
42
42
 
43
- expect { @foos.size.will == @rows.size }
44
- expect { @foos.values.will == @rows.map{|r| r[1]} }
45
- expect { @foos.documents.size.will == @rows.map{|r| r[2]}.uniq.size }
46
- expect { @foos.documents.all? {|id,d| d.kind_of?(DocCollectionTestDoc) }.will == true }
47
- expect { @foos.documents['foo'].object_id.will == @collection.documents['foo'].object_id }
43
+ expect { @foos.size.must_equal @rows.size }
44
+ expect { @foos.values.must_equal @rows.map{|r| r[1]} }
45
+ expect { @foos.documents.size.must_equal @rows.map{|r| r[2]}.uniq.size }
46
+ expect { @foos.documents.each {|id,d| d.must_be_kind_of DocCollectionTestDoc } }
47
+ expect { @foos.documents['foo'].object_id.must_equal @collection.documents['foo'].object_id }
48
48
 
49
- context "with array keys" do
49
+ describe "with array keys" do
50
50
  before do
51
51
  @rows = [ [%w(bar baz), 5, 'bar'],
52
52
  [%w(bar bee), 5, 'bee'],
@@ -60,17 +60,17 @@ class ExegesisDocumentCollectionTest < Test::Unit::TestCase
60
60
  @collection = Exegesis::DocumentCollection.new(@response_rows, @db)
61
61
  end
62
62
 
63
- expect { @collection['foo'].size.will == @rows.select{|r| r[0][0]=='foo'}.size }
64
- expect { @collection['foo'].values.will == @rows.select{|r| r[0][0]=='foo' }.map{|r| r[1]} }
65
- expect { @collection['foo']['bar'].size.will == @rows.select{|r| r[0][0]=='foo' && r[0][1]=='bar'}.size }
66
- expect { @collection['foo']['bar'].values.will == @rows.select{|r| r[0][0]=='foo'&&r[0][1]=='bar'}.map{|r| r[1]} }
63
+ expect { @collection['foo'].size.must_equal @rows.select{|r| r[0][0]=='foo'}.size }
64
+ expect { @collection['foo'].values.must_equal @rows.select{|r| r[0][0]=='foo' }.map{|r| r[1]} }
65
+ expect { @collection['foo']['bar'].size.must_equal @rows.select{|r| r[0][0]=='foo' && r[0][1]=='bar'}.size }
66
+ expect { @collection['foo']['bar'].values.must_equal @rows.select{|r| r[0][0]=='foo'&&r[0][1]=='bar'}.map{|r| r[1]} }
67
67
  end
68
68
 
69
69
  end
70
70
 
71
71
  end
72
72
 
73
- context "iterating" do
73
+ describe "iterating" do
74
74
  before do
75
75
  reset_db
76
76
  @docs = [%w(bar bee), %w(bee foo), %w(foo bar)].map {|k,t| {'_id'=>k, 'thing'=>t, 'class'=>'DocCollectionTestDoc'} }
@@ -79,7 +79,7 @@ class ExegesisDocumentCollectionTest < Test::Unit::TestCase
79
79
  @collection = Exegesis::DocumentCollection.new(@rows, @db)
80
80
  end
81
81
 
82
- context "each" do
82
+ describe "each" do
83
83
  before do
84
84
  @counter = 0
85
85
  @bin = []
@@ -88,10 +88,10 @@ class ExegesisDocumentCollectionTest < Test::Unit::TestCase
88
88
  @valbinning = lambda{ @collection.each{|k,v,d| @bin << v }; @bin }
89
89
  @docbinning = lambda{ @collection.each{|k,v,d| @bin << d.id }; @bin }
90
90
  end
91
- expect { @counting.call.will == 3 }
92
- expect { @keybinning.call.will == @rows.map{|r| r['key']} }
93
- expect { @valbinning.call.will == @rows.map{|r| r['value']} }
94
- expect { @docbinning.call.will == @rows.map{|r| @db.get(r['id']).id} }
91
+ expect { @counting.call.must_equal 3 }
92
+ expect { @keybinning.call.must_equal @rows.map{|r| r['key']} }
93
+ expect { @valbinning.call.must_equal @rows.map{|r| r['value']} }
94
+ expect { @docbinning.call.must_equal @rows.map{|r| @db.get(r['id']).id} }
95
95
  end
96
96
  end
97
97
  end
@@ -23,10 +23,10 @@ class UniqueIdBlockTestDocument
23
23
  unique_id {|doc, attempt| attempt.zero? ? doc['pk'] : "#{doc['pk']}-#{attempt}" }
24
24
  end
25
25
 
26
- class ExegesisDocumentClassDefinitionsTest < Test::Unit::TestCase
26
+ describe Exegesis::Document do
27
27
 
28
- context "class definitions" do
29
- context "with timestamps" do
28
+ describe "class definitions" do
29
+ describe "with timestamps" do
30
30
  before do
31
31
  reset_db
32
32
  @obj = TimestampTestDocument.new({}, @db)
@@ -34,144 +34,143 @@ class ExegesisDocumentClassDefinitionsTest < Test::Unit::TestCase
34
34
  @obj = @db.get(@obj.id)
35
35
  end
36
36
 
37
- context "initial save" do
38
- expect { @obj.created_at.to_f.will be_close(Time.now.to_f, 2) }
39
- expect { @obj.updated_at.to_f.will be_close(Time.now.to_f, 2) }
37
+ describe "initial save" do
38
+ expect { @obj.created_at.to_f.must_be_close_to Time.now.to_f, 2 }
39
+ expect { @obj.updated_at.to_f.must_be_close_to Time.now.to_f, 2 }
40
40
  end
41
41
 
42
- context "when created_at already exists" do
42
+ describe "when created_at already exists" do
43
43
  before do
44
44
  @obj['created_at'] = Time.now - 3600
45
45
  @obj.save
46
46
  @obj = @db.get(@obj.id)
47
47
  end
48
48
 
49
- expect { @obj.created_at.to_f.will be_close((Time.now - 3600).to_f, 2) }
50
- expect { @obj.updated_at.to_f.will be_close(Time.now.to_f, 2) }
49
+ expect { @obj.created_at.to_f.must_be_close_to((Time.now - 3600).to_f, 2) }
50
+ expect { @obj.updated_at.to_f.must_be_close_to Time.now.to_f, 2 }
51
51
  end
52
52
 
53
53
  end
54
54
 
55
- context "with a custom unique_id setter" do
56
- context "as a method" do
55
+ describe "with a custom unique_id setter" do
56
+ describe "as a method" do
57
57
  before do
58
58
  reset_db
59
59
  @obj = UniqueIdTestDocument.new({}, @db)
60
60
  end
61
61
 
62
- context "when the id isn't in place yet" do
62
+ describe "when the id isn't in place yet" do
63
63
  before do
64
64
  @obj.save
65
65
  end
66
66
 
67
- expect { @obj.id.will == "snowflake" }
67
+ expect { @obj.id.must_equal "snowflake" }
68
68
  end
69
69
 
70
- context "when there is an id in place already" do
70
+ describe "when there is an id in place already" do
71
71
  before do
72
72
  @obj['_id'] = 'foo'
73
73
  @obj.save
74
74
  end
75
75
 
76
- expect { @obj.id.will == "foo" }
76
+ expect { @obj.id.must_equal "foo" }
77
77
  end
78
78
 
79
- context "when the desired id is already in use" do
79
+ describe "when the desired id is already in use" do
80
80
  before do
81
81
  @db.put('snowflake', {'_id' => 'snowflake', 'foo' => 'bar'})
82
82
  @obj.save
83
83
  end
84
84
 
85
- expect { @obj.id.will == 'snowflake-1' }
85
+ expect { @obj.id.must_equal 'snowflake-1' }
86
86
  end
87
87
  end
88
88
 
89
- context "as a block" do
89
+ describe "as a block" do
90
90
  before do
91
91
  reset_db
92
92
  @obj = UniqueIdBlockTestDocument.new({'pk'=>'bar'}, @db)
93
93
  end
94
94
 
95
- context "when the id doesn't yet exist and no id in place" do
95
+ describe "when the id doesn't yet exist and no id in place" do
96
96
  before { @obj.save }
97
- expect { @obj.id.will == @obj['pk'] }
97
+ expect { @obj.id.must_equal @obj['pk'] }
98
98
  end
99
99
 
100
- context "when the document has an id in place already" do
100
+ describe "when the document has an id in place already" do
101
101
  before do
102
102
  @obj['_id'] = 'foo'
103
103
  @obj.save
104
104
  end
105
- expect { @obj.id.will == 'foo' }
105
+ expect { @obj.id.must_equal 'foo' }
106
106
  end
107
107
 
108
- context "when the desired id is already in use" do
108
+ describe "when the desired id is already in use" do
109
109
  before do
110
110
  @db.put('bar', {'_id' => 'bar', 'pk' => 'bar'})
111
111
  @obj.save
112
112
  end
113
- expect { @obj.id.will == 'bar-1'}
113
+ expect { @obj.id.must_equal 'bar-1'}
114
114
  end
115
115
  end
116
116
  end
117
117
  end
118
118
 
119
- context "instance methods" do
119
+ describe "instance methods" do
120
120
  before do
121
121
  reset_db
122
122
  end
123
123
 
124
- context "updating attributes" do
124
+ describe "updating attributes" do
125
125
 
126
- context "an existing doc" do
126
+ describe "an existing doc" do
127
127
  before do
128
128
  @doc = TestDocument.new({'foo' => 'bar'}, @db)
129
129
  @doc.save
130
130
  @old_rev = @doc.rev
131
131
  end
132
132
 
133
- context "without a matching rev" do
134
- expect { lambda {@doc.update_attributes({'foo' => 'bee'})}.will raise_error(ArgumentError) }
135
- expect { lambda {@doc.update_attributes({'foo' => 'bee', '_rev' => 'z'})}.will raise_error(ArgumentError) }
133
+ describe "without a matching rev" do
134
+ expect { lambda{@doc.update_attributes({'foo' => 'bee'})}.must_raise ArgumentError }
135
+ expect { lambda{@doc.update_attributes({'foo' => 'bee', '_rev' => 'z'})}.must_raise ArgumentError }
136
136
  end
137
137
 
138
- context "with a matching rev" do
138
+ describe "with a matching rev" do
139
139
  before do
140
140
  @doc.update_attributes({'_rev' => @doc.rev, 'foo' => 'bee'})
141
141
  end
142
142
 
143
- expect { @doc['foo'].will == 'bee' }
144
- expect { @doc.rev.wont == @old_rev }
143
+ expect { @doc['foo'].must_equal 'bee' }
144
+ expect { @doc.rev.wont_equal @old_rev }
145
145
  end
146
146
 
147
- context "when given keys without writers" do
147
+ describe "when given keys without writers" do
148
148
  before do
149
149
  @action = lambda {@doc.update_attributes({'_rev' => @doc.rev, 'bar' => 'boo'})}
150
150
  end
151
151
 
152
- expect { @action.will raise_error(NoMethodError) }
152
+ expect { @action.must_raise NoMethodError }
153
153
  end
154
154
  end
155
155
 
156
- context "a new doc" do
156
+ describe "a new doc" do
157
157
  before { @doc = TestDocument.new({'foo' => 'bar'}, @db) }
158
158
 
159
- context "without a rev" do
159
+ describe "without a rev" do
160
160
  before { @doc.update_attributes({'foo' => 'baz'}) }
161
- expect { @doc['foo'].will == 'baz' }
161
+ expect { @doc['foo'].must_equal 'baz' }
162
162
  end
163
163
 
164
- context "with a blank rev" do
164
+ describe "with a blank rev" do
165
165
  before { @doc.update_attributes({'foo' => 'baz', '_rev' => ''}) }
166
- expect { @doc['foo'].will == 'baz' }
166
+ expect { @doc['foo'].must_equal 'baz' }
167
167
  end
168
- context "with a non blank rev" do
168
+ describe "with a non blank rev" do
169
169
  before { @action = lambda{@doc.update_attributes({'foo'=>'baz', '_rev'=>'1-3034523523'})} }
170
- expect { @action.will raise_error(ArgumentError)}
170
+ expect { @action.must_raise ArgumentError }
171
171
  end
172
172
  end
173
173
 
174
-
175
174
  end
176
175
  end
177
176
 
data/test/http_test.rb CHANGED
@@ -2,20 +2,20 @@ require File.join(File.dirname(__FILE__), 'test_helper.rb')
2
2
  require 'restclient'
3
3
  require 'json'
4
4
 
5
- class HttpTest < Test::Unit::TestCase
5
+ describe Exegesis::Http do
6
6
 
7
- context "url formatting" do
8
- context "with no params" do
7
+ describe "url formatting" do
8
+ describe "with no params" do
9
9
  before do
10
10
  @url = "/some_url"
11
11
  @action = lambda {|params| Exegesis::Http.format_url(@url, params) }
12
12
  end
13
13
 
14
- expect { @action.call(nil).will == "/some_url" }
15
- expect { @action.call({}).will == "/some_url" }
14
+ expect { @action.call(nil).must_equal "/some_url" }
15
+ expect { @action.call({}).must_equal "/some_url" }
16
16
  end
17
17
 
18
- context "with normal params" do
18
+ describe "with normal params" do
19
19
  before do
20
20
  @url = "/some_url"
21
21
  @params = {
@@ -25,54 +25,52 @@ class HttpTest < Test::Unit::TestCase
25
25
  @expected = ["/some_url?one=1&two=2", "/some_url?two=2&one=1"]
26
26
  end
27
27
 
28
- expect { @expected.will include(Exegesis::Http.format_url(@url, @params)) }
28
+ expect { @expected.must_include Exegesis::Http.format_url(@url, @params) }
29
29
  end
30
30
  end
31
31
 
32
- context "making requests" do
33
- before(:all) do
32
+ describe "making requests" do
33
+ before do
34
34
  @db = 'http://localhost:5984/exegesis-test'
35
35
  RestClient.delete(@db) rescue nil
36
36
  RestClient.put(@db, '')
37
37
  end
38
38
 
39
- after(:all) do
39
+ after do
40
40
  RestClient.delete(@db) rescue nil
41
41
  end
42
42
 
43
- context "get requests" do
43
+ describe "get requests" do
44
44
  before do
45
45
  @response = Exegesis::Http.get(@db)
46
46
  end
47
47
 
48
- expect { @response['db_name'].will == 'exegesis-test' }
48
+ expect { @response['db_name'].must_equal 'exegesis-test' }
49
49
  end
50
50
 
51
- context "post requests" do
51
+ describe "post requests" do
52
52
  before do
53
53
  @response = Exegesis::Http.post(@db, {'test' => 'value'}.to_json)
54
54
  end
55
55
 
56
- expect { @response['ok'].will == true }
56
+ expect { @response['ok'].must_equal true }
57
57
  end
58
58
 
59
- context "put requests" do
59
+ describe "put requests" do
60
60
  before do
61
61
  @response = Exegesis::Http.put("#{@db}/test-document", {'test' => 'value'}.to_json)
62
62
  end
63
63
 
64
- expect { @response['ok'].will == true }
65
-
66
- after { RestClient.delete("#{@db}/test-document?rev=#{@response['rev']}") }
64
+ expect { @response['ok'].must_equal true }
67
65
  end
68
66
 
69
- context "delete requests" do
67
+ describe "delete requests" do
70
68
  before do
71
69
  @doc = JSON.parse RestClient.put("#{@db}/test-document", {'test' => 'value'}.to_json)
72
70
  @response = RestClient.delete("#{@db}/test-document?rev=#{@doc['rev']}")
73
71
  end
74
72
 
75
- expect { @response['ok'].will == 'ok' }
73
+ expect { @response['ok'].must_equal 'ok' }
76
74
  end
77
75
  end
78
76