mimoco 0.3.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +13 -14
- data/.gitignore +3 -2
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/README.md +15 -3
- data/lib/mimoco/version.rb +3 -1
- data/lib/mimoco.rb +8 -128
- data/lib/mimoco_base.rb +48 -0
- data/lib/mimoco_controllers.rb +31 -0
- data/lib/mimoco_models.rb +36 -0
- data/lib/mimoco_valid.rb +39 -0
- data/mimoco.gemspec +1 -1
- data/test/internal/app/controllers/application_controller.rb +0 -1
- data/test/internal/app/controllers/orders_controller.rb +15 -26
- data/test/models/models_ignore_test.rb +34 -0
- data/test/models/models_test.rb +0 -34
- data/test/models/models_valid_test.rb +38 -0
- metadata +10 -7
- data/test/internal/app/views/orders/_order.json.jbuilder +0 -2
- data/test/internal/app/views/orders/index.json.jbuilder +0 -1
- data/test/internal/app/views/orders/show.json.jbuilder +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1796b354edbe98b20ea8aadfdf251b0c9729741df6960747cd68e678996d7451
|
4
|
+
data.tar.gz: d21b500b222ec94c01425d329bac0bbf2182492baaceffdd4d20a52d685576f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37dd105bd461a6538047de9c27f046e46881474abebf878094b5e6c8567a52e1210d8f5ad0a8ca4f7530f80d40c291f831ddb80e8c01b8fbfa9728a62099a2d6
|
7
|
+
data.tar.gz: 134215525e99400306ae22f85f28a021fa47a91a37f7dc74ee712080635f19a9396edfa01766be4f2d087be1273f1c36eaf3e7c39339587efac14c5fd3fb035a
|
data/.github/workflows/rake.yml
CHANGED
@@ -8,19 +8,18 @@ jobs:
|
|
8
8
|
strategy:
|
9
9
|
fail-fast: false
|
10
10
|
matrix:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
ruby: ["3.0", "3.2", 3.3]
|
12
|
+
gemfile:
|
13
|
+
- Gemfile
|
14
|
+
# - gemfiles/Gemfile.rails-7.1
|
15
|
+
runs-on: ubuntu-latest
|
15
16
|
|
16
17
|
steps:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
bundle
|
25
|
-
bundle update
|
26
|
-
- run: ${{ matrix.test_command }}
|
18
|
+
- uses: actions/checkout@v3
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby_version }}
|
23
|
+
bundler-cache: true
|
24
|
+
- name: Build and test with Rake
|
25
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.ruby-gemset
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rails-7.
|
1
|
+
rails-7.1
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.3.0
|
data/README.md
CHANGED
@@ -73,9 +73,21 @@ class ControllersTest < ActionDispatch::IntegrationTest
|
|
73
73
|
end
|
74
74
|
```
|
75
75
|
|
76
|
+
## Parameter
|
77
|
+
|
78
|
+
Rails magic adds a few additional methods to a model or a controller
|
79
|
+
(e.g. #column_headers).
|
80
|
+
|
81
|
+
MiMoCo ignores them, but future versions of Rails may add more.
|
82
|
+
They can be ignored by:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
check_models models, ignore_methods: magic_method
|
86
|
+
...
|
87
|
+
check_controllers controllers, ignore_methods: %i[magic2 magic3]
|
88
|
+
```
|
89
|
+
|
76
90
|
## Miscellaneous
|
77
91
|
|
78
92
|
Copyright (c) 2022-2023 Dittmar Krall (www.matiq.com),
|
79
|
-
released under the MIT license
|
80
|
-
|
81
|
-
* https://opensource.org/licenses/MIT
|
93
|
+
released under the [MIT license](https://opensource.org/licenses/MIT).
|
data/lib/mimoco/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Mimoco
|
4
|
-
VERSION = "0.
|
4
|
+
VERSION = "1.0.1" # 2024-02-16
|
5
|
+
# VERSION = "1.0.0" # 2023-12-06
|
6
|
+
# VERSION = "0.3.2" # 2023-04-25
|
5
7
|
# VERSION = "0.3.1" # 2022-12-25
|
6
8
|
# VERSION = "0.3.0" # 2022-02-11
|
7
9
|
# VERSION = "0.2.0" # 2022-01-06
|
data/lib/mimoco.rb
CHANGED
@@ -1,140 +1,20 @@
|
|
1
1
|
require "minitest"
|
2
|
+
require "mimoco_base"
|
3
|
+
require "mimoco_valid"
|
4
|
+
require "mimoco_models"
|
5
|
+
require "mimoco_controllers"
|
2
6
|
|
3
7
|
module Minitest
|
4
8
|
module Checks
|
5
|
-
def check_models(data)
|
6
|
-
Models.run data, self
|
9
|
+
def check_models(data, ignore_methods: nil)
|
10
|
+
Models.run data, self, ignore_methods
|
7
11
|
end
|
8
12
|
|
9
|
-
def check_controllers(data)
|
10
|
-
Controllers.run data, self
|
13
|
+
def check_controllers(data, ignore_methods: nil)
|
14
|
+
Controllers.run data, self, ignore_methods
|
11
15
|
end
|
12
16
|
|
13
17
|
class ValidMissingError < StandardError; end
|
14
|
-
|
15
|
-
class Base
|
16
|
-
attr_accessor :minitest, :klass, :klass_hash, :where
|
17
|
-
|
18
|
-
def self.run(data, minitest)
|
19
|
-
@minitest = minitest
|
20
|
-
data.each do |klass, hash|
|
21
|
-
@klass = klass
|
22
|
-
@klass_hash = hash
|
23
|
-
hash.each do |function, value|
|
24
|
-
@where = "#{klass}##{function}"
|
25
|
-
send(function, value)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.check_equal(expected, actual, msg = nil)
|
31
|
-
expected = expected.sort.map(&:to_sym)
|
32
|
-
actual = actual.sort.map(&:to_sym)
|
33
|
-
msg = msg ? "#{@where}: #{msg}" : @where
|
34
|
-
@minitest.assert_equal expected, actual, msg
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.check_no_nil(actual, msg = nil)
|
38
|
-
msg = msg ? "#{@where}: #{msg}" : @where
|
39
|
-
@minitest.refute_nil actual, msg
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class Models < Base
|
44
|
-
def self.valid(params)
|
45
|
-
valids([params])
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.valids(arr)
|
49
|
-
arr.each { |params| one_valid(params) }
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.invalid(params)
|
53
|
-
invalids([params])
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.invalids(arr)
|
57
|
-
arr.each { |params| one_invalid(params) }
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.class_methods(expected)
|
61
|
-
cls = @klass.methods(false).sort
|
62
|
-
cls.delete_if { |x| /^_/ =~ x }
|
63
|
-
cls.delete_if { |x| /^(after|before|find_by)_/ =~ x }
|
64
|
-
cls -= %i[column_headers attribute_type_decorations
|
65
|
-
attributes_to_define_after_schema_loads
|
66
|
-
default_scope_override defined_enums]
|
67
|
-
check_equal expected, cls
|
68
|
-
end
|
69
|
-
|
70
|
-
# call class methods; don't check result
|
71
|
-
def self.call_class_methods(methods)
|
72
|
-
methods.each { |meth|
|
73
|
-
check_no_nil @klass.send(meth), "<#{meth}> should return no nil"
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.public_methods(expected)
|
78
|
-
cls = @klass.public_instance_methods(false).sort
|
79
|
-
cls.delete_if { |x| /.*_associated_records_.*/ =~ x }
|
80
|
-
# validate_associated_records_for_projects]
|
81
|
-
check_equal expected, cls
|
82
|
-
end
|
83
|
-
|
84
|
-
# call_public_methods; don't check result
|
85
|
-
def self.call_public_methods(methods)
|
86
|
-
klass_params = @klass_hash[:valid] || @klass_hash[:valids]&.first
|
87
|
-
raise ValidMissingError unless klass_params
|
88
|
-
|
89
|
-
methods.each { |meth|
|
90
|
-
row, _msg = @klass.create(klass_params)
|
91
|
-
check_no_nil row.send(meth), "<#{meth}> should return no nil"
|
92
|
-
}
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.one_valid(params)
|
96
|
-
row, msg = create_model(params)
|
97
|
-
@minitest.assert row.valid?, "#{msg} #{row.errors.full_messages}"
|
98
|
-
end
|
99
|
-
|
100
|
-
def self.one_invalid(params)
|
101
|
-
row, msg = create_model(params)
|
102
|
-
@minitest.refute row.valid?, "#{msg} expected to be invalid"
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.create_model(params)
|
106
|
-
row = @klass.create(params)
|
107
|
-
[row, "#{@klass}: #{params}"]
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
class Controllers < Base
|
112
|
-
def self.respond_to(methods)
|
113
|
-
instance = @klass.new
|
114
|
-
methods.each { |method|
|
115
|
-
msg = "#{@klass} should respond to #{method}"
|
116
|
-
@minitest.assert instance.respond_to?(method), msg
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
|
-
def self.class_methods(expected)
|
121
|
-
cls = @klass.methods(false).sort
|
122
|
-
cls.delete_if { |x| /^_/ =~ x }
|
123
|
-
cls -= %i[__callbacks helpers_path middleware_stack]
|
124
|
-
check_equal expected, cls
|
125
|
-
end
|
126
|
-
|
127
|
-
def self.call_class_methods(methods)
|
128
|
-
methods.each { |meth|
|
129
|
-
check_no_nil @klass.send(meth), "<#{meth}> should return no nil"
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
|
-
def self.public_methods(expected)
|
134
|
-
cls = @klass.new.public_methods(false).sort
|
135
|
-
check_equal expected, cls
|
136
|
-
end
|
137
|
-
end
|
138
18
|
end
|
139
19
|
|
140
20
|
class Test
|
data/lib/mimoco_base.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "minitest"
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module Checks
|
5
|
+
class Base
|
6
|
+
attr_accessor :minitest, :klass, :klass_hash, :where
|
7
|
+
|
8
|
+
def self.run(data, minitest, ignore_methods)
|
9
|
+
@minitest = minitest
|
10
|
+
@ignore = [ignore_methods].flatten
|
11
|
+
data.each do |klass, hash|
|
12
|
+
@klass = klass
|
13
|
+
@klass_hash = hash
|
14
|
+
hash.each do |function, value|
|
15
|
+
@where = "#{klass}##{function}"
|
16
|
+
send(function, value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.check_equal(expected, actual, msg = nil)
|
22
|
+
expected = expected.sort.map(&:to_sym)
|
23
|
+
actual = actual.sort.map(&:to_sym)
|
24
|
+
msg = msg ? "#{@where}: #{msg}" : @where
|
25
|
+
@minitest.assert_equal expected, actual, msg
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.check_no_nil(actual, msg = nil)
|
29
|
+
msg = msg ? "#{@where}: #{msg}" : @where
|
30
|
+
@minitest.refute_nil actual, msg
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.delete_methods(which)
|
34
|
+
ignore2 = %i[attribute_aliases
|
35
|
+
attributes_to_define_after_schema_loads column_headers
|
36
|
+
default_scope_override]
|
37
|
+
# cls -= %i[__callbacks helpers_path middleware_stack]
|
38
|
+
# cls -= %i[attribute_type_decorations defined_enums]
|
39
|
+
methods = @klass.send(which, false).sort
|
40
|
+
methods.delete_if { |x| /^_/ =~ x }
|
41
|
+
methods.delete_if { |x| /^(after|before|find_by)_/ =~ x }
|
42
|
+
methods.delete_if { |x| /.*_associated_records_.*/ =~ x }
|
43
|
+
methods2 = @klass.superclass.send(which, false).sort
|
44
|
+
methods - methods2 - @ignore - ignore2
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "minitest"
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module Checks
|
5
|
+
class Controllers < Base
|
6
|
+
def self.respond_to(methods)
|
7
|
+
instance = @klass.new
|
8
|
+
methods.each { |method|
|
9
|
+
msg = "#{@klass} should respond to #{method}"
|
10
|
+
@minitest.assert instance.respond_to?(method), msg
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.class_methods(expected)
|
15
|
+
meths = delete_methods(:methods)
|
16
|
+
check_equal expected, meths
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.call_class_methods(methods)
|
20
|
+
methods.each { |meth|
|
21
|
+
check_no_nil @klass.send(meth), "<#{meth}> should return no nil"
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.public_methods(expected)
|
26
|
+
cls = @klass.new.public_methods(false).sort
|
27
|
+
check_equal expected, cls
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "minitest"
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module Checks
|
5
|
+
class Models < Base
|
6
|
+
def self.class_methods(expected)
|
7
|
+
meths = delete_methods(:methods)
|
8
|
+
check_equal expected, meths
|
9
|
+
end
|
10
|
+
|
11
|
+
# call class methods; don't check result
|
12
|
+
def self.call_class_methods(methods)
|
13
|
+
methods.each { |meth|
|
14
|
+
check_no_nil @klass.send(meth), "<#{meth}> should return no nil"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.public_methods(expected)
|
19
|
+
meths = delete_methods(:public_instance_methods)
|
20
|
+
check_equal expected, meths
|
21
|
+
end
|
22
|
+
|
23
|
+
# call_public_methods; don't check result
|
24
|
+
def self.call_public_methods(methods)
|
25
|
+
klass_params = @klass_hash[:valid] || @klass_hash[:valids]&.first
|
26
|
+
raise ValidMissingError unless klass_params
|
27
|
+
|
28
|
+
methods.each { |meth|
|
29
|
+
# row, _msg = @klass.create(klass_params)
|
30
|
+
row = @klass.new(klass_params)
|
31
|
+
check_no_nil row.send(meth), "<#{meth}> should return no nil"
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/mimoco_valid.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "minitest"
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module Checks
|
5
|
+
class Models < Base
|
6
|
+
def self.valid(params)
|
7
|
+
valids([params])
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.valids(arr)
|
11
|
+
arr.each { |params| one_valid(params) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.invalid(params)
|
15
|
+
invalids([params])
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.invalids(arr)
|
19
|
+
arr.each { |params| one_invalid(params) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.one_valid(params)
|
23
|
+
row, msg = create_model(params)
|
24
|
+
@minitest.assert row.valid?, "#{msg} #{row.errors.full_messages}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.one_invalid(params)
|
28
|
+
row, msg = create_model(params)
|
29
|
+
@minitest.refute row.valid?, "#{msg} expected to be invalid"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.create_model(params)
|
33
|
+
# row = @klass.create(params)
|
34
|
+
row = @klass.new(params)
|
35
|
+
[row, "#{@klass}: #{params}"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/mimoco.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = "Some testing for models and controllers"
|
11
11
|
s.authors = ["Dittmar Krall"]
|
12
12
|
s.email = ["dittmar.krall@matiq.com"]
|
13
|
-
s.homepage = "
|
13
|
+
s.homepage = "https://github.com/matique/mimoco"
|
14
14
|
s.license = "MIT"
|
15
15
|
|
16
16
|
s.metadata["source_code_uri"] = "https://github.com/matique/mimoco"
|
@@ -5,12 +5,12 @@ class OrdersController < ApplicationController
|
|
5
5
|
"just for testing purposes"
|
6
6
|
end
|
7
7
|
|
8
|
-
# GET /orders
|
8
|
+
# GET /orders
|
9
9
|
def index
|
10
10
|
@orders = Order.all
|
11
11
|
end
|
12
12
|
|
13
|
-
# GET /orders/1
|
13
|
+
# GET /orders/1
|
14
14
|
def show
|
15
15
|
end
|
16
16
|
|
@@ -23,41 +23,30 @@ class OrdersController < ApplicationController
|
|
23
23
|
def edit
|
24
24
|
end
|
25
25
|
|
26
|
-
# POST /orders
|
26
|
+
# POST /orders
|
27
27
|
def create
|
28
28
|
@order = Order.new(order_params)
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
else
|
35
|
-
format.html { render :new, status: :unprocessable_entity }
|
36
|
-
format.json { render json: @order.errors, status: :unprocessable_entity }
|
37
|
-
end
|
30
|
+
if @order.save
|
31
|
+
redirect_to @order, notice: "Order was successfully created."
|
32
|
+
else
|
33
|
+
render :new, status: :unprocessable_entity
|
38
34
|
end
|
39
35
|
end
|
40
36
|
|
41
|
-
# PATCH/PUT /orders/1
|
37
|
+
# PATCH/PUT /orders/1
|
42
38
|
def update
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
else
|
48
|
-
format.html { render :edit, status: :unprocessable_entity }
|
49
|
-
format.json { render json: @order.errors, status: :unprocessable_entity }
|
50
|
-
end
|
39
|
+
if @order.update(order_params)
|
40
|
+
redirect_to @order, notice: "Order was successfully updated.", status: :see_other
|
41
|
+
else
|
42
|
+
render :edit, status: :unprocessable_entity
|
51
43
|
end
|
52
44
|
end
|
53
45
|
|
54
|
-
# DELETE /orders/1
|
46
|
+
# DELETE /orders/1
|
55
47
|
def destroy
|
56
|
-
@order.destroy
|
57
|
-
|
58
|
-
format.html { redirect_to orders_url, notice: "Order was successfully destroyed." }
|
59
|
-
format.json { head :no_content }
|
60
|
-
end
|
48
|
+
@order.destroy!
|
49
|
+
redirect_to orders_url, notice: "Order was successfully destroyed.", status: :see_other
|
61
50
|
end
|
62
51
|
|
63
52
|
private
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "mimoco"
|
3
|
+
|
4
|
+
class ModelsIgnoreTest < Minitest::Test
|
5
|
+
def test_no_ignore_class_methods
|
6
|
+
models = {Order => {class_methods: %i[class_method]}}
|
7
|
+
check_models models
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_ignore_class_methods
|
11
|
+
models = {Order => {class_methods: %i[]}}
|
12
|
+
check_models models, ignore_methods: :class_method
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_no_ignore_public_methods
|
16
|
+
models = {Order => {public_methods: %i[public_method]}}
|
17
|
+
check_models models
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_ignore_public_methods
|
21
|
+
models = {Order => {public_methods: %i[]}}
|
22
|
+
check_models models, ignore_methods: :public_method
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_controllers_no_ignore_class_methods
|
26
|
+
controllers = {OrdersController => {class_methods: %i[class_method]}}
|
27
|
+
check_controllers controllers
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_controllers_ignore_class_methods
|
31
|
+
controllers = {OrdersController => {class_methods: %i[]}}
|
32
|
+
check_controllers controllers, ignore_methods: :class_method
|
33
|
+
end
|
34
|
+
end
|
data/test/models/models_test.rb
CHANGED
@@ -2,40 +2,6 @@ require "test_helper"
|
|
2
2
|
require "mimoco"
|
3
3
|
|
4
4
|
class ModelsTest < Minitest::Test
|
5
|
-
def test_valid
|
6
|
-
models = {Order => {valid: {name: "Name", qty: 123}}}
|
7
|
-
check_models models
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_valids
|
11
|
-
models = {
|
12
|
-
Order => {
|
13
|
-
valids: [
|
14
|
-
{name: "Name", qty: 123},
|
15
|
-
{qty: 123}
|
16
|
-
]
|
17
|
-
}
|
18
|
-
}
|
19
|
-
check_models models
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_invalid
|
23
|
-
models = {Order => {invalid: {qty: :abc}}}
|
24
|
-
check_models models
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_invalids
|
28
|
-
models = {
|
29
|
-
Order => {
|
30
|
-
invalids: [
|
31
|
-
{qty: :abc},
|
32
|
-
{name: "Name", qty: :def}
|
33
|
-
]
|
34
|
-
}
|
35
|
-
}
|
36
|
-
check_models models
|
37
|
-
end
|
38
|
-
|
39
5
|
def test_class_methods
|
40
6
|
models = {Order => {class_methods: %i[class_method]}}
|
41
7
|
check_models models
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "mimoco"
|
3
|
+
|
4
|
+
class ModelsTest < Minitest::Test
|
5
|
+
def test_valid
|
6
|
+
models = {Order => {valid: {name: "Name", qty: 123}}}
|
7
|
+
check_models models
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_valids
|
11
|
+
models = {
|
12
|
+
Order => {
|
13
|
+
valids: [
|
14
|
+
{name: "Name", qty: 123},
|
15
|
+
{qty: 123}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
}
|
19
|
+
check_models models
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_invalid
|
23
|
+
models = {Order => {invalid: {qty: :abc}}}
|
24
|
+
check_models models
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_invalids
|
28
|
+
models = {
|
29
|
+
Order => {
|
30
|
+
invalids: [
|
31
|
+
{qty: :abc},
|
32
|
+
{name: "Name", qty: :def}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
}
|
36
|
+
check_models models
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mimoco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: combustion
|
@@ -69,6 +69,10 @@ files:
|
|
69
69
|
- Rakefile
|
70
70
|
- lib/mimoco.rb
|
71
71
|
- lib/mimoco/version.rb
|
72
|
+
- lib/mimoco_base.rb
|
73
|
+
- lib/mimoco_controllers.rb
|
74
|
+
- lib/mimoco_models.rb
|
75
|
+
- lib/mimoco_valid.rb
|
72
76
|
- mimoco.gemspec
|
73
77
|
- test/controllers/controllers_test.rb
|
74
78
|
- test/controllers/orders_controller_test.rb
|
@@ -78,20 +82,19 @@ files:
|
|
78
82
|
- test/internal/app/models/order.rb
|
79
83
|
- test/internal/app/views/orders/_form.html.erb
|
80
84
|
- test/internal/app/views/orders/_order.html.erb
|
81
|
-
- test/internal/app/views/orders/_order.json.jbuilder
|
82
85
|
- test/internal/app/views/orders/edit.html.erb
|
83
86
|
- test/internal/app/views/orders/index.html.erb
|
84
|
-
- test/internal/app/views/orders/index.json.jbuilder
|
85
87
|
- test/internal/app/views/orders/new.html.erb
|
86
88
|
- test/internal/app/views/orders/show.html.erb
|
87
|
-
- test/internal/app/views/orders/show.json.jbuilder
|
88
89
|
- test/internal/config/database.yml
|
89
90
|
- test/internal/config/routes.rb
|
90
91
|
- test/internal/db/migrate/20141016161801_create_orders.rb
|
91
92
|
- test/internal/db/schema.rb
|
93
|
+
- test/models/models_ignore_test.rb
|
92
94
|
- test/models/models_test.rb
|
95
|
+
- test/models/models_valid_test.rb
|
93
96
|
- test/test_helper.rb
|
94
|
-
homepage:
|
97
|
+
homepage: https://github.com/matique/mimoco
|
95
98
|
licenses:
|
96
99
|
- MIT
|
97
100
|
metadata:
|
@@ -111,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
114
|
- !ruby/object:Gem::Version
|
112
115
|
version: '0'
|
113
116
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.5.6
|
115
118
|
signing_key:
|
116
119
|
specification_version: 4
|
117
120
|
summary: 'Mimoco: some minitests for models and controllers'
|
@@ -1 +0,0 @@
|
|
1
|
-
json.array! @orders, partial: "orders/order", as: :order
|
@@ -1 +0,0 @@
|
|
1
|
-
json.partial! "orders/order", order: @order
|