rspec-sleeping_king_studios 2.0.3 → 2.1.0.rc.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
  SHA1:
3
- metadata.gz: f3427b043889c866103ff0e5a58222621798f825
4
- data.tar.gz: 3f7ea93de6bc4be9d9c6a5687be25eb57b406e78
3
+ metadata.gz: 9989fe8d25e1e4cc3e01704d54d783d7de466edb
4
+ data.tar.gz: 5134740008100f8fc5617da5d0fb4df269666c7d
5
5
  SHA512:
6
- metadata.gz: 5696860258e7bb62a86b97af732f8cab837bca81f6665cffb46dcf28ec407b54031e8c6d28029762b8039b5eab220db4515d39c35773593946ad6d42b8b2af9c
7
- data.tar.gz: ec5dcd4a1a3ecd74e7dbf88e3761a27ed3e5e46fb295709a64b54a9f4b27cc9632311ef6883add79968104747c6d67a6eaa5654a135026c805f71c68e49326fd
6
+ metadata.gz: 9818552afcebbd54b0fab96dca38e66701922563fe30492d47dd0193d7a4ab524d906d1e40abe3362c6f5077369cd9e9737894dcacf837a1c640bc2db4e7324c
7
+ data.tar.gz: 158147781997f5e0ba2c27a1a3e85ec2dbaab392e87bcddd2e7ca33ab6c403ffeafb85bfecbfe01a832cf337b5c93f158d10de2f1ab48df5deda1ba30b7e9414
data/CHANGELOG.md CHANGED
@@ -1,11 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Concerns
6
+
7
+ #### `WrapExamples` Concern
8
+
9
+ Added module RSpec::SleepingKingStudios::Concerns::WrapExamples to support a common use case for shared examples/shared contexts and avoid surprising behavior when using multiple adjacent shared contexts (or shared examples that have side effects).
10
+
3
11
  ## 2.0.3
4
12
 
5
13
  Internal update to add support for RSpec 3.3.
6
14
 
7
15
  ## 2.0.2
8
16
 
17
+ ### Matchers
18
+
9
19
  #### `construct` and `respond_to` Matchers
10
20
 
11
21
  Added new fluent syntax for keyword expectations:
data/DEVELOPMENT.md CHANGED
@@ -2,38 +2,26 @@
2
2
 
3
3
  ## Tasks
4
4
 
5
- ### Release Candidate
5
+ ### Planned Features
6
6
 
7
- ### 2.0.3
8
-
9
- - Add support for RSpec 3.3
10
- - Transition from RSpec::Matchers::Pretty to RSpec::Matchers::EnglishPhrasing?
11
- - Support new implementation of RSpec::Matchers::BuiltIn::Include
12
-
13
- ### 2.1.0+
14
-
15
- - Add #wrap_context, #wrap_examples (alias encapsulate_X ?) for pattern `describe ""; include_examples "": end`
16
- - Configuration option 'alias_wrap_examples'?
17
- - Automatically-focused #fwrap_context, #fwrap_examples?
18
7
  - Add #have_constant matcher.
8
+ - Add shared examples for 'should have constant', 'should have immutable constant'
19
9
  - Add shared examples for 'should not have reader/writer/property'
20
-
21
- ### 2.2.0+
22
-
23
10
  - Add shared examples for #belongs_to, #has_one, #has_many, #embedded_in, #embeds_one, #embeds_many.
24
11
  - Add shared examples for core ActiveModel validations.
25
- - Add alt doc test formatter - --format=list ? --format=documentation-list ?
26
- - Prints full expanded example name for each example
27
- - Add minimal test formatter - --format=smoke ? --format=librarian ?
28
- - Prints nothing for examples
29
- - Suppress STDOUT output? As configurable option for any formatted?
30
-
31
- ### 3.0.0
32
-
33
- - Ensure behavior of `#have_reader`, `#have_writer`, `#have_property` is consistent.
34
12
 
35
13
  ### Maintenance
36
14
 
37
15
  - Remove SCENARIOS from spec files.
16
+ - Refactor #respond_to, #be_constructible to use RSpec 3 method reflection.
38
17
  - Revisit failure messages for #respond_to, #be_constructible.
39
18
  - Pare down Cucumber features for matchers - repurpose as documentation/examples only.
19
+ - - Ensure behavior of `#have_reader`, `#have_writer`, `#have_property` is consistent (non-compatible; needs version 3.0).
20
+
21
+ ### Icebox
22
+
23
+ - Add alt doc test formatter - --format=list ? --format=documentation-list ?
24
+ - Prints full expanded example name for each example
25
+ - Add minimal test formatter - --format=smoke ? --format=librarian ?
26
+ - Prints nothing for examples
27
+ - Suppress STDOUT output? As configurable option for any formatted?
data/README.md CHANGED
@@ -61,14 +61,57 @@ RSpec::SleepingKingStudios defines a few concerns that can be included in or ext
61
61
 
