jelly_bird 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,14 +2,14 @@ module JellyBird
2
2
 
3
3
  module Define
4
4
 
5
- @@generators = nil
5
+ @@generator = {}
6
6
 
7
7
  def define(&default_lambda)
8
- @@generator = default_lambda
8
+ @@generator[self.to_s] = default_lambda
9
9
  end
10
10
 
11
11
  def generator
12
- @@generator
12
+ @@generator[self.to_s]
13
13
  end
14
14
 
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module JellyBird
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -59,6 +59,15 @@ describe JellyBird do
59
59
 
60
60
  describe "#gen" do
61
61
 
62
+ before(:all) do
63
+
64
+ Dummy.define {{
65
+ :name => /\w{3,8}/.gen,
66
+ :number => /\d\d\d\d\d\d\d/.gen
67
+ }}
68
+
69
+ end
70
+
62
71
  it "should be able to generate object" do
63
72
  dummy = Dummy.gen( :name => "test" )
64
73
  dummy.should be_kind_of(Dummy)
@@ -71,6 +80,40 @@ describe JellyBird do
71
80
  end
72
81
  end
73
82
 
83
+ it "should create object with other objects inside" do
84
+ dummy = Dummy.gen({:bomb => {:size => 15, :purpose => "anti-personal", :type => {:name => "claymore", :category => ["land", "mine"] }}})
85
+ dummy[:name].should_not be_nil
86
+ dummy[:bomb][:type][:category][1].should eql("mine")
87
+ end
88
+
89
+ it "should generate object inside of other object" do
90
+
91
+ # bug, currently for hashes you can input a gen inside of a define ;/
92
+ dummy = Dummy.gen
93
+
94
+ Rummy.define {{
95
+ :baby_rummy_is_a => dummy
96
+ }}
97
+
98
+ mummy = Rummy.gen
99
+ mummy[:baby_rummy_is_a][:name].should_not be_nil
100
+
101
+ end
102
+
103
+ it "should not override other generators" do
104
+
105
+ Rummy.define {{
106
+ :aa => "Rummy"
107
+ }}
108
+
109
+ Dummy.define {{
110
+ :bb => "Dummy"
111
+ }}
112
+
113
+ Rummy.gen[:aa].should eql("Rummy")
114
+
115
+ end
116
+
74
117
  end
75
118
 
76
119
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jelly_bird
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - JO
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-30 00:00:00 Z
18
+ date: 2011-07-03 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: JellyBird is a ultra small factory to help generating objects for purpose of tests.
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  requirements: []
70
70
 
71
71
  rubyforge_project: jelly_bird
72
- rubygems_version: 1.8.5
72
+ rubygems_version: 1.8.3
73
73
  signing_key:
74
74
  specification_version: 3
75
75
  summary: Ultra small gem for generating objects