blueprints 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +4 -1
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +82 -18
  4. data/LICENSE +1 -1
  5. data/README.rdoc +38 -8
  6. data/Rakefile +11 -35
  7. data/blueprints.gemspec +29 -123
  8. data/features/support/env.rb +7 -10
  9. data/lib/blueprints.rb +68 -12
  10. data/lib/blueprints/blueprint.rb +39 -19
  11. data/lib/blueprints/buildable.rb +92 -74
  12. data/lib/blueprints/configuration.rb +18 -4
  13. data/lib/blueprints/context.rb +148 -5
  14. data/lib/blueprints/database_cleaner_fix.rb +9 -0
  15. data/lib/blueprints/dependency.rb +32 -21
  16. data/lib/blueprints/eval_context.rb +51 -0
  17. data/lib/blueprints/extensions.rb +115 -0
  18. data/lib/blueprints/extensions/rspec.rb +3 -1
  19. data/lib/blueprints/helper.rb +52 -20
  20. data/lib/blueprints/namespace.rb +31 -12
  21. data/lib/blueprints/root_namespace.rb +24 -25
  22. data/lib/blueprints/version.rb +3 -0
  23. data/spec/{active_record/blueprint.rb → blueprint.rb} +14 -17
  24. data/spec/{active_record/blueprints_spec.rb → blueprints_spec.rb} +40 -59
  25. data/spec/spec_helper.rb +34 -0
  26. data/spec/support/active_record/database.yml.example +7 -0
  27. data/spec/support/active_record/initializer.rb +15 -0
  28. data/spec/{active_record/fixtures → support/active_record}/schema.rb +0 -0
  29. data/spec/support/dm-core/initializer.rb +31 -0
  30. data/spec/support/mongo_mapper/database.yml.example +2 -0
  31. data/spec/support/mongo_mapper/initializer.rb +20 -0
  32. data/spec/support/mongoid/database.yml.example +2 -0
  33. data/spec/support/mongoid/initializer.rb +23 -0
  34. data/spec/support/none/initializer.rb +63 -0
  35. data/spec/unit/active_record_spec.rb +1 -6
  36. data/spec/unit/blueprint_spec.rb +91 -20
  37. data/spec/unit/blueprints_spec.rb +44 -0
  38. data/spec/unit/buildable_spec.rb +37 -6
  39. data/spec/unit/configuration_spec.rb +11 -0
  40. data/spec/unit/context_spec.rb +100 -0
  41. data/spec/unit/dependency_spec.rb +24 -19
  42. data/spec/unit/eval_context_spec.rb +56 -0
  43. data/spec/unit/fixtures.rb +61 -0
  44. data/spec/unit/namespace_spec.rb +59 -11
  45. data/spec/unit/spec_helper.rb +8 -16
  46. data/test/blueprints_test.rb +40 -59
  47. data/test/test_helper.rb +6 -16
  48. data/test_all.sh +45 -0
  49. metadata +178 -61
  50. data/VERSION +0 -1
  51. data/lib/blueprints/core_ext.rb +0 -69
  52. data/lib/blueprints/file_context.rb +0 -37
  53. data/spec/active_record/fixtures/database.yml.example +0 -8
  54. data/spec/active_record/fixtures/fruit.rb +0 -3
  55. data/spec/active_record/fixtures/tree.rb +0 -4
  56. data/spec/active_record/spec_helper.rb +0 -37
  57. data/spec/no_db/blueprint.rb +0 -9
  58. data/spec/no_db/blueprints_spec.rb +0 -45
  59. data/spec/no_db/fixtures/fruit.rb +0 -15
  60. data/spec/no_db/spec_helper.rb +0 -14
  61. data/spec/test_all.sh +0 -39
@@ -1,25 +1,16 @@
1
1
  require 'rubygems'
2
+ require 'logger'
2
3
  require 'active_record'
3
4
  require 'test/unit'
4
5
  require 'active_record/test_case'
5
6
  require 'shoulda'
6
7
  require 'mocha'
