fruit_to_lime 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,13 @@ module FruitToLime
4
4
  attr_accessor :id, :integration_id, :first_name, :last_name, :email, :direct_phone_number,
5
5
  :mobile_phone_number, :home_phone_number
6
6
 
7
- def initialize()
7
+ def initialize(opt = nil)
8
+ if opt != nil
9
+ serialize_variables.each do |myattr|
10
+ val = opt[myattr[:id]]
11
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
12
+ end
13
+ end
8
14
  end
9
15
 
10
16
  def serialize_variables
@@ -3,7 +3,13 @@ module FruitToLime
3
3
  include SerializeHelper
4
4
  attr_accessor :id, :heading, :integration_id
5
5
 
6
- def initialize()
6
+ def initialize(opt = nil)
7
+ if opt != nil
8
+ serialize_variables.each do |myattr|
9
+ val = opt[myattr[:id]]
10
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
11
+ end
12
+ end
7
13
  end
8
14
 
9
15
  def serialize_variables
@@ -1,6 +1,6 @@
1
1
  module FruitToLime
2
2
  class CustomField
3
- include SerializeHelper
3
+ include SerializeHelper, ModelWithIntegrationIdSameAs
4
4
 
5
5
  attr_accessor :id, :integration_id, :title, :value
6
6
 
@@ -90,22 +90,32 @@ module FruitToLime
90
90
 
91
91
  def add_employee(val)
92
92
  @employees = [] if @employees==nil
93
- @employees.push(if val.is_a? Person then val else Person.new(val) end)
93
+ person = if val.is_a? Person then val else Person.new(val) end
94
+ @employees.push(person)
95
+ person
96
+ end
97
+
98
+ def add_responsible_coworker(val)
99
+ coworker = if val.is_a? CoworkerReference then val else CoworkerReference.new(val) end
100
+ @responsible_coworker = coworker
101
+ coworker
94
102
  end
95
103
 
96
104
  def serialize_variables
97
- [
98
- :id, :integration_id, :name, :organization_number,
99
- :email, :web_site, :central_phone_number ].map {
100
- |prop| { :id => prop, :type => :string }
101
- } +
102
105
  [
106
+ { :id => :id, :type => :string },
107
+ { :id => :integration_id, :type => :string },
108
+ { :id => :source, :type => :source_ref },
109
+ { :id => :name, :type => :string },
110
+ { :id => :organization_number, :type => :string },
103
111
  { :id => :postal_address, :type => :address },
104
112
  { :id => :visit_address, :type => :address },
113
+ { :id => :central_phone_number, :type => :string },
114
+ { :id => :email, :type => :string },
115
+ { :id => :web_site, :type => :string },
105
116
  { :id => :employees, :type => :persons },
106
- { :id => :tags, :type => :tags },
107
117
  { :id => :custom_fields, :type => :custom_fields },
108
- { :id => :source, :type => :source_ref },
118
+ { :id => :tags, :type => :tags },
109
119
  { :id => :responsible_coworker, :type => :coworker_reference}
110
120
  ]
111
121
  end
@@ -30,7 +30,7 @@ module FruitToLime
30
30
  end
31
31
 
32
32
  class Person < PersonReference
33
- include SerializeHelper
33
+ include SerializeHelper, ModelHasCustomFields, ModelHasTags
34
34
  attr_accessor :first_name, :last_name,
35
35
  :direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number,
36
36
  :position, :email, :alternative_email, :postal_address, :currently_employed,
@@ -38,6 +38,7 @@ module FruitToLime
38
38
  attr_reader :custom_fields
39
39
 
40
40
  def initialize(opt = nil)
41
+ @currently_employed = true
41
42
  if opt != nil
42
43
  serialize_variables.each do |myattr|
43
44
  val = opt[myattr[:id]]
@@ -51,11 +52,6 @@ module FruitToLime
51
52
  yield @postal_address
52
53
  end
