given_core 3.7.1 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +13 -13
- data/README.md +26 -6
- data/Rakefile +0 -4
- data/lib/given/extensions.rb +5 -4
- data/lib/given/line_extractor.rb +4 -4
- data/lib/given/minitest/configure.rb +1 -1
- data/lib/given/module_methods.rb +0 -17
- data/lib/given/natural_assertion.rb +24 -10
- data/lib/given/rspec/all.rb +2 -4
- data/lib/given/rspec/configure.rb +1 -1
- data/lib/given/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c5460fda0b68ed478e3e65df1fa7c37c6d58cbc
|
4
|
+
data.tar.gz: fab707bbc059a7c79280baea8627933d36755856
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2ca385bc6f7a8583193cf7a0363222faefa96500441ebd217673d43f3aa110f5133fb2f8845a77f7f92ea8b7fa91f1919ad87e8e07842f92a41ad5c06cce788
|
7
|
+
data.tar.gz: fddd6ae9b41e390e03a4db1d2cf3baf81afb19528ddbdac283e81849e2b9f0d03df1ad239668d0dd685a6a9da070dde7c8177c29d4240b128de12533986cf201
|
data/Gemfile.lock
CHANGED
@@ -2,21 +2,21 @@ GEM
|
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
diff-lcs (1.2.5)
|
5
|
-
minitest (5.
|
6
|
-
rake (10.
|
7
|
-
rspec (3.
|
8
|
-
rspec-core (~> 3.
|
9
|
-
rspec-expectations (~> 3.
|
10
|
-
rspec-mocks (~> 3.
|
11
|
-
rspec-core (3.
|
12
|
-
rspec-support (~> 3.
|
13
|
-
rspec-expectations (3.
|
5
|
+
minitest (5.8.3)
|
6
|
+
rake (10.5.0)
|
7
|
+
rspec (3.4.0)
|
8
|
+
rspec-core (~> 3.4.0)
|
9
|
+
rspec-expectations (~> 3.4.0)
|
10
|
+
rspec-mocks (~> 3.4.0)
|
11
|
+
rspec-core (3.4.1)
|
12
|
+
rspec-support (~> 3.4.0)
|
13
|
+
rspec-expectations (3.4.0)
|
14
14
|
diff-lcs (>= 1.2.0, < 2.0)
|
15
|
-
rspec-support (~> 3.
|
16
|
-
rspec-mocks (3.
|
15
|
+
rspec-support (~> 3.4.0)
|
16
|
+
rspec-mocks (3.4.1)
|
17
17
|
diff-lcs (>= 1.2.0, < 2.0)
|
18
|
-
rspec-support (~> 3.
|
19
|
-
rspec-support (3.
|
18
|
+
rspec-support (~> 3.4.0)
|
19
|
+
rspec-support (3.4.1)
|
20
20
|
sorcerer (1.0.2)
|
21
21
|
|
22
22
|
PLATFORMS
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
| :----: |
|
5
5
|
| [![Master Build Status](https://secure.travis-ci.org/rspec-given/rspec-given.png?branch=master)](https://travis-ci.org/rspec-given/rspec-given) |
|
6
6
|
|
7
|
-
Covering rspec-given, minitest-given, and given-core, version 3.
|
7
|
+
Covering rspec-given, minitest-given, and given-core, version 3.8.0.
|
8
8
|
|
9
9
|
rspec-given and minitest-given are extensions to your favorite testing
|
10
10
|
framework to allow Given/When/Then notation when writing specs.
|
@@ -347,6 +347,17 @@ should use an empty _Then_ clause, like this:
|
|
347
347
|
Then { }
|
348
348
|
```
|
349
349
|
|
350
|
+
A _Then_ clause accepts arguments for user-defined RSpec metadata:
|
351
|
+
|
352
|
+
```ruby
|
353
|
+
Then(:zippy, :foo => 17) { ... }
|
354
|
+
```
|
355
|
+
|
356
|
+
Metadata on _Then_ clauses is an RSpec-only feature. You can read more about
|
357
|
+
metadata [in RSpec's
|
358
|
+
documentation](https://www.relishapp.com/rspec/rspec-core/docs/metadata/user-defined-metadata).
|
359
|
+
|
360
|
+
|
350
361
|
#### Then examples:
|
351
362
|
|
352
363
|
```ruby
|
@@ -760,12 +771,13 @@ _expect_.
|
|
760
771
|
|
761
772
|
Given uses the Ripper library to parse the source lines and failing
|
762
773
|
conditions to find all the sub-expression values upon a failure.
|
763
|
-
Currently Ripper is not supported on Rubinius and versions of JRuby
|
764
|
-
prior to JRuby-1.7.5.
|
765
774
|
|
766
|
-
If
|
767
|
-
|
768
|
-
|
775
|
+
If Ripper is not available, like on Rubinius and versions of JRuby prior to
|
776
|
+
JRuby-1.7.5, detailed explanations of failures for natural assertions won't be
|
777
|
+
available. Natural assertions will still work, though.
|
778
|
+
|
779
|
+
If you want to use a version of Ruby that does not support Ripper, then you
|
780
|
+
should disable source caching in the configuration (see the configuration
|
769
781
|
section below).
|
770
782
|
|
771
783
|
### Non-Spec Assertions
|
@@ -870,6 +882,14 @@ License. See the MIT-LICENSE file in the source distribution.
|
|
870
882
|
|
871
883
|
# History
|
872
884
|
|
885
|
+
* Version 3.8.0
|
886
|
+
|
887
|
+
* RSpec metadata can now be added to _Then_ clauses (see [#11](https://github.com/rspec-given/rspec-given/pull/11))
|
888
|
+
* Natural assertions now run on Rubinius and older versions of JRuby (see [#15](https://github.com/rspec-given/rspec-given/issues/15))
|
889
|
+
* WARNING: On these platforms, detailed failure explanations aren't available and source code snippets of Then clauses will only show the first line.
|
890
|
+
* WARNING: Assertions of void statements (e.g. `Then { }`) will fail only under runtimes lacking Ripper support
|
891
|
+
* `Given.ok_to_use_natural_assertions` was removed; the method was never properly supported as public, but it was publicly reachable
|
892
|
+
|
873
893
|
* Version 3.7.1
|
874
894
|
|
875
895
|
* Mixin Minitest extensions for both ActiveSupport::TestCase (when present) as well as for MiniTest::Spec (see [#8](https://github.com/rspec-given/rspec-given/pulls/8))
|
data/Rakefile
CHANGED
@@ -67,10 +67,6 @@ EXAMPLES = FileList['examples/**/*_spec.rb', 'examples/use_assertions.rb'].
|
|
67
67
|
|
68
68
|
MT_EXAMPLES = FileList['examples/minitest-rails/**/*_spec.rb', 'examples/minitest/**/*_spec.rb']
|
69
69
|
|
70
|
-
unless Given::NATURAL_ASSERTIONS_SUPPORTED
|
71
|
-
EXAMPLES.exclude("examples/stack/*.rb")
|
72
|
-
end
|
73
|
-
|
74
70
|
FAILING_EXAMPLES = FileList['examples/failing/**/*_spec.rb']
|
75
71
|
|
76
72
|
desc "Run the RSpec specs and examples"
|
data/lib/given/extensions.rb
CHANGED
@@ -247,11 +247,13 @@ module Given
|
|
247
247
|
# :call-seq:
|
248
248
|
# Then { ... assertion ... }
|
249
249
|
#
|
250
|
-
def Then(
|
251
|
-
|
250
|
+
def Then(*metadata, &block)
|
251
|
+
opts = metadata.last
|
252
|
+
opts = {} unless opts.is_a? Hash
|
253
|
+
on_eval = opts.delete(:on_eval) || "_gvn_then"
|
252
254
|
file, line = Given.location_of(block)
|
253
255
|
description = _Gvn_lines.line(file, line) unless Given.source_caching_disabled
|
254
|
-
cmd = description ? "it(description)" : "specify"
|
256
|
+
cmd = description ? "it(description, *metadata)" : "specify(*metadata)"
|
255
257
|
eval %{#{cmd} do #{on_eval}(&block) end}, binding, file, line
|
256
258
|
_Gvn_context_info[:then_defined] = true
|
257
259
|
end
|
@@ -270,7 +272,6 @@ module Given
|
|
270
272
|
|
271
273
|
# Configure the use of natural assertions in this context.
|
272
274
|
def use_natural_assertions(enabled=true)
|
273
|
-
Given.ok_to_use_natural_assertions(enabled)
|
274
275
|
_Gvn_context_info[:natural_assertions_enabled] = enabled
|
275
276
|
end
|
276
277
|
end
|
data/lib/given/line_extractor.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'sorcerer'
|
1
|
+
require 'given/natural_assertion'
|
3
2
|
require 'given/file_cache'
|
4
3
|
|
5
4
|
module Given
|
@@ -20,6 +19,7 @@ module Given
|
|
20
19
|
private
|
21
20
|
|
22
21
|
def extract_lines_from(lines, line_index)
|
22
|
+
return lines[line_index] unless NATURAL_ASSERTIONS_SUPPORTED
|
23
23
|
result = lines[line_index]
|
24
24
|
while result && incomplete?(result)
|
25
25
|
line_index += 1
|
@@ -29,13 +29,13 @@ module Given
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def incomplete?(string)
|
32
|
-
!
|
32
|
+
!complete_sexp?(parse(string))
|
33
33
|
end
|
34
34
|
|
35
35
|
def complete_sexp?(sexp)
|
36
36
|
Sorcerer.source(sexp)
|
37
37
|
true
|
38
|
-
rescue Sorcerer::Resource::NotSexpError
|
38
|
+
rescue Sorcerer::Resource::NotSexpError
|
39
39
|
false
|
40
40
|
end
|
41
41
|
|
@@ -12,4 +12,4 @@ Minitest::Spec.send(:extend, Given::MiniTest::ClassExtensions)
|
|
12
12
|
Minitest::Spec.send(:include, Given::FailureMethod)
|
13
13
|
Minitest::Spec.send(:include, Given::InstanceExtensions)
|
14
14
|
Minitest::Spec.send(:include, Given::MiniTest::InstanceExtensions)
|
15
|
-
Given.use_natural_assertions
|
15
|
+
Given.use_natural_assertions
|
data/lib/given/module_methods.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
|
2
2
|
module Given
|
3
|
-
# Does this platform support natural assertions?
|
4
|
-
RBX_IN_USE = (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx')
|
5
|
-
JRUBY_IN_USE = defined?(JRUBY_VERSION)
|
6
|
-
OLD_JRUBY_IN_USE = JRUBY_IN_USE && (JRUBY_VERSION < '1.7.5')
|
7
|
-
|
8
|
-
NATURAL_ASSERTIONS_SUPPORTED = ! (OLD_JRUBY_IN_USE || RBX_IN_USE)
|
9
3
|
|
10
4
|
def self.framework
|
11
5
|
@_gvn_framework
|
@@ -28,7 +22,6 @@ module Given
|
|
28
22
|
# There is a similar function in Extensions that works at a
|
29
23
|
# describe or context scope.
|
30
24
|
def self.use_natural_assertions(enabled=true)
|
31
|
-
ok_to_use_natural_assertions(enabled)
|
32
25
|
@natural_assertions_enabled = enabled
|
33
26
|
end
|
34
27
|
|
@@ -37,16 +30,6 @@ module Given
|
|
37
30
|
@natural_assertions_enabled
|
38
31
|
end
|
39
32
|
|
40
|
-
# Is is OK to use natural assertions on this platform.
|
41
|
-
#
|
42
|
-
# An error is raised if the the platform does not support natural
|
43
|
-
# assertions and the flag is attempting to enable them.
|
44
|
-
def self.ok_to_use_natural_assertions(enabled)
|
45
|
-
if enabled && ! NATURAL_ASSERTIONS_SUPPORTED
|
46
|
-
fail ArgumentError, "Natural Assertions are disabled for JRuby"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
33
|
# Return file and line number where the block is defined.
|
51
34
|
def self.location_of(block)
|
52
35
|
eval "[__FILE__, __LINE__]", block.binding
|
@@ -2,12 +2,22 @@ require 'given/module_methods'
|
|
2
2
|
require 'given/evaluator'
|
3
3
|
require 'given/binary_operation'
|
4
4
|
|
5
|
-
if Given::NATURAL_ASSERTIONS_SUPPORTED
|
6
|
-
require 'ripper'
|
7
|
-
require 'sorcerer'
|
8
|
-
end
|
9
|
-
|
10
5
|
module Given
|
6
|
+
NATURAL_ASSERTIONS_SUPPORTED = begin
|
7
|
+
require 'ripper'
|
8
|
+
require 'sorcerer'
|
9
|
+
true
|
10
|
+
rescue LoadError
|
11
|
+
# Expected on Rubinius & old JRuby
|
12
|
+
warn <<-WARNING.gsub(/^\s+/,'')
|
13
|
+
rspec-given: WARNING: Ripper is not available, so multi-line Then
|
14
|
+
statements will not be printed correctly and detailed failure
|
15
|
+
explanations of natural assertions WILL NOT be printed. Additionally,
|
16
|
+
assertions containing void statements (e.g. `Then { }`) will fail
|
17
|
+
in this runtime.
|
18
|
+
WARNING
|
19
|
+
false
|
20
|
+
end
|
11
21
|
|
12
22
|
InvalidThenError = Class.new(StandardError)
|
13
23
|
|
@@ -23,15 +33,20 @@ module Given
|
|
23
33
|
VOID_SEXP = [:void_stmt]
|
24
34
|
|
25
35
|
def has_content?
|
36
|
+
return true unless NATURAL_ASSERTIONS_SUPPORTED
|
26
37
|
assertion_sexp != VOID_SEXP
|
27
38
|
end
|
28
39
|
|
29
40
|
def message
|
30
41
|
@output = "#{@clause_type} expression failed at #{source_line}\n"
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
42
|
+
if NATURAL_ASSERTIONS_SUPPORTED
|
43
|
+
@output << "Failing expression: #{source.strip}\n" if @clause_type != "Then"
|
44
|
+
explain_failure
|
45
|
+
display_pairs(expression_value_pairs)
|
46
|
+
@output << "\n"
|
47
|
+
else
|
48
|
+
@output << "Failing expression (possibly truncated): #{source.strip}\n"
|
49
|
+
end
|
35
50
|
@output
|
36
51
|
end
|
37
52
|
|
@@ -174,5 +189,4 @@ module Given
|
|
174
189
|
"#{@code_file}:#{@code_line}"
|
175
190
|
end
|
176
191
|
end
|
177
|
-
|
178
192
|
end
|
data/lib/given/rspec/all.rb
CHANGED
@@ -6,10 +6,8 @@ module RSpec
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
raise "Unsupported version of RSpec (#{RSpec::Version::STRING}), unable to detect assertions" unless RSpec::Given::MONKEY
|
12
|
-
end
|
9
|
+
require 'given/rspec/monkey'
|
10
|
+
raise "Unsupported version of RSpec (#{RSpec::Version::STRING}), unable to detect assertions" unless RSpec::Given::MONKEY
|
13
11
|
|
14
12
|
require 'given/rspec/have_failed'
|
15
13
|
require 'given/rspec/before_extensions'
|
data/lib/given/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: given_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorcerer
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project: given
|
106
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.4.5
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Core engine for RSpec::Given and Minitest::Given.
|