sspec-support 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/Changelog.md +242 -0
  3. data/LICENSE.md +23 -0
  4. data/README.md +40 -0
  5. data/lib/rspec/support.rb +149 -0
  6. data/lib/rspec/support/caller_filter.rb +83 -0
  7. data/lib/rspec/support/comparable_version.rb +46 -0
  8. data/lib/rspec/support/differ.rb +215 -0
  9. data/lib/rspec/support/directory_maker.rb +63 -0
  10. data/lib/rspec/support/encoded_string.rb +165 -0
  11. data/lib/rspec/support/fuzzy_matcher.rb +48 -0
  12. data/lib/rspec/support/hunk_generator.rb +47 -0
  13. data/lib/rspec/support/matcher_definition.rb +42 -0
  14. data/lib/rspec/support/method_signature_verifier.rb +426 -0
  15. data/lib/rspec/support/mutex.rb +73 -0
  16. data/lib/rspec/support/object_formatter.rb +275 -0
  17. data/lib/rspec/support/recursive_const_methods.rb +76 -0
  18. data/lib/rspec/support/reentrant_mutex.rb +53 -0
  19. data/lib/rspec/support/ruby_features.rb +176 -0
  20. data/lib/rspec/support/source.rb +75 -0
  21. data/lib/rspec/support/source/location.rb +21 -0
  22. data/lib/rspec/support/source/node.rb +110 -0
  23. data/lib/rspec/support/source/token.rb +87 -0
  24. data/lib/rspec/support/spec.rb +81 -0
  25. data/lib/rspec/support/spec/deprecation_helpers.rb +64 -0
  26. data/lib/rspec/support/spec/formatting_support.rb +9 -0
  27. data/lib/rspec/support/spec/in_sub_process.rb +69 -0
  28. data/lib/rspec/support/spec/library_wide_checks.rb +150 -0
  29. data/lib/rspec/support/spec/shell_out.rb +84 -0
  30. data/lib/rspec/support/spec/stderr_splitter.rb +63 -0
  31. data/lib/rspec/support/spec/string_matcher.rb +46 -0
  32. data/lib/rspec/support/spec/with_isolated_directory.rb +13 -0
  33. data/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
  34. data/lib/rspec/support/version.rb +7 -0
  35. data/lib/rspec/support/warnings.rb +39 -0
  36. metadata +115 -0