53
54
 
54
- def set_custom_field(obj)
55
- @custom_fields = [] if @custom_fields==nil
56
- @custom_fields.push CustomField.new(obj)
57
- end
58
-
59
55
  def with_source
60
56
  @source = ReferenceToSource.new
61
57
  yield @source
@@ -65,29 +61,35 @@ module FruitToLime
65
61
  @tags
66
62
  end
67
63
 
68
- def add_tag(str)
69
- @tags = [] if @tags == nil
70
- @tags.push(Tag.new(str))
71
- end
72
-
73
64
  def serialize_name
74
65
  "Person"
75
66
  end
76
67
 
77
68
  def serialize_variables
78
69
  [
79
- :id, :integration_id, :first_name, :last_name,
80
- :direct_phone_number, :fax_phone_number, :mobile_phone_number, :home_phone_number,
81
- :position, :email, :alternative_email
82
- ].map {
83
- |prop| {:id => prop, :type => :string}
84
- }+[
85
- {:id => :postal_address, :type => :address},
86
- {:id => :currently_employed, :type => :bool},
70
+ {:id => :id, :type => :string},
71
+ {:id => :integration_id, :type => :string},
72
+ {:id => :source, :type => :source_ref},
73
+ {:id => :first_name, :type => :string},
74
+ {:id => :last_name, :type => :string},
75
+
76
+ {:id => :direct_phone_number, :type => :string},
77
+ {:id => :fax_phone_number, :type => :string},
78
+ {:id => :mobile_phone_number, :type => :string},
79
+ {:id => :home_phone_number, :type => :string},
80
+
81
+ {:id => :position, :type => :string},
82
+
87
83
  {:id => :tags, :type => :tags},
84
+
85
+ {:id => :email, :type => :string},
86
+ {:id => :alternative_email, :type => :string},
87
+
88
+ {:id => :postal_address, :type => :address},
88
89
  {:id => :custom_fields, :type => :custom_fields},
89
- {:id => :source, :type => :source_ref},
90
- {:id => :organization, :type => :organization_reference}
90
+ {:id => :currently_employed, :type => :bool},
91
+ {:id => :organization, :type => :organization_reference},
92
+
91
93
  ]
92
94
  end
93
95
 
@@ -4,7 +4,7 @@ module FruitToLime
4
4
  attr_accessor :name, :id, :format
5
5
 
6
6
  def serialize_variables
7
- [:name, :id, :format].map { |prop| { :id => prop, :type => :string } }
7
+ [:name, :format, :id].map { |prop| { :id => prop, :type => :string } }
8
8
  end
9
9
 
10
10
  def serialize_name
@@ -31,6 +31,9 @@ module FruitToLime
31
31
  end
32
32
 
33
33
  def ==(other)
34
+ if other==nil
35
+ return false
36
+ end
34
37
  return @name == other.name && @id == other.id && @format== other.format
35
38
  end
36
39
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module FruitToLime
2
3
  class RootModel
3
4
  # the import_coworker is a special coworker that is set as
@@ -5,8 +6,8 @@ module FruitToLime
5
6
  attr_accessor :organizations, :coworkers, :deals, :notes, :import_coworker
6
7
  def serialize_variables
7
8
  [
8
- {:id => :coworkers, :type => :coworkers},
9
9
  {:id => :organizations, :type => :organizations},
10
+ {:id => :coworkers, :type => :coworkers},
10
11
  {:id => :deals, :type => :deals},
11
12
  {:id => :notes, :type => :notes},
12
13
  ]
@@ -138,5 +139,11 @@ module FruitToLime
138
139
 
139
140
  return error.strip
140
141
  end
142
+
143
+ def to_rexml(doc)
144
+ element_name = serialize_name
145
+ elem = doc.add_element(element_name,{"Version"=>"v1_0"})
146
+ SerializeHelper::serialize_variables_rexml(elem, self)
147
+ end
141
148
  end
