regressor 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/regressor/model_generator.rb +1 -1
- data/lib/model/expression.rb +25 -0
- data/lib/model/mongoid/database/field.rb +11 -2
- data/lib/model/mongoid/relation/belongs_to.rb +10 -2
- data/lib/model/mongoid/relation/embedded.rb +9 -2
- data/lib/model/mongoid/relation/has_many.rb +10 -2
- data/lib/model/mongoid/relation/has_one.rb +10 -2
- data/lib/model/mongoid_model.rb +1 -0
- data/lib/regressor/version.rb +1 -1
- data/lib/templates/model/mongoid/model_template.erb +5 -5
- metadata +30 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfdcab4e5984a23cebaa698fe65888d2e9133cac
|
4
|
+
data.tar.gz: 11333c03404c2d9744abc14eb11f317d3d0dec96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4acccb1b860384c10200da8c5c38da8f21700a6d7245866971de24d40be9aaf27c9ebfcc8d0fd863d51ad5d980e0d24a490c6cbd5b337d1b876e4da4ed012593
|
7
|
+
data.tar.gz: ed378bf13882af17043aec5f78ee22fa314802a9629a082d19b3fb7a1f7f00f8a0b60231c09c7768f30b2c80972f49029b234025f21928dfb96434df290ddf4f
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Regressor
|
2
|
+
module Model
|
3
|
+
class Expression
|
4
|
+
|
5
|
+
attr_accessor :subject, :expectation, :matcher, :matcher_expectation, :modification
|
6
|
+
|
7
|
+
def initialize(subject, expectation, matcher, matcher_expectation, modification = nil)
|
8
|
+
self.subject = subject
|
9
|
+
self.expectation = expectation
|
10
|
+
self.matcher = matcher
|
11
|
+
self.matcher_expectation = matcher_expectation
|
12
|
+
self.modification = modification
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
if self.modification.nil?
|
17
|
+
"it { #{self.subject}.#{self.expectation} #{self.matcher}(:#{self.matcher_expectation}) }"
|
18
|
+
else
|
19
|
+
"it { #{self.subject}.#{self.expectation} #{self.matcher}(:#{self.matcher_expectation}).#{self.modification} }"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -3,10 +3,19 @@ module Regressor
|
|
3
3
|
module Mongoid
|
4
4
|
module Database
|
5
5
|
module Field
|
6
|
+
|
7
|
+
def fields_as_string
|
8
|
+
fields.join("\n ")
|
9
|
+
end
|
10
|
+
|
6
11
|
def fields
|
7
12
|
@model.fields.keys.map do |field|
|
8
|
-
|
9
|
-
|
13
|
+
::Regressor::Model::Expression.new(:is_expected,
|
14
|
+
:to,
|
15
|
+
:have_field,
|
16
|
+
field,
|
17
|
+
"of_type(#{field_type(@model, field)})").to_s
|
18
|
+
end
|
10
19
|
end
|
11
20
|
|
12
21
|
private
|
@@ -3,11 +3,19 @@ module Regressor
|
|
3
3
|
module Mongoid
|
4
4
|
module Relation
|
5
5
|
module BelongsTo
|
6
|
+
|
7
|
+
def belongs_to_relations_as_string
|
8
|
+
belongs_to_relations.join("\n ")
|
9
|
+
end
|
10
|
+
|
6
11
|
def belongs_to_relations
|
7
12
|
@model.reflect_on_all_associations(:belongs_to).map(&:name).map do |relation|
|
8
|
-
|
9
|
-
|
13
|
+
::Regressor::Model::Expression.new(:is_expected,
|
14
|
+
:to,
|
15
|
+
:belong_to, relation).to_s
|
16
|
+
end
|
10
17
|
end
|
18
|
+
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
@@ -3,11 +3,18 @@ module Regressor
|
|
3
3
|
module Mongoid
|
4
4
|
module Relation
|
5
5
|
module Embedded
|
6
|
+
|
7
|
+
def embedded_relations_as_string
|
8
|
+
embedded_relations.join("\n ")
|
9
|
+
end
|
10
|
+
|
6
11
|
def embedded_relations
|
7
12
|
@model.embedded_relations.keys.map do |key|
|
8
13
|
macro = @model.embedded_relations[key].macro
|
9
|
-
|
10
|
-
|
14
|
+
::Regressor::Model::Expression.new(:is_expected,
|
15
|
+
:to,
|
16
|
+
embedded_type[macro], key).to_s
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
20
|
private
|
@@ -3,11 +3,19 @@ module Regressor
|
|
3
3
|
module Mongoid
|
4
4
|
module Relation
|
5
5
|
module HasMany
|
6
|
+
|
7
|
+
def has_many_relations_as_string
|
8
|
+
has_many_relations.join("\n ")
|
9
|
+
end
|
10
|
+
|
6
11
|
def has_many_relations
|
7
12
|
@model.reflect_on_all_associations(:has_many).map(&:name).map do |relation|
|
8
|
-
|
9
|
-
|
13
|
+
::Regressor::Model::Expression.new(:is_expected,
|
14
|
+
:to,
|
15
|
+
:have_many, relation).to_s
|
16
|
+
end
|
10
17
|
end
|
18
|
+
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
@@ -3,11 +3,19 @@ module Regressor
|
|
3
3
|
module Mongoid
|
4
4
|
module Relation
|
5
5
|
module HasOne
|
6
|
+
|
7
|
+
def has_one_relations_as_string
|
8
|
+
has_one_relations.join("\n ")
|
9
|
+
end
|
10
|
+
|
6
11
|
def has_one_relations
|
7
12
|
@model.reflect_on_all_associations(:has_one).map(&:name).map do |relation|
|
8
|
-
|
9
|
-
|
13
|
+
::Regressor::Model::Expression.new(:is_expected,
|
14
|
+
:to,
|
15
|
+
:have_one, relation).to_s
|
16
|
+
end
|
10
17
|
end
|
18
|
+
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/model/mongoid_model.rb
CHANGED
data/lib/regressor/version.rb
CHANGED
@@ -6,11 +6,11 @@ RSpec.describe <%= @model.model %>, regressor: true do
|
|
6
6
|
<%= @model.version_include %>
|
7
7
|
|
8
8
|
# === Relations ===
|
9
|
-
<%= @model.
|
10
|
-
<%= @model.
|
11
|
-
<%= @model.
|
12
|
-
<%= @model.
|
9
|
+
<%= @model.belongs_to_relations_as_string %>
|
10
|
+
<%= @model.has_one_relations_as_string %>
|
11
|
+
<%= @model.has_many_relations_as_string %>
|
12
|
+
<%= @model.embedded_relations_as_string %>
|
13
13
|
|
14
14
|
# === Database (Fields) ===
|
15
|
-
<%= @model.
|
15
|
+
<%= @model.fields_as_string %>
|
16
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regressor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erwin Schens
|
@@ -92,6 +92,34 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec-rails
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.3'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.3'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: mongoid
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 4.0.0
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 4.0.0
|
95
123
|
description: Regressor generates regression specs based on ActiveRecord models. Currently
|
96
124
|
relations, validations, attributes, and database indexes are supported.
|
97
125
|
email:
|
@@ -124,6 +152,7 @@ files:
|
|
124
152
|
- lib/model/active_record/validation/numericality.rb
|
125
153
|
- lib/model/active_record/validation/presence.rb
|
126
154
|
- lib/model/active_record_model.rb
|
155
|
+
- lib/model/expression.rb
|
127
156
|
- lib/model/mongoid/database/field.rb
|
128
157
|
- lib/model/mongoid/document/timestamp.rb
|
129
158
|
- lib/model/mongoid/document/version.rb
|