instructor 0.8.2 → 0.8.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e3514be63395d163fbbffaf7f7bbe99495e537bf8ac54ba3def4d521a034155
4
- data.tar.gz: 7e12e5505209f56e7d1040a3d095155c376c29bcb7afc713b6080897785cd215
3
+ metadata.gz: 1266100b7c4c4e77b42859999bdfa8ccdf6aea7d50a36a1ebcc54a871484dce5
4
+ data.tar.gz: 26f238022b77bc263a41df65b1478db3ebb334edff0e52c36d3908348a6a18cb
5
5
  SHA512:
6
- metadata.gz: 1ad95ed38f49b3ae1b3cb5ecdc96e907c90c879a0ef9143083beedf16df8e08c0a4f8bf7a64ea508c59738567ce90c921aebf9fd1b56caeb612dbd848dc43ebf
7
- data.tar.gz: 44dcf5d4a5ba8cf0a89fb2015b6fa7f5f13f8ac5ea4e379d7d70951056a604339cc44551e6fb399b3cc37ec2206e4ca6d8eaa450fcd8798434db4a80c31dc94c
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
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "shared_examples/an_instructor_with_a_class_collection_attribute"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "custom_matchers"
4
+ require_relative "shared_examples"
4
5
  require_relative "shoulda_matcher_helper"
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Instructor
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.8.2"
5
+ VERSION = "0.8.3"
6
6
  end
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.2
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