hash_dealer 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.3
data/hash_dealer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hash_dealer}
8
- s.version = "1.2.2"
8
+ s.version = "1.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Langevin"]
12
- s.date = %q{2011-08-22}
12
+ s.date = %q{2011-08-23}
13
13
  s.description = %q{Like Factory Girl but for Hashes only}
14
14
  s.email = %q{dan.langevin@lifebooker.com}
15
15
  s.extra_rdoc_files = [
data/lib/hash_dealer.rb CHANGED
@@ -36,7 +36,7 @@ class HashDealer
36
36
  def _attributes(*args)
37
37
 
38
38
  # allows us to set a root value
39
- return @attributes unless @attributes.is_a?(Hash)
39
+ return @attributes.clone unless @attributes.is_a?(Hash)
40
40
  att = @parent ? HashDealer.roll(@parent.to_sym) : Hash.new
41
41
  @attributes.each do |k,v|
42
42
  att[k] = v.is_a?(Proc) ? v.call(*args) : v
@@ -103,6 +103,17 @@ describe HashDealer do
103
103
  end
104
104
  HashDealer.roll(:variable).matcher.should eql([{:abc => ":123", :deff => ":1234"}])
105
105
  end
106
+
107
+ it "should return a clone of its attributes, not an actual reference" do
108
+ HashDealer.define(:a) do
109
+ root({:a => "b"})
110
+ end
111
+ HashDealer.define(:b) do
112
+ a "test"
113
+ end
114
+ HashDealer.roll(:a).should_not be HashDealer.roll(:a)
115
+ HashDealer.roll(:b).should_not be HashDealer.roll(:b)
116
+ end
106
117
 
107
118
  it "should allow defining a hash where one of the keys is attributes" do
108
119
  HashDealer.define(:test) do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hash_dealer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.2
5
+ version: 1.2.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Langevin
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-22 00:00:00 Z
13
+ date: 2011-08-23 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -129,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
- hash: 2268842333028353407
132
+ hash: -4242599819582722325
133
133
  segments:
134
134
  - 0
135
135
  version: "0"