142
149
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  module FruitToLime
3
4
  class Tag
4
5
  def serialize_name
@@ -13,9 +14,9 @@ module FruitToLime
13
14
  end
14
15
  end
15
16
 
16
- def to_xml
17
- varn = serialize_name
18
- "<#{varn}>#{ @value.to_s.encode('utf-8').encode(:xml => :text) }</#{varn}>"
17
+ def to_rexml(elem)
18
+ element_name = serialize_name
19
+ elem.add_element(element_name).text = @value.to_s.encode('utf-8')
19
20
  end
20
21
 
21
22
  def to_s
@@ -1,12 +1,35 @@
1
1
  module FruitToLime
2
2
  module ModelHasCustomFields
3
- # attr_reader :custom_fields
4
-
5
- #@custom_fields = []
6
-
7
3
  def set_custom_field(obj)
8
4
  @custom_fields = [] if @custom_fields==nil
9
- @custom_fields.push CustomField.new(obj)
5
+ new_custom_field = CustomField.new(obj)
6
+ index = @custom_fields.find_index do |custom_field|
7
+ custom_field.same_as?(new_custom_field)
8
+ end
9
+ if index
10
+ @custom_fields.delete_at index
11
+ end
12
+ @custom_fields.push new_custom_field
13
+ return new_custom_field
14
+ end
15
+
16
+ def add_custom_field(obj)
17
+ @custom_fields = [] if @custom_fields==nil
18
+ custom_field = CustomField.new(obj)
19
+ @custom_fields.push custom_field
20
+ return custom_field
21
+ end
22
+ end
23
+
24
+ module ModelWithIntegrationIdSameAs
25
+ def same_as?(other)
26
+ if @integration_id!=nil && @integration_id == other.integration_id
27
+ return true
28
+ end
29
+ if @id != nil && @id == other.id
30
+ return true
31
+ end
32
+ return false
10
33
  end
11
34
  end
12
35
 
@@ -15,5 +38,11 @@ module FruitToLime
15
38
  @tags = [] if @tags == nil
16
39
  @tags.push(Tag.new(str))
17
40
  end
41
+ def set_tag(str)
42
+ @tags = [] if @tags == nil
43
+ if ! @tags.any? {|tag| tag.value = str }
44
+ @tags.push(Tag.new(str))
45
+ end
46
+ end
18
47
  end
19
48
  end
@@ -1,4 +1,6 @@
1
1
  # encoding: utf-8
2
+ require "rexml/document"
3
+
2
4
  module FruitToLime
3
5
  module SerializeHelper
4
6
  def serialize()
@@ -9,36 +11,56 @@ module FruitToLime
9
11
  SerializeHelper::serialize_to_file(file, self)
10
12
  end
11
13
 
12
- def self.serialize_variables(obj)
14
+ def self.serialize_variables_rexml(elem, obj)
13
15
  if (obj.respond_to?(:serialize_variables))
14
- return obj.serialize_variables.map do |ivar|
15
- varn = ivar[:id].to_s.gsub(/^\@/,'').split('_').map do |m|
16
+ obj.serialize_variables.each do |serialize_variable|
17
+ element_name = serialize_variable[:id].to_s.gsub(/^\@/,'').split('_').map do |m|
16
18
  m.capitalize
17
19
  end.join('')
18
20
 
