factory_girl_sequences 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,83 +1,43 @@
1
- FactoryGirl.define do
2
- # == Basic types ==
3
-
4
- sequence :integer do |n|
5
- n
6
- end
7
-
8
- sequence :string do |n|
9
- "string-#{n}"
10
- end
11
-
12
- sequence :date do
13
- Date.today
14
- end
15
-
16
- sequence :datetime do
17
- Time.current
18
- end
19
-
20
- sequence :boolean do |n|
21
- [false, true][n%2]
22
- end
23
-
24
- # == Personal ==
25
-
26
- sequence :name, :aliases => [:login, :first_name, :last_name] do |n|
27
- "name-#{n}"
28
- end
29
-
30
- sequence :password do |n|
31
- "password-#{n}"
32
- end
33
-
34
- sequence :email do |n|
35
- "person#{n}@example.com"
36
- end
37
-
38
- # == Network ==
39
-
40
- sequence :ip_address do |n|
41
- "192.168.0.#{n%256}"
42
- end
43
-
44
- sequence :ip_subnet do |n|
45
- "192.168.#{n%256}.0"
46
- end
47
-
48
- sequence :mac_address do |n|
49
- "01:23:45:67:89:" + ("%02x" % "#{n%256}")
50
- end
51
-
52
- # == Post (article) ==
53
-
54
- sequence :title do
55
- "Title #{n}"
56
- end
57
-
58
- sequence :body, :aliases => [:description] do |n|
59
- "body-#{n}"
60
- end
61
-
62
- sequence :slug do |n|
63
- "slug-#{n}"
64
- end
65
-
66
- # == Other ==
67
-
68
- sequence :domain do |n|
69
- "example#{n}.com"
70
- end
71
-
72
- sequence :subdomain do |n|
73
- "blog#{n}"
74
- end
75
-
76
- sequence :color do |n|
77
- "%06d" % n
78
- end
79
-
80
- sequence :checksum do |n|
81
- n
1
+ module FactoryGirl
2
+
3
+ def self.register_default_sequences
4
+ # basic types
5
+ register_sequence(Sequence.new(:integer) { |n| n })
6
+ register_sequence(Sequence.new(:string) { |n| "string-#{n}" })
7
+ register_sequence(Sequence.new(:date) { Date.today })
8
+ register_sequence(Sequence.new(:datetime) { Time.current })
9
+ register_sequence(Sequence.new(:boolean) { |n| [false, true][n%2] })
10
+
11
+ # personal
12
+ register_sequence(Sequence.new(:name, :aliases => [:login, :first_name, :last_name]) { |n| "name-#{n}" })
13
+ register_sequence(Sequence.new(:password) { |n| "password-#{n}" })
14
+ register_sequence(Sequence.new(:email) { |n| "person#{n}@example.com" })
15
+
16
+ # network
17
+ register_sequence(Sequence.new(:ip_address) { |n| "192.168.0.#{n%256}" })
18
+ register_sequence(Sequence.new(:ip_subnet) { |n| "192.168.#{n%256}.0" })
19
+ register_sequence(Sequence.new(:mac_address) { |n| "01:23:45:67:89:" + ("%02x" % "#{n%256}") })
20
+
21
+ # post (or article)
22
+ register_sequence(Sequence.new(:title) { |n| "Title #{n}" })
23
+ register_sequence(Sequence.new(:body, :aliases => [:description]) { |n| "body-#{n}" })
24
+ register_sequence(Sequence.new(:slug) { |n| "slug-#{n}" })
25
+
26
+ # other
27
+ register_sequence(Sequence.new(:domain) { |n| "example#{n}.com" })
28
+ register_sequence(Sequence.new(:subdomain) { |n| "blog#{n}" })
29
+ register_sequence(Sequence.new(:color) { |n| "%06d" % n })
30
+ register_sequence(Sequence.new(:checksum) { |n| n })
31
+ end
32
+
33
+ # FIXME [AK] Monkey-patching here. There should be another way around.
34
+ def self.reload
35
+ reset_configuration
36
+ register_default_strategies
37
+ register_default_callbacks
38
+ register_default_sequences
39
+ find_definitions
82
40
  end
83
41
  end
42
+
43
+ FactoryGirl.register_default_sequences
@@ -1,3 +1,3 @@
1
1
  module FactoryGirlSequences
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl_sequences
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -124,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  segments:
126
126
  - 0
127
- hash: -2488072498665253576
127
+ hash: -3035240991900668198
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: -2488072498665253576
136
+ hash: -3035240991900668198
137
137
  requirements: []
138
138
  rubyforge_project:
139
139
  rubygems_version: 1.8.24