7
- begin
8
- require 'mysqlplus'
9
- rescue LoadError
10
- end
11
-
12
- Dir.chdir(File.join(File.dirname(__FILE__), '..'))
13
-
14
- ActiveRecord::Base.logger = Logger.new("debug.log")
15
8
 
16
- databases = YAML::load(IO.read("spec/active_record/fixtures/database.yml"))
17
- db_info = databases[ENV["DB"] || "test"]
18
- ActiveRecord::Base.establish_connection(db_info)
9
+ Root = Pathname.new(__FILE__).dirname.join('..')
10
+ $: << Root.join('lib').to_s
19
11
 
20
- require 'lib/blueprints'
21
- require 'spec/active_record/fixtures/fruit'
22
- require 'spec/active_record/fixtures/tree'
12
+ require 'blueprints'
13
+ require File.dirname(__FILE__) + "/../spec/support/active_record/initializer"
23
14
 
24
15
  class ActiveSupport::TestCase
25
16
  def assert_similar(array1, array2)
@@ -29,7 +20,6 @@ class ActiveSupport::TestCase
29
20
  end
30
21
 
31
22
  Blueprints.enable do |config|
32
- config.root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
23
+ config.root = Root.join('spec')
33
24
  config.prebuild = :big_cherry
34
- config.filename = 'spec/active_record/blueprint.rb'
35
25
  end