19
- varv = obj.instance_variable_get("@#{ivar[:id].to_s}")
20
- if (varv.respond_to?(:serialize_variables))
21
- varv = serialize_variables(varv)
22
- elsif (varv.is_a?(Array))
23
- varv = varv.map { |elem| SerializeHelper::serialize(elem) }.join("\n")
24
- elsif (varv == nil)
25
- varv = nil
26
- else
27
- varv = varv.to_s.encode('UTF-8').encode(:xml => :text)
21
+ raw_var = obj.instance_variable_get("@#{serialize_variable[:id].to_s}")
22
+ if raw_var != nil
23
+ element = elem.add_element(element_name)
24
+ if (raw_var.respond_to?(:serialize_variables))
25
+ SerializeHelper::serialize_variables_rexml(element, raw_var)
26
+ elsif (raw_var.is_a?(Array))
27
+ raw_var.each do |raw_var_elem|
28
+ SerializeHelper::serialize_rexml(element, raw_var_elem)
29
+ end
30
+ else
31
+ element.text = raw_var.to_s.encode('UTF-8')
32
+ end
28
33
  end
29
- if varv != nil then "<#{varn}>#{ varv }</#{varn}>" else "" end
30
- if varv != nil then "<#{varn}>#{ varv }</#{varn}>" end
31
- end.join("\n")
34
+ end
35
+ return
32
36
  end
33
- raise "!!#{obj.class}"
37
+ raise "Do not know how to handle #{obj.class} !!"
34
38
  end
35
39
 
36
- def self.serialize(obj)
37
- if (obj.respond_to?(:serialize_variables))
38
- varn = obj.serialize_name
39
- "<#{varn}>#{ SerializeHelper::serialize_variables(obj) }</#{varn}>"
40
- elsif obj.respond_to?(:to_xml)
41
- obj.to_xml
40
+ def self.serialize_rexml(elem, obj)
41
+ if obj.respond_to?(:to_rexml)
42
+ obj.to_rexml(elem)
43
+ elsif (obj.respond_to?(:serialize_variables))
44
+ element_name = obj.serialize_name
45
+ SerializeHelper::serialize_variables_rexml(elem.add_element(element_name), obj)
46
+ else
47
+ elem.text = obj.to_s
48
+ end
49
+ end
50
+
51
+ def self.serialize(obj, indent= 2)
52
+ # indent -1 to avoid indent
53
+ if obj.respond_to?(:to_rexml)
54
+ doc = REXML::Document.new()
55
+ SerializeHelper::serialize_rexml(doc, obj)
56
+ doc.write( xml_str = "" , indent, true)
57
+ xml_str
58
+ elsif (obj.respond_to?(:serialize_variables))
59
+ element_name = obj.serialize_name
60
+ doc = REXML::Document.new()
61
+ SerializeHelper::serialize_variables_rexml(doc.add_element(element_name), obj)
62
+ doc.write( xml_str = "", indent, true)
63
+ xml_str
42
64
  else
43
65
  obj.to_s.encode(:xml => :text)
44
66
  end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+ require 'fruit_to_lime'
3
+
4
+ describe "CustomField" do
5
+ before (:all) do
6
+ @custom_field = FruitToLime::CustomField.new({:id => 'the id',
7
+ :integration_id=>'the key',
8
+ :title=> 'the title',
9
+ :value=> 'the value'})
10
+ end
11
+
12
+ it "is the same as a custom field with the same integration_id" do
13
+ @custom_field.same_as?(FruitToLime::CustomField.new({:integration_id=>'the key',
14
+ :title=> 'the title 2',
15
+ :value=> 'the value 2'})).should eq true
16
+ end
17
+
18
+ it "is the same as a custom field with the same id" do
19
+ @custom_field.same_as?(FruitToLime::CustomField.new({:id=>'the id',
20
+ :title=> 'the title 2',
21
+ :value=> 'the value 2'})).should eq true
22
+ end
23
+
24
+ end
25
+
@@ -7,10 +7,10 @@ describe FruitToLime::SerializeHelper do
7
7
  let(:serialized) {
8
8
  n = FruitToLime::Note.new
9
9
  n.text = "text"
10
- FruitToLime::SerializeHelper::serialize(n)
10
+ FruitToLime::SerializeHelper::serialize(n,-1)
11
11
  }
12
12
  it "should contain text" do
13
- serialized.should match(/<Text>text<\/Text>/)
13
+ serialized.should match(/<Text>[\n ]*text[\n ]*<\/Text>/)
14
14
  end
