pseudo_entity 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87b2c3e4e1b76f53dd83e944a62574811ca1fc50
4
- data.tar.gz: 4828e030a98fd0ae03c4a76c096e2982bb4911c6
3
+ metadata.gz: ed330667433de06f720edbf6c5521158da50a187
4
+ data.tar.gz: f6fa6936cf78078cb624047f74015c1cb97dc0bf
5
5
  SHA512:
6
- metadata.gz: 12f20b5a0dee07b906b6f4ac30e8042e22fded9c7cbda1c4ef4fa9c7801c4ea46e271b15fd5fb42575edc01a0089d14d4aca49d9730b6e9444b88d9418f242f5
7
- data.tar.gz: f9d61bf57d08c692c227543edbbf9874c1751e85dcd878e17f034a423252f6c7695d081c5dd614c249fc5ddd08318fa74da81f95afd54ac79acec4bc6300f4de
6
+ metadata.gz: ce9ad2fc3efb2fa8019a202933c87e9c03c034e3df2795dad22f9f35e4c43e4d1f1bce2535572560882a0df9e7050ec55be617016d609660bebc6be12c58176e
7
+ data.tar.gz: 379cf79c9cda5989f52eaaa5067d906bfeb99196a03a2943b332d96e3b184b37adf1cfbc02eb989770c83d48fc8c02e494483a6ff0f16d6db48fb8bc271e4a84
data/lib/pseudo_entity.rb CHANGED
@@ -44,6 +44,16 @@ class PseudoEntity
44
44
  self
45
45
  end
46
46
 
47
+ def reset(value_name)
48
+ value_name = value_name.to_s.to_sym
49
+ if self.respond_to?(value_name)
50
+ instance_variable_set("@#{value_name}".to_sym, nil)
51
+ self.send(value_name)
52
+ else
53
+ nil
54
+ end
55
+ end
56
+
47
57
  def street_address
48
58
  # Yes it is in 2-1 order because that's how the US Post Office says to do it.
49
59
  # Apartment, Suites, etc go on the first line if there are two lines or at the end of the single line
@@ -1,3 +1,3 @@
1
1
  class PseudoEntity
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -65,26 +65,41 @@ describe PseudoEntity do
65
65
  end
66
66
 
67
67
  it "should not return new values without resetting" do
68
- names = [ 'Jack', 'Jill' ]
69
68
  pseudo_entity = PseudoEntity.new
70
- pseudo_entity.stub(:random_first_name).and_return(names.shift)
71
- pseudo_entity.first_name.should equal(pseudo_entity.first_name)
69
+ first_name = pseudo_entity.first_name
70
+ pseudo_entity.first_name.should equal(first_name)
72
71
  end
73
72
 
74
73
  it "should return new values after a reset" do
75
- names = [ 'Jack', 'Jill' ]
76
74
  pseudo_entity = PseudoEntity.new
77
- pseudo_entity.stub(:random_first_name).and_return(names.shift)
78
- name = pseudo_entity.first_name
75
+ first_name = pseudo_entity.first_name
76
+ last_name = pseudo_entity.last_name
79
77
  pseudo_entity.reset!
80
- pseudo_entity.stub(:random_first_name).and_return(names.shift)
81
- pseudo_entity.first_name.should_not eql(name)
78
+ pseudo_entity.first_name.should_not eql(first_name)
79
+ pseudo_entity.last_name.should_not eql(last_name)
82
80
  end
83
81
 
84
82
  it "should return self after a reset" do
85
83
  pseudo_entity.reset!.should equal(pseudo_entity)
86
84
  end
87
85
 
86
+ it "should reset a single value" do
87
+ pseudo_entity = PseudoEntity.new
88
+ first_name = pseudo_entity.first_name
89
+ last_name = pseudo_entity.last_name
90
+ pseudo_entity.reset("first_name")
91
+ pseudo_entity.first_name.should_not eql(first_name)
92
+ pseudo_entity.last_name.should eql(last_name)
93
+ end
94
+
95
+ it "should return the new value after a reset of a single value" do
96
+ pseudo_entity = PseudoEntity.new
97
+ first_name_a = pseudo_entity.first_name
98
+ first_name_b = pseudo_entity.reset("first_name")
99
+ first_name_a.should_not eql(first_name_b)
100
+ first_name_b.should eql(pseudo_entity.first_name)
101
+ end
102
+
88
103
  it "should combine addresses in 2,1 order" do
89
104
  pseudo_entity.stub(:street_address_line_1).and_return(:street_address_line_1)
90
105
  pseudo_entity.stub(:street_address_line_2).and_return(:street_address_line_2)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pseudo_entity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Hall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-11 00:00:00.000000000 Z
11
+ date: 2013-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler