regressor 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/spec_regression_generator.rb +2 -15
- data/lib/generators/templates/regressor.rb +2 -2
- data/lib/generators/templates/spec_regression_template.rb.erb +4 -0
- data/lib/regression_model.rb +12 -1
- data/lib/regressor.rb +2 -1
- data/lib/regressor/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a9762ad61cc0732c76bdedc8cc81638bfd963ab
|
4
|
+
data.tar.gz: 889ef8f16687215eb57dac9ab8591d11121762fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83aecd15b83dc28a72c51e5d4c147b59505a4e5079c8a582035e5291bb66f0a793aa103dcee3f929a3a7c4afe1592e8dca0211f2bc680efb8b115201e83be3c3
|
7
|
+
data.tar.gz: ae53b7aa764d1a9431006f6a03584df75bb439c5d1288611a8252761c70d38c8ed4bd731cbdccc09a86fd5e9a0da178a1a3e6b4afa081e00fb1583a05166d7ee
|
@@ -1,22 +1,9 @@
|
|
1
1
|
require 'regression_model'
|
2
2
|
class SpecRegressionGenerator < Rails::Generators::Base
|
3
3
|
|
4
|
-
def all_models
|
5
|
-
# must eager load all the classes...
|
6
|
-
Dir.glob("#{Rails.root}/app/models/**/*.rb") do |model_path|
|
7
|
-
begin
|
8
|
-
require model_path
|
9
|
-
rescue
|
10
|
-
# ignore
|
11
|
-
end
|
12
|
-
end
|
13
|
-
# simply return them
|
14
|
-
ActiveRecord::Base.send(:subclasses)
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
4
|
def create_regression_files
|
19
|
-
|
5
|
+
Rails.application.eager_load!
|
6
|
+
ActiveRecord::Base.descendants.map(&:name).reject { |x| Regressor.configuration.excluded_models.include? x }.each do |model|
|
20
7
|
@model = RegressionModel.new(model)
|
21
8
|
create_file "#{Regressor.configuration.regression_path}/#{model.tableize.gsub("/", "_").singularize}_spec.rb", ERB.new(File.new(File.expand_path('templates/spec_regression_template.rb.erb', File.dirname(__FILE__))).read).result(binding)
|
22
9
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# If the regressor gem is inside a group
|
1
|
+
# If the regressor gem is inside a group wrap your initializer in
|
2
2
|
# if defined?(Regressor) do .. end
|
3
3
|
Regressor.configure do |config|
|
4
4
|
# Defines the path where the generated files will be placed
|
@@ -7,4 +7,4 @@ Regressor.configure do |config|
|
|
7
7
|
# Exclude Models for regression spec generation.
|
8
8
|
# Provide model names as String (e.g. 'User')
|
9
9
|
# config.excluded_models = []
|
10
|
-
end
|
10
|
+
end
|
data/lib/regression_model.rb
CHANGED
@@ -24,6 +24,17 @@ class RegressionModel
|
|
24
24
|
end.join("\n\t") rescue nil
|
25
25
|
end
|
26
26
|
|
27
|
+
def enums
|
28
|
+
enum_specs = []
|
29
|
+
@model.constantize.defined_enums.each do |enum_k, enum_v|
|
30
|
+
enum_values = enum_v.map do |key, value|
|
31
|
+
key
|
32
|
+
end
|
33
|
+
enum_specs << "it { is_expected.to define_enum_for(:#{enum_k}).with(#{enum_values})}"
|
34
|
+
end
|
35
|
+
enum_specs.compact.uniq.join("\n\t")
|
36
|
+
end
|
37
|
+
|
27
38
|
def validators
|
28
39
|
validator_specs = []
|
29
40
|
@model.constantize.validators.each do |validator|
|
@@ -62,7 +73,7 @@ class RegressionModel
|
|
62
73
|
|
63
74
|
def database_indexes
|
64
75
|
ActiveRecord::Base.connection.indexes(@model.tableize.gsub("/", "_")).map do |indexes|
|
65
|
-
|
76
|
+
"it { is_expected.to have_db_index #{indexes.columns}}"
|
66
77
|
end.flatten.join("\n\t") rescue nil
|
67
78
|
end
|
68
79
|
|
data/lib/regressor.rb
CHANGED
@@ -9,11 +9,12 @@ module Regressor
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class Configuration
|
12
|
-
attr_accessor :regression_path, :excluded_models
|
12
|
+
attr_accessor :regression_path, :excluded_models, :include_enums
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
@regression_path = 'spec/models/regression'
|
16
16
|
@excluded_models = []
|
17
|
+
@include_enums = true
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/regressor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regressor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erwin Schens
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: generator_spec
|
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'
|
83
97
|
description: Regressor generates regression specs based on ActiveRecord models. Currently
|
84
98
|
relations, validations, attributes, and database indexes are supported.
|
85
99
|
email:
|
@@ -118,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
132
|
version: '0'
|
119
133
|
requirements: []
|
120
134
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.4.6
|
122
136
|
signing_key:
|
123
137
|
specification_version: 4
|
124
138
|
summary: Regressor generates regression specs based on ActiveRecord models
|