62
62
  Utility functions for defining shared examples. If included in a module, any shared examples defined in that module are scoped to the module, rather than placed in a global scope. This allows you to define different shared examples with the same name in different contexts, similar to the current behavior when defining a shared example inside an example group. To use the defined examples, simply `include` the module in an example group. **Important Note:** Shared examples and aliases must be defined **before** including the module in an example group. Any shared examples or aliases defined afterword will not be available inside the example group.
63
63
 
64
- ### `::alias_shared_examples`
64
+ #### `::alias_shared_examples`
65
65
 
66
66
  (also `::alias_shared_context`) Aliases a defined shared example group, allowing it to be accessed using a new name. The example group must be defined in the current context using `shared_examples`. The aliases must be defined before including the module into an example group, or they will not be available in the example group.
67
67
 
68
- ### `::shared_examples`
68
+ #### `::shared_examples`
69
69
 
70
70
  (also `::shared_context`) Defines a shared example group within the context of the current module. Unlike a top-level example group defined using RSpec#shared_examples, these examples are not globally available, and must be mixed into an example group by including the module. The shared examples must be defined before including the module, or they will not be available in the example group.
71
71
 
72
+ ### Wrap Examples
73
+
74
+ require 'rspec/sleeping_king_studios/concerns/wrap_examples'
75
+
76
+ RSpec.describe String do
77
+ extend RSpec::SleepingKingStudios::Concerns::WrapExamples
78
+
79
+ shared_context 'with a long quote' do
80
+ let(:quote) do
81
+ 'Greetings, starfighter! You have been recruited by the Star League'\
82
+ ' to defend the frontier against Xur and the Ko-Dan armada!'
83
+ end # let
84
+ end # shared context
85
+
86
+ shared_context 'with a short quote' do`
87
+ let(:quote) { 'Greetings, programs!' }
88
+ end # shared_context
89
+
90
+ describe '#length' do
91
+ wrap_context 'with a long quote' do
92
+ it { expect(quote.length).to be == 124 }
93
+ end # wrap_context
94
+
95
+ wrap_context 'with a short quote' do
96
+ it { expect(quote.length).to be == 20 }
97
+ end # wrap_context
98
+ end # describe
99
+ end # describe
100
+
101
+ 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.
102
+
103
+ #### `::wrap_examples`
104
+
105
+ (also `::wrap_context`) Creates an implicit `describe` block and includes the context or examples within the `describe` block to avoid leaking values or callbacks to the outer context. Any parameters or keywords will be passed along to the `include_examples` call. If a block is given, it is evaluated in the context of the `describe` block after the `include_examples` call, allowing you to define additional examples or customize the values and callbacks defined in the shared examples.
106
+
107
+ #### `::fwrap_examples`
108
+
109
+ (also `::fwrap_context`) A shortcut for wrapping the context or examples in an automatically-focused `describe` block, similar to the built-in `fit` and `fdescribe` methods.
110
+
111
+ #### `::xwrap_examples`
112
+
113
+ (also `::xwrap_context`) A shortcut for wrapping the context or examples in an automatically-skipped `describe` block, similar to the built-in `xit` and `xdescribe` methods.
114
+
72
115
  ## Custom Matchers
73
116
 
74
117
  To enable a custom matcher, simply require the associated file. Matchers can be required individually or by category:
@@ -0,0 +1,78 @@
1
+ # lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb
2
+
3
+ require 'rspec/sleeping_king_studios/concerns'
4
+
5
+ module RSpec::SleepingKingStudios::Concerns
6
+ # Methods for encapsulating shared example groups to include contexts or
7
+ # examples without affecting the surrounding context.
8
+ #
9
+ # @examples
10
+ module WrapExamples
11
+ # Includes the specified shared example group and wraps it inside a
12
+ # `describe` block. If a block is provided, it is evaluated in the
13
+ # context of the describe block after the example group has been included.
14
+ #
15
+ # @param [String] name The name of the shared example group to be wrapped.
16
+ # @param [Array] args Optional array of arguments that are passed on to
17
+ # the shared example group.
18
+ # @param [Hash] kwargs Optional hash of keyword arguments that are passed
19
+ # on to the shared example group.
20
+ #
21
+ # @yield Additional code to run in the context of the wrapping `describe`
22
+ # block, such as additional examples or memoized values.
23
+ def wrap_examples name, *args, **kwargs, &block
24
+ describe name do
25
+ include_examples name, *args, **kwargs
26
+
27
+ instance_eval(&block) if block_given?
28
+ end # describe
29
+ end # method wrap_examples
30
+ alias_method :wrap_context, :wrap_examples
31
+
32
+ # Includes the specified shared example group and wraps it inside a
33
+ # focused `fdescribe` block. If a block is provided, it is evaluated in the
34
+ # context of the fdescribe block after the example group has been included.
35
+ #
36
+ # @param [String] name The name of the shared example group to be wrapped.
37
+ # @param [Array] args Optional array of arguments that are passed on to
38
+ # the shared example group.
39
+ # @param [Hash] kwargs Optional hash of keyword arguments that are passed
40
+ # on to the shared example group.
41
+ #
42
+ # @yield Additional code to run in the context of the wrapping `fdescribe`
43
+ # block, such as additional examples or memoized values.
44
+ def fwrap_examples name, *args, **kwargs, &block
45
+ fdescribe name do
46
+ include_examples name, *args, **kwargs
47
+
48
+ instance_eval(&block) if block_given?
49
+ end # describe
50
+ end # method fwrap_examples
51
+ alias_method :fwrap_context, :fwrap_examples
52
+
53
+ # Includes the specified shared example group and wraps it inside a
54
+ # skipped `xdescribe` block. If a block is provided, it is evaluated in the
55
+ # context of the xdescribe block after the example group has been included.
56
+ # Mostly used to temporarily disable a wrapped example group while updating
57
+ # or debugging a spec.
58
+ #
59
+ # @param [String] name The name of the shared example group to be wrapped.
60
+ # @param [Array] args Optional array of arguments that are passed on to
61
+ # the shared example group.
62
+ # @param [Hash] kwargs Optional hash of keyword arguments that are passed
63
+ # on to the shared example group.
64
+ #
65
+ # @yield Additional code to run in the context of the wrapping `fdescribe`
66
+ # block, such as additional examples or memoized values.
67
+ def xwrap_examples name, *args, **kwargs, &block
68
+ xdescribe name do
69
+ include_examples name, *args, **kwargs
70
+
71
+ instance_eval(&block) if block_given?
72
+ end # describe
73
+ end # method fwrap_examples
74
+ alias_method :xwrap_context, :xwrap_examples
75
+
76
+
77
+ end # module
78
+ end # module
@@ -11,13 +11,13 @@ module RSpec
11
11
  # Major version.
12
12
  MAJOR = 2
13
13
  # Minor version.
14
- MINOR = 0
14
+ MINOR = 1
15
15
  # Patch version.
16
- PATCH = 3
16
+ PATCH = 0
17
17
  # Prerelease version.
18
- PRERELEASE = nil
18
+ PRERELEASE = 'rc'
19
19
  # Build metadata.
20
- BUILD = nil
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.0.3
4
+ version: 2.1.0.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: 2015-07-07 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -118,20 +118,14 @@ dependencies:
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: '0.6'
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 0.6.2
121
+ version: '0.9'
125
122
  type: :development
126
123
  prerelease: false
127
124
  version_requirements: !ruby/object:Gem::Requirement
128
125
  requirements:
129
126
  - - "~>"
130
127
  - !ruby/object:Gem::Version
131
- version: '0.6'
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: 0.6.2
128
+ version: '0.9'
135
129
  - !ruby/object:Gem::Dependency
136
130
  name: cucumber
137
131
  requirement: !ruby/object:Gem::Requirement
@@ -191,6 +185,7 @@ files:
191
185
  - lib/rspec/sleeping_king_studios/concerns.rb
192
186
  - lib/rspec/sleeping_king_studios/concerns/all.rb
193
187
  - lib/rspec/sleeping_king_studios/concerns/shared_example_group.rb
188
+ - lib/rspec/sleeping_king_studios/concerns/wrap_examples.rb
194
189
  - lib/rspec/sleeping_king_studios/configuration.rb
195
190
  - lib/rspec/sleeping_king_studios/examples.rb
196
191
  - lib/rspec/sleeping_king_studios/examples/all.rb
@@ -234,9 +229,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
229
  version: '0'
235
230
  required_rubygems_version: !ruby/object:Gem::Requirement
236
231
  requirements:
237
- - - ">="
232
+ - - ">"
238
233
  - !ruby/object:Gem::Version
239
- version: '0'
234
+ version: 1.3.1
240
235
  requirements: []
241
236
  rubyforge_project:
242
237
  rubygems_version: 2.4.6
@@ -244,4 +239,3 @@ signing_key:
244
239
  specification_version: 4
245
240
  summary: A collection of RSpec patches and custom matchers.
246
241
  test_files: []
247
- has_rdoc: