fruit_to_lime 0.8.2 → 0.9.0
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/bin/fruit_to_lime +24 -24
- data/lib/fruit_to_lime/address_helper.rb +17 -17
- data/lib/fruit_to_lime/csv_helper.rb +32 -32
- data/lib/fruit_to_lime/model/address.rb +37 -37
- data/lib/fruit_to_lime/model/coworker.rb +44 -0
- data/lib/fruit_to_lime/model/coworker_reference.rb +17 -14
- data/lib/fruit_to_lime/model/customfield.rb +30 -29
- data/lib/fruit_to_lime/model/deal.rb +49 -0
- data/lib/fruit_to_lime/model/note.rb +38 -27
- data/lib/fruit_to_lime/model/organization.rb +140 -121
- data/lib/fruit_to_lime/model/person.rb +115 -111
- data/lib/fruit_to_lime/model/referencetosource.rb +42 -42
- data/lib/fruit_to_lime/model/rootmodel.rb +142 -39
- data/lib/fruit_to_lime/model/tag.rb +33 -28
- data/lib/fruit_to_lime/model_helpers.rb +19 -0
- data/lib/fruit_to_lime/roo_helper.rb +59 -54
- data/lib/fruit_to_lime/serialize_helper.rb +139 -139
- data/lib/fruit_to_lime/templating.rb +51 -51
- data/lib/fruit_to_lime.rb +13 -12
- data/spec/helpers/address_helper_spec.rb +48 -48
- data/spec/helpers/csv_helper_spec.rb +15 -15
- data/spec/helpers/roo_helper_spec.rb +10 -10
- data/spec/helpers/serialize_helper_spec.rb +211 -211
- data/spec/person_spec.rb +44 -44
- data/spec/spec_helper.rb +24 -24
- data/spec/templating_spec.rb +40 -40
- data/templates/csv/Gemfile +5 -5
- data/templates/csv/Rakefile.rb +7 -7
- data/templates/csv/convert.rb +2 -2
- data/templates/csv/lib/tomodel.rb +56 -42
- data/templates/csv/spec/sample_data/organizations.csv +2 -2
- data/templates/csv/spec/spec_helper.rb +24 -24
- data/templates/csv/spec/tomodel_spec.rb +14 -14
- data/templates/excel/Gemfile +6 -6
- data/templates/excel/Rakefile.rb +7 -7
- data/templates/excel/convert.rb +2 -2
- data/templates/excel/lib/tomodel.rb +53 -39
- data/templates/excel/spec/spec_helper.rb +20 -20
- data/templates/excel/spec/tomodel_spec.rb +18 -18
- data/templates/sqlserver/Gemfile +6 -6
- data/templates/sqlserver/Rakefile.rb +7 -7
- data/templates/sqlserver/convert.rb +2 -2
- data/templates/sqlserver/lib/tomodel.rb +67 -53
- data/templates/sqlserver/spec/spec_helper.rb +20 -20
- data/templates/sqlserver/spec/tomodel_spec.rb +9 -9
- metadata +23 -4
@@ -1,211 +1,211 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fruit_to_lime'
|
3
|
-
|
4
|
-
describe FruitToLime::SerializeHelper do
|
5
|
-
|
6
|
-
describe "Serialize note" do
|
7
|
-
let(:serialized) {
|
8
|
-
n = FruitToLime::Note.new
|
9
|
-
n.text = "text"
|
10
|
-
FruitToLime::SerializeHelper::serialize(n)
|
11
|
-
}
|
12
|
-
it "should contain text" do
|
13
|
-
serialized.should match(/<Text>text<\/Text>/)
|
14
|
-
end
|
15
|
-
it "should contain start tag" do
|
16
|
-
serialized.should match(/<Note>/)
|
17
|
-
end
|
18
|
-
it "should be utf-8" do
|
19
|
-
serialized.encoding.should equal Encoding::UTF_8
|
20
|
-
end
|
21
|
-
end
|
22
|
-
describe "Serialize without data" do
|
23
|
-
let(:serialized) {
|
24
|
-
p = FruitToLime::Person.new
|
25
|
-
FruitToLime::SerializeHelper::serialize(p)
|
26
|
-
}
|
27
|
-
it "should not contain fields that are not set" do
|
28
|
-
#puts serialized
|
29
|
-
serialized.should_not match(/<Email>/)
|
30
|
-
serialized.should_not match(/<Position>/)
|
31
|
-
serialized.should_not match(/<AlternativeEmail>/)
|
32
|
-
serialized.should_not match(/<Tags>/)
|
33
|
-
serialized.should_not match(/<CustomFields>/)
|
34
|
-
end
|
35
|
-
it "should be utf-8" do
|
36
|
-
serialized.encoding.should equal Encoding::UTF_8
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "Serialize person" do
|
41
|
-
let(:serialized) {
|
42
|
-
p = FruitToLime::Person.new
|
43
|
-
p.id = "1"
|
44
|
-
p.first_name = "Kalle"
|
45
|
-
p.last_name = "Anka"
|
46
|
-
p.with_source do |source|
|
47
|
-
source.par_se('122345')
|
48
|
-
end
|
49
|
-
#p.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
50
|
-
p.with_postal_address do |addr|
|
51
|
-
addr.city = "Ankeborg"
|
52
|
-
end
|
53
|
-
p.add_tag("tag:anka")
|
54
|
-
p.add_tag("tag:Bj\u{00F6}rk")
|
55
|
-
p.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
|
56
|
-
p.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
|
57
|
-
FruitToLime::SerializeHelper::serialize(p)
|
58
|
-
}
|
59
|
-
it "should contain first and last name" do
|
60
|
-
serialized.should match(/<FirstName>Kalle<\/FirstName>/)
|
61
|
-
serialized.should match(/Anka/)
|
62
|
-
end
|
63
|
-
it "should tag name" do
|
64
|
-
serialized.should match(/tag:anka/)
|
65
|
-
end
|
66
|
-
it "should contain address" do
|
67
|
-
serialized.should match(/Ankeborg/)
|
68
|
-
end
|
69
|
-
it "should contain custom field" do
|
70
|
-
serialized.should match(/cf title/)
|
71
|
-
serialized.should match(/cf value/)
|
72
|
-
end
|
73
|
-
it "should contain reference to source" do
|
74
|
-
serialized.should match(/122345/)
|
75
|
-
end
|
76
|
-
it "should handle sv chars in tags" do
|
77
|
-
serialized.should match(/tag:Bj\u{00F6}rk/)
|
78
|
-
end
|
79
|
-
it "should handle sv chars in custom value" do
|
80
|
-
serialized.should match(/cf Bj\u{00F6}rk/)
|
81
|
-
end
|
82
|
-
it "should be utf-8" do
|
83
|
-
serialized.encoding.should equal Encoding::UTF_8
|
84
|
-
end
|
85
|
-
end
|
86
|
-
describe "Serialize organization" do
|
87
|
-
let(:serialized) {
|
88
|
-
o = FruitToLime::Organization.new
|
89
|
-
o.name = "Ankeborgs bibliotek"
|
90
|
-
o.with_source do |source|
|
91
|
-
source.par_se('122345')
|
92
|
-
end
|
93
|
-
#o.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
94
|
-
o.add_tag("tag:bibliotek")
|
95
|
-
o.add_tag("tag:Bj\u{00F6}rk")
|
96
|
-
o.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
|
97
|
-
o.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
|
98
|
-
o.with_postal_address do |addr|
|
99
|
-
addr.city = "Ankeborg"
|
100
|
-
end
|
101
|
-
o.with_visit_address do |addr|
|
102
|
-
addr.city = "Gaaseborg"
|
103
|
-
end
|
104
|
-
o.add_employee({
|
105
|
-
:id => "1",
|
106
|
-
:first_name => "Kalle",
|
107
|
-
:last_name => "Anka"
|
108
|
-
})
|
109
|
-
FruitToLime::SerializeHelper::serialize(o)
|
110
|
-
}
|
111
|
-
it "should contain name" do
|
112
|
-
serialized.should match(/Ankeborgs bibliotek/)
|
113
|
-
end
|
114
|
-
it "should contain employee" do
|
115
|
-
serialized.should match(/Kalle/)
|
116
|
-
serialized.should match(/Anka/)
|
117
|
-
end
|
118
|
-
it "should contain address" do
|
119
|
-
serialized.should match(/Ankeborg/)
|
120
|
-
serialized.should match(/Gaaseborg/)
|
121
|
-
end
|
122
|
-
it "should tag name" do
|
123
|
-
serialized.should match(/<Tag>tag:bibliotek<\/Tag>/)
|
124
|
-
end
|
125
|
-
it "should contain custom field" do
|
126
|
-
serialized.should match(/cf title/)
|
127
|
-
serialized.should match(/cf value/)
|
128
|
-
#puts serialized
|
129
|
-
end
|
130
|
-
it "should contain reference to source" do
|
131
|
-
serialized.should match(/122345/)
|
132
|
-
end
|
133
|
-
it "should handle sv chars in tags" do
|
134
|
-
serialized.should match(/tag:Bj\u{00F6}rk/)
|
135
|
-
end
|
136
|
-
it "should handle sv chars in custom value" do
|
137
|
-
serialized.should match(/cf Bj\u{00F6}rk/)
|
138
|
-
end
|
139
|
-
it "should be utf-8" do
|
140
|
-
serialized.encoding.should equal Encoding::UTF_8
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe "Serialize goimport" do
|
145
|
-
let(:serialized) {
|
146
|
-
i = FruitToLime::RootModel.new
|
147
|
-
o = FruitToLime::Organization.new
|
148
|
-
o.name = "Ankeborgs bibliotek"
|
149
|
-
i.organizations.push(o)
|
150
|
-
FruitToLime::SerializeHelper::serialize(i)
|
151
|
-
}
|
152
|
-
it "should contain name" do
|
153
|
-
serialized.should match(/Ankeborgs bibliotek/)
|
154
|
-
end
|
155
|
-
it "should be utf-8" do
|
156
|
-
serialized.encoding.should equal Encoding::UTF_8
|
157
|
-
end
|
158
|
-
end
|
159
|
-
describe "Get import rows" do
|
160
|
-
describe "for person" do
|
161
|
-
let(:import_rows) { FruitToLime::Person.new.get_import_rows }
|
162
|
-
it "should contain integration id" do
|
163
|
-
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
164
|
-
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
165
|
-
end
|
166
|
-
it "should contain address" do
|
167
|
-
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
168
|
-
:model=>[
|
169
|
-
{:id=>'street',:name=>'Street', :type=>:string},
|
170
|
-
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
171
|
-
{:id=>'city',:name=>'City', :type=>:string},
|
172
|
-
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
173
|
-
{:id=>'location',:name=>'Location', :type=>:string},
|
174
|
-
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
175
|
-
]}
|
176
|
-
import_rows.should include(expected)
|
177
|
-
end
|
178
|
-
it "should contain organization" do
|
179
|
-
import_rows.should include({
|
180
|
-
:id=>'organization',
|
181
|
-
:name=>'Organization',
|
182
|
-
:type=>:organization_reference,
|
183
|
-
:model=>[
|
184
|
-
{:id=>'id', :name=>'Go id', :type=>:string},
|
185
|
-
{:id=>'integration_id', :name=>'Integration id', :type=>:string},
|
186
|
-
{:id=>'
|
187
|
-
]
|
188
|
-
})
|
189
|
-
end
|
190
|
-
end
|
191
|
-
describe "for organization" do
|
192
|
-
let(:import_rows) { FruitToLime::Organization.new.get_import_rows }
|
193
|
-
it "should contain integration id" do
|
194
|
-
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
195
|
-
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
196
|
-
end
|
197
|
-
it "should contain address" do
|
198
|
-
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
199
|
-
:model=>[
|
200
|
-
{:id=>'street',:name=>'Street', :type=>:string},
|
201
|
-
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
202
|
-
{:id=>'city',:name=>'City', :type=>:string},
|
203
|
-
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
204
|
-
{:id=>'location',:name=>'Location', :type=>:string},
|
205
|
-
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
206
|
-
]}
|
207
|
-
import_rows.should include(expected)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe FruitToLime::SerializeHelper do
|
5
|
+
|
6
|
+
describe "Serialize note" do
|
7
|
+
let(:serialized) {
|
8
|
+
n = FruitToLime::Note.new
|
9
|
+
n.text = "text"
|
10
|
+
FruitToLime::SerializeHelper::serialize(n)
|
11
|
+
}
|
12
|
+
it "should contain text" do
|
13
|
+
serialized.should match(/<Text>text<\/Text>/)
|
14
|
+
end
|
15
|
+
it "should contain start tag" do
|
16
|
+
serialized.should match(/<Note>/)
|
17
|
+
end
|
18
|
+
it "should be utf-8" do
|
19
|
+
serialized.encoding.should equal Encoding::UTF_8
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe "Serialize without data" do
|
23
|
+
let(:serialized) {
|
24
|
+
p = FruitToLime::Person.new
|
25
|
+
FruitToLime::SerializeHelper::serialize(p)
|
26
|
+
}
|
27
|
+
it "should not contain fields that are not set" do
|
28
|
+
#puts serialized
|
29
|
+
serialized.should_not match(/<Email>/)
|
30
|
+
serialized.should_not match(/<Position>/)
|
31
|
+
serialized.should_not match(/<AlternativeEmail>/)
|
32
|
+
serialized.should_not match(/<Tags>/)
|
33
|
+
serialized.should_not match(/<CustomFields>/)
|
34
|
+
end
|
35
|
+
it "should be utf-8" do
|
36
|
+
serialized.encoding.should equal Encoding::UTF_8
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "Serialize person" do
|
41
|
+
let(:serialized) {
|
42
|
+
p = FruitToLime::Person.new
|
43
|
+
p.id = "1"
|
44
|
+
p.first_name = "Kalle"
|
45
|
+
p.last_name = "Anka"
|
46
|
+
p.with_source do |source|
|
47
|
+
source.par_se('122345')
|
48
|
+
end
|
49
|
+
#p.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
50
|
+
p.with_postal_address do |addr|
|
51
|
+
addr.city = "Ankeborg"
|
52
|
+
end
|
53
|
+
p.add_tag("tag:anka")
|
54
|
+
p.add_tag("tag:Bj\u{00F6}rk")
|
55
|
+
p.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
|
56
|
+
p.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
|
57
|
+
FruitToLime::SerializeHelper::serialize(p)
|
58
|
+
}
|
59
|
+
it "should contain first and last name" do
|
60
|
+
serialized.should match(/<FirstName>Kalle<\/FirstName>/)
|
61
|
+
serialized.should match(/Anka/)
|
62
|
+
end
|
63
|
+
it "should tag name" do
|
64
|
+
serialized.should match(/tag:anka/)
|
65
|
+
end
|
66
|
+
it "should contain address" do
|
67
|
+
serialized.should match(/Ankeborg/)
|
68
|
+
end
|
69
|
+
it "should contain custom field" do
|
70
|
+
serialized.should match(/cf title/)
|
71
|
+
serialized.should match(/cf value/)
|
72
|
+
end
|
73
|
+
it "should contain reference to source" do
|
74
|
+
serialized.should match(/122345/)
|
75
|
+
end
|
76
|
+
it "should handle sv chars in tags" do
|
77
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
78
|
+
end
|
79
|
+
it "should handle sv chars in custom value" do
|
80
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
81
|
+
end
|
82
|
+
it "should be utf-8" do
|
83
|
+
serialized.encoding.should equal Encoding::UTF_8
|
84
|
+
end
|
85
|
+
end
|
86
|
+
describe "Serialize organization" do
|
87
|
+
let(:serialized) {
|
88
|
+
o = FruitToLime::Organization.new
|
89
|
+
o.name = "Ankeborgs bibliotek"
|
90
|
+
o.with_source do |source|
|
91
|
+
source.par_se('122345')
|
92
|
+
end
|
93
|
+
#o.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
94
|
+
o.add_tag("tag:bibliotek")
|
95
|
+
o.add_tag("tag:Bj\u{00F6}rk")
|
96
|
+
o.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
|
97
|
+
o.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
|
98
|
+
o.with_postal_address do |addr|
|
99
|
+
addr.city = "Ankeborg"
|
100
|
+
end
|
101
|
+
o.with_visit_address do |addr|
|
102
|
+
addr.city = "Gaaseborg"
|
103
|
+
end
|
104
|
+
o.add_employee({
|
105
|
+
:id => "1",
|
106
|
+
:first_name => "Kalle",
|
107
|
+
:last_name => "Anka"
|
108
|
+
})
|
109
|
+
FruitToLime::SerializeHelper::serialize(o)
|
110
|
+
}
|
111
|
+
it "should contain name" do
|
112
|
+
serialized.should match(/Ankeborgs bibliotek/)
|
113
|
+
end
|
114
|
+
it "should contain employee" do
|
115
|
+
serialized.should match(/Kalle/)
|
116
|
+
serialized.should match(/Anka/)
|
117
|
+
end
|
118
|
+
it "should contain address" do
|
119
|
+
serialized.should match(/Ankeborg/)
|
120
|
+
serialized.should match(/Gaaseborg/)
|
121
|
+
end
|
122
|
+
it "should tag name" do
|
123
|
+
serialized.should match(/<Tag>tag:bibliotek<\/Tag>/)
|
124
|
+
end
|
125
|
+
it "should contain custom field" do
|
126
|
+
serialized.should match(/cf title/)
|
127
|
+
serialized.should match(/cf value/)
|
128
|
+
#puts serialized
|
129
|
+
end
|
130
|
+
it "should contain reference to source" do
|
131
|
+
serialized.should match(/122345/)
|
132
|
+
end
|
133
|
+
it "should handle sv chars in tags" do
|
134
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
135
|
+
end
|
136
|
+
it "should handle sv chars in custom value" do
|
137
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
138
|
+
end
|
139
|
+
it "should be utf-8" do
|
140
|
+
serialized.encoding.should equal Encoding::UTF_8
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "Serialize goimport" do
|
145
|
+
let(:serialized) {
|
146
|
+
i = FruitToLime::RootModel.new
|
147
|
+
o = FruitToLime::Organization.new
|
148
|
+
o.name = "Ankeborgs bibliotek"
|
149
|
+
i.organizations.push(o)
|
150
|
+
FruitToLime::SerializeHelper::serialize(i)
|
151
|
+
}
|
152
|
+
it "should contain name" do
|
153
|
+
serialized.should match(/Ankeborgs bibliotek/)
|
154
|
+
end
|
155
|
+
it "should be utf-8" do
|
156
|
+
serialized.encoding.should equal Encoding::UTF_8
|
157
|
+
end
|
158
|
+
end
|
159
|
+
describe "Get import rows" do
|
160
|
+
describe "for person" do
|
161
|
+
let(:import_rows) { FruitToLime::Person.new.get_import_rows }
|
162
|
+
it "should contain integration id" do
|
163
|
+
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
164
|
+
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
165
|
+
end
|
166
|
+
it "should contain address" do
|
167
|
+
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
168
|
+
:model=>[
|
169
|
+
{:id=>'street',:name=>'Street', :type=>:string},
|
170
|
+
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
171
|
+
{:id=>'city',:name=>'City', :type=>:string},
|
172
|
+
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
173
|
+
{:id=>'location',:name=>'Location', :type=>:string},
|
174
|
+
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
175
|
+
]}
|
176
|
+
import_rows.should include(expected)
|
177
|
+
end
|
178
|
+
it "should contain organization" do
|
179
|
+
import_rows.should include({
|
180
|
+
:id=>'organization',
|
181
|
+
:name=>'Organization',
|
182
|
+
:type=>:organization_reference,
|
183
|
+
:model=>[
|
184
|
+
{:id=>'id', :name=>'Go id', :type=>:string},
|
185
|
+
{:id=>'integration_id', :name=>'Integration id', :type=>:string},
|
186
|
+
{:id=>'heading', :name=>'Heading', :type=>:string}
|
187
|
+
]
|
188
|
+
})
|
189
|
+
end
|
190
|
+
end
|
191
|
+
describe "for organization" do
|
192
|
+
let(:import_rows) { FruitToLime::Organization.new.get_import_rows }
|
193
|
+
it "should contain integration id" do
|
194
|
+
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
195
|
+
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
196
|
+
end
|
197
|
+
it "should contain address" do
|
198
|
+
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
199
|
+
:model=>[
|
200
|
+
{:id=>'street',:name=>'Street', :type=>:string},
|
201
|
+
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
202
|
+
{:id=>'city',:name=>'City', :type=>:string},
|
203
|
+
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
204
|
+
{:id=>'location',:name=>'Location', :type=>:string},
|
205
|
+
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
206
|
+
]}
|
207
|
+
import_rows.should include(expected)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
data/spec/person_spec.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require 'fruit_to_lime'
|
3
|
-
|
4
|
-
describe "Person" do
|
5
|
-
before (:all) do
|
6
|
-
@person = FruitToLime::Person.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "can set a customfield" do
|
10
|
-
@person.set_custom_field({:integration_id=>'the key',
|
11
|
-
:title=> 'the title',
|
12
|
-
:value=> 'the value'})
|
13
|
-
|
14
|
-
field = @person.custom_fields[0]
|
15
|
-
field.integration_id.should eq 'the key'
|
16
|
-
field.title.should eq 'the title'
|
17
|
-
field.value.should eq 'the value'
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should have a firstname if no lastname" do
|
21
|
-
@person.first_name = "Vincent"
|
22
|
-
@person.last_name = nil
|
23
|
-
|
24
|
-
error = @person.validate
|
25
|
-
error.should be_empty
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should have a lastname if no firstname" do
|
29
|
-
@person.first_name = String.new
|
30
|
-
@person.last_name = "Vega"
|
31
|
-
|
32
|
-
error = @person.validate
|
33
|
-
error.should be_empty
|
34
|
-
end
|
35
|
-
|
36
|
-
it "shouldnt pass validation with no firstname and lastname" do
|
37
|
-
@person.first_name = String.new
|
38
|
-
@person.last_name = nil
|
39
|
-
|
40
|
-
error = @person.validate
|
41
|
-
error.should start_with("A firstname or lastname is required for person")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
1
|
+
require "spec_helper"
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe "Person" do
|
5
|
+
before (:all) do
|
6
|
+
@person = FruitToLime::Person.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can set a customfield" do
|
10
|
+
@person.set_custom_field({:integration_id=>'the key',
|
11
|
+
:title=> 'the title',
|
12
|
+
:value=> 'the value'})
|
13
|
+
|
14
|
+
field = @person.custom_fields[0]
|
15
|
+
field.integration_id.should eq 'the key'
|
16
|
+
field.title.should eq 'the title'
|
17
|
+
field.value.should eq 'the value'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have a firstname if no lastname" do
|
21
|
+
@person.first_name = "Vincent"
|
22
|
+
@person.last_name = nil
|
23
|
+
|
24
|
+
error = @person.validate
|
25
|
+
error.should be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a lastname if no firstname" do
|
29
|
+
@person.first_name = String.new
|
30
|
+
@person.last_name = "Vega"
|
31
|
+
|
32
|
+
error = @person.validate
|
33
|
+
error.should be_empty
|
34
|
+
end
|
35
|
+
|
36
|
+
it "shouldnt pass validation with no firstname and lastname" do
|
37
|
+
@person.first_name = String.new
|
38
|
+
@person.last_name = nil
|
39
|
+
|
40
|
+
error = @person.validate
|
41
|
+
error.should start_with("A firstname or lastname is required for person")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
#require File.expand_path("../../config/environment", __FILE__)
|
3
|
-
require 'rspec/autorun'
|
4
|
-
|
5
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
6
|
-
# in spec/support/ and its subdirectories.
|
7
|
-
Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
# ## Mock Framework
|
11
|
-
#
|
12
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
13
|
-
#
|
14
|
-
# config.mock_with :mocha
|
15
|
-
# config.mock_with :flexmock
|
16
|
-
# config.mock_with :rr
|
17
|
-
|
18
|
-
# Run specs in random order to surface order dependencies. If you find an
|
19
|
-
# order dependency and want to debug it, you can fix the order by providing
|
20
|
-
# the seed, which is printed after each run.
|
21
|
-
# --seed 1234
|
22
|
-
config.order = "random"
|
23
|
-
end
|
24
|
-
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
#require File.expand_path("../../config/environment", __FILE__)
|
3
|
+
require 'rspec/autorun'
|
4
|
+
|
5
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
6
|
+
# in spec/support/ and its subdirectories.
|
7
|
+
Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
# ## Mock Framework
|
11
|
+
#
|
12
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
13
|
+
#
|
14
|
+
# config.mock_with :mocha
|
15
|
+
# config.mock_with :flexmock
|
16
|
+
# config.mock_with :rr
|
17
|
+
|
18
|
+
# Run specs in random order to surface order dependencies. If you find an
|
19
|
+
# order dependency and want to debug it, you can fix the order by providing
|
20
|
+
# the seed, which is printed after each run.
|
21
|
+
# --seed 1234
|
22
|
+
config.order = "random"
|
23
|
+
end
|
24
|
+
|
data/spec/templating_spec.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'tmpdir'
|
3
|
-
|
4
|
-
def execute_command_with_success(cmd)
|
5
|
-
system(cmd)
|
6
|
-
if ! $?.success?
|
7
|
-
puts "Failed with #{$?}"
|
8
|
-
raise "failed! #{cmd}"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'Templating' do
|
13
|
-
let(:templating) { FruitToLime::Templating.new(File.expand_path("../templates", File.dirname(__FILE__))) }
|
14
|
-
|
15
|
-
describe 'list' do
|
16
|
-
it 'can find some templates' do
|
17
|
-
templating.list().length.should > 0
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'unpack' do
|
22
|
-
unpack_path = File.expand_path("unpacked", Dir.tmpdir)
|
23
|
-
before {
|
24
|
-
FileUtils.remove_dir(unpack_path, true)
|
25
|
-
FileUtils.mkdir(unpack_path)
|
26
|
-
}
|
27
|
-
|
28
|
-
it 'can unpack all templates and run the template tests' do
|
29
|
-
templating.list().each {|t|
|
30
|
-
templating.unpack t, unpack_path
|
31
|
-
Dir.chdir(File.expand_path(t, unpack_path)) do
|
32
|
-
execute_command_with_success('rake spec')
|
33
|
-
end
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
after {
|
38
|
-
FileUtils.remove_dir(unpack_path, true)
|
39
|
-
}
|
40
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
def execute_command_with_success(cmd)
|
5
|
+
system(cmd)
|
6
|
+
if ! $?.success?
|
7
|
+
puts "Failed with #{$?}"
|
8
|
+
raise "failed! #{cmd}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'Templating' do
|
13
|
+
let(:templating) { FruitToLime::Templating.new(File.expand_path("../templates", File.dirname(__FILE__))) }
|
14
|
+
|
15
|
+
describe 'list' do
|
16
|
+
it 'can find some templates' do
|
17
|
+
templating.list().length.should > 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'unpack' do
|
22
|
+
unpack_path = File.expand_path("unpacked", Dir.tmpdir)
|
23
|
+
before {
|
24
|
+
FileUtils.remove_dir(unpack_path, true)
|
25
|
+
FileUtils.mkdir(unpack_path)
|
26
|
+
}
|
27
|
+
|
28
|
+
it 'can unpack all templates and run the template tests' do
|
29
|
+
templating.list().each {|t|
|
30
|
+
templating.unpack t, unpack_path
|
31
|
+
Dir.chdir(File.expand_path(t, unpack_path)) do
|
32
|
+
execute_command_with_success('rake spec')
|
33
|
+
end
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
after {
|
38
|
+
FileUtils.remove_dir(unpack_path, true)
|
39
|
+
}
|
40
|
+
end
|
41
41
|
end
|
data/templates/csv/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
gem 'thor'
|
4
|
-
gem 'fruit_to_lime'
|
5
|
-
gem 'rspec'
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'thor'
|
4
|
+
gem 'fruit_to_lime'
|
5
|
+
gem 'rspec'
|