forge-factories 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  A Factory library that's about as barebones as you can get.
4
4
 
5
+ ## Installation
6
+
7
+ # "forge" was taken -_-
8
+
9
+ gem "forge-factories"
10
+ $ bundle install
11
+
12
+ # or
13
+
14
+ gem install forge-factories
15
+
5
16
  ## Define Factories
6
17
 
7
18
  ```ruby
@@ -16,6 +16,11 @@ module Forge
16
16
 
17
17
  def self.reset!
18
18
  @registry = {}
19
+ @sequence = Sequence.new
20
+ end
21
+
22
+ def self.sequence
23
+ @sequence ||= Sequence.new
19
24
  end
20
25
 
21
26
  def self.define(name, klass, &block)
@@ -34,6 +39,20 @@ module Forge
34
39
  @registry[name].create(attrs)
35
40
  end
36
41
 
42
+ class Sequence
43
+ def initialize
44
+ @n = 1
45
+ end
46
+
47
+ def value
48
+ @n
49
+ end
50
+
51
+ def next
52
+ @n += 1
53
+ end
54
+ end
55
+
37
56
  class Definition
38
57
  attr_accessor :klass, :block
39
58
 
@@ -1,3 +1,3 @@
1
1
  module Forge
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -45,4 +45,19 @@ describe Forge do
45
45
 
46
46
  Forge.build(:bounty_hunter).partner.name.should == "Jet"
47
47
  end
48
+
49
+ describe "sequence" do
50
+ it "keeps a integer sequence" do
51
+ Forge.sequence.value.should == 1
52
+ Forge.sequence.next.should == 2
53
+ Forge.sequence.value.should == 2
54
+ end
55
+
56
+ it "is reset" do
57
+ Forge.sequence.next
58
+ Forge.sequence.value.should == 2
59
+ Forge.reset!
60
+ Forge.sequence.value.should == 1
61
+ end
62
+ end
48
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forge-factories
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-11 00:00:00.000000000 Z
12
+ date: 2012-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  segments:
75
75
  - 0
76
- hash: -2953300044199411992
76
+ hash: -3166714612456625710
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  none: false
79
79
  requirements:
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  segments:
84
84
  - 0
85
- hash: -2953300044199411992
85
+ hash: -3166714612456625710
86
86
  requirements: []
87
87
  rubyforge_project:
88
88
  rubygems_version: 1.8.24