fluiddb 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/FluidDb/Mock.rb +12 -4
- metadata +2 -2
data/lib/FluidDb/Mock.rb
CHANGED
@@ -2,6 +2,10 @@ require "FluidDb"
|
|
2
2
|
|
3
3
|
module FluidDb
|
4
4
|
|
5
|
+
class SqlNotMatchedError<StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
|
5
9
|
#A constant way of enabling testing for FluidDb
|
6
10
|
class Mock<Base
|
7
11
|
attr_reader :hash
|
@@ -23,12 +27,16 @@ module FluidDb
|
|
23
27
|
|
24
28
|
def close
|
25
29
|
end
|
30
|
+
|
31
|
+
def getSqlFromHash( sql )
|
32
|
+
raise SqlNotMatchedError.new( sql ) unless @hash.has_key?( sql )
|
33
|
+
end
|
26
34
|
|
27
35
|
def queryForArray( sql, params=[] )
|
28
36
|
sql = self.format_to_sql( sql, params )
|
29
37
|
puts "FluidDb::Mock.queryForArray. sql: #{sql}" if @verbose == true
|
30
38
|
|
31
|
-
results =
|
39
|
+
results = self.getSqlFromHash( sql )
|
32
40
|
case results.length
|
33
41
|
when 0
|
34
42
|
raise FluidDb::NoDataFoundError.new
|
@@ -45,7 +53,7 @@ module FluidDb
|
|
45
53
|
sql = self.format_to_sql( sql, params )
|
46
54
|
puts "FluidDb::Mock.queryForValue. sql: #{sql}" if @verbose == true
|
47
55
|
|
48
|
-
results =
|
56
|
+
results = self.getSqlFromHash( sql )
|
49
57
|
case results.length
|
50
58
|
when 0
|
51
59
|
raise FluidDb::NoDataFoundError.new
|
@@ -60,13 +68,13 @@ module FluidDb
|
|
60
68
|
def queryForResultset( sql, params=[] )
|
61
69
|
sql = self.format_to_sql( sql, params )
|
62
70
|
puts "FluidDb::Mock.queryForResultset. sql: #{sql}" if @verbose == true
|
63
|
-
return
|
71
|
+
return self.getSqlFromHash( sql )
|
64
72
|
end
|
65
73
|
|
66
74
|
def execute( sql, params=[], expected_affected_rows=nil )
|
67
75
|
sql = self.format_to_sql( sql, params )
|
68
76
|
puts "FluidDb::Mock.execute. sql: #{sql}" if @verbose == true
|
69
|
-
return
|
77
|
+
return self.getSqlFromHash( sql )
|
70
78
|
end
|
71
79
|
|
72
80
|
def insert( sql, params )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluiddb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A semantic layer for db interaction
|
15
15
|
email: guy@guyirvine.com
|