dm-persevere-adapter 0.18.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -1,52 +1,15 @@
1
1
  require 'pathname'
2
2
  require 'rubygems'
3
-
4
3
  require 'addressable/uri'
5
4
  require 'spec'
6
-
7
- require 'ruby-debug'
8
-
5
+
9
6
  require 'dm-core'
10
7
 
11
- require 'adapter_shared_spec'
12
-
13
- SPEC_ROOT = Pathname(__FILE__).dirname.expand_path
14
- # $LOAD_PATH.unshift(SPEC_ROOT.parent + 'lib')
15
-
16
- Pathname.glob((SPEC_ROOT + '{lib,*/shared}/**/*.rb').to_s).each { |file| require file }
17
-
18
- ENV['ADAPTERS'] ||= 'all'
19
-
20
- ADAPTERS = []
21
-
22
- PRIMARY = {
23
- 'persevere' => {:adapter => 'persevere', :host => 'localhost', :port => '8080'}
24
- }
25
-
26
- adapters = ENV['ADAPTERS'].split(' ').map { |adapter_name| adapter_name.strip.downcase }.uniq
27
- adapters = PRIMARY.keys if adapters.include?('all')
28
-
29
- PRIMARY.only(*adapters).each do |name, default|
30
- connection_string = ENV["#{name.upcase}_SPEC_URI"] || default
31
- begin
32
- adapter = DataMapper.setup(name.to_sym, connection_string)
33
-
34
- # test the connection if possible
35
- if adapter.respond_to?(:query)
36
- name == 'oracle' ? adapter.select('SELECT 1 FROM dual') : adapter.select('SELECT 1')
37
- end
38
-
39
- ADAPTERS << name
40
- PRIMARY[name] = connection_string # ensure *_SPEC_URI is saved
41
- rescue Exception => exception
42
- puts "Could not connect to the database using #{connection_string.inspect} because: #{exception.inspect}"
8
+ def path_to(gem_name, version=nil)
9
+ version = version ? Gem::Requirement.create(version) : Gem::Requirement.default
10
+ specs = Gem.source_index.find_name(gem_name, version)
11
+ paths = specs.map do |spec|
12
+ spec_path = spec.loaded_from
13
+ expanded_path = File.join(File.dirname(spec_path), '..', 'gems', "#{spec.name}-#{spec.version}")
43
14
  end
44
- end
45
-
46
- logger = DataMapper::Logger.new(DataMapper.root / 'log' / 'dm.log', :debug)
47
- logger.auto_flush = true
48
-
49
- Spec::Runner.configure do |config|
50
- config.extend(DataMapper::Spec::AdapterHelpers)
51
- # config.include(DataMapper::Spec::PendingHelpers)
52
15
  end
metadata CHANGED
@@ -1,95 +1,93 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-persevere-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ivan R. Judson
8
- - The Yogo Data Management Development Team
7
+ - Ivan R. Judson
8
+ - The Yogo Data Management Development Team
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-13 00:00:00 -07:00
13
+ date: 2010-01-19 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: dm-core
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 0.10.1
25
- version:
26
- - !ruby/object:Gem::Dependency
27
- name: extlib
28
- type: :runtime
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
35
- version:
16
+ - !ruby/object:Gem::Dependency
17
+ name: dm-core
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.10.1
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: extlib
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ version:
36
36
  description: A DataMapper Adapter for persevere
37
37
  email:
38
- - irjudson [a] gmail [d] com
38
+ - irjudson [a] gmail [d] com
39
39
  executables: []
40
40
 
41
41
  extensions: []
42
42
 
43
43
  extra_rdoc_files:
44
- - LICENSE.txt
45
- - README.txt
44
+ - LICENSE.txt
45
+ - README.txt
46
46
  files:
