rspec-sleeping_king_studios 2.1.0 → 2.1.1.rc.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 +18 -0
- data/DEVELOPMENT.md +11 -2
- data/README.md +46 -4
- data/lib/rspec/sleeping_king_studios/concerns/focus_examples.rb +70 -0
- data/lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb +15 -7
- data/lib/rspec/sleeping_king_studios/matchers/built_in/respond_to.rb +2 -0
- data/lib/rspec/sleeping_king_studios/version.rb +3 -3
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1649e39464b7d6dd962aeb7c4de50d2aea52c130
|
4
|
+
data.tar.gz: 9617e65ae0caf7522408525bc682ce07caabd7e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d57031970580753d83a7310cbead9b82bee16e3fd81e6e0141bdeb6df5c5fa18a2978c225ffd49f595e75b7bd1349180cd2f3acfa59e9ef062e871bf9e7034c
|
7
|
+
data.tar.gz: fa0dd5f37ac2f6e97c0b8fe82b0fb656e82ee5ab0160b3779ba5ab77c0250a5305a34fbed34b272345b46396650b9a2d4d6831bf2fc34a659985b0108e177e0f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.1
|
4
|
+
|
5
|
+
### Concerns
|
6
|
+
|
7
|
+
#### `FocusExamples` Concern
|
8
|
+
|
9
|
+
Added module RSpec::SleepingKingStudios::Concerns::FocusExamples to create a shorthand for quickly focusing/skipping included shared example groups, e.g. `include_examples '...'` => `finclude_examples '...'`.
|
10
|
+
|
11
|
+
#### `WrapExamples` Concern
|
12
|
+
|
13
|
+
Ensured correct behavior when passing an empty keywords hash to a method with optional arguments.
|
14
|
+
|
15
|
+
### Matchers
|
16
|
+
|
17
|
+
#### `respond_to` Matcher
|
18
|
+
|
19
|
+
Added methods `#with_any_keywords` and `#and_any_keywords`, which are both equivalent to the existing `#with_arbitrary_keywords`.
|
20
|
+
|
3
21
|
## 2.1.0
|
4
22
|
|
5
23
|
### Concerns
|
data/DEVELOPMENT.md
CHANGED
@@ -2,8 +2,11 @@
|
|
2
2
|
|
3
3
|
## Tasks
|
4
4
|
|
5
|
+
- Resolve Aruba deprecation warnings.
|
6
|
+
|
5
7
|
### Planned Features
|
6
8
|
|
9
|
+
- Add `#with_any_keywords` alias to RespondToMatcher.
|
7
10
|
- Add #have_constant matcher.
|
8
11
|
- Add #have_predicate matcher.
|
9
12
|
- Add shared examples for 'should have constant', 'should have immutable constant'
|
@@ -11,6 +14,8 @@
|
|
11
14
|
- Add shared examples for 'should not have reader/writer'
|
12
15
|
- Add shared examples for #belongs_to, #has_one, #has_many, #embedded_in, #embeds_one, #embeds_many.
|
13
16
|
- Add shared examples for core ActiveModel validations.
|
17
|
+
- Add allow/expect(object).to alias_method(:my_method).to(:other_method)
|
18
|
+
- Add allow/expect(object).to delegate(:my_method).to(other_object[, :other_method])
|
14
19
|
|
15
20
|
### Maintenance
|
16
21
|
|
@@ -18,12 +23,16 @@
|
|
18
23
|
- Refactor #respond_to, #be_constructible to use RSpec 3 method reflection.
|
19
24
|
- Revisit failure messages for #respond_to, #be_constructible.
|
20
25
|
- Pare down Cucumber features for matchers - repurpose as documentation/examples only.
|
21
|
-
-
|
26
|
+
- Ensure behavior of `#have_reader`, `#have_writer`, `#have_property` is consistent (non-compatible; needs version 3.0).
|
22
27
|
|
23
28
|
### Icebox
|
24
29
|
|
25
30
|
- Add alt doc test formatter - --format=list ? --format=documentation-list ?
|
26
31
|
- Prints full expanded example name for each example
|
27
|
-
- Add minimal test formatter - --format=smoke ? --format=librarian ?
|
32
|
+
- Add minimal test formatter - --format=smoke ? --format=librarian ? --format=quiet ?
|
28
33
|
- Prints nothing for examples
|
29
34
|
- Suppress STDOUT output? As configurable option for any formatted?
|
35
|
+
- Add DSL for shared_examples-heavy specs?
|
36
|
+
- #should(name) => include_examples "should #{name}"
|
37
|
+
- #with(name) => wrap_context "with #{name}"
|
38
|
+
- #when(name) => wrap_context "when #{name}"
|
data/README.md
CHANGED
@@ -46,6 +46,45 @@ This option is used with the RSpec matcher examples (see Examples, below), and d
|
|
46
46
|
|
47
47
|
RSpec::SleepingKingStudios defines a few concerns that can be included in or extended into modules or example groups for additional functionality.
|
48
48
|
|
49
|
+
### Focus Examples
|
50
|
+
|
51
|
+
require 'rspec/sleeping_king_studios/concerns/focus_examples'
|
52
|
+
|
53
|
+
RSpec.describe String do
|
54
|
+
extend RSpec::SleepingKingStudios::Concerns::WrapExamples
|
55
|
+
|
56
|
+
shared_examples 'should be a greeting' do
|
57
|
+
it { expect(salutation).to be =~ /greeting/i }
|
58
|
+
end # shared_examples
|
59
|
+
|
60
|
+
shared_examples 'should greet the user by name' do
|
61
|
+
it { expect(salutation).to match user.name }
|
62
|
+
end # shared_examples
|
63
|
+
|
64
|
+
let(:salutation) { 'Greetings, programs!' }
|
65
|
+
|
66
|
+
# Focused example groups are always run when config.filter_run :focus is
|
67
|
+
# set to true.
|
68
|
+
finclude_examples 'should be a greeting'
|
69
|
+
|
70
|
+
# Skipped example groups are marked as pending and never run.
|
71
|
+
xinclude_examples 'should greet the user by name'
|
72
|
+
end # describe
|
73
|
+
|
74
|
+
A shorthand for focusing or skipping included shared example groups with a single keystroke, e.g. `include_examples '...'` => `finclude_examples '...'`.
|
75
|
+
|
76
|
+
A simplified syntax for re-using shared context or examples without having to explicitly wrap them in `describe` blocks or allowing memoized values or callbacks to change the containing context. In the example above, if the programmer had used the standard `include_context` instead, the first expectation would have failed, as the value of :quote would have been overwritten.
|
77
|
+
|
78
|
+
*Important Note:* Do not use these methods with example groups that have side effects, e.g. that define a memoized `#let` helper or a `#before` block that is intended to modify the behavior of sibling examples. Wrapping the example group in a `describe` block breaks that relationship. Best practice is to use the `#wrap_examples` method to safely encapsulate example groups with side effects, and the `#fwrap_examples` method to automatically focus such groups.
|
79
|
+
|
80
|
+
#### `::finclude_examples`
|
81
|
+
|
82
|
+
(also `::finclude_context`) A shortcut for focusing the example group by wrapping it in a `describe` block, similar to the built-in `fit` and `fdescribe` methods.
|
83
|
+
|
84
|
+
#### `::xinclude_examples`
|
85
|
+
|
86
|
+
(also `::xinclude_context`) A shortcut for skipping the example group by wrapping it in a `describe` block, similar to the built-in `xit` and `xdescribe` methods.
|
87
|
+
|
49
88
|
### Shared Example Groups
|
50
89
|
|
51
90
|
require 'rspec/sleeping_king_studios/concerns/shared_example_group'
|
@@ -196,15 +235,18 @@ Now has additional chaining functionality to validate the number of arguments ac
|
|
196
235
|
expect(instance).to respond_to(:foo).with(2..3).arguments.and_a_block
|
197
236
|
|
198
237
|
# With keyword arguments.
|
199
|
-
expect(instance).to respond_to(:foo).
|
238
|
+
expect(instance).to respond_to(:foo).with_keywords(:bar, :baz)
|
239
|
+
|
240
|
+
# With both arguments and keywords.
|
241
|
+
expect(instance).to respond_to(:foo).with(2).arguments.and_keywords(:bar, :baz)
|
200
242
|
|
201
243
|
**Chaining:**
|
202
244
|
|
203
|
-
* **`#with`:** Expects at most one Integer or Range argument, and zero or more Symbol arguments corresponding to optional keywords. Verifies that the method accepts that keyword, or has a variadic keyword of the form `**
|
245
|
+
* **`#with`:** Expects at most one Integer or Range argument, and zero or more Symbol arguments corresponding to optional keywords. Verifies that the method accepts that keyword, or has a variadic keyword of the form `**kwargs`. As of 2.1.0 and required keywords, verifies that all required keywords are provided.
|
204
246
|
* **`#with_unlimited_arguments`:** (also `and_unlimited_arguments`) No parameters. Verifies that the method accepts any number of arguments via a variadic argument of the form `*args`.
|
205
247
|
* **`#with_a_block`:** (also `and_a_block`) No parameters. Verifies that the method requires a block argument of the form `&my_argument`. _Important note:_ A negative result _does not_ mean the method cannot accept a block, merely that it does not require one. Also, _does not_ check whether the block is called or yielded.
|
206
|
-
* **`#with_keywords`:** (also `and_keywords`) Expects one or more String or Symbol arguments. Verifies that the method accepts each provided keyword or has a variadic keyword of the form `**
|
207
|
-
* **`#
|
248
|
+
* **`#with_keywords`:** (also `and_keywords`) Expects one or more String or Symbol arguments. Verifies that the method accepts each provided keyword or has a variadic keyword of the form `**kwargs`. As of 2.1.0 and required keywords, verifies that all required keywords are provided.
|
249
|
+
* **`#with_any_keywords`:** (also `and_any_keywords`, `and_arbitrary_keywords`, `and_arbitrary_keywords`) No parameters. Verifies that the method accepts any keyword arguments via a variadic keyword of the form `**kwargs`.
|
208
250
|
|
209
251
|
### Core
|
210
252
|
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# lib/rspec/sleeping_king_studios/concerns/focus_examples.rb
|
2
|
+
|
3
|
+
require 'rspec/sleeping_king_studios/concerns'
|
4
|
+
|
5
|
+
module RSpec::SleepingKingStudios::Concerns
|
6
|
+
# Convenience methods for automatically focusing or skipping shared example
|
7
|
+
# groups.
|
8
|
+
module FocusExamples
|
9
|
+
# Includes the specified shared example group and wraps it inside an
|
10
|
+
# `fdescribe` block named "(focused)". If the spec runner is set to run only
|
11
|
+
# focused specs, this will ensure that the wrapped example group is run.
|
12
|
+
#
|
13
|
+
# @param [String] name The name of the shared example group to be wrapped.
|
14
|
+
# @param [Array] args Optional array of arguments that are passed on to
|
15
|
+
# the shared example group.
|
16
|
+
# @param [Hash] kwargs Optional hash of keyword arguments that are passed
|
17
|
+
# on to the shared example group.
|
18
|
+
#
|
19
|
+
# @yield Optional block that is passed on to the shared example group.
|
20
|
+
#
|
21
|
+
# @note Do not use this method with example groups that have side effects,
|
22
|
+
# e.g. define a memoized `#let` helper or a `#before` block that is
|
23
|
+
# intended to modify the behavior of sibling examples. Wrapping the
|
24
|
+
# example group in a `describe` block breaks that relationship. Best
|
25
|
+
# practice is to use the `#wrap_examples` method to safely encapsulate
|
26
|
+
# example groups with side effects, and the `#fwrap_examples` method to
|
27
|
+
# automatically focus such groups.
|
28
|
+
def finclude_examples name, *args, **kwargs, &block
|
29
|
+
fdescribe '(focused)' do
|
30
|
+
if kwargs.empty?
|
31
|
+
include_examples name, *args, &block
|
32
|
+
else
|
33
|
+
include_examples name, *args, **kwargs, &block
|
34
|
+
end # if-else
|
35
|
+
end # describe
|
36
|
+
end # method wrap_examples
|
37
|
+
alias_method :finclude_context, :finclude_examples
|
38
|
+
|
39
|
+
# Includes the specified shared example group and wraps it inside an
|
40
|
+
# `xdescribe` block named "(skipped)". This will ensure that the wrapped
|
41
|
+
# example group is not run.
|
42
|
+
#
|
43
|
+
# @param [String] name The name of the shared example group to be wrapped.
|
44
|
+
# @param [Array] args Optional array of arguments that are passed on to
|
45
|
+
# the shared example group.
|
46
|
+
# @param [Hash] kwargs Optional hash of keyword arguments that are passed
|
47
|
+
# on to the shared example group.
|
48
|
+
#
|
49
|
+
# @yield Optional block that is passed on to the shared example group.
|
50
|
+
#
|
51
|
+
# @note Do not use this method with example groups that have side effects,
|
52
|
+
# e.g. define a memoized `#let` helper or a `#before` block that is
|
53
|
+
# intended to modify the behavior of sibling examples. Wrapping the
|
54
|
+
# example group in a `describe` block breaks that relationship. Best
|
55
|
+
# practice is to use the `#wrap_examples` method to safely encapsulate
|
56
|
+
# example groups with side effects, and the `#xwrap_examples` method to
|
57
|
+
# automatically skip such groups.
|
58
|
+
# groups.
|
59
|
+
def xinclude_examples name, *args, **kwargs, &block
|
60
|
+
xdescribe '(focused)' do
|
61
|
+
if kwargs.empty?
|
62
|
+
include_examples name, *args, &block
|
63
|
+
else
|
64
|
+
include_examples name, *args, **kwargs, &block
|
65
|
+
end # if-else
|
66
|
+
end # describe
|
67
|
+
end # method xinclude_examples
|
68
|
+
alias_method :xinclude_context, :xinclude_examples
|
69
|
+
end # module
|
70
|
+
end # module
|
@@ -5,8 +5,6 @@ require 'rspec/sleeping_king_studios/concerns'
|
|
5
5
|
module RSpec::SleepingKingStudios::Concerns
|
6
6
|
# Methods for encapsulating shared example groups to include contexts or
|
7
7
|
# examples without affecting the surrounding context.
|
8
|
-
#
|
9
|
-
# @examples
|
10
8
|
module WrapExamples
|
11
9
|
# Includes the specified shared example group and wraps it inside a
|
12
10
|
# `describe` block. If a block is provided, it is evaluated in the
|
@@ -22,7 +20,11 @@ module RSpec::SleepingKingStudios::Concerns
|
|
22
20
|
# block, such as additional examples or memoized values.
|
23
21
|
def wrap_examples name, *args, **kwargs, &block
|
24
22
|
describe name do
|
25
|
-
|
23
|
+
if kwargs.empty?
|
24
|
+
include_examples name, *args
|
25
|
+
else
|
26
|
+
include_examples name, *args, **kwargs
|
27
|
+
end # if-else
|
26
28
|
|
27
29
|
instance_eval(&block) if block_given?
|
28
30
|
end # describe
|
@@ -43,7 +45,11 @@ module RSpec::SleepingKingStudios::Concerns
|
|
43
45
|
# block, such as additional examples or memoized values.
|
44
46
|
def fwrap_examples name, *args, **kwargs, &block
|
45
47
|
fdescribe name do
|
46
|
-
|
48
|
+
if kwargs.empty?
|
49
|
+
include_examples name, *args
|
50
|
+
else
|
51
|
+
include_examples name, *args, **kwargs
|
52
|
+
end # if-else
|
47
53
|
|
48
54
|
instance_eval(&block) if block_given?
|
49
55
|
end # describe
|
@@ -66,13 +72,15 @@ module RSpec::SleepingKingStudios::Concerns
|
|
66
72
|
# block, such as additional examples or memoized values.
|
67
73
|
def xwrap_examples name, *args, **kwargs, &block
|
68
74
|
xdescribe name do
|
69
|
-
|
75
|
+
if kwargs.empty?
|
76
|
+
include_examples name, *args
|
77
|
+
else
|
78
|
+
include_examples name, *args, **kwargs
|
79
|
+
end # if-else
|
70
80
|
|
71
81
|
instance_eval(&block) if block_given?
|
72
82
|
end # describe
|
73
83
|
end # method fwrap_examples
|
74
84
|
alias_method :xwrap_context, :xwrap_examples
|
75
|
-
|
76
|
-
|
77
85
|
end # module
|
78
86
|
end # module
|
@@ -94,6 +94,8 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
|
|
94
94
|
self
|
95
95
|
end # method with_arbitrary_keywords
|
96
96
|
alias_method :and_arbitrary_keywords, :with_arbitrary_keywords
|
97
|
+
alias_method :with_any_keywords, :with_arbitrary_keywords
|
98
|
+
alias_method :and_any_keywords, :with_any_keywords
|
97
99
|
|
98
100
|
# Adds a block expectation. The actual object will only match a block
|
99
101
|
# expectation if it expects a parameter of the form &block.
|
@@ -13,11 +13,11 @@ module RSpec
|
|
13
13
|
# Minor version.
|
14
14
|
MINOR = 1
|
15
15
|
# Patch version.
|
16
|
-
PATCH =
|
16
|
+
PATCH = 1
|
17
17
|
# Prerelease version.
|
18
|
-
PRERELEASE =
|
18
|
+
PRERELEASE = 'rc'
|
19
19
|
# Build metadata.
|
20
|
-
BUILD =
|
20
|
+
BUILD = 0
|
21
21
|
|
22
22
|
# Generates the gem version string from the Version constants.
|
23
23
|
def self.to_gem_version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-sleeping_king_studios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0
|
4
|
+
version: 2.1.1.rc.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob "Merlin" Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '0.1'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.1.
|
36
|
+
version: 0.1.3
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0.1'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.1.
|
46
|
+
version: 0.1.3
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: appraisal
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/rspec/sleeping_king_studios/all.rb
|
185
185
|
- lib/rspec/sleeping_king_studios/concerns.rb
|
186
186
|
- lib/rspec/sleeping_king_studios/concerns/all.rb
|
187
|
+
- lib/rspec/sleeping_king_studios/concerns/focus_examples.rb
|
187
188
|
- lib/rspec/sleeping_king_studios/concerns/shared_example_group.rb
|
188
189
|
- lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb
|
189
190
|
- lib/rspec/sleeping_king_studios/configuration.rb
|
@@ -229,12 +230,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
229
230
|
version: '0'
|
230
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
232
|
requirements:
|
232
|
-
- - "
|
233
|
+
- - ">"
|
233
234
|
- !ruby/object:Gem::Version
|
234
|
-
version:
|
235
|
+
version: 1.3.1
|
235
236
|
requirements: []
|
236
237
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.
|
238
|
+
rubygems_version: 2.5.1
|
238
239
|
signing_key:
|
239
240
|
specification_version: 4
|
240
241
|
summary: A collection of RSpec patches and custom matchers.
|