unidom-common-rspec 1.1 → 2.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 +4 -0
- data/README.md +6 -3
- data/ROADMAP.md +4 -0
- data/lib/unidom/common/rspec.rb +3 -1
- data/lib/unidom/common/rspec/scope_shared_examples.rb +24 -2
- data/lib/unidom/common/rspec/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08978e31550f24686da26c0a790887b6fe033aac165ec7db16bb4dcc5f56b1cb'
|
4
|
+
data.tar.gz: 78c99b4e6a005aa3313bc7c88ea88e32141ba4bd6d34981e6c90db7c9dd17328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0902ba335e02cd60910258edbe8a89fc488205a5983b4d2084b4971c935b89c12250cab02baeb6c120d2f132ead3a75d095eda3c8356f02ffd8501da25a130c3'
|
7
|
+
data.tar.gz: f928fc097ae1207abda9b12f497c425e0f43b6068bf9fab9b450b92f7526050e2eced2efb949bf1657564860e8f46a6831e4149d38bc3dc89d789e4698cfe395
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,12 +27,15 @@ gem 'unidom-common-rspec'
|
|
27
27
|
|
28
28
|
And then execute:
|
29
29
|
|
30
|
-
|
30
|
+
```shell
|
31
|
+
$ bundle
|
32
|
+
```
|
31
33
|
|
32
34
|
Or install it yourself as:
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
```shell
|
37
|
+
$ gem install unidom-common-rspec
|
38
|
+
```
|
36
39
|
|
37
40
|
|
38
41
|
## Usage
|
data/ROADMAP.md
CHANGED
data/lib/unidom/common/rspec.rb
CHANGED
@@ -6,19 +6,41 @@ shared_examples 'scope' do |scope_name, fixtures|
|
|
6
6
|
|
7
7
|
fixtures.select { |fixture| 'E'!=fixture[:count_diff] } .each do |fixture|
|
8
8
|
describe ".#{scope_name}(#{fixture[:args].blank? ? '' : (fixture[:args].map &:inspect).join(', ')})" do
|
9
|
+
|
9
10
|
before :each do
|
10
|
-
|
11
|
+
#@count = fixture[:args].present? ? described_class.send(scope_name, *fixture[:args]).count : described_class.send(scope_name).count
|
12
|
+
if fixture[:args].present?
|
13
|
+
if fixture[:args][0].is_a? Hash
|
14
|
+
@count = described_class.send(scope_name, **fixture[:args][0]).count
|
15
|
+
else
|
16
|
+
@count = described_class.send(scope_name, *fixture[:args]).count
|
17
|
+
end
|
18
|
+
else
|
19
|
+
@count = described_class.send(scope_name).count
|
20
|
+
end
|
11
21
|
@model_instances = []
|
12
22
|
fixture[:attributes_collection].each do |attributes| @model_instances << (described_class.create! attributes) end
|
13
23
|
end
|
24
|
+
|
14
25
|
after :each do
|
15
26
|
@count = 0
|
16
27
|
@model_instances.each do |model_instance| model_instance.destroy end if @model_instances.present?
|
17
28
|
end
|
29
|
+
|
18
30
|
it "has #{fixture[:count_diff]} added" do
|
19
|
-
|
31
|
+
if fixture[:args].present?
|
32
|
+
if fixture[:args][0].is_a? Hash
|
33
|
+
actual_count = described_class.send(scope_name, **fixture[:args][0]).count
|
34
|
+
else
|
35
|
+
actual_count = described_class.send(scope_name, *fixture[:args]).count
|
36
|
+
end
|
37
|
+
else
|
38
|
+
actual_count = described_class.send(scope_name).count
|
39
|
+
end
|
40
|
+
#actual_count = fixture[:args].present? ? described_class.send(scope_name, **fixture[:args][0]).count : described_class.send(scope_name).count
|
20
41
|
expect(actual_count).to eq(fixture[:count_diff]+@count)
|
21
42
|
end
|
43
|
+
|
22
44
|
end
|
23
45
|
end
|
24
46
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-common-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-rails
|
@@ -106,7 +106,7 @@ homepage: https://github.com/topbitdu/unidom-common-rspec
|
|
106
106
|
licenses:
|
107
107
|
- MIT
|
108
108
|
metadata: {}
|
109
|
-
post_install_message:
|
109
|
+
post_install_message:
|
110
110
|
rdoc_options: []
|
111
111
|
require_paths:
|
112
112
|
- lib
|
@@ -121,8 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
125
|
-
signing_key:
|
124
|
+
rubygems_version: 3.2.3
|
125
|
+
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Unidom Common RSpec 是为 Unidom Common 设计的基于 RSpec 的共享测试用例。
|
128
128
|
test_files: []
|