given_core 3.6.0 → 3.8.2

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
- SHA1:
3
- metadata.gz: 81a55b27b471044bc3e47122ddce790fc92bf11b
4
- data.tar.gz: b179e4e397fbdf8af463f9fc8aeb487648db7bcd
2
+ SHA256:
3
+ metadata.gz: 3c2192daced24063b62f217adf7f4678e1494ead3f719b18163f966a3d6b1b8d
4
+ data.tar.gz: 0d31d574f7a14ae2c0d6604444cbc8f8b9310ddb3944e1b365536558291142ea
5
5
  SHA512:
6
- metadata.gz: 4c9fb7d5e745e3af86aeb27821ab5bd206074b3aadcedf1ecc9aac3963a10abef885e0537901a924ac5ddb0bed169b930120ae177d9cc312d993f23cd43b972d
7
- data.tar.gz: a0794444e365c2f259e9bd3261f2cb889df7e71e80a48dd3b63feb459c87119d4ae3253fb97854c3db847676a52205cfc27242f51a831cf176fbff5c7d18a372
6
+ metadata.gz: 95982f411402f3fcffba65f5cbfa0f1925fe504af3cf9b1abc0774864a345383d3647ae4da10ccb4071c9a7ffb5dd805ed34daf751b5d0928995dd7ea3ed6792
7
+ data.tar.gz: 1f0e5b72fee72726667f45d4e7af536218b383dfab8cc964c1905bbebc1e5c57ee890a2cddb13597cd11e27fbed9ffeeeb12d3f5b399014b3226ccea0bb94ed0
@@ -1,25 +1,25 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.2.5)
5
- minitest (5.5.0)
6
- rake (10.4.2)
7
- rspec (3.1.0)
8
- rspec-core (~> 3.1.0)
9
- rspec-expectations (~> 3.1.0)
10
- rspec-mocks (~> 3.1.0)
11
- rspec-core (3.1.7)
12
- rspec-support (~> 3.1.0)
13
- rspec-expectations (3.1.2)
4
+ diff-lcs (1.4.4)
5
+ minitest (5.14.3)
6
+ rake (13.0.3)
7
+ rspec (3.10.0)
8
+ rspec-core (~> 3.10.0)
9
+ rspec-expectations (~> 3.10.0)
10
+ rspec-mocks (~> 3.10.0)
11
+ rspec-core (3.10.1)
12
+ rspec-support (~> 3.10.0)
13
+ rspec-expectations (3.10.1)
14
14
  diff-lcs (>= 1.2.0, < 2.0)
15
- rspec-support (~> 3.1.0)
16
- rspec-mocks (3.1.3)
17
- rspec-support (~> 3.1.0)
18
- rspec-support (3.1.2)
19
- sorcerer (1.0.2)
15
+ rspec-support (~> 3.10.0)
16
+ rspec-mocks (3.10.2)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.10.0)
19
+ rspec-support (3.10.2)
20
+ sorcerer (2.0.1)
20
21
 
21
22
  PLATFORMS
22
- java
23
23
  ruby
24
24
 
25
25
  DEPENDENCIES
@@ -27,3 +27,6 @@ DEPENDENCIES
27
27
  rake
28
28
  rspec (>= 2.14.0)
29
29
  sorcerer (>= 0.3.7)
30
+
31
+ BUNDLED WITH
32
+ 2.1.4
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.6.0.
7
+ Covering rspec-given, minitest-given, and given-core, version 3.8.2.
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.
@@ -53,7 +53,7 @@ things to watch out for:
53
53
 
54
54
  * Only one before block is allowed in any given Minitest::Spec
55
55
  describe block. This doesn't effect the number of Givens you are
56
- allowed to use, but it may surprise if you are use to RSpec.
56
+ allowed to use, but it may surprise you if you are used to RSpec.
57
57
 
58
58
  ### Auto Selecting
59
59
 