47
- - .gitignore
48
- - History.txt
49
- - LICENSE.txt
50
- - Manifest.txt
51
- - README.txt
52
- - Rakefile
53
- - VERSION
54
- - lib/model_json_support.rb
55
- - lib/persevere.rb
56
- - lib/persevere_adapter.rb
57
- - persevere/History.txt
58
- - persevere/LICENSE.txt
59
- - persevere/Manifest.txt
60
- - persevere/README.txt
61
- - spec/adapter_shared_spec.rb
62
- - spec/lib/adapter_helpers.rb
63
- - spec/persevere_adapter_spec.rb
64
- - spec/persevere_spec.rb
65
- - spec/spec.opts
66
- - spec/spec_helper.rb
67
- - spec/unit/create_spec.rb
68
- - spec/unit/delete_spec.rb
69
- - spec/unit/read_spec.rb
70
- - spec/unit/update_spec.rb
71
- - tasks/spec.rb
47
+ - .gitignore
48
+ - History.txt
49
+ - LICENSE.txt
50
+ - Manifest.txt
51
+ - README.txt
52
+ - Rakefile
53
+ - VERSION
54
+ - lib/model_json_support.rb
55
+ - lib/persevere.rb
56
+ - lib/persevere_adapter.rb
57
+ - persevere/History.txt
58
+ - persevere/LICENSE.txt
59
+ - persevere/Manifest.txt
60
+ - persevere/README.txt
61
+ - spec/persevere_adapter_spec.rb
62
+ - spec/persevere_spec.rb
63
+ - spec/spec.opts
64
+ - spec/spec_helper.rb
65
+ - spec/unit/create_spec.rb
66
+ - spec/unit/delete_spec.rb
67
+ - spec/unit/read_spec.rb
68
+ - spec/unit/update_spec.rb
69
+ - tasks/spec.rb
72
70
  has_rdoc: true
73
71
  homepage: http://github.com/yogo/dm-persevere-adapter
74
72
  licenses: []
75
73
 
76
74
  post_install_message:
77
75
  rdoc_options:
78
- - --main
79
- - README.txt
76
+ - --main
77
+ - README.txt
80
78
  require_paths:
81
- - lib
79
+ - lib
82
80
  required_ruby_version: !ruby/object:Gem::Requirement
83
81
  requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: "0"
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
87
85
  version:
88
86
  required_rubygems_version: !ruby/object:Gem::Requirement
89
87
  requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: "0"
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
93
91
  version:
94
92
  requirements: []
95
93
 
@@ -99,12 +97,10 @@ signing_key:
99
97
  specification_version: 3
100
98
  summary: A DataMapper Adapter for persevere
101
99
  test_files:
