fabrication 2.9.8 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe7f9d8e73dc89c93bfef3a396ba4ac7e5f8cdf7
4
- data.tar.gz: e2bf0994300ca75c8cbaf2cc235256f63aa561b8
3
+ metadata.gz: 9e953b16555d4952d603134e3a609f2e18351a01
4
+ data.tar.gz: 88df71f9858b36e5911193238d5711ece3058fc5
5
5
  SHA512:
6
- metadata.gz: b829a8b42f44fe41f4c1f544c7839e0c7b18ed4de6a6b6c47f77ea6a444085e6f0af1d7897557e0075babadf4583de8ee7f0ad43a9fec62f3d9c66feb5f8ab98
7
- data.tar.gz: 784c0956e2fda65b4e87c517b443468b789ee16f743e6640808d372f3043a4af100db9b53c52b6881bb55ae7d2fbc6f5055edf0fc4af3576b2bee6c0ec2a823d
6
+ metadata.gz: c128fe8be585de63e07538b52743672449980bf8c9b09a0c7ec7e105a04a9eb9795ab186315182eaed2b89e1250efcaa1df6f369513ceb264b41968292d5e812
7
+ data.tar.gz: c89cf69b9395208ab787f58d9141db782ea37ab1c9ffda90e30a09729250edb045d71cd00c0f985fbd9adfc4d6ef2ce1028ab116d418f4fd777d19eeccccfb04
data/Rakefile CHANGED
@@ -1,11 +1,20 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ Bundler.require
5
+
1
6
  require "rspec/core/rake_task"
2
7
  RSpec::Core::RakeTask.new(:spec) do |spec|
3
8
  spec.pattern = "spec/**/*_spec.rb"
4
9
  end
5
10
 
6
- require 'cucumber/rake/task'
7
- Cucumber::Rake::Task.new(:cucumber) do |t|
8
- t.cucumber_opts = "--format progress --tags ~@wip"
11
+ desc 'All cucumber features with kitchen sink appraisal'
12
+ task :cucumber do
13
+ system('appraisal kitchen-sink cucumber -f progress')
9
14
  end
10
15
 
11
- task :default => [:spec, :cucumber]
16
+ if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
17
+ task default: %i(cucumber appraisal)
18
+ else
19
+ task default: :spec
20
+ end
@@ -5,7 +5,7 @@ module Fabrication
5
5
 
6
6
  def initialize(model_name, opts ={})
7
7
  @model = dehumanize(model_name)
8
- @fabricator = @model.singularize.to_sym
8
+ @fabricator = Fabrication::Support.singularize(@model).to_sym
9
9
  @parent_name = opts.delete(:parent)
10
10
  end
11
11
 
@@ -50,7 +50,7 @@ module Fabrication
50
50
  end
51
51
 
52
52
  def singular?
53
- @model == @model.singularize
53
+ @model == Fabrication::Support.singularize(@model)
54
54
  end
55
55
 
56
56
  def dehumanize(string)
@@ -1,6 +1,6 @@
1
1
  class Fabrication::UnfabricatableError < StandardError
2
2
 
3
- def initialize(name)
4
- super("No class found for '#{name}'")
3
+ def initialize(name, original_error)
4
+ super("No class found for '#{name}' (original exception: #{original_error.message})")
5
5
  end
6
6
  end
@@ -22,8 +22,8 @@ class Fabrication::Schematic::Attribute
22
22
  end
23
23
 
24
24
  def processed_value(processed_attributes)
25
- if count
26
- (1..count).map { |i| execute(processed_attributes, i, &value) }
25
+ if process_count
26
+ (1..process_count).map { |i| execute(processed_attributes, i, &value) }
27
27
  elsif value_proc?
28
28
  execute(processed_attributes, &value)
29
29
  else
@@ -37,7 +37,18 @@ class Fabrication::Schematic::Attribute
37
37
  Fabrication::Schematic::Runner.new(klass).instance_exec(*args, &block)
38
38
  end
39
39
 
40
- def count; params[:count] end
40
+ def process_count
41
+ count || rand
42
+ end
43
+
44
+ def count
45
+ params[:count]
46
+ end
47
+
48
+ def rand
49
+ Kernel.rand((1..params[:rand])) if params[:rand]
50
+ end
51
+
41
52
  def value_proc?; Proc === value end
42
53
 
43
54
  end
@@ -108,7 +108,7 @@ class Fabrication::Schematic::Definition
108
108
 
109
109
  def generate_value(name, params)
110
110
  if params[:count]
111
- name = name.to_s.singularize if name.to_s.respond_to?(:singularize)
111
+ name = Fabrication::Support.singularize(name.to_s)
112
112
  proc { Fabricate.build(params[:fabricator] || name) }
113
113
  else
114
114
  proc { Fabricate(params[:fabricator] || name) }
@@ -11,9 +11,8 @@ class Fabrication::Support
11
11
  klass = class_name.split('::').inject(Object) do |object, string|
12
12
  object.const_get(string)
13
13
  end
14
- rescue NameError
15
- ensure
16
- raise Fabrication::UnfabricatableError.new(class_or_to_s) unless klass
14
+ rescue NameError => original_error
15
+ raise Fabrication::UnfabricatableError.new(class_or_to_s, original_error)
17
16
  end
18
17
 
19
18
  def extract_options!(args)
@@ -43,6 +42,12 @@ class Fabrication::Support
43
42
  @hash_class ||= defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : Hash
44
43
  end
45
44
 
45
+ def singularize(string)
46
+ string.singularize
47
+ rescue
48
+ string.end_with?('s') ? string[0..-2] : string
49
+ end
50
+
46
51
  end
47
52
 
48
53
  end
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.9.8'
2
+ VERSION = '2.10.0'
3
3
  end
metadata CHANGED
@@ -1,215 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabrication
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.8
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Elliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-15 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activerecord
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bson_ext
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: cucumber
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: sqlite3
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: dm-core
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: dm-migrations
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: dm-sqlite-adapter
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: dm-validations
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: ffaker
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: mongoid
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '3.0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '3.0'
153
- - !ruby/object:Gem::Dependency
154
- name: pry
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: rake
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: rspec
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: sequel
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
+ dependencies: []
209
13
  description: Fabrication is an object generation framework for ActiveRecord, Mongoid,
210
14
  DataMapper, Sequel, or any other Ruby object.
211
15
  email:
212
- - paul@hashrocket.com
16
+ - paul@codingfrontier.com
213
17
  executables: []
214
18
  extensions: []
215
19
  extra_rdoc_files: []
@@ -268,5 +72,5 @@ rubyforge_project:
268
72
  rubygems_version: 2.2.1
269
73
  signing_key:
270
74
  specification_version: 4
271
- summary: Fabrication provides a simple solution for test object generation.
75
+ summary: Implementing the factory pattern in Ruby so you don't have to.
272
76
  test_files: []