15
15
  it "should contain start tag" do
16
16
  serialized.should match(/<Note>/)
@@ -19,13 +19,24 @@ describe FruitToLime::SerializeHelper do
19
19
  serialized.encoding.should equal Encoding::UTF_8
20
20
  end
21
21
  end
22
+
23
+ describe "Serialize note with xml inside" do
24
+ let(:serialized) {
25
+ n = FruitToLime::Note.new
26
+ n.text = "<text>"
27
+ FruitToLime::SerializeHelper::serialize(n,-1)
28
+ }
29
+ it "should contain encoded text" do
30
+ serialized.should match(/<Text>[\n ]*&lt;text&gt;[\n ]*<\/Text>/)
31
+ end
32
+ end
33
+
22
34
  describe "Serialize without data" do
23
35
  let(:serialized) {
24
36
  p = FruitToLime::Person.new
25
- FruitToLime::SerializeHelper::serialize(p)
37
+ FruitToLime::SerializeHelper::serialize(p,-1)
26
38
  }
27
39
  it "should not contain fields that are not set" do
28
- #puts serialized
29
40
  serialized.should_not match(/<Email>/)
30
41
  serialized.should_not match(/<Position>/)
31
42
  serialized.should_not match(/<AlternativeEmail>/)
@@ -50,16 +61,22 @@ describe FruitToLime::SerializeHelper do
50
61
  p.with_postal_address do |addr|
51
62
  addr.city = "Ankeborg"
52
63
  end
64
+ p.currently_employed=true
53
65
  p.add_tag("tag:anka")
54
66
  p.add_tag("tag:Bj\u{00F6}rk")
67
+ p.add_tag("tag:<Bj\u{00F6}rk>")
55
68
  p.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
56
69
  p.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
57
- FruitToLime::SerializeHelper::serialize(p)
70
+ p.set_custom_field({:id=>"4", :title=>"cf <title3>", :value=>"cf <Bj\u{00F6}rk>"})
71
+ FruitToLime::SerializeHelper::serialize(p,-1)
58
72
  }
59
73
  it "should contain first and last name" do
60
- serialized.should match(/<FirstName>Kalle<\/FirstName>/)
74
+ serialized.should match(/<FirstName>[\n ]*Kalle[\n ]*<\/FirstName>/)
61
75
  serialized.should match(/Anka/)
62
76
  end
77
+ it "should contain currently_employed" do
78
+ serialized.should match(/<CurrentlyEmployed>[\n ]*true[\n ]*<\/CurrentlyEmployed>/)
79
+ end
63
80
  it "should tag name" do
64
81
  serialized.should match(/tag:anka/)
65
82
  end
@@ -79,6 +96,12 @@ describe FruitToLime::SerializeHelper do
79
96
  it "should handle sv chars in custom value" do
80
97
  serialized.should match(/cf Bj\u{00F6}rk/)
81
98
  end
99
+ it "should handle xml in tag" do
100
+ serialized.should match(/tag:&lt;Bj\u{00F6}rk&gt;/)
101
+ end
102
+ it "should handle xml in custom value" do
103
+ serialized.should match(/cf &lt;Bj\u{00F6}rk&gt;/)
104
+ end
82
105
  it "should be utf-8" do
83
106
  serialized.encoding.should equal Encoding::UTF_8
84
107
  end
@@ -106,7 +129,7 @@ describe FruitToLime::SerializeHelper do
106
129
  :first_name => "Kalle",
107
130
  :last_name => "Anka"
108
131
  })
109
- FruitToLime::SerializeHelper::serialize(o)
132
+ FruitToLime::SerializeHelper::serialize(o,-1)
110
133
  }
111
134
  it "should contain name" do
112
135
  serialized.should match(/Ankeborgs bibliotek/)
