unidom-common-rspec 1.1 → 2.0

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
  SHA256:
3
- metadata.gz: 5755de5fe32c294c67ba6796498142cdeee98092524661746f56c90e8c97924e
4
- data.tar.gz: 152301ee160e24f78b4bcf0f09b1cddce5f274487310191d105ccd0357537837
3
+ metadata.gz: '08978e31550f24686da26c0a790887b6fe033aac165ec7db16bb4dcc5f56b1cb'
4
+ data.tar.gz: 78c99b4e6a005aa3313bc7c88ea88e32141ba4bd6d34981e6c90db7c9dd17328
5
5
  SHA512:
6
- metadata.gz: 48c808e177675177d5af581b2804e7dfb5c5815da73c5c5ae82f5a95adb23ba7ec38592dae82feb7acd38a8b4eb33abaaf0a992f6127307006b1a90f6293555a
7
- data.tar.gz: dddfea95c685f0d4ed9e2737bd5ec4caf9c4b3d8290bc761d64acc127245eb14be0f61df17f6944a1f6ea8bcbd8f15b57a871e6d608078388aa6344011dfe79c
6
+ metadata.gz: '0902ba335e02cd60910258edbe8a89fc488205a5983b4d2084b4971c935b89c12250cab02baeb6c120d2f132ead3a75d095eda3c8356f02ffd8501da25a130c3'
7
+ data.tar.gz: f928fc097ae1207abda9b12f497c425e0f43b6068bf9fab9b450b92f7526050e2eced2efb949bf1657564860e8f46a6831e4149d38bc3dc89d789e4698cfe395
data/CHANGELOG.md CHANGED
@@ -78,3 +78,7 @@
78
78
  ## v1.1
79
79
 
80
80
  1. Improved the Ruby Gem Specification to depend on Rake v13.0, & RSpec v3.9
81
+
82
+ ## v2.0
83
+
84
+ 1. Improved the Scope shared examples for Ruby 3.0
data/README.md CHANGED
@@ -27,12 +27,15 @@ gem 'unidom-common-rspec'
27
27
 
28
28
  And then execute:
29
29
 
30
- $ bundle
30
+ ```shell
31
+ $ bundle
32
+ ```
31
33
 
32
34
  Or install it yourself as:
33
35
 
34
- $ gem install unidom-common-rspec
35
-
36
+ ```shell
37
+ $ gem install unidom-common-rspec
38
+ ```
36
39
 
37
40
 
38
41
  ## Usage
data/ROADMAP.md CHANGED
@@ -78,3 +78,7 @@
78
78
  ## v1.1
79
79
 
80
80
  1. Improve the Ruby Gem Specification to depend on Rake v13.0, & RSpec v4.0
81
+
82
+ ## v2.0
83
+
84
+ 1. Improve the Scope shared examples for Ruby 3.0
@@ -1,4 +1,6 @@
1
- require "unidom/common/rspec/version"
1
+ require 'rspec/core'
2
+
3
+ require 'unidom/common/rspec/version'
2
4
 
3
5
  require 'unidom/common/rspec/assert_present_shared_examples'
4
6
 
@@ -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
- @count = fixture[:args].present? ? described_class.send(scope_name, *fixture[:args]).count : described_class.send(scope_name).count
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
- actual_count = fixture[:args].present? ? described_class.send(scope_name, *fixture[:args]).count : described_class.send(scope_name).count
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
 
@@ -1,7 +1,7 @@
1
1
  module Unidom
2
2
  module Common
3
3
  module RSpec
4
- VERSION = '1.1'
4
+ VERSION = '2.0'
5
5
  end
6
6
  end
7
7
  end
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: '1.1'
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: 2020-04-28 00:00:00.000000000 Z
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.1.2
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: []