regressor 0.5.1 → 0.5.2

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: 03c519eab78d13f7b2a196583b308fff03dc40db
4
- data.tar.gz: f5eabe9db02d521be8b1abe7d007f87397e70ca6
3
+ metadata.gz: 79c37f1dc82def55a51fbe5361c67c796bc323cf
4
+ data.tar.gz: 040a75add8d05a52af41705277be79aeec404d79
5
5
  SHA512:
6
- metadata.gz: e57a1c699f42c3c0e840d5c1822a14bba2ee7140efdd6ffdea35f1d601f9af3a17bd6e741bb6f82266eb215a997967305e66f61a0be1ebe847070e6d5da7bd92
7
- data.tar.gz: 44be0ca4abc8e8e73a09c675643a5e4a38bc80853bbc7a592d26856dbbb586d90d4d8d481214ce05346840a2ee39c3ff2e07e5c597100485068a559d35ff3040
6
+ metadata.gz: e756cccd3dccfdb1e0b96a7250d4c6eb2a70099934b517bb57b9d12b9bd3a50265c4452a7cd0da06c9e5f6992e9a597206c8f08a26f5e924c1858477477f3bd2
7
+ data.tar.gz: f6242b1742094db9396cfebf04cccb24a740237475e4a149ed766c2aada3b27c944b4521501120c0c6273e8aae368bd05d5a2aaee641fe3cfb27a4032f5519e7
@@ -37,6 +37,7 @@ module Regressor
37
37
  begin
38
38
  yield
39
39
  rescue Exception => e
40
+ puts e.backtrace
40
41
  puts "Cannot create model regression for #{model}"
41
42
  end
42
43
  end
@@ -0,0 +1,47 @@
1
+ module Regressor
2
+ module Model
3
+ module Mongoid
4
+ module Document
5
+ module Timestamp
6
+ def timestamp_includes
7
+ included_timestamp_modules.map do |module_included|
8
+ "it { is_expected.to #{timestamp_module(module_included)} }"
9
+ end.join("\n ")
10
+ end
11
+
12
+ private
13
+
14
+ def included_timestamp_modules
15
+ @model.included_modules.select do |module_included|
16
+ ['Mongoid::Timestamps::Created', 'Mongoid::Timestamps::Updated', 'Mongoid::Timestamps'].include? module_included.to_s
17
+ end
18
+ end
19
+
20
+ def timestamp_module(module_included)
21
+ case module_included.to_s
22
+ when 'Mongoid::Timestamps'
23
+ timestamped_document
24
+ when 'Mongoid::Timestamps::Created'
25
+ timestamped_document_with_created
26
+ when 'Mongoid::Timestamps::Updated'
27
+ timestamped_document_with_updated
28
+ end
29
+ end
30
+
31
+ def timestamped_document
32
+ 'be_timestamped_document'
33
+ end
34
+
35
+ def timestamped_document_with_created
36
+ "#{timestamped_document}.with(:created)"
37
+ end
38
+
39
+ def timestamped_document_with_updated
40
+ "#{timestamped_document}.with(:updated)"
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -3,6 +3,7 @@ require 'model/mongoid/relation/has_many'
3
3
  require 'model/mongoid/relation/has_one'
4
4
  require 'model/mongoid/relation/belongs_to'
5
5
  require 'model/mongoid/relation/embedded'
6
+ require 'model/mongoid/document/timestamp'
6
7
 
7
8
  module Regressor
8
9
  module Model
@@ -13,6 +14,7 @@ module Regressor
13
14
  include Mongoid::Relation::HasOne
14
15
  include Mongoid::Relation::BelongsTo
15
16
  include Mongoid::Relation::Embedded
17
+ include Mongoid::Document::Timestamp
16
18
 
17
19
  # === Attribute Accessors ===
18
20
  attr_accessor :model
@@ -1,3 +1,3 @@
1
1
  module Regressor
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -1,6 +1,8 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  RSpec.describe <%= @model.model %>, regressor: true do
4
+ # === Document ===
5
+ <%= @model.timestamp_includes %>
4
6
 
5
7
  # === Relations ===
6
8
  <%= @model.belongs_to_relations %>
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.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erwin Schens
@@ -155,6 +155,7 @@ files:
155
155
  - lib/model/active_record/validation/presence.rb
156
156
  - lib/model/active_record_model.rb
157
157
  - lib/model/mongoid/database/field.rb
158
+ - lib/model/mongoid/document/timestamp.rb
158
159
  - lib/model/mongoid/relation/belongs_to.rb
159
160
  - lib/model/mongoid/relation/embedded.rb
160
161
  - lib/model/mongoid/relation/has_many.rb