rspice 0.4.3 → 0.5.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 651dd42d3b2abbb823d0cf946f2de5a641873756939e1af717f5e1632c673386
|
4
|
+
data.tar.gz: 5c23a2024c0402571e8144c8c38e2ae08a228ffe47cf1b846a5fa9b59abe91dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7736fb620d39207483fbb5f8e243917d56cdec97d71d72702c40729b91d87057975164dbf94a55bfdcfa6d295b0d11faac3e16897c35a0a09f5dd7e06d97dde
|
7
|
+
data.tar.gz: 1f96d00331b565a1dfddf321067a6e89151f41c122a3c5a0b1698d60e4b570e04de09e9c09b8b1b8215ac1a298b912fe89b38b379f1d78cf3a7934e3d81e7ddd
|
@@ -1,36 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# TODO: Jank - this should use Method#parameters, not Method#arity
|
4
|
-
|
5
3
|
RSpec.shared_examples_for "a class pass method" do |method|
|
6
4
|
subject do
|
7
|
-
if
|
8
|
-
test_class.public_send(method, *arguments,
|
5
|
+
if accepts_block?
|
6
|
+
test_class.public_send(method, *arguments, &block)
|
9
7
|
else
|
10
8
|
test_class.public_send(method, *arguments)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
14
12
|
let(:test_class) { described_class }
|
15
|
-
|
16
|
-
let(:
|
17
|
-
let(:argument_arity) {
|
13
|
+
|
14
|
+
let(:method_parameters) { test_class.instance_method(:initialize).parameters }
|
15
|
+
let(:argument_arity) { method_parameters.map(&:first).select { |type| type.in?(%i[req opt]) }.length }
|
16
|
+
let(:option_keys) { method_parameters.select { |param| param.first.in?(%i[key keyreq]) }.map(&:last) }
|
17
|
+
let(:accepts_block?) { method_parameters.any? { |param| param.first == :block } }
|
18
18
|
|
19
19
|
let(:arguments) do
|
20
|
-
Array.new(argument_arity) { double }
|
20
|
+
Array.new(argument_arity) { double }.tap do |array|
|
21
|
+
array << options if options.present?
|
22
|
+
end
|
21
23
|
end
|
22
|
-
let(:options) {
|
24
|
+
let(:options) { option_keys.each_with_object({}) { |key, hash| hash[key] = Faker::Lorem.word } }
|
25
|
+
let(:block) { -> {} }
|
23
26
|
let(:instance) { instance_double(test_class) }
|
24
27
|
let(:output) { double }
|
25
28
|
|
26
29
|
before do
|
27
30
|
allow(instance).to receive(method).and_return(output)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
|
32
|
+
if accepts_block?
|
33
|
+
allow(test_class).to receive(:new).with(*arguments, &block).and_return(instance)
|
34
|
+
elsif arguments.any?
|
31
35
|
allow(test_class).to receive(:new).with(*arguments).and_return(instance)
|
36
|
+
else
|
37
|
+
allow(test_class).to receive(:new).with(no_args).and_return(instance)
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
35
41
|
it { is_expected.to eq output }
|
42
|
+
|
43
|
+
it "has matching parameters with initialize" do
|
44
|
+
expect(test_class.method(method).parameters).to eq test_class.instance_method(:initialize).parameters
|
45
|
+
end
|
36
46
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.shared_examples_for "a versioned spicerack gem" do
|
4
|
+
it "has a version number" do
|
5
|
+
expect(described_class::VERSION).to be_a String
|
6
|
+
expect(described_class::VERSION).not_to be_blank
|
7
|
+
expect(described_class::VERSION).to eq Spicerack::VERSION
|
8
|
+
end
|
9
|
+
end
|
data/lib/rspice/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/rspice/shared_context/with_an_example_descendant_class.rb
|
58
58
|
- lib/rspice/shared_examples.rb
|
59
59
|
- lib/rspice/shared_examples/a_class_pass_method.rb
|
60
|
+
- lib/rspice/shared_examples/a_versioned_spicerack_gem.rb
|
60
61
|
- lib/rspice/version.rb
|
61
62
|
homepage: https://www.freshly.com
|
62
63
|
licenses:
|