ditto 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ditto +1 -1
- data/features/create_entities.feature +1 -0
- data/features/load_entity.feature +1 -0
- data/features/store_entity.feature +5 -4
- data/lib/ditto.rb +1 -0
- data/lib/ditto/dsl.rb +14 -9
- data/lib/ditto/entity.rb +118 -106
- data/lib/ditto/error.rb +19 -0
- data/lib/ditto/options.rb +45 -13
- data/lib/ditto/runner.rb +37 -56
- data/lib/ditto/version.rb +1 -1
- data/spec/entity_spec.rb +83 -59
- data/spec/fixtures/badmap.ditto +18 -0
- data/spec/fixtures/badver.ditto +17 -0
- data/spec/fixtures/bigcircle.ditto +17 -0
- data/spec/fixtures/circle.ditto +16 -0
- data/spec/fixtures/continent.ditto +16 -0
- data/spec/fixtures/country.ditto +16 -0
- data/spec/fixtures/currency.ditto +30 -0
- data/spec/fixtures/currency_group.ditto +17 -0
- data/spec/fixtures/dot.ditto +17 -0
- data/spec/fixtures/dupversion.ditto +32 -0
- data/spec/fixtures/good.ditto +17 -0
- data/spec/fixtures/multiversion.ditto +32 -0
- data/spec/fixtures/nocomma.ditto +16 -0
- data/spec/fixtures/nomethod.ditto +18 -0
- data/spec/fixtures/random.ditto +17 -0
- data/spec/fixtures/syntax.ditto +19 -0
- data/spec/options_spec.rb +43 -25
- data/test/data/simple_object.xml +23 -0
- data/test/data/simple_object.yaml +39 -0
- data/test/ditto/currency.ditto +30 -0
- data/test/ditto/currency_group.ditto +17 -0
- data/test/dm/currency-1.0.0.dm +13 -0
- data/test/dm/currency_group-1.0.0.dm +10 -0
- data/test/dm/datamart-1.0 +7 -0
- data/test/dm/nested +2 -0
- data/test/dmtest.rb +41 -0
- data/test/sample.test +2 -0
- metadata +59 -42
- data/lib/ditto/map.rb +0 -39
data/test/dm/nested
ADDED
data/test/dmtest.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Test that Datamapper and the database things are working
|
2
|
+
#
|
3
|
+
require 'data_mapper'
|
4
|
+
|
5
|
+
load 'dm/currency-1.0.0.dm'
|
6
|
+
load 'dm/currency_group-1.0.0.dm'
|
7
|
+
|
8
|
+
DataMapper::Logger.new($stdout, :debug)
|
9
|
+
DataMapper.setup(:default, 'oracle://nick:secret@nixora.local/orcl')
|
10
|
+
DataMapper.finalize
|
11
|
+
|
12
|
+
DataMapper.auto_migrate!
|
13
|
+
|
14
|
+
americas = CurrencyGroup.create(
|
15
|
+
:code => 'Americas',
|
16
|
+
:description => 'The Americas',
|
17
|
+
:is_commodity => true
|
18
|
+
)
|
19
|
+
europe = CurrencyGroup.create(
|
20
|
+
:code => 'Europe',
|
21
|
+
:description => 'European Union',
|
22
|
+
:is_commodity => false
|
23
|
+
)
|
24
|
+
europe.currencies.create(
|
25
|
+
:code => 'GBP',
|
26
|
+
:description => 'Pounds Sterling',
|
27
|
+
:exchange_rate => 1.5,
|
28
|
+
:is_designated => false
|
29
|
+
)
|
30
|
+
europe.currencies.create(
|
31
|
+
:code => 'EUR',
|
32
|
+
:description => 'Euro',
|
33
|
+
:exchange_rate => 1.2,
|
34
|
+
:is_designated => false
|
35
|
+
)
|
36
|
+
americas.currencies.create(
|
37
|
+
:code => 'USD',
|
38
|
+
:description => 'Greenback',
|
39
|
+
:exchange_rate => 1.0,
|
40
|
+
:is_designated => true
|
41
|
+
)
|
data/test/sample.test
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ditto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,44 +43,9 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '2.11'
|
46
|
-
description: ! '
|
47
|
-
|
48
|
-
|
49
|
-
Ditto defines a simple DSL that allows test data to be expressed in a database independent
|
50
|
-
format.
|
51
|
-
|
52
|
-
When the underlying tables are remapped the QA team don''t have to go and change
|
53
|
-
all the historical test cases.
|
54
|
-
|
55
|
-
|
56
|
-
There are three parts, all of them versioned:
|
57
|
-
|
58
|
-
1. The data declarations
|
59
|
-
|
60
|
-
2. The mappings to the underlying database
|
61
|
-
|
62
|
-
3. The data itself
|
63
|
-
|
64
|
-
|
65
|
-
Idea is to replace an XML dialect with something simpler. See sample at simple_object.xml
|
66
|
-
|
67
|
-
|
68
|
-
Notes on DSL
|
69
|
-
|
70
|
-
------------
|
71
|
-
|
72
|
-
|
73
|
-
The entity declaration style uses verb and hash only, without a block.
|
74
|
-
|
75
|
-
Contrast this with mapping style which uses verb, params and then block. Of course
|
76
|
-
|
77
|
-
mappings need code and so the block usage is natural. This could also be done
|
78
|
-
|
79
|
-
for the declarations, very similar to the way the gem ''datamapper'' does it.
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
Nick Townsend, Oct 2012
|
46
|
+
description: ! 'Ditto defines a simple DSL that allows test data to be expressed in
|
47
|
+
a database independent format.When the underlying tables are remapped the QA team
|
48
|
+
don''t have to go and change all the historical test cases.
|
84
49
|
|
85
50
|
'
|
86
51
|
email: nick.townsend@mac.com
|
@@ -90,11 +55,11 @@ extensions: []
|
|
90
55
|
extra_rdoc_files: []
|
91
56
|
files:
|
92
57
|
- lib/ditto/dsl.rb
|
93
|
-
- lib/ditto/options.rb
|
94
58
|
- lib/ditto/entity.rb
|
95
|
-
- lib/ditto/
|
96
|
-
- lib/ditto/
|
59
|
+
- lib/ditto/error.rb
|
60
|
+
- lib/ditto/options.rb
|
97
61
|
- lib/ditto/runner.rb
|
62
|
+
- lib/ditto/version.rb
|
98
63
|
- lib/ditto.rb
|
99
64
|
- bin/ditto
|
100
65
|
- features/create_entities.feature
|
@@ -103,7 +68,33 @@ files:
|
|
103
68
|
- features/store_entity.feature
|
104
69
|
- features/support/hooks.rb
|
105
70
|
- spec/entity_spec.rb
|
71
|
+
- spec/fixtures/badmap.ditto
|
72
|
+
- spec/fixtures/badver.ditto
|
73
|
+
- spec/fixtures/bigcircle.ditto
|
74
|
+
- spec/fixtures/circle.ditto
|
75
|
+
- spec/fixtures/continent.ditto
|
76
|
+
- spec/fixtures/country.ditto
|
77
|
+
- spec/fixtures/currency.ditto
|
78
|
+
- spec/fixtures/currency_group.ditto
|
79
|
+
- spec/fixtures/dot.ditto
|
80
|
+
- spec/fixtures/dupversion.ditto
|
81
|
+
- spec/fixtures/good.ditto
|
82
|
+
- spec/fixtures/multiversion.ditto
|
83
|
+
- spec/fixtures/nocomma.ditto
|
84
|
+
- spec/fixtures/nomethod.ditto
|
85
|
+
- spec/fixtures/random.ditto
|
86
|
+
- spec/fixtures/syntax.ditto
|
106
87
|
- spec/options_spec.rb
|
88
|
+
- test/data/simple_object.xml
|
89
|
+
- test/data/simple_object.yaml
|
90
|
+
- test/ditto/currency.ditto
|
91
|
+
- test/ditto/currency_group.ditto
|
92
|
+
- test/dm/currency-1.0.0.dm
|
93
|
+
- test/dm/currency_group-1.0.0.dm
|
94
|
+
- test/dm/datamart-1.0
|
95
|
+
- test/dm/nested
|
96
|
+
- test/dmtest.rb
|
97
|
+
- test/sample.test
|
107
98
|
homepage: https://github.com/townsen/ditto
|
108
99
|
licenses: []
|
109
100
|
post_install_message:
|
@@ -135,4 +126,30 @@ test_files:
|
|
135
126
|
- features/store_entity.feature
|
136
127
|
- features/support/hooks.rb
|
137
128
|
- spec/entity_spec.rb
|
129
|
+
- spec/fixtures/badmap.ditto
|
130
|
+
- spec/fixtures/badver.ditto
|
131
|
+
- spec/fixtures/bigcircle.ditto
|
132
|
+
- spec/fixtures/circle.ditto
|
133
|
+
- spec/fixtures/continent.ditto
|
134
|
+
- spec/fixtures/country.ditto
|
135
|
+
- spec/fixtures/currency.ditto
|
136
|
+
- spec/fixtures/currency_group.ditto
|
137
|
+
- spec/fixtures/dot.ditto
|
138
|
+
- spec/fixtures/dupversion.ditto
|
139
|
+
- spec/fixtures/good.ditto
|
140
|
+
- spec/fixtures/multiversion.ditto
|
141
|
+
- spec/fixtures/nocomma.ditto
|
142
|
+
- spec/fixtures/nomethod.ditto
|
143
|
+
- spec/fixtures/random.ditto
|
144
|
+
- spec/fixtures/syntax.ditto
|
138
145
|
- spec/options_spec.rb
|
146
|
+
- test/data/simple_object.xml
|
147
|
+
- test/data/simple_object.yaml
|
148
|
+
- test/ditto/currency.ditto
|
149
|
+
- test/ditto/currency_group.ditto
|
150
|
+
- test/dm/currency-1.0.0.dm
|
151
|
+
- test/dm/currency_group-1.0.0.dm
|
152
|
+
- test/dm/datamart-1.0
|
153
|
+
- test/dm/nested
|
154
|
+
- test/dmtest.rb
|
155
|
+
- test/sample.test
|
data/lib/ditto/map.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# Mapping support for Ditto
|
2
|
-
#
|
3
|
-
require 'ostruct'
|
4
|
-
require 'data_mapper'
|
5
|
-
|
6
|
-
module Ditto
|
7
|
-
module Map
|
8
|
-
@maps = {}
|
9
|
-
|
10
|
-
def self.add name, opts, &block
|
11
|
-
@maps[name] = block
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.check_maps seq, definitions
|
15
|
-
nerr = 0
|
16
|
-
seq.each do |entity|
|
17
|
-
unless @maps.has_key? entity
|
18
|
-
nerr += 1
|
19
|
-
Ditto::Entity.error("no mapping", entity, definitions[entity])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
return nerr
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.add_all seq, data
|
26
|
-
ninst = 0
|
27
|
-
seq.each do |entity|
|
28
|
-
instances = data[entity]
|
29
|
-
instances.each do |ihash|
|
30
|
-
puts "adding #{entity} #{ihash.inspect}" if Ditto::Options.instance.verbose > 1
|
31
|
-
instance = OpenStruct.new ihash
|
32
|
-
@maps[entity].call instance
|
33
|
-
ninst += 1
|
34
|
-
end
|
35
|
-
end
|
36
|
-
return ninst
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|