@@ -120,7 +143,7 @@ describe FruitToLime::SerializeHelper do
120
143
  serialized.should match(/Gaaseborg/)
121
144
  end
122
145
  it "should tag name" do
123
- serialized.should match(/<Tag>tag:bibliotek<\/Tag>/)
146
+ serialized.should match(/<Tag>[\n ]*tag:bibliotek[\n ]*<\/Tag>/)
124
147
  end
125
148
  it "should contain custom field" do
126
149
  serialized.should match(/cf title/)
@@ -147,7 +170,7 @@ describe FruitToLime::SerializeHelper do
147
170
  o = FruitToLime::Organization.new
148
171
  o.name = "Ankeborgs bibliotek"
149
172
  i.organizations.push(o)
150
- FruitToLime::SerializeHelper::serialize(i)
173
+ FruitToLime::SerializeHelper::serialize(i,-1)
151
174
  }
152
175
  it "should contain name" do
153
176
  serialized.should match(/Ankeborgs bibliotek/)
@@ -0,0 +1,49 @@
1
+
2
+ require 'spec_helper'
3
+ require 'fruit_to_lime'
4
+ require 'nokogiri'
5
+ describe FruitToLime::SerializeHelper do
6
+
7
+ describe "Validate according to xsd" do
8
+ let(:validate_result) {
9
+ i = FruitToLime::RootModel.new
10
+ o = FruitToLime::Organization.new
11
+ o.name = "Ankeborgs bibliotek"
12
+ o.with_source do |source|
13
+ source.par_se('122345')
14
+ end
15
+ #o.source_ref = {:name=>'Go',:id=>"PASE122345"}
16
+ o.add_tag("tag:bibliotek")
17
+ o.add_tag("tag:Bj\u{00F6}rk")
18
+ o.set_custom_field({:id=>"2", :title=>"cf title", :value=>"cf value"})
19
+ o.set_custom_field({:id=>"3", :title=>"cf title2", :value=>"cf Bj\u{00F6}rk"})
20
+ o.with_postal_address do |addr|
21
+ addr.city = "Ankeborg"
22
+ end
23
+ o.with_visit_address do |addr|
24
+ addr.city = "Gaaseborg"
25
+ end
26
+ o.add_responsible_coworker({
27
+ :id => "1"
28
+ })
29
+ emp = o.add_employee({
30
+ :id => "1",
31
+ :first_name => "Kalle",
32
+ :last_name => "Anka"
33
+ })
34
+ emp.direct_phone_number = '234234234'
35
+ emp.currently_employed = true
36
+ i.organizations.push(o)
37
+ xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
38
+
39
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
40
+ #puts FruitToLime::SerializeHelper::serialize(i)
41
+ doc = Nokogiri::XML(FruitToLime::SerializeHelper::serialize(i,-1))
42
+ xsd.validate(doc)
43
+ }
44
+ it "Should not contain validation errors" do
45
+ expect(validate_result).to eq([])
46
+ end
47
+
48
+ end
49
+ end
data/spec/person_spec.rb CHANGED
@@ -2,42 +2,76 @@ require "spec_helper"
2
2
  require 'fruit_to_lime'
3
3
 
4
4
  describe "Person" do
5
- before (:all) do
6
- @person = FruitToLime::Person.new
7
- end
5
+ let(:person) {
6
+ FruitToLime::Person.new
7
+ }
8
8
 
9
9
  it "can set a customfield" do
