baja 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/baja.gemspec +1 -1
- data/lib/baja/version.rb +1 -1
- data/lib/baja.rb +13 -43
- data/spec/factories/helper.rb +92 -0
- data/spec/factories/sample.rb +18 -0
- metadata +5 -4
- data/spec/factories/test.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14257de7de16b8020d616dc59f66f6e63dfd4b4c
|
4
|
+
data.tar.gz: 73ec437fbc51f1e10c47932b3379a3f23fc5e21e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e54e9a1df3e79036aee21aeb09836bfbb6f32a36806dd252dc0dfabb301292339dc6015ac1abbabd39641cc9f220f8ae094638299e9246b4835798ee6f0c73
|
7
|
+
data.tar.gz: 49d37c71f28e1b65d44901accb6ddbe9eee690915cd0697ba97f63ee8b9988c3900d46a9d445ba56d329c4a5c869932b580c8fb1e46e6cc575dcf01bd4f96465
|
data/baja.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_dependency "factory_girl_rails"
|
27
27
|
spec.add_dependency "rspec-rails"
|
28
|
+
spec.add_dependency "bundler", "~> 1.8"
|
28
29
|
|
29
|
-
spec.add_development_dependency "bundler", "~> 1.8"
|
30
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
31
|
end
|
data/lib/baja/version.rb
CHANGED
data/lib/baja.rb
CHANGED
@@ -12,17 +12,21 @@ module Baja
|
|
12
12
|
class Blast
|
13
13
|
@@definition_file_paths = %w(factories test/factories spec/factories).map { |path| File.expand_path(path) }
|
14
14
|
@@baja = JSON.parse(YAML.load_file('baja.yml').to_json,:symbolize_names => true)
|
15
|
-
def self.now!
|
15
|
+
def self.now!
|
16
16
|
unless Baja::Blast.baja[:factories].nil?
|
17
17
|
@@baja[:factories].each do |dew|
|
18
|
-
|
18
|
+
|
19
19
|
drink = IO.popen("bundle show #{dew}").readline.strip
|
20
|
+
unless dew[:dependencies].nil?
|
21
|
+
dew[:dependencies].each do |d|
|
22
|
+
load("#{drink}/#{d}")
|
23
|
+
end
|
24
|
+
end
|
20
25
|
@@definition_file_paths << Pathname.new("#{drink}/spec/factories").to_s
|
21
26
|
@@definition_file_paths.uniq!
|
22
27
|
puts @@definition_file_paths
|
23
28
|
end
|
24
29
|
end
|
25
|
-
puts "throwing it down!"
|
26
30
|
|
27
31
|
|
28
32
|
end
|
@@ -73,39 +77,7 @@ module FactoryLoad
|
|
73
77
|
def self.path
|
74
78
|
@@path
|
75
79
|
end
|
76
|
-
|
77
|
-
# class FactoryGirl::Syntax::Default::DSL
|
78
|
-
|
79
|
-
# def factory(name, options = {}, &block)
|
80
|
-
# puts "path: #{FactoryLoad.path}"
|
81
|
-
# options[:class] = name.to_s.gsub(/_list/,'') unless options.has_key?(:class)
|
82
|
-
|
83
|
-
# unless @namespace.nil?
|
84
|
-
# name = :"#{@namespace}__#{name.to_s}"
|
85
|
-
# else
|
86
|
-
# puts "else lol nut"
|
87
|
-
# Baja::Blast.baja.each do |dew|
|
88
|
-
# puts "dew: #{dew}"
|
89
|
-
# if FactoryLoad.path.include?(dew)
|
90
|
-
|
91
|
-
# name = :"#{dew}__#{name.to_s}"
|
92
|
-
# end
|
93
|
-
# end
|
94
|
-
# end
|
95
|
-
|
96
|
-
# puts name
|
97
|
-
# factory = FactoryGirl::Factory.new(name, options)
|
98
|
-
# proxy = FactoryGirl::DefinitionProxy.new(factory.definition)
|
99
|
-
# proxy.instance_eval(&block) if block_given?
|
100
|
-
|
101
|
-
# FactoryGirl.register_factory(factory)
|
102
|
-
|
103
|
-
# proxy.child_factories.each do |(child_name, child_options, child_block)|
|
104
|
-
# parent_factory = child_options.delete(:parent) || name
|
105
|
-
# factory(child_name, child_options.merge(parent: parent_factory), &child_block)
|
106
|
-
# end
|
107
|
-
# end
|
108
|
-
# end
|
80
|
+
|
109
81
|
end
|
110
82
|
|
111
83
|
|
@@ -125,18 +97,16 @@ end
|
|
125
97
|
unless @namespace.nil?
|
126
98
|
name = :"#{@namespace}__#{name.to_s}"
|
127
99
|
else
|
128
|
-
puts "
|
100
|
+
puts "#{Baja::Blast.class_variables}, #{Baja::Blast.baja}"
|
129
101
|
unless Baja::Blast.baja[:factories].nil?
|
130
|
-
Baja::Blast.baja[:factories].each do |dew|
|
131
|
-
puts "dew: #{dew}"
|
102
|
+
Baja::Blast.baja[:factories].each do |dew|
|
132
103
|
if FactoryLoad.path.include?(dew)
|
133
104
|
name = :"#{dew}__#{name.to_s}"
|
134
|
-
end
|
105
|
+
end
|
135
106
|
end
|
136
|
-
end
|
107
|
+
end
|
137
108
|
end
|
138
|
-
|
139
|
-
puts name
|
109
|
+
puts "name: #{name}"
|
140
110
|
factory = FactoryGirl::Factory.new(name, options)
|
141
111
|
proxy = FactoryGirl::DefinitionProxy.new(factory.definition)
|
142
112
|
proxy.instance_eval(&block) if block_given?
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Mock Rails.application.eager_load! and define some
|
2
|
+
# Rails models for use in specs.
|
3
|
+
class Rails
|
4
|
+
def self.application
|
5
|
+
self
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.eager_load!
|
9
|
+
@already_called ||= false
|
10
|
+
|
11
|
+
if !@already_called
|
12
|
+
Object.const_set('Sample', Class.new(ActiveRecord::Base))
|
13
|
+
|
14
|
+
Object.const_set('AnotherSample', Class.new(ActiveRecord::Base))
|
15
|
+
|
16
|
+
Object.const_set('YetAnotherSample', Class.new(ActiveRecord::Base))
|
17
|
+
|
18
|
+
Object.const_set('NoTableModel', Class.new(ActiveRecord::Base))
|
19
|
+
|
20
|
+
Object.const_set('EmptyModel', Class.new(ActiveRecord::Base))
|
21
|
+
|
22
|
+
@already_called = true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.env
|
27
|
+
'test'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module Helpers
|
32
|
+
def create_db
|
33
|
+
ActiveRecord::Migration.verbose = false
|
34
|
+
|
35
|
+
ActiveRecord::Schema.define(:version => 1) do
|
36
|
+
create_table 'samples', :force => true do |t|
|
37
|
+
t.string 'string'
|
38
|
+
t.text 'text'
|
39
|
+
t.integer 'integer'
|
40
|
+
t.float 'float'
|
41
|
+
t.decimal 'decimal'
|
42
|
+
t.datetime 'datetime'
|
43
|
+
t.time 'time'
|
44
|
+
t.date 'date'
|
45
|
+
t.binary 'binary'
|
46
|
+
t.boolean 'boolean'
|
47
|
+
t.datetime 'created_at', :null => false
|
48
|
+
t.datetime 'updated_at', :null => false
|
49
|
+
end
|
50
|
+
|
51
|
+
create_table 'another_samples', :force => true do |t|
|
52
|
+
t.string 'string'
|
53
|
+
t.text 'text'
|
54
|
+
t.integer 'integer'
|
55
|
+
t.float 'float'
|
56
|
+
t.decimal 'decimal'
|
57
|
+
t.datetime 'datetime'
|
58
|
+
t.time 'time'
|
59
|
+
t.date 'date'
|
60
|
+
t.binary 'binary'
|
61
|
+
t.boolean 'boolean'
|
62
|
+
t.datetime 'created_at', :null => false
|
63
|
+
t.datetime 'updated_at', :null => false
|
64
|
+
end
|
65
|
+
|
66
|
+
create_table 'yet_another_samples', :force => true do |t|
|
67
|
+
t.string 'string'
|
68
|
+
t.text 'text'
|
69
|
+
t.integer 'integer'
|
70
|
+
t.float 'float'
|
71
|
+
t.decimal 'decimal'
|
72
|
+
t.datetime 'datetime'
|
73
|
+
t.time 'time'
|
74
|
+
t.date 'date'
|
75
|
+
t.binary 'binary'
|
76
|
+
t.boolean 'boolean'
|
77
|
+
t.datetime 'created_at', :null => false
|
78
|
+
t.datetime 'updated_at', :null => false
|
79
|
+
end
|
80
|
+
|
81
|
+
create_table 'empty_models', force: true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def load_sample_data
|
86
|
+
Rails.application.eager_load!
|
87
|
+
|
88
|
+
Sample.create!
|
89
|
+
|
90
|
+
ChildSample.create!
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
|
3
|
+
factory :sample do
|
4
|
+
string 'string'
|
5
|
+
text 'text'
|
6
|
+
integer 42
|
7
|
+
float 3.14
|
8
|
+
decimal 2.72
|
9
|
+
datetime DateTime.parse('July 4, 1776 7:14pm UTC')
|
10
|
+
time Time.parse('3:15am UTC')
|
11
|
+
date Date.parse('November 19, 1863')
|
12
|
+
binary 'binary'
|
13
|
+
boolean false
|
14
|
+
created_at DateTime.parse('July 20, 1969 20:18 UTC')
|
15
|
+
updated_at DateTime.parse('November 10, 1989 4:20 UTC')
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baja
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Zuercher
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: factory_girl_rails
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.8'
|
49
|
-
type: :
|
49
|
+
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
@@ -93,7 +93,8 @@ files:
|
|
93
93
|
- lib/baja/version.rb
|
94
94
|
- lib/tasks/baja.rake
|
95
95
|
- spec/baja_spec.rb
|
96
|
-
- spec/factories/
|
96
|
+
- spec/factories/helper.rb
|
97
|
+
- spec/factories/sample.rb
|
97
98
|
- spec/spec_helper.rb
|
98
99
|
homepage: ''
|
99
100
|
licenses:
|