102
- - spec/adapter_shared_spec.rb
103
- - spec/lib/adapter_helpers.rb
104
- - spec/persevere_adapter_spec.rb
105
- - spec/persevere_spec.rb
106
- - spec/spec_helper.rb
107
- - spec/unit/create_spec.rb
108
- - spec/unit/delete_spec.rb
109
- - spec/unit/read_spec.rb
110
- - spec/unit/update_spec.rb
100
+ - spec/persevere_adapter_spec.rb
101
+ - spec/persevere_spec.rb
102
+ - spec/spec_helper.rb
103
+ - spec/unit/create_spec.rb
104
+ - spec/unit/delete_spec.rb
105
+ - spec/unit/read_spec.rb
106
+ - spec/unit/update_spec.rb
@@ -1,311 +0,0 @@
1
- share_examples_for 'An Adapter Foo' do
2
-
3
- def self.adapter_supports?(*methods)
4
- methods.all? do |method|
5
- # TODO: figure out a way to see if the instance method is only inherited
6
- # from the Abstract Adapter, and not defined in it's class. If that is
7
- # the case return false
8
-
9
- # CRUD methods can be inherited from parent class
10
- described_type.instance_methods.any? { |instance_method| method.to_s == instance_method.to_s }
11
- end
12
- end
13
-
14
- before :all do
15
- raise '+@adapter+ should be defined in before block' unless instance_variable_get('@adapter')
16
-
17
- class ::Heffalump
18
- include DataMapper::Resource
19
-
20
- property :id, Serial
21
- property :color, String
22
- property :num_spots, Integer
23
- property :striped, Boolean
24
- end
25
-
26
- # create all tables and constraints before each spec
27
-
28
- # if @repository.respond_to?(:auto_migrate!)
29
- Heffalump.auto_migrate!
30
- # end
31
- end
32
-
33
- if adapter_supports?(:create)
34
- describe '#create' do
35
- it 'should not raise any errors' do
36
- lambda {
37
- Heffalump.create(:color => 'peach')
38
- }.should_not raise_error
39
- end
40
-
41
- it 'should set the identity field for the resource' do
42
- heffalump = Heffalump.new(:color => 'peach')
43
- heffalump.id.should be_nil
44
- heffalump.save
45
- heffalump.id.should_not be_nil
46
- end
47
- end
48
- else
49
- it 'needs to support #create'
50
- end
51
-
52
- if adapter_supports?(:read)
53
- describe '#read' do
54
- before :all do
55
- @heffalump = Heffalump.create(:color => 'brownish hue')
56
- #just going to borrow this, so I can check the return values
57
- @query = Heffalump.all.query
58
- end
59
-
60
- it 'should not raise any errors' do
61
- lambda {
62
- Heffalump.all()
63
- }.should_not raise_error
64
- end
65
-
66
- it 'should return stuff' do
67
- Heffalump.all.should be_include(@heffalump)
68
- end
69
- end
70
- else
71
- it 'needs to support #read'
72
- end
73
-
74
- if adapter_supports?(:update)
75
- describe '#update' do
76
- before do
77
- @heffalump = Heffalump.create(:color => 'indigo')
78
- end
79
-
80
- it 'should not raise any errors' do
81
- lambda {
82
- @heffalump.color = 'violet'
83
- @heffalump.save
84
- }.should_not raise_error
85
- end
86
-
87
- it 'should not alter the identity field' do
88
- id = @heffalump.id
89
- @heffalump.color = 'violet'
90
- @heffalump.save
91
- @heffalump.id.should == id
92
- end
93
-
94
- it 'should update altered fields' do
95
- @heffalump.color = 'violet'
96
- @heffalump.save
97
- Heffalump.get(*@heffalump.key).color.should == 'violet'
98
- end
99
-
100
- it 'should not alter other fields' do
101
- color = @heffalump.color
102
- @heffalump.num_spots = 3
103
- @heffalump.save
104
- Heffalump.get(*@heffalump.key).color.should == color
105
- end
106
- end
107
- else
108
- it 'needs to support #update'
109
- end
110
-
111
- if adapter_supports?(:delete)
112
- describe '#delete' do
113
- before do
114
- @heffalump = Heffalump.create(:color => 'forest green')
115
- end
116
-
117
- it 'should not raise any errors' do
118
- lambda {
119
- @heffalump.destroy
120
- }.should_not raise_error
121
- end
122
-
123
- it 'should delete the requested resource' do
124
- id = @heffalump.id
125
- @heffalump.destroy
126
- Heffalump.get(id).should be_nil
127
- end
128
- end
129
- else
130
- it 'needs to support #delete'
131
- end
132
-
133
- if adapter_supports?(:read, :create)
134
- describe 'query matching' do
135
- before :all do
136
- @red = Heffalump.create(:color => 'red')
137
- @two = Heffalump.create(:num_spots => 2)
138
- @five = Heffalump.create(:num_spots => 5)
139
- end
140
-
141
- describe 'conditions' do
142
- describe 'eql' do
143
- it 'should be able to search for objects included in an inclusive range of values' do
144
- Heffalump.all(:num_spots => 1..5).should be_include(@five)
145
- end
146
-
147
- it 'should be able to search for objects included in an exclusive range of values' do
148
- Heffalump.all(:num_spots => 1...6).should be_include(@five)
149
- end
150
-
151
- it 'should not be able to search for values not included in an inclusive range of values' do
152
- Heffalump.all(:num_spots => 1..4).should_not be_include(@five)
153
- end
154
-
155
- it 'should not be able to search for values not included in an exclusive range of values' do
156
- Heffalump.all(:num_spots => 1...5).should_not be_include(@five)
157
- end
158
- end
159
-
160
- describe 'not' do
161
- it 'should be able to search for objects with not equal value' do
162
- Heffalump.all(:color.not => 'red').should_not be_include(@red)
163
- end
164
-
165
- it 'should include objects that are not like the value' do
166
- Heffalump.all(:color.not => 'black').should be_include(@red)
167
- end
168
-
169
- it 'should be able to search for objects with not nil value' do
170
- Heffalump.all(:color.not => nil).should be_include(@red)
171
- end
172
-
173
- it 'should not include objects with a nil value' do
174
- Heffalump.all(:color.not => nil).should_not be_include(@two)
175
- end
176
-
177
- it 'should be able to search for object with a nil value using required properties' do
178
- Heffalump.all(:id.not => nil).should == [ @red, @two, @five ]
179
- end
180
-
181
- it 'should be able to search for objects not in an empty list (match all)' do
182
- Heffalump.all(:color.not => []).should == [ @red, @two, @five ]
183
- end
184
-
185
- it 'should be able to search for objects in an empty list and another OR condition (match none on the empty list)' do
186
- Heffalump.all(:conditions => DataMapper::Query::Conditions::Operation.new(
187
- :or,
188
- DataMapper::Query::Conditions::Comparison.new(:in, Heffalump.properties[:color], []),
189
- DataMapper::Query::Conditions::Comparison.new(:in, Heffalump.properties[:num_spots], [5]))).should == [ @five ]
190
- end
191
-
192
- it 'should be able to search for objects not included in an array of values' do
193
- Heffalump.all(:num_spots.not => [ 1, 3, 5, 7 ]).should be_include(@two)
194
- end
195
-
196
- it 'should be able to search for objects not included in an array of values' do
197
- Heffalump.all(:num_spots.not => [ 1, 3, 5, 7 ]).should_not be_include(@five)
198
- end
199
-
200
- it 'should be able to search for objects not included in an inclusive range of values' do
201
- Heffalump.all(:num_spots.not => 1..4).should be_include(@five)
202
- end
203
-
204
- it 'should be able to search for objects not included in an exclusive range of values' do
205
- Heffalump.all(:num_spots.not => 1...5).should be_include(@five)
206
- end
207
-
208
- it 'should not be able to search for values not included in an inclusive range of values' do
209
- Heffalump.all(:num_spots.not => 1..5).should_not be_include(@five)
210
- end
211
-
212
- it 'should not be able to search for values not included in an exclusive range of values' do
213
- Heffalump.all(:num_spots.not => 1...6).should_not be_include(@five)
214
- end
215
- end
216
-
217
- describe 'like' do
218
- it 'should be able to search for objects that match value' do
219
- Heffalump.all(:color.like => '%ed').should be_include(@red)
220
- end
221
-
222
- it 'should not search for objects that do not match the value' do
223
- Heffalump.all(:color.like => '%blak%').should_not be_include(@red)
224
- end
225
- end
226
-
227
- describe 'regexp' do
228
- before do
229
- if (defined?(DataMapper::Adapters::Sqlite3Adapter) && @adapter.kind_of?(DataMapper::Adapters::Sqlite3Adapter) ||
230
- defined?(DataMapper::Adapters::SqlserverAdapter) && @adapter.kind_of?(DataMapper::Adapters::SqlserverAdapter))
231
- pending 'delegate regexp matches to same system that the InMemory and YAML adapters use'
232
- end
233
- end
234
-
235
- it 'should be able to search for objects that match value' do
236
- Heffalump.all(:color => /ed/).should be_include(@red)
237
- end
238
-
239
- it 'should not be able to search for objects that do not match the value' do
240
- Heffalump.all(:color => /blak/).should_not be_include(@red)
241
- end
242
-
243
- it 'should be able to do a negated search for objects that match value' do
244
- Heffalump.all(:color.not => /blak/).should be_include(@red)
245
- end
246
-
247
- it 'should not be able to do a negated search for objects that do not match value' do
248
- Heffalump.all(:color.not => /ed/).should_not be_include(@red)
249
- end
250
-
251
- end
252
-
253
- describe 'gt' do
254
- it 'should be able to search for objects with value greater than' do
255
- Heffalump.all(:num_spots.gt => 1).should be_include(@two)
256
- end
257
-
258
- it 'should not find objects with a value less than' do
259
- Heffalump.all(:num_spots.gt => 3).should_not be_include(@two)
260
- end
261
- end
262
-
263
- describe 'gte' do
264
- it 'should be able to search for objects with value greater than' do
265
- Heffalump.all(:num_spots.gte => 1).should be_include(@two)
266
- end
267
-
268
- it 'should be able to search for objects with values equal to' do
269
- Heffalump.all(:num_spots.gte => 2).should be_include(@two)
270
- end
271
-
272
- it 'should not find objects with a value less than' do
273
- Heffalump.all(:num_spots.gte => 3).should_not be_include(@two)
274
- end
275
- end
276
-
277
- describe 'lt' do
278
- it 'should be able to search for objects with value less than' do
279
- Heffalump.all(:num_spots.lt => 3).should be_include(@two)
280
- end
281
-
282
- it 'should not find objects with a value less than' do
283
- Heffalump.all(:num_spots.gt => 2).should_not be_include(@two)
284
- end
285
- end
286
-
287
- describe 'lte' do
288
- it 'should be able to search for objects with value less than' do
289
- Heffalump.all(:num_spots.lte => 3).should be_include(@two)
290
- end
291
-
292
- it 'should be able to search for objects with values equal to' do
293
- Heffalump.all(:num_spots.lte => 2).should be_include(@two)
294
- end
295
-
296
- it 'should not find objects with a value less than' do
297
- Heffalump.all(:num_spots.lte => 1).should_not be_include(@two)
298
- end
299
- end
300
- end
301
-
302
- describe 'limits' do
303
- it 'should be able to limit the objects' do
304
- Heffalump.all(:limit => 2).length.should == 2
305
- end
306
- end
307
- end
308
- else
309
- it 'needs to support #read and #create to test query matching'
310
- end
311
- end