fluiddb 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/FluidDb.rb +2 -2
  2. data/lib/FluidDb/Mock.rb +54 -0
  3. metadata +3 -2
data/lib/FluidDb.rb CHANGED
@@ -49,10 +49,10 @@ module FluidDb
49
49
  elsif v.is_a?(Numeric) then
50
50
  sql = sql.sub( "?", v.to_s )
51
51
  else
52
- raise FluidDb_ParamTypeNotSupportedError.new
52
+ raise ParamTypeNotSupportedError.new( "Name of unknown param type, #{v.class.name}, for sql, #{sql}" )
53
53
  end
54
54
  end
55
-
55
+
56
56
  return sql
57
57
  end
58
58
 
@@ -0,0 +1,54 @@
1
+ require "FluidDb"
2
+
3
+ module FluidDb
4
+
5
+ #A constant way of enabling testing for FluidDb
6
+ class Mock<Base
7
+
8
+ def initialize
9
+ @hash = Hash.new
10
+ end
11
+
12
+ def connect()
13
+ end
14
+
15
+ def close
16
+ end
17
+
18
+ def queryForArray( sql, params )
19
+ sql = self.format_to_sql( sql, params )
20
+ return @hash[sql]
21
+ end
22
+
23
+ def queryForValue( sql, params )
24
+ sql = self.format_to_sql( sql, params )
25
+ return @hash[sql]
26
+ end
27
+
28
+ def queryForResultset( sql, params )
29
+ sql = self.format_to_sql( sql, params )
30
+ return @hash[sql]
31
+ end
32
+
33
+ def execute( sql, params, expected_affected_rows=nil )
34
+ sql = self.format_to_sql( sql, params )
35
+ return @hash[sql]
36
+ end
37
+
38
+ def insert( sql, params )
39
+ raise "Pgsql uses SEQUENCES, so possibly easier to use 2 executes"
40
+ end
41
+
42
+ def addSql( sql, result )
43
+ @hash[sql] = result;
44
+ end
45
+
46
+ def addSqlWithParams( sql, params, result )
47
+ sql = self.format_to_sql( sql, params )
48
+
49
+ self.addSql( sql, result )
50
+ end
51
+
52
+ end
53
+
54
+ end
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.0.8
4
+ version: 0.0.9
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: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A semantic layer for db interaction
15
15
  email: guy@guyirvine.com
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - lib/FluidDb/Mock.rb
20
21
  - lib/FluidDb/Mysql.rb
21
22
  - lib/FluidDb/Mysql2.rb
22
23
  - lib/FluidDb/Pgsql.rb