10
- @person.set_custom_field({:integration_id=>'the key',
10
+ person.set_custom_field({:integration_id=>'the key',
11
11
  :title=> 'the title',
12
12
  :value=> 'the value'})
13
13
 
14
- field = @person.custom_fields[0]
14
+ field = person.custom_fields[0]
15
15
  field.integration_id.should eq 'the key'
16
16
  field.title.should eq 'the title'
17
17
  field.value.should eq 'the value'
18
18
  end
19
19
 
20
+ it "will set custom field with same integration_id to the last value" do
21
+ person.set_custom_field({:integration_id=>'the key',
22
+ :title=> 'the title',
23
+ :value=> 'the value'})
24
+
25
+ person.set_custom_field({:integration_id=>'the key',
26
+ :title=> 'the title 2',
27
+ :value=> 'the value 2'})
28
+ person.custom_fields.length.should eq 1
29
+ field = person.custom_fields[0]
30
+ field.integration_id.should eq 'the key'
31
+ field.title.should eq 'the title 2'
32
+ field.value.should eq 'the value 2'
33
+ end
34
+
35
+ it "will set custom field with same id to the last value" do
36
+ person.set_custom_field({:id=>'the id',
37
+ :title=> 'the title',
38
+ :value=> 'the value'})
39
+
40
+ person.set_custom_field({:id=>'the id',
41
+ :title=> 'the title 2',
42
+ :value=> 'the value 2'})
43
+ person.custom_fields.length.should eq 1
44
+ field = person.custom_fields[0]
45
+ field.id.should eq 'the id'
46
+ field.title.should eq 'the title 2'
47
+ field.value.should eq 'the value 2'
48
+ end
49
+
20
50
  it "should have a firstname if no lastname" do
21
- @person.first_name = "Vincent"
22
- @person.last_name = nil
51
+ person.first_name = "Vincent"
52
+ person.last_name = nil
23
53
 
24
- error = @person.validate
54
+ error = person.validate
25
55
  error.should be_empty
26
56
  end
27
57
 
58
+ it "should be currently employed if nothing specified" do
59
+ expect(person.currently_employed).to eq(true)
60
+ end
61
+
28
62
  it "should have a lastname if no firstname" do
29
- @person.first_name = String.new
30
- @person.last_name = "Vega"
63
+ person.first_name = String.new
64
+ person.last_name = "Vega"
31
65
 
32
- error = @person.validate
66
+ error = person.validate
33
67
  error.should be_empty
34
68
  end
35
69
 
36
70
  it "shouldnt pass validation with no firstname and lastname" do
37
- @person.first_name = String.new
38
- @person.last_name = nil
71
+ person.first_name = String.new
72
+ person.last_name = nil
39
73
 
40
- error = @person.validate
74
+ error = person.validate
41
75
  error.should start_with("A firstname or lastname is required for person")
42
76
  end
43
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fruit_to_lime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-03-27 00:00:00.000000000 Z
14
+ date: 2014-04-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: iso_country_codes
@@ -175,10 +175,12 @@ files:
175
175
  - templates/sqlserver/Rakefile.rb
176
176
  - templates/sqlserver/spec/spec_helper.rb
177
177
  - templates/sqlserver/spec/tomodel_spec.rb
178
+ - spec/custom_field_spec.rb
178
179
  - spec/helpers/address_helper_spec.rb
179
180
  - spec/helpers/csv_helper_spec.rb
180
181
  - spec/helpers/roo_helper_spec.rb
181
182
  - spec/helpers/serialize_helper_spec.rb
183
+ - spec/helpers/xsd_validate_spec.rb
182
184
  - spec/person_spec.rb
183
185
  - spec/spec_helper.rb
184
186
  - spec/templating_spec.rb
@@ -207,10 +209,12 @@ signing_key:
207
209
  specification_version: 3
208
210
  summary: Library to generate Lime Go xml import format
209
211
  test_files:
212
+ - spec/custom_field_spec.rb
210
213
  - spec/helpers/address_helper_spec.rb
211
214
  - spec/helpers/csv_helper_spec.rb
212
215
  - spec/helpers/roo_helper_spec.rb
213
216
  - spec/helpers/serialize_helper_spec.rb
217
+ - spec/helpers/xsd_validate_spec.rb
214
218
  - spec/person_spec.rb
215
219
  - spec/spec_helper.rb
216
220
  - spec/templating_spec.rb