progne_tapera-rspec 0.3.2 → 1.0
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/CHANGELOG.md +5 -1
- data/Gemfile.lock +3 -3
- data/README.md +4 -2
- data/ROADMAP.md +5 -1
- data/lib/progne_tapera/rspec.rb +1 -3
- data/lib/progne_tapera/rspec/enum_code_shared_examples.rb +0 -93
- data/lib/progne_tapera/rspec/version.rb +1 -1
- data/progne_tapera-rspec.gemspec +2 -2
- metadata +2 -3
- data/lib/progne_tapera/rspec/code_attribute_shared_examples.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcf19582bae7928fc8f2d7a68a0eafbb86667391
|
4
|
+
data.tar.gz: 436d11fe5962d1289c6b41bb1a7fa1073069b359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ec2abf0e5849273ea3f9785ac34131f258eccda14f031201d20944cced0b0297aa33ee6cb8a557c7ef63cc6c335e16c3df0f13ae5c1321c1de7dc0b60b0cd8
|
7
|
+
data.tar.gz: 3395d1e3a949a8aea803fa5853c5a668d996f35bde646dad03b8ca4af60cfd5f39a5aaab9c95416439be92d98d1a652ff60832b24d220eea49cee2da01c2183c
|
data/CHANGELOG.md
CHANGED
@@ -17,4 +17,8 @@
|
|
17
17
|
5. Improve the Progne Tapera RSpec module to require the Progne Tapera Enum Config shared examples & the Progne Tapera Enum Code shared examples automatically
|
18
18
|
|
19
19
|
## v0.3.2
|
20
|
-
1. Improve the Ruby Gem Specification to depend on rspec v3.0 at runtime
|
20
|
+
1. Improve the Ruby Gem Specification to depend on [RSpec](https://github.com/rspec/rspec) v3.0 at runtime
|
21
|
+
|
22
|
+
## v1.0
|
23
|
+
1. Remove the Enum Code shared examples
|
24
|
+
2. Remove the Code Attribute shared examples
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
progne_tapera-rspec (0.3.
|
4
|
+
progne_tapera-rspec (0.3.2)
|
5
5
|
rspec (~> 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
diff-lcs (1.
|
10
|
+
diff-lcs (1.3)
|
11
11
|
rake (10.5.0)
|
12
12
|
rspec (3.5.0)
|
13
13
|
rspec-core (~> 3.5.0)
|
@@ -32,4 +32,4 @@ DEPENDENCIES
|
|
32
32
|
rake (~> 10.0)
|
33
33
|
|
34
34
|
BUNDLED WITH
|
35
|
-
1.
|
35
|
+
1.13.6
|
data/README.md
CHANGED
@@ -52,18 +52,20 @@ Create the RSpec examples for your model which has the #gender_code attribute (a
|
|
52
52
|
```ruby
|
53
53
|
# person.rb
|
54
54
|
class Person < ApplicationRecord
|
55
|
+
|
55
56
|
include Unidom::Common::ModelExtension
|
56
57
|
include ProgneTapera::EnumCode
|
57
58
|
|
58
59
|
code :gender # 这里将 #gender_code 字段和 Gender 枚举型集成起来。
|
60
|
+
|
59
61
|
end
|
60
62
|
|
61
63
|
# person_spec.rb
|
62
64
|
require 'rails_helper'
|
63
65
|
|
64
|
-
describe Person do
|
66
|
+
describe Person, type: :model do
|
65
67
|
|
66
|
-
context
|
68
|
+
context do
|
67
69
|
@person = Person.new
|
68
70
|
it_behaves_like 'ProgneTapera::EnumCode', @person, :gender, Gender
|
69
71
|
end
|
data/ROADMAP.md
CHANGED
@@ -17,4 +17,8 @@
|
|
17
17
|
5. Improve the Progne Tapera RSpec module to require the Progne Tapera Enum Config shared examples & the Progne Tapera Enum Code shared examples automatically
|
18
18
|
|
19
19
|
## v0.3.2
|
20
|
-
1. Improve the Ruby Gem Specification to depend on rspec v3.0 at runtime
|
20
|
+
1. Improve the Ruby Gem Specification to depend on [RSpec](https://github.com/rspec/rspec) v3.0 at runtime
|
21
|
+
|
22
|
+
## v1.0
|
23
|
+
1. Remove the Enum Code shared examples
|
24
|
+
2. Remove the Code Attribute shared examples
|
data/lib/progne_tapera/rspec.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'progne_tapera/rspec/version'
|
2
2
|
|
3
3
|
require 'progne_tapera/rspec/enum_code_shared_examples'
|
4
4
|
require 'progne_tapera/rspec/enum_config_shared_examples'
|
5
|
-
require 'progne_tapera/rspec/code_attribute_shared_examples'
|
6
5
|
|
7
6
|
module ProgneTapera
|
8
7
|
module RSpec
|
9
|
-
# Your code goes here...
|
10
8
|
end
|
11
9
|
end
|
@@ -45,96 +45,3 @@ shared_examples 'ProgneTapera::EnumCode' do |model, attribute_name, enum|
|
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# The shared examples are deprecated.
|
52
|
-
|
53
|
-
shared_examples 'enum code' do |code_count, enum_list|
|
54
|
-
|
55
|
-
warn 'The "enum code" shared examples is deprecated and will be removed since v1.0, please use "ProgneTapera::EnumConfig" instead.'
|
56
|
-
|
57
|
-
describe '.enum_name' do
|
58
|
-
it 'exists' do expect(described_class).to respond_to(:enum_name) end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '.item_defined?' do
|
62
|
-
it 'exists' do expect(described_class).to respond_to(:item_defined?) end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe '.add_item' do
|
66
|
-
it 'exists' do expect(described_class).to respond_to(:add_item) end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '.safe_add_item' do
|
70
|
-
it 'exists' do expect(described_class).to respond_to(:safe_add_item) end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe '.enum_constants' do
|
74
|
-
it 'exists' do expect(described_class).to respond_to(:enum_constants) end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '.all' do
|
78
|
-
it 'exists' do expect(described_class).to respond_to(:all) end
|
79
|
-
it 'returns all values' do expect(described_class.all).to be_present end
|
80
|
-
it "returns #{code_count} items" do expect(described_class.all.length).to eq(code_count) end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '.selected' do
|
84
|
-
it 'exists' do expect(described_class).to respond_to(:selected) end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '.each' do
|
88
|
-
it 'exists' do expect(described_class).to respond_to(:each) end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '.form_options' do
|
92
|
-
it 'exists' do expect(described_class).to respond_to(:form_options) end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '.enum' do
|
96
|
-
it 'exists' do expect(described_class).to respond_to(:enum) end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe '.overload_enum_i18n' do
|
100
|
-
it 'exists' do expect(described_class).to respond_to(:overload_enum_i18n) end
|
101
|
-
end
|
102
|
-
|
103
|
-
enum_list.each do |enum_item|
|
104
|
-
|
105
|
-
const_name = enum_item[:name].upcase
|
106
|
-
|
107
|
-
describe "::#{const_name}" do
|
108
|
-
before :each do @enum_item = described_class.const_get const_name end
|
109
|
-
it 'exists' do expect(@enum_item).to be_present end
|
110
|
-
enum_item.each do |key, value|
|
111
|
-
it "#{key.to_s.gsub('_', ' ')} is #{value}" do expect(@enum_item.send key.to_sym).to eq(value) end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe '.lookup' do
|
116
|
-
it "should be able to find the #{enum_item[:name]} enum item per #{enum_item[:code]}" do
|
117
|
-
found_enum_item = described_class.lookup enum_item[:code]
|
118
|
-
expect(found_enum_item).to be_present
|
119
|
-
expect(found_enum_item.code).to eq(enum_item[:code])
|
120
|
-
expect(found_enum_item.name).to eq(enum_item[:name])
|
121
|
-
expect(found_enum_item.localized_name).to eq(enum_item[:localized_name])
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
#enum_list.each do |enum_item|
|
128
|
-
# it ".lookup('#{enum_item[:code]}')" do expect(described_class.lookup enum_item[:code]).to eq(described_class.const_get enum_item[:name].upcase) end
|
129
|
-
#end
|
130
|
-
|
131
|
-
#view_collection_mappings = {} if view_collection_mappings.nil?
|
132
|
-
#view_collection_mappings[:view_collection] = code_count
|
133
|
-
#view_collection_mappings.each do |view_collection, expected_count|
|
134
|
-
# describe ".#{view_collection}" do
|
135
|
-
# it 'exists' do expect(described_class).to respond_to(view_collection) end
|
136
|
-
# it "returns #{expected_count} items" do expect(described_class.send(view_collection).length).to eq(expected_count) end
|
137
|
-
# end
|
138
|
-
#end
|
139
|
-
|
140
|
-
end
|
data/progne_tapera-rspec.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = [ 'lib' ]
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
31
|
-
spec.add_development_dependency 'rake',
|
32
|
-
spec.add_dependency
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_dependency 'rspec', '~> 3.0'
|
33
33
|
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progne_tapera-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,7 +74,6 @@ files:
|
|
74
74
|
- bin/console
|
75
75
|
- bin/setup
|
76
76
|
- lib/progne_tapera/rspec.rb
|
77
|
-
- lib/progne_tapera/rspec/code_attribute_shared_examples.rb
|
78
77
|
- lib/progne_tapera/rspec/enum_code_shared_examples.rb
|
79
78
|
- lib/progne_tapera/rspec/enum_config_shared_examples.rb
|
80
79
|
- lib/progne_tapera/rspec/version.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# The following shared examples are deprecated.
|
2
|
-
|
3
|
-
shared_examples 'code attribute' do |model, attribute_name, enum|
|
4
|
-
|
5
|
-
warn 'The "code attribute" shared examples is deprecated and will be removed since v1.0, please use "ProgneTapera::EnumCode" instead.'
|
6
|
-
|
7
|
-
describe "##{attribute_name}" do
|
8
|
-
it 'exists' do expect(model).to respond_to(attribute_name) end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "##{attribute_name}=" do
|
12
|
-
|
13
|
-
it 'exists' do expect(model).to respond_to("#{attribute_name}=") end
|
14
|
-
|
15
|
-
enum.each do |enum_item|
|
16
|
-
it "should be able to assign #{enum_item.inspect} and load by ##{attribute_name}" do
|
17
|
-
model.send "#{attribute_name}=", enum_item
|
18
|
-
expect(model.send attribute_name).to eq(enum_item)
|
19
|
-
end
|
20
|
-
it "should be able to assign #{enum_item.inspect} and load by ##{attribute_name}_code" do
|
21
|
-
model.send "#{attribute_name}=", enum_item
|
22
|
-
expect(model.send "#{attribute_name}_code").to eq(enum_item.code)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "##{attribute_name}_code" do
|
29
|
-
|
30
|
-
it 'exists' do expect(model).to respond_to("#{attribute_name}_code") end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "##{attribute_name}_code=" do
|
35
|
-
|
36
|
-
it 'exists' do expect(model).to respond_to("#{attribute_name}_code=") end
|
37
|
-
|
38
|
-
enum.each do |enum_item|
|
39
|
-
it "should be able to assign #{enum_item.code.inspect} and load by ##{attribute_name}" do
|
40
|
-
model.send "#{attribute_name}_code=", enum_item.code
|
41
|
-
expect(model.send attribute_name).to eq(enum_item)
|
42
|
-
end
|
43
|
-
it "should be able to assign #{enum_item.code.inspect} and load by ##{attribute_name}_code" do
|
44
|
-
model.send "#{attribute_name}_code=", enum_item.code
|
45
|
-
expect(model.send "#{attribute_name}_code").to eq(enum_item.code)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|