tamebou 0.0.5 → 0.0.6
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/.gitignore +1 -0
- data/README.md +121 -18
- data/lib/tamebou/version.rb +1 -1
- data/tamebou.gemspec +1 -1
- metadata +3 -5
- data/tamebou-0.0.1.gem +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 545cadc85fbfe8c8c2308c37ec56fb65f994935a
|
|
4
|
+
data.tar.gz: d4e6987aa32bdb4eb6e72fb419d5aa401057c9be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90762b35fccc3d225004da5e233bda8a8c86dcba06acbf41fecdc677fa33567e2f25a4ae0ac66b59707e1061eeb05e9a7864757786c66db9e309b65782b5d170
|
|
7
|
+
data.tar.gz: 19f1cdd9b1d9cfcf882607d9d88630581c7a2eb6d19d0f6dd36ab1e9307466d50ed9ee9c4eae5f35eb2a8cd64314349acd79dd65b27a7da2505d92d84e5f5819
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,39 +1,142 @@
|
|
|
1
1
|
# Tamebou
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Simple validation test generator for rails.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Tamebou generates a simple test for validation of rails.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Add this line to your application's Gemfile:
|
|
7
|
+
It read single-line `validates` methods and write test code according to templates. the default fomart is prepared for minitest and rspec.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
gem 'tamebou'
|
|
13
|
-
```
|
|
9
|
+
## cover validation options
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
- `exclusion`
|
|
12
|
+
- `inclusion`
|
|
13
|
+
- `length`
|
|
14
|
+
- `numericality`
|
|
15
|
+
- `presence`
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
For other validation options, Tamebou generates a template with placeholders.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Installation
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
```
|
|
22
|
+
$ gem install tamebou
|
|
23
|
+
```
|
|
22
24
|
|
|
23
25
|
## Usage
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
```rb
|
|
28
|
+
class Sample < ActiveRecord::Base
|
|
29
|
+
validates :name, length: { maximum: 32, minimum: 6 }, presence: true
|
|
30
|
+
validates :id, numericality: { only_integer: true, greater_than: 0 }
|
|
31
|
+
|
|
32
|
+
# ...
|
|
33
|
+
end
|
|
34
|
+
```
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
```rb
|
|
37
|
+
irb(main):001:0> Tamebou::Writer.new("../path/to/model/sample.rb").write
|
|
38
|
+
=============================================
|
|
39
|
+
class TestSample < MiniTest::Unit::TestCase
|
|
40
|
+
def setup
|
|
41
|
+
@sample = build(:sample)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def teardown
|
|
45
|
+
# you can some clean up code in this method
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_valid_name_values_in_terms_of_length
|
|
49
|
+
expected_values = ["aaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
|
|
50
|
+
expected_values.each do |expected_value|
|
|
51
|
+
@sample.name = expected_value
|
|
52
|
+
assert @sample.valid?
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_invalid_name_values_in_terms_of_length
|
|
57
|
+
invalid_values = ["aaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
|
|
58
|
+
invalid_values.each do |invalid_value|
|
|
59
|
+
@sample.name = invalid_value
|
|
60
|
+
assert_not @sample.valid?
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
=============================================
|
|
65
|
+
=============================================
|
|
66
|
+
class TestSample < MiniTest::Unit::TestCase
|
|
67
|
+
def setup
|
|
68
|
+
@sample = build(:sample)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def teardown
|
|
72
|
+
# you can some clean up code in this method
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_valid_name_values_in_terms_of_presence
|
|
76
|
+
expected_values = ["presence"]
|
|
77
|
+
expected_values.each do |expected_value|
|
|
78
|
+
@sample.name = expected_value
|
|
79
|
+
assert @sample.valid?
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_invalid_name_values_in_terms_of_presence
|
|
84
|
+
invalid_values = [nil]
|
|
85
|
+
invalid_values.each do |invalid_value|
|
|
86
|
+
@sample.name = invalid_value
|
|
87
|
+
assert_not @sample.valid?
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
=============================================
|
|
92
|
+
=============================================
|
|
93
|
+
class TestSample < MiniTest::Unit::TestCase
|
|
94
|
+
def setup
|
|
95
|
+
@sample = build(:sample)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def teardown
|
|
99
|
+
# you can some clean up code in this method
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_valid_id_values_in_terms_of_numericality
|
|
103
|
+
expected_values = [2, 1]
|
|
104
|
+
expected_values.each do |expected_value|
|
|
105
|
+
@sample.id = expected_value
|
|
106
|
+
assert @sample.valid?
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_invalid_id_values_in_terms_of_numericality
|
|
111
|
+
invalid_values = ["1.1", 2.0, 0]
|
|
112
|
+
invalid_values.each do |invalid_value|
|
|
113
|
+
@sample.id = invalid_value
|
|
114
|
+
assert_not @sample.valid?
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
=============================================
|
|
119
|
+
=> #<File:../path/to/model/sample.rb (closed)>
|
|
120
|
+
```
|
|
28
121
|
|
|
29
|
-
|
|
122
|
+
if you want to use template for RSpec:
|
|
30
123
|
|
|
31
|
-
|
|
124
|
+
```rb
|
|
125
|
+
Tamebou::Writer.new("../path/to/model/sample.rb", Tamebou::Writer::DefaultTemplate::RSPEC).write
|
|
126
|
+
```
|
|
32
127
|
|
|
33
|
-
|
|
128
|
+
if you want to use custom template:
|
|
34
129
|
|
|
35
|
-
|
|
130
|
+
```rb
|
|
131
|
+
Tamebou::Writer.new("../path/to/model/sample.rb", "/path/to/your_template").write
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Contributing
|
|
36
135
|
|
|
136
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
|
137
|
+
2. Commit your changes (`git commit -am 'Add some feature'`)
|
|
138
|
+
3. Push to the branch (`git push origin my-new-feature`)
|
|
139
|
+
4. Create a new Pull Request
|
|
37
140
|
|
|
38
141
|
## License
|
|
39
142
|
|
data/lib/tamebou/version.rb
CHANGED
data/tamebou.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ["bibro.pcg@gmail.com"]
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{simple validation test generator for rails}
|
|
13
|
-
spec.description = %q{
|
|
13
|
+
spec.description = %q{it read single-line `validates` methods and write test code according to templates. the default fomart is prepared for minitest and rspec.}
|
|
14
14
|
spec.homepage = "https://github.com/woshidan/tamebou"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tamebou
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- woshidan
|
|
@@ -52,9 +52,8 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '5.0'
|
|
55
|
-
description:
|
|
56
|
-
|
|
57
|
-
for minitest and rspec.
|
|
55
|
+
description: it read single-line `validates` methods and write test code according
|
|
56
|
+
to templates. the default fomart is prepared for minitest and rspec.
|
|
58
57
|
email:
|
|
59
58
|
- bibro.pcg@gmail.com
|
|
60
59
|
executables: []
|
|
@@ -82,7 +81,6 @@ files:
|
|
|
82
81
|
- lib/tamebou/writer.rb
|
|
83
82
|
- lib/templates/minitest.txt.erb
|
|
84
83
|
- lib/templates/rspec.txt.erb
|
|
85
|
-
- tamebou-0.0.1.gem
|
|
86
84
|
- tamebou.gemspec
|
|
87
85
|
homepage: https://github.com/woshidan/tamebou
|
|
88
86
|
licenses:
|
data/tamebou-0.0.1.gem
DELETED
|
Binary file
|