@@ -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 you want to use a version of Ruby that does not support Ripper,
767
- then natural assertions will disabled. In addition, you should also
768
- disable source caching in the configuration (see the configuration
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,26 @@ License. See the MIT-LICENSE file in the source distribution.
870
882
 
871
883
  # History
872
884
 
885
+ * Version 3.8.1
886
+
887
+ * Fix deprecation warnings fro Ruby 2.6 & up
888
+
889
+ * Version 3.8.0
890
+
891
+ * RSpec metadata can now be added to _Then_ clauses (see [#11](https://github.com/rspec-given/rspec-given/pull/11))
892
+ * Natural assertions now run on Rubinius and older versions of JRuby (see [#15](https://github.com/rspec-given/rspec-given/issues/15))
893
+ * WARNING: On these platforms, detailed failure explanations aren't available and source code snippets of Then clauses will only show the first line.
894
+ * WARNING: Assertions of void statements (e.g. `Then { }`) will fail only under runtimes lacking Ripper support
895
+ * `Given.ok_to_use_natural_assertions` was removed; the method was never properly supported as public, but it was publicly reachable
896
+
897
+ * Version 3.7.1
898
+
899
+ * 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))
900
+
901
+ * Version 3.7.0
902
+
903
+ * Add support for Rails tests when using minitest-given (See [#6](https://github.com/rspec-given/rspec-given/pull/6))
904
+
873
905
  * Version 3.6.0
874
906
 
875
907
  * Various fixes for RSpec 3.0 (See [#1](https://github.com/rspec-given/rspec-given/pull/1))
data/Rakefile CHANGED
@@ -62,13 +62,10 @@ end
62
62
  EXAMPLES = FileList['examples/**/*_spec.rb', 'examples/use_assertions.rb'].
63
63
  exclude('examples/failing/*.rb').
64
64
  exclude('examples/minitest/*.rb').
65
+ exclude('examples/minitest-rails/*.rb').
65
66
  exclude('examples/integration/failing/*.rb')
66
67
 
67
- MT_EXAMPLES = FileList['examples/minitest/**/*_spec.rb']
68
-
69
- unless Given::NATURAL_ASSERTIONS_SUPPORTED
70
- EXAMPLES.exclude("examples/stack/*.rb")
71
- end
68
+ MT_EXAMPLES = FileList['examples/minitest-rails/**/*_spec.rb', 'examples/minitest/**/*_spec.rb']
72
69
 
73
70
  FAILING_EXAMPLES = FileList['examples/failing/**/*_spec.rb']
74
71
 
@@ -247,11 +247,13 @@ module Given
247
247
  # :call-seq:
248
248
  # Then { ... assertion ... }
249
249
  #
250
- def Then(opts={}, &block)
251
- on_eval = opts.fetch(:on_eval, "_gvn_then")
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
@@ -1,5 +1,4 @@
1
- require 'ripper'
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
- ! complete_sexp?(parse(string))
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 => ex
38
+ rescue Sorcerer::Resource::NotSexpError
39
39
  false
40
40
  end
41
41
 
@@ -2,35 +2,55 @@
2
2
  # The before blocks defined in Minitest are inadequate for our use.
3
3
  # This before_extension file allows us to use real before blocks.
4
4
 
5
+ module Given
6
+ module MiniTest
7
+ module ClassExtensions
8
+ # Lazy accessor for Given's before blocks
9
+ def _Gvn_before_blocks
10
+ @_Gvn_before_blocks ||= []
11
+ end
12
+
13
+ # Define a Given style before block
14
+ def _Gvn_before(&block)
15
+ _Gvn_before_blocks << block
16
+ end
17
+ end
18
+
19
+ module InstanceExtensions
20
+ # Establish the before blocks
21
+ def _gvn_establish_befores
22
+ return if defined?(@_gvn_ran_befores) && @_gvn_ran_befores
23
+ @_gvn_ran_befores = true
24
+ _gvn_contexts.each do |context|
25
+ context._Gvn_before_blocks.each do |before_block|
26
+ instance_eval(&before_block)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
5
34
  module Minitest
6
35
  class Spec
7
-
8
36
  # Redefine setup to trigger before chains
9
37
  alias original_setup_without_given setup
10
38
  def setup
11
39
  original_setup_without_given
12
40
  _gvn_establish_befores
13
41
  end
42
+ end
43
+ end
14
44
 
15
- # Establish the before blocks
16
- def _gvn_establish_befores
17
- return if defined?(@_gvn_ran_befores) && @_gvn_ran_befores
18
- @_gvn_ran_befores = true
19
- _gvn_contexts.each do |context|
20
- context._Gvn_before_blocks.each do |before_block|
21
- instance_eval(&before_block)
22
- end
45
+ if defined?(ActiveSupport::TestCase)
46
+ module ActiveSupport
47
+ class TestCase
48
+ # Redefine setup to trigger before chains
49
+ alias original_setup_without_given setup
50
+ def setup
51
+ original_setup_without_given
52
+ _gvn_establish_befores
23
53
  end
24
54
  end
25
-
26
- # Lazy accessor for Given's before blocks
27
- def self._Gvn_before_blocks
28
- @_Gvn_before_blocks ||= []
29
- end
30
-
31
- # Define a Given style before block
32
- def self._Gvn_before(&block)
33
- _Gvn_before_blocks << block
34
- end
35
55
  end
36
56
  end
@@ -1,7 +1,15 @@
1
-
1
+ # Configure ActiveSupprt::TestCase to use the Given extensions.
2
+ if defined?(ActiveSupport::TestCase)
3
+ ActiveSupport::TestCase.send(:extend, Given::ClassExtensions)
4
+ ActiveSupport::TestCase.send(:extend, Given::MiniTest::ClassExtensions)
5
+ ActiveSupport::TestCase.send(:include, Given::FailureMethod)
6
+ ActiveSupport::TestCase.send(:include, Given::InstanceExtensions)
7
+ ActiveSupport::TestCase.send(:include, Given::MiniTest::InstanceExtensions)
8
+ end
2
9
  # Configure Minitest to use the Given extensions.
3
-
4
10
  Minitest::Spec.send(:extend, Given::ClassExtensions)
11
+ Minitest::Spec.send(:extend, Given::MiniTest::ClassExtensions)
5
12
  Minitest::Spec.send(:include, Given::FailureMethod)
6
13
  Minitest::Spec.send(:include, Given::InstanceExtensions)
7
- Given.use_natural_assertions if Given::NATURAL_ASSERTIONS_SUPPORTED
14
+ Minitest::Spec.send(:include, Given::MiniTest::InstanceExtensions)
15
+ Given.use_natural_assertions
@@ -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,19 +30,13 @@ 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
- eval "[__FILE__, __LINE__]", block.binding
35
+ if block.binding.respond_to?(:source_location)
36
+ block.binding.source_location
37
+ else
38
+ eval "[__FILE__, __LINE__]", block.binding
39
+ end
53
40
  end
54
41
 
55
42
  # Methods forwarded to the framework object.
@@ -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
- @output << "Failing expression: #{source.strip}\n" if @clause_type != "Then"
32
- explain_failure
33
- display_pairs(expression_value_pairs)
34
- @output << "\n"
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
@@ -6,10 +6,8 @@ module RSpec
6
6
  end
7
7
  end
8
8
 
9
- if Given::NATURAL_ASSERTIONS_SUPPORTED
10
- require 'given/rspec/monkey'
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'
@@ -15,6 +15,6 @@ RSpec.configure do |c|
15
15
  c.backtrace_clean_patterns << /lib\/rspec\/given/
16
16
  end
17
17
 
18
- Given.use_natural_assertions if Given::NATURAL_ASSERTIONS_SUPPORTED
18
+ Given.use_natural_assertions
19
19
  Given.source_caching_disabled = false
20
20
  end
@@ -2,8 +2,8 @@
2
2
  module Given
3
3
  VERSION_NUMBERS = [
4
4
  VERSION_MAJOR = 3,
5
- VERSION_MINOR = 6,
6
- VERSION_BUILD = 0,
5
+ VERSION_MINOR = 8,
6
+ VERSION_BUILD = 2,
7
7
  ]
8
8
  VERSION = VERSION_NUMBERS.join(".")
9
9
  end
@@ -56,7 +56,6 @@ EOF
56
56
  s.author = "Jim Weirich"
57
57
  s.email = "jim.weirich@gmail.com"
58
58
  s.homepage = "http://github.com/rspec-given/rspec-given"
59
- s.rubyforge_project = "given"
60
59
  end
61
60
 
62
61
  MINITEST_GIVEN_SPEC = Gem::Specification.new do |s|
@@ -84,7 +83,6 @@ EOF
84
83
  s.author = "Jim Weirich"
85
84
  s.email = "jim.weirich@gmail.com"
86
85
  s.homepage = "http://github.com/rspec-given/rspec-given"
87
- s.rubyforge_project = "given"
88
86
  end
89
87
 
90
88
  GIVEN_CORE_SPEC = Gem::Specification.new do |s|
@@ -112,7 +110,6 @@ EOF
112
110
  s.author = "Jim Weirich"
113
111
  s.email = "jim.weirich@gmail.com"
114
112
  s.homepage = "http://github.com/rspec-given/rspec-given"
115
- s.rubyforge_project = "given"
116
113
  end
117
114
 
118
115
  Gem::PackageTask.new(MINITEST_GIVEN_SPEC) do |pkg|
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.6.0
4
+ version: 3.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorcerer
@@ -81,7 +81,7 @@ homepage: http://github.com/rspec-given/rspec-given
81
81
  licenses:
82
82
  - MIT
83
83
  metadata: {}
84
- post_install_message:
84
+ post_install_message:
85
85
  rdoc_options:
86
86
  - "--line-numbers"
87
87
  - "--inline-source"
@@ -102,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubyforge_project: given
106
- rubygems_version: 2.4.4
107
- signing_key:
105
+ rubygems_version: 3.1.4
106
+ signing_key:
108
107
  specification_version: 4
109
108
  summary: Core engine for RSpec::Given and Minitest::Given.
110
109
  test_files: []