@@ -0,0 +1,63 @@
1
+ require 'stringio'
2
+
3
+ module RSpec
4
+ module Support
5
+ class StdErrSplitter
6
+ def initialize(original)
7
+ @orig_stderr = original
8
+ @output_tracker = ::StringIO.new
9
+ end
10
+
11
+ respond_to_name = (::RUBY_VERSION.to_f < 1.9) ? :respond_to? : :respond_to_missing?
12
+ define_method respond_to_name do |*args|
13
+ @orig_stderr.respond_to?(*args) || super(*args)
14
+ end
15
+
16
+ def method_missing(name, *args, &block)
17
+ @output_tracker.__send__(name, *args, &block) if @output_tracker.respond_to?(name)
18
+ @orig_stderr.__send__(name, *args, &block)
19
+ end
20
+
21
+ def ==(other)
22
+ @orig_stderr == other
23
+ end
24
+
25
+ def reopen(*args)
26
+ reset!
27
+ @orig_stderr.reopen(*args)
28
+ end
29
+
30
+ # To work around JRuby error:
31
+ # can't convert RSpec::Support::StdErrSplitter into String
32
+ def to_io
33
+ @orig_stderr.to_io
34
+ end
35
+
36
+ # To work around JRuby error:
37
+ # TypeError: $stderr must have write method, RSpec::StdErrSplitter given
38
+ def write(line)
39
+ return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG
40
+
41
+ @orig_stderr.write(line)
42
+ @output_tracker.write(line)
43
+ end
44
+
45
+ def has_output?
46
+ !output.empty?
47
+ end
48
+
49
+ def reset!
50
+ @output_tracker = ::StringIO.new
51
+ end
52
+
53
+ def verify_no_warnings!
54
+ raise "Warnings were generated: #{output}" if has_output?
55
+ reset!
56
+ end
57
+
58
+ def output
59
+ @output_tracker.string
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,46 @@
1
+ require 'rspec/matchers'
2
+ # Special matcher for comparing encoded strings so that
3
+ # we don't run any expectation failures through the Differ,
4
+ # which also relies on EncodedString. Instead, confirm the
5
+ # strings have the same bytes.
6
+ RSpec::Matchers.define :be_identical_string do |expected|
7
+
8
+ if String.method_defined?(:encoding)
9
+ match do
10
+ expected_encoding? &&
11
+ actual.bytes.to_a == expected.bytes.to_a
12
+ end
13
+
14
+ failure_message do
15
+ "expected\n#{actual.inspect} (#{actual.encoding.name}) to be identical to\n"\
16
+ "#{expected.inspect} (#{expected.encoding.name})\n"\
17
+ "The exact bytes are printed below for more detail:\n"\
18
+ "#{actual.bytes.to_a}\n"\
19
+ "#{expected.bytes.to_a}\n"\
20
+ end
21
+
22
+ # Depends on chaining :with_same_encoding for it to
23
+ # check for string encoding.
24
+ def expected_encoding?
25
+ if defined?(@expect_same_encoding) && @expect_same_encoding
26
+ actual.encoding == expected.encoding
27
+ else
28
+ true
29
+ end
30
+ end
31
+ else
32
+ match do
33
+ actual.split(//) == expected.split(//)
34
+ end
35
+
36
+ failure_message do
37
+ "expected\n#{actual.inspect} to be identical to\n#{expected.inspect}\n"
38
+ end
39
+ end
40
+
41
+ chain :with_same_encoding do
42
+ @expect_same_encoding ||= true
43
+ end
44
+ end
45
+ RSpec::Matchers.alias_matcher :a_string_identical_to, :be_identical_string
46
+ RSpec::Matchers.alias_matcher :be_diffed_as, :be_identical_string
@@ -0,0 +1,13 @@
1
+ require 'tmpdir'
2
+
3
+ RSpec.shared_context "isolated directory" do
4
+ around do |ex|
5
+ Dir.mktmpdir do |tmp_dir|
6
+ Dir.chdir(tmp_dir, &ex)
7
+ end
8
+ end
9
+ end
10
+
11
+ RSpec.configure do |c|
12
+ c.include_context "isolated directory", :isolated_directory => true
13
+ end
@@ -0,0 +1,13 @@
1
+ module RSpec
2
+ module Support
3
+ module WithIsolatedStdErr
4
+ def with_isolated_stderr
5
+ original = $stderr
6
+ $stderr = StringIO.new
7
+ yield
8
+ ensure
9
+ $stderr = original
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module RSpec
2
+ module Support
3
+ module Version
4
+ STRING = '3.8.0'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,39 @@
1
+ require 'rspec/support'
2
+ RSpec::Support.require_rspec_support "caller_filter"
3
+
4
+ module RSpec
5
+ module Support
6
+ module Warnings
7
+ def deprecate(deprecated, options={})
8
+ warn_with "DEPRECATION: #{deprecated} is deprecated.", options
9
+ end
10
+
11
+ # @private
12
+ #
13
+ # Used internally to print deprecation warnings
14
+ # when rspec-core isn't loaded
15
+ def warn_deprecation(message, options={})
16
+ warn_with "DEPRECATION: \n #{message}", options
17
+ end
18
+
19
+ # @private
20
+ #
21
+ # Used internally to print warnings
22
+ def warning(text, options={})
23
+ warn_with "WARNING: #{text}.", options
24
+ end
25
+
26
+ # @private
27
+ #
28
+ # Used internally to print longer warnings
29
+ def warn_with(message, options={})
30
+ call_site = options.fetch(:call_site) { CallerFilter.first_non_rspec_line }
31
+ message += " Use #{options[:replacement]} instead." if options[:replacement]
32
+ message += " Called from #{call_site}." if call_site
33
+ Support.warning_notifier.call message
34
+ end
35
+ end
36
+ end
37
+
38
+ extend RSpec::Support::Warnings
39
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sspec-support
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.8.0
5
+ platform: ruby
6
+ authors:
7
+ - David Chelimsky
8
+ - Myron Marson
9
+ - Jon Rowe
10
+ - Sam Phippen
11
+ - Xaviery Shay
12
+ - Bradley Schaefer
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+ date: 2019-04-11 00:00:00.000000000 Z
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: rake
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - "~>"
23
+ - !ruby/object:Gem::Version
24
+ version: 10.0.0
25
+ type: :development
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - "~>"
30
+ - !ruby/object:Gem::Version
31
+ version: 10.0.0
32
+ - !ruby/object:Gem::Dependency
33
+ name: thread_order
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: 1.1.0
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.0
46
+ description: Support utilities for RSpec gems
47
+ email: rspec-users@rubyforge.org
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - Changelog.md
53
+ - LICENSE.md
54
+ - README.md
55
+ - lib/rspec/support.rb
56
+ - lib/rspec/support/caller_filter.rb
57
+ - lib/rspec/support/comparable_version.rb
58
+ - lib/rspec/support/differ.rb
59
+ - lib/rspec/support/directory_maker.rb
60
+ - lib/rspec/support/encoded_string.rb
61
+ - lib/rspec/support/fuzzy_matcher.rb
62
+ - lib/rspec/support/hunk_generator.rb
63
+ - lib/rspec/support/matcher_definition.rb
64
+ - lib/rspec/support/method_signature_verifier.rb
65
+ - lib/rspec/support/mutex.rb
66
+ - lib/rspec/support/object_formatter.rb
67
+ - lib/rspec/support/recursive_const_methods.rb
68
+ - lib/rspec/support/reentrant_mutex.rb
69
+ - lib/rspec/support/ruby_features.rb
70
+ - lib/rspec/support/source.rb
71
+ - lib/rspec/support/source/location.rb
72
+ - lib/rspec/support/source/node.rb
73
+ - lib/rspec/support/source/token.rb
74
+ - lib/rspec/support/spec.rb
75
+ - lib/rspec/support/spec/deprecation_helpers.rb
76
+ - lib/rspec/support/spec/formatting_support.rb
77
+ - lib/rspec/support/spec/in_sub_process.rb
78
+ - lib/rspec/support/spec/library_wide_checks.rb
79
+ - lib/rspec/support/spec/shell_out.rb
80
+ - lib/rspec/support/spec/stderr_splitter.rb
81
+ - lib/rspec/support/spec/string_matcher.rb
82
+ - lib/rspec/support/spec/with_isolated_directory.rb
83
+ - lib/rspec/support/spec/with_isolated_stderr.rb
84
+ - lib/rspec/support/version.rb
85
+ - lib/rspec/support/warnings.rb
86
+ homepage: https://github.com/rspec/rspec-support
87
+ licenses:
88
+ - MIT
89
+ metadata:
90
+ bug_tracker_uri: https://github.com/rspec/rspec-support/issues
91
+ changelog_uri: https://github.com/rspec/rspec-support/blob/v3.8.0/Changelog.md
92
+ documentation_uri: https://rspec.info/documentation/
93
+ mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
94
+ source_code_uri: https://github.com/rspec/rspec-support
95
+ post_install_message:
96
+ rdoc_options:
97
+ - "--charset=UTF-8"
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 1.8.7
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.0.3
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: rspec-support-3.8.0
115
+ test_files: []