@@ -0,0 +1,45 @@
1
+ #!/bin/bash
2
+ function e {
3
+ echo ''
4
+ echo '----------------------------------------'
5
+ echo $1
6
+ echo '----------------------------------------'
7
+ }
8
+
9
+ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
10
+
11
+ e "Normal spec"
12
+ rspec -c spec/blueprints_spec.rb
13
+ rspec -c spec/unit/*_spec.rb
14
+
15
+ e "With no db"
16
+ ORM=none rspec -c spec/blueprints_spec.rb
17
+
18
+ e "With mongoid"
19
+ ORM=mongoid rspec -c spec/blueprints_spec.rb
20
+
21
+ e "With mongo_mapper"
22
+ ORM=mongo_mapper rspec -c spec/blueprints_spec.rb
23
+
24
+ e "With Test::Unit"
25
+ rake rspec_to_test
26
+ ruby test/blueprints_test.rb
27
+
28
+ e "With Cucumber"
29
+ cucumber features/blueprints.feature -f progress
30
+
31
+ e "With Rails 2 and RSpec 1.3.0"
32
+ rvm 1.8.7@rails2
33
+ ORM="active_record.2.3.0" spec "_1.3.1_" -c spec/blueprints_spec.rb
34
+
35
+ e "With ruby 1.9.2"
36
+ rvm 1.9.2
37
+ rspec -c spec/blueprints_spec.rb
38
+ rspec -c spec/unit/*_spec.rb
39
+
40
+ e "With rubinius"
41
+ rvm rbx
42
+ rspec -c spec/blueprints_spec.rb
43
+ rspec -c spec/unit/*_spec.rb
44
+
45
+ rvm system
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 8
9
- - 2
10
- version: 0.8.2
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrius Chamentauskas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-23 00:00:00 +03:00
18
+ date: 2011-01-14 00:00:00 +02:00
19
19
  default_executable: blueprintify
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,20 +56,34 @@ dependencies:
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ">="
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- hash: 27
61
+ hash: 7
62
62
  segments:
63
- - 1
64
- - 3
63
+ - 2
64
+ - 2
65
65
  - 0
66
- version: 1.3.0
66
+ version: 2.2.0
67
67
  type: :development
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
70
- name: activerecord
70
+ name: mysql2
71
71
  prerelease: false
72
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: activerecord
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
73
87
  none: false
74
88
  requirements:
75
89
  - - ">="
@@ -81,11 +95,108 @@ dependencies:
81
95
  - 0
82
96
  version: 2.3.0
83
97
  type: :development
84
- version_requirements: *id004
98
+ version_requirements: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ name: bson_ext
101
+ prerelease: false
102
+ requirement: &id006 !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 27
108
+ segments:
109
+ - 1
110
+ - 1
111
+ - 4
112
+ version: 1.1.4
113
+ type: :development
114
+ version_requirements: *id006
115
+ - !ruby/object:Gem::Dependency
116
+ name: mongoid
117
+ prerelease: false
118
+ requirement: &id007 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 31098209
124
+ segments:
125
+ - 2
126
+ - 0
127
+ - 0
128
+ - beta
129
+ version: 2.0.0.beta
130
+ type: :development
131
+ version_requirements: *id007
132
+ - !ruby/object:Gem::Dependency
133
+ name: mongo_mapper
134
+ prerelease: false
135
+ requirement: &id008 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 63
141
+ segments:
142
+ - 0
143
+ - 8
144
+ - 0
145
+ version: 0.8.0
146
+ type: :development
147
+ version_requirements: *id008
148
+ - !ruby/object:Gem::Dependency
149
+ name: dm-migrations
150
+ prerelease: false
151
+ requirement: &id009 !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ hash: 23
157
+ segments:
158
+ - 1
159
+ - 0
160
+ - 0
161
+ version: 1.0.0
162
+ type: :development
163
+ version_requirements: *id009
164
+ - !ruby/object:Gem::Dependency
165
+ name: dm-transactions
166
+ prerelease: false
167
+ requirement: &id010 !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ hash: 23
173
+ segments:
174
+ - 1
175
+ - 0
176
+ - 0
177
+ version: 1.0.0
178
+ type: :development
179
+ version_requirements: *id010
180
+ - !ruby/object:Gem::Dependency
181
+ name: dm-mysql-adapter
182
+ prerelease: false
183
+ requirement: &id011 !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ hash: 23
189
+ segments:
190
+ - 1
191
+ - 0
192
+ - 0
193
+ version: 1.0.0
194
+ type: :development
195
+ version_requirements: *id011
85
196
  - !ruby/object:Gem::Dependency
86
197
  name: mocha
87
198
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
199
+ requirement: &id012 !ruby/object:Gem::Requirement
89
200
  none: false
90
201
  requirements:
91
202
  - - ">="
@@ -97,11 +208,11 @@ dependencies:
97
208
  - 8
98
209
  version: 0.9.8
99
210
  type: :development
100
- version_requirements: *id005
211
+ version_requirements: *id012
101
212
  - !ruby/object:Gem::Dependency
102
213
  name: shoulda
103
214
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
215
+ requirement: &id013 !ruby/object:Gem::Requirement
105
216
  none: false
106
217
  requirements:
107
218
  - - ">="
@@ -113,11 +224,11 @@ dependencies:
113
224
  - 0
114
225
  version: 2.10.0
115
226
  type: :development
116
- version_requirements: *id006
227
+ version_requirements: *id013
117
228
  - !ruby/object:Gem::Dependency
118
229
  name: cucumber
119
230
  prerelease: false
120
- requirement: &id007 !ruby/object:Gem::Requirement
231
+ requirement: &id014 !ruby/object:Gem::Requirement
121
232
  none: false
122
233
  requirements:
123
234
  - - ">="
@@ -129,8 +240,24 @@ dependencies:
129
240
  - 0
130
241
  version: 0.7.0
131
242
  type: :development
132
- version_requirements: *id007
133
- description: Another replacement for factories and fixtures. The library that lazy typists will love
243
+ version_requirements: *id014
244
+ - !ruby/object:Gem::Dependency
245
+ name: bundler
246
+ prerelease: false
247
+ requirement: &id015 !ruby/object:Gem::Requirement
248
+ none: false
249
+ requirements:
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ hash: 23
253
+ segments:
254
+ - 1
255
+ - 0
256
+ - 0
257
+ version: 1.0.0
258
+ type: :development
259
+ version_requirements: *id015
260
+ description: Awesome replacement for factories and fixtures that focuses on being DRY and making developers type as little as possible.
134
261
  email: sinsiliux@gmail.com
135
262
  executables:
136
263
  - blueprintify
@@ -146,7 +273,6 @@ files:
146
273
  - LICENSE
147
274
  - README.rdoc
148
275
  - Rakefile
149
- - VERSION
150
276
  - bin/blueprintify
151
277
  - blueprints.gemspec
152
278
  - features/blueprints.feature
@@ -161,45 +287,52 @@ files:
161
287
  - lib/blueprints/context.rb
162
288
  - lib/blueprints/convertable.rb
163
289
  - lib/blueprints/convertable/fixtures.rb
164
- - lib/blueprints/core_ext.rb
290
+ - lib/blueprints/database_cleaner_fix.rb
165
291
  - lib/blueprints/dependency.rb
166
292
  - lib/blueprints/errors.rb
293
+ - lib/blueprints/eval_context.rb
294
+ - lib/blueprints/extensions.rb
167
295
  - lib/blueprints/extensions/cucumber.rb
168
296
  - lib/blueprints/extensions/rspec.rb
169
297
  - lib/blueprints/extensions/test_unit.rb
170
- - lib/blueprints/file_context.rb
171
298
  - lib/blueprints/helper.rb
172
299
  - lib/blueprints/namespace.rb
173
300
  - lib/blueprints/root_namespace.rb
174
- - spec/active_record/blueprint.rb
175
- - spec/active_record/blueprints_spec.rb
176
- - spec/active_record/fixtures/database.yml.example
177
- - spec/active_record/fixtures/fruit.rb
178
- - spec/active_record/fixtures/schema.rb
179
- - spec/active_record/fixtures/tree.rb
180
- - spec/active_record/spec_helper.rb
181
- - spec/no_db/blueprint.rb
182
- - spec/no_db/blueprints_spec.rb
183
- - spec/no_db/fixtures/fruit.rb
184
- - spec/no_db/spec_helper.rb
185
- - spec/test_all.sh
301
+ - lib/blueprints/version.rb
302
+ - spec/blueprint.rb
303
+ - spec/blueprints_spec.rb
304
+ - spec/spec_helper.rb
305
+ - spec/support/active_record/database.yml.example
306
+ - spec/support/active_record/initializer.rb
307
+ - spec/support/active_record/schema.rb
308
+ - spec/support/dm-core/initializer.rb
309
+ - spec/support/mongo_mapper/database.yml.example
310
+ - spec/support/mongo_mapper/initializer.rb
311
+ - spec/support/mongoid/database.yml.example
312
+ - spec/support/mongoid/initializer.rb
313
+ - spec/support/none/initializer.rb
186
314
  - spec/unit/active_record_spec.rb
187
315
  - spec/unit/blueprint_spec.rb
316
+ - spec/unit/blueprints_spec.rb
188
317
  - spec/unit/buildable_spec.rb
189
318
  - spec/unit/configuration_spec.rb
319
+ - spec/unit/context_spec.rb
190
320
  - spec/unit/dependency_spec.rb
321
+ - spec/unit/eval_context_spec.rb
322
+ - spec/unit/fixtures.rb
191
323
  - spec/unit/namespace_spec.rb
192
324
  - spec/unit/spec_helper.rb
193
325
  - test/blueprints_test.rb
194
326
  - test/test_helper.rb
327
+ - test_all.sh
195
328
  - uninstall.rb
196
329
  has_rdoc: true
197
- homepage: http://github.com/sinsiliux/blueprints
330
+ homepage: http://sinsiliux.github.com/blueprints
198
331
  licenses: []
199
332
 
200
333
  post_install_message:
201
- rdoc_options:
202
- - --charset=UTF-8
334
+ rdoc_options: []
335
+
203
336
  require_paths:
204
337
  - lib
205
338
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -216,34 +349,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
349
  requirements:
217
350
  - - ">="
218
351
  - !ruby/object:Gem::Version
219
- hash: 3
352
+ hash: 23
220
353
  segments:
221
- - 0
222
- version: "0"
354
+ - 1
355
+ - 3
356
+ - 6
357
+ version: 1.3.6
223
358
  requirements: []
224
359
 
225
- rubyforge_project:
360
+ rubyforge_project: blueprints
226
361
  rubygems_version: 1.3.7
227
362
  signing_key:
228
363
  specification_version: 3
229
- summary: Another replacement for factories and fixtures
230
- test_files:
231
- - spec/no_db/fixtures/fruit.rb
232
- - spec/no_db/spec_helper.rb
233
- - spec/no_db/blueprints_spec.rb
234
- - spec/no_db/blueprint.rb
235
- - spec/unit/active_record_spec.rb
236
- - spec/unit/blueprint_spec.rb
237
- - spec/unit/spec_helper.rb
238
- - spec/unit/configuration_spec.rb
239
- - spec/unit/namespace_spec.rb
240
- - spec/unit/buildable_spec.rb
241
- - spec/unit/dependency_spec.rb
242
- - spec/active_record/fixtures/fruit.rb
243
- - spec/active_record/fixtures/tree.rb
244
- - spec/active_record/fixtures/schema.rb
245
- - spec/active_record/spec_helper.rb
246
- - spec/active_record/blueprints_spec.rb
247
- - spec/active_record/blueprint.rb
248
- - test/test_helper.rb
249
- - test/blueprints_test.rb
364
+ summary: Awesome replacement for factories and fixtures
365
+ test_files: []
366
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.8.2
@@ -1,69 +0,0 @@
1
- # Include this module into your class if you need klass.blueprint and object.blueprint methods.
2
- module Blueprints::Blueprintable
3
- module ClassMethods
4
- # Two forms of this method can be used. First one is typically used inside blueprint block. Essentially it does
5
- # same as <tt>create!</tt>, except it does bypass attr_protected and attr_accessible. It accepts only a hash or attributes,
6
- # same as <tt>create!</tt> does.
7
- # blueprint :post => [:user, :board] do
8
- # @user.posts.blueprint(:title => 'first post', :text => 'My first post')
9
- # end
10
- # The second form is used when you want to define new blueprint. It takes first argument as name of blueprint
11
- # and second one as hash of attributes. As you cannot use instance variables outside of blueprint block, you need
12
- # to prefix them with colon. So the example above could be rewritten like this:
13
- # Post.blueprint(:post, :title => 'first post', :text => 'My first post', :user => d(:user)).depends_on(:board)
14
- def blueprint(name_or_attrs, attrs = {})
15
- if Blueprints::FileContext.current
16
- define_blueprint(name_or_attrs, attrs)
17
- else
18
- if name_or_attrs.is_a?(Array)
19
- name_or_attrs.collect { |attrs| blueprint(attrs) }
20
- else
21
- blueprint_object(name_or_attrs)
22
- end
23
- end
24
- end
25
-
26
- private
27
-
28
- def define_blueprint(name, attrs)
29
- klass = self
30
- blueprint = Blueprints::Blueprint.new(name, Blueprints::FileContext.current.file) { klass.blueprint attributes }
31
- blueprint.attributes(attrs)
32
- blueprint
33
- end
34
-
35
- def blueprint_object(attrs)
36
- object = new
37
- object.blueprint(attrs)
38
- object
39
- end
40
- end
41
-
42
- def self.included(mod)
43
- mod.extend Blueprints::Blueprintable::ClassMethods
44
- end
45
-
46
- # Updates attributes of object by calling setter methods.
47
- def blueprint(attributes)
48
- Blueprints::Blueprint.normalize_attributes(attributes).each do |attr, val|
49
- send(:"#{attr}=", val)
50
- end
51
- end
52
- end
53
-
54
- # Include this instead of Blueprints::Blueprintable if record needs to persist, includes Blueprints::Blueprintable
55
- module Blueprints::Saveable
56
- include Blueprints::Blueprintable
57
-
58
- def self.included(mod)
59
- mod.extend Blueprints::Blueprintable::ClassMethods
60
- end
61
-
62
- # Overrides object.blueprint to also call save!
63
- def blueprint(attributes)
64
- super(attributes)
65
- save!
66
- end
67
- end
68
-
69
- ::ActiveRecord::Base.send(:include, Blueprints::Saveable) if defined?(ActiveRecord)