instructor 0.8.2 → 0.8.3
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: 1266100b7c4c4e77b42859999bdfa8ccdf6aea7d50a36a1ebcc54a871484dce5
|
4
|
+
data.tar.gz: 26f238022b77bc263a41df65b1478db3ebb334edff0e52c36d3908348a6a18cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2426f1ac926d5f1367658f225b76bad3acfc613e08f61d83a0ed4d771d57a94defe61cb91b2912f2bf93ec7679012b6eacdc7e4f7c9968d460996a15b92f85e7
|
7
|
+
data.tar.gz: 55850ea84817d2ad7f910048ecfc76e5d4a2ec392bb19022bc8de2116318649b877eb013c7c832c0325e7faa5b9d4fc12781bcf35fe5ccc994d948d51aafeb06
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.shared_examples_for "an instructor with a class collection attribute" do |method, collection|
|
4
|
+
subject(:define) { example_instructor_class.__send__(method, value) }
|
5
|
+
|
6
|
+
let(:value) { Faker::Lorem.word.to_sym }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(example_instructor_class).to receive(:define_default).and_call_original
|
10
|
+
allow(example_instructor_class).to receive(:define_attribute).and_call_original
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "defines value" do
|
14
|
+
let(:default) { Faker::Lorem.word }
|
15
|
+
|
16
|
+
shared_examples_for "an value is defined" do
|
17
|
+
it "adds to _values" do
|
18
|
+
expect { define }.to change { example_instructor_class.public_send(collection) }.from([]).to([ value ])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when no block is given" do
|
23
|
+
subject(:define) { example_instructor_class.__send__(method, value, default: default) }
|
24
|
+
|
25
|
+
it_behaves_like "an value is defined"
|
26
|
+
|
27
|
+
it "defines an static default" do
|
28
|
+
define
|
29
|
+
expect(example_instructor_class).to have_received(:define_default).with(value, static: default)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when a block is given" do
|
34
|
+
subject(:define) { example_instructor_class.__send__(method, value, default: default, &block) }
|
35
|
+
|
36
|
+
let(:block) do
|
37
|
+
->(_) { :block }
|
38
|
+
end
|
39
|
+
|
40
|
+
shared_examples_for "values are handed off to define_default" do
|
41
|
+
it "calls define_default" do
|
42
|
+
define
|
43
|
+
expect(example_instructor_class).to have_received(:define_default).with(value, static: default, &block)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with a static default" do
|
48
|
+
it_behaves_like "values are handed off to define_default"
|
49
|
+
end
|
50
|
+
|
51
|
+
context "without a static default" do
|
52
|
+
let(:default) { nil }
|
53
|
+
|
54
|
+
it_behaves_like "values are handed off to define_default"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "defines an attribute" do
|
60
|
+
define
|
61
|
+
expect(example_instructor_class).to have_received(:define_attribute).with(value)
|
62
|
+
end
|
63
|
+
end
|
data/lib/instructor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instructor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Garside
|
@@ -61,6 +61,8 @@ files:
|
|
61
61
|
- lib/instructor/custom_matchers/define_argument.rb
|
62
62
|
- lib/instructor/custom_matchers/define_attribute.rb
|
63
63
|
- lib/instructor/custom_matchers/define_option.rb
|
64
|
+
- lib/instructor/shared_examples.rb
|
65
|
+
- lib/instructor/shared_examples/an_instructor_with_a_class_collection_attribute.rb
|
64
66
|
- lib/instructor/shoulda_matcher_helper.rb
|
65
67
|
- lib/instructor/spec_helper.rb
|
66
68
|
- lib/instructor/version.rb
|