rspec-expectations 2.11.3 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/.document +1 -1
- data/.yardopts +1 -1
- data/Changelog.md +1026 -21
- data/{License.txt → LICENSE.md} +5 -3
- data/README.md +174 -78
- data/lib/rspec/expectations/block_snippet_extractor.rb +253 -0
- data/lib/rspec/expectations/configuration.rb +230 -0
- data/lib/rspec/expectations/expectation_target.rb +130 -55
- data/lib/rspec/expectations/fail_with.rb +17 -33
- data/lib/rspec/expectations/failure_aggregator.rb +212 -0
- data/lib/rspec/expectations/handler.rb +163 -29
- data/lib/rspec/expectations/minitest_integration.rb +58 -0
- data/lib/rspec/expectations/syntax.rb +68 -54
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/expectations.rb +59 -24
- data/lib/rspec/matchers/aliased_matcher.rb +116 -0
- data/lib/rspec/matchers/built_in/all.rb +86 -0
- data/lib/rspec/matchers/built_in/base_matcher.rb +150 -20
- data/lib/rspec/matchers/built_in/be.rb +115 -109
- data/lib/rspec/matchers/built_in/be_between.rb +77 -0
- data/lib/rspec/matchers/built_in/be_instance_of.rb +16 -1
- data/lib/rspec/matchers/built_in/be_kind_of.rb +10 -1
- data/lib/rspec/matchers/built_in/be_within.rb +43 -17
- data/lib/rspec/matchers/built_in/change.rb +392 -75
- data/lib/rspec/matchers/built_in/compound.rb +290 -0
- data/lib/rspec/matchers/built_in/contain_exactly.rb +302 -0
- data/lib/rspec/matchers/built_in/count_expectation.rb +169 -0
- data/lib/rspec/matchers/built_in/cover.rb +3 -0
- data/lib/rspec/matchers/built_in/eq.rb +26 -8
- data/lib/rspec/matchers/built_in/eql.rb +19 -8
- data/lib/rspec/matchers/built_in/equal.rb +56 -19
- data/lib/rspec/matchers/built_in/exist.rb +74 -10
- data/lib/rspec/matchers/built_in/has.rb +141 -22
- data/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
- data/lib/rspec/matchers/built_in/include.rb +175 -20
- data/lib/rspec/matchers/built_in/match.rb +95 -1
- data/lib/rspec/matchers/built_in/operators.rb +128 -0
- data/lib/rspec/matchers/built_in/output.rb +207 -0
- data/lib/rspec/matchers/built_in/raise_error.rb +212 -38
- data/lib/rspec/matchers/built_in/respond_to.rb +155 -29
- data/lib/rspec/matchers/built_in/satisfy.rb +39 -9
- data/lib/rspec/matchers/built_in/start_or_end_with.rb +94 -0
- data/lib/rspec/matchers/built_in/throw_symbol.rb +58 -14
- data/lib/rspec/matchers/built_in/yield.rb +252 -98
- data/lib/rspec/matchers/built_in.rb +47 -33
- data/lib/rspec/matchers/composable.rb +171 -0
- data/lib/rspec/matchers/dsl.rb +530 -10
- data/lib/rspec/matchers/english_phrasing.rb +58 -0
- data/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +82 -0
- data/lib/rspec/matchers/fail_matchers.rb +42 -0
- data/lib/rspec/matchers/generated_descriptions.rb +15 -10
- data/lib/rspec/matchers/matcher_delegator.rb +35 -0
- data/lib/rspec/matchers/matcher_protocol.rb +105 -0
- data/lib/rspec/matchers.rb +604 -252
- data.tar.gz.sig +0 -0
- metadata +178 -278
- metadata.gz.sig +0 -0
- data/features/README.md +0 -49
- data/features/Upgrade.md +0 -53
- data/features/built_in_matchers/README.md +0 -90
- data/features/built_in_matchers/be.feature +0 -173
- data/features/built_in_matchers/be_within.feature +0 -46
- data/features/built_in_matchers/cover.feature +0 -45
- data/features/built_in_matchers/end_with.feature +0 -46
- data/features/built_in_matchers/equality.feature +0 -145
- data/features/built_in_matchers/exist.feature +0 -43
- data/features/built_in_matchers/expect_change.feature +0 -59
- data/features/built_in_matchers/expect_error.feature +0 -138
- data/features/built_in_matchers/have.feature +0 -103
- data/features/built_in_matchers/include.feature +0 -121
- data/features/built_in_matchers/match.feature +0 -50
- data/features/built_in_matchers/operators.feature +0 -221
- data/features/built_in_matchers/predicates.feature +0 -128
- data/features/built_in_matchers/respond_to.feature +0 -78
- data/features/built_in_matchers/satisfy.feature +0 -31
- data/features/built_in_matchers/start_with.feature +0 -46
- data/features/built_in_matchers/throw_symbol.feature +0 -85
- data/features/built_in_matchers/types.feature +0 -114
- data/features/built_in_matchers/yield.feature +0 -146
- data/features/custom_matchers/access_running_example.feature +0 -53
- data/features/custom_matchers/define_diffable_matcher.feature +0 -27
- data/features/custom_matchers/define_matcher.feature +0 -340
- data/features/custom_matchers/define_matcher_outside_rspec.feature +0 -38
- data/features/custom_matchers/define_matcher_with_fluent_interface.feature +0 -24
- data/features/customized_message.feature +0 -22
- data/features/diffing.feature +0 -85
- data/features/implicit_docstrings.feature +0 -52
- data/features/step_definitions/additional_cli_steps.rb +0 -22
- data/features/support/env.rb +0 -5
- data/features/syntax_configuration.feature +0 -68
- data/features/test_frameworks/test_unit.feature +0 -46
- data/lib/rspec/expectations/deprecation.rb +0 -38
- data/lib/rspec/expectations/differ.rb +0 -81
- data/lib/rspec/expectations/errors.rb +0 -9
- data/lib/rspec/expectations/extensions/array.rb +0 -9
- data/lib/rspec/expectations/extensions/object.rb +0 -39
- data/lib/rspec/expectations/extensions.rb +0 -2
- data/lib/rspec/matchers/be_close.rb +0 -9
- data/lib/rspec/matchers/built_in/have.rb +0 -108
- data/lib/rspec/matchers/built_in/match_array.rb +0 -45
- data/lib/rspec/matchers/built_in/start_and_end_with.rb +0 -48
- data/lib/rspec/matchers/compatibility.rb +0 -14
- data/lib/rspec/matchers/configuration.rb +0 -66
- data/lib/rspec/matchers/extensions/instance_eval_with_args.rb +0 -39
- data/lib/rspec/matchers/matcher.rb +0 -299
- data/lib/rspec/matchers/method_missing.rb +0 -12
- data/lib/rspec/matchers/operator_matcher.rb +0 -84
- data/lib/rspec/matchers/pretty.rb +0 -60
- data/lib/rspec-expectations.rb +0 -1
- data/spec/rspec/expectations/differ_spec.rb +0 -153
- data/spec/rspec/expectations/expectation_target_spec.rb +0 -65
- data/spec/rspec/expectations/extensions/kernel_spec.rb +0 -67
- data/spec/rspec/expectations/fail_with_spec.rb +0 -70
- data/spec/rspec/expectations/handler_spec.rb +0 -206
- data/spec/rspec/matchers/base_matcher_spec.rb +0 -60
- data/spec/rspec/matchers/be_close_spec.rb +0 -22
- data/spec/rspec/matchers/be_instance_of_spec.rb +0 -40
- data/spec/rspec/matchers/be_kind_of_spec.rb +0 -37
- data/spec/rspec/matchers/be_spec.rb +0 -452
- data/spec/rspec/matchers/be_within_spec.rb +0 -80
- data/spec/rspec/matchers/change_spec.rb +0 -528
- data/spec/rspec/matchers/configuration_spec.rb +0 -202
- data/spec/rspec/matchers/cover_spec.rb +0 -69
- data/spec/rspec/matchers/description_generation_spec.rb +0 -176
- data/spec/rspec/matchers/dsl_spec.rb +0 -57
- data/spec/rspec/matchers/eq_spec.rb +0 -54
- data/spec/rspec/matchers/eql_spec.rb +0 -41
- data/spec/rspec/matchers/equal_spec.rb +0 -60
- data/spec/rspec/matchers/exist_spec.rb +0 -110
- data/spec/rspec/matchers/has_spec.rb +0 -118
- data/spec/rspec/matchers/have_spec.rb +0 -461
- data/spec/rspec/matchers/include_spec.rb +0 -367
- data/spec/rspec/matchers/match_array_spec.rb +0 -124
- data/spec/rspec/matchers/match_spec.rb +0 -61
- data/spec/rspec/matchers/matcher_spec.rb +0 -434
- data/spec/rspec/matchers/matchers_spec.rb +0 -31
- data/spec/rspec/matchers/method_missing_spec.rb +0 -24
- data/spec/rspec/matchers/operator_matcher_spec.rb +0 -221
- data/spec/rspec/matchers/raise_error_spec.rb +0 -344
- data/spec/rspec/matchers/respond_to_spec.rb +0 -295
- data/spec/rspec/matchers/satisfy_spec.rb +0 -44
- data/spec/rspec/matchers/start_with_end_with_spec.rb +0 -182
- data/spec/rspec/matchers/throw_symbol_spec.rb +0 -116
- data/spec/rspec/matchers/yield_spec.rb +0 -402
- data/spec/spec_helper.rb +0 -27
- data/spec/support/classes.rb +0 -56
- data/spec/support/in_sub_process.rb +0 -31
- data/spec/support/matchers.rb +0 -22
- data/spec/support/ruby_version.rb +0 -10
- data/spec/support/shared_examples.rb +0 -13
data/spec/spec_helper.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
def add_to_load_path(path, prepend=false)
|
2
|
-
path = File.expand_path("../../#{path}/lib", __FILE__)
|
3
|
-
if prepend
|
4
|
-
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
5
|
-
else
|
6
|
-
$LOAD_PATH << path unless $LOAD_PATH.include?(path)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
|
12
|
-
add_to_load_path("rspec-expectations", :prepend)
|
13
|
-
add_to_load_path("rspec-core")
|
14
|
-
add_to_load_path("rspec-mocks")
|
15
|
-
|
16
|
-
require 'rspec/expectations'
|
17
|
-
require 'rspec/core'
|
18
|
-
require 'rspec/mocks'
|
19
|
-
|
20
|
-
Dir['./spec/support/**/*'].each {|f| require f}
|
21
|
-
|
22
|
-
RSpec::configure do |config|
|
23
|
-
config.color_enabled = true
|
24
|
-
config.filter_run :focused => true
|
25
|
-
config.run_all_when_everything_filtered = true
|
26
|
-
config.order = :random
|
27
|
-
end
|
data/spec/support/classes.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# various classes used by the specs
|
2
|
-
module RSpec
|
3
|
-
module Expectations
|
4
|
-
module Helper
|
5
|
-
class CollectionWithSizeMethod
|
6
|
-
def initialize; @list = []; end
|
7
|
-
def size; @list.size; end
|
8
|
-
def push(item); @list.push(item); end
|
9
|
-
end
|
10
|
-
|
11
|
-
class CollectionWithLengthMethod
|
12
|
-
def initialize; @list = []; end
|
13
|
-
def length; @list.size; end
|
14
|
-
def push(item); @list.push(item); end
|
15
|
-
end
|
16
|
-
|
17
|
-
class CollectionWithCountMethod
|
18
|
-
def initialize; @list = []; end
|
19
|
-
def count; @list.count; end
|
20
|
-
def push(item); @list.push(item); end
|
21
|
-
end
|
22
|
-
|
23
|
-
class CollectionOwner
|
24
|
-
attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method, :items_in_collection_with_count_method
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
@items_in_collection_with_size_method = CollectionWithSizeMethod.new
|
28
|
-
@items_in_collection_with_length_method = CollectionWithLengthMethod.new
|
29
|
-
@items_in_collection_with_count_method = CollectionWithCountMethod.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def add_to_collection_with_size_method(item)
|
33
|
-
@items_in_collection_with_size_method.push(item)
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_to_collection_with_length_method(item)
|
37
|
-
@items_in_collection_with_length_method.push(item)
|
38
|
-
end
|
39
|
-
|
40
|
-
def add_to_collection_with_count_method(item)
|
41
|
-
@items_in_collection_with_count_method.push(item)
|
42
|
-
end
|
43
|
-
|
44
|
-
def items_for(arg)
|
45
|
-
return [1, 2, 3] if arg == 'a'
|
46
|
-
[1]
|
47
|
-
end
|
48
|
-
|
49
|
-
def items
|
50
|
-
@items_in_collection_with_size_method
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module InSubProcess
|
2
|
-
# Useful as a way to isolate a global change to a subprocess.
|
3
|
-
def in_sub_process
|
4
|
-
readme, writeme = IO.pipe
|
5
|
-
|
6
|
-
pid = Process.fork do
|
7
|
-
value = nil
|
8
|
-
begin
|
9
|
-
yield
|
10
|
-
rescue => e
|
11
|
-
value = e
|
12
|
-
end
|
13
|
-
|
14
|
-
writeme.write Marshal.dump(value)
|
15
|
-
|
16
|
-
readme.close
|
17
|
-
writeme.close
|
18
|
-
exit! # prevent at_exit hooks from running (e.g. minitest)
|
19
|
-
end
|
20
|
-
|
21
|
-
writeme.close
|
22
|
-
Process.waitpid(pid)
|
23
|
-
|
24
|
-
if exception = Marshal.load(readme.read)
|
25
|
-
raise exception
|
26
|
-
end
|
27
|
-
|
28
|
-
readme.close
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
data/spec/support/matchers.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
RSpec::Matchers.define :include_method do |expected|
|
2
|
-
match do |actual|
|
3
|
-
actual.map { |m| m.to_s }.include?(expected.to_s)
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
module RSpec
|
8
|
-
module Matchers
|
9
|
-
def fail
|
10
|
-
raise_error(RSpec::Expectations::ExpectationNotMetError)
|
11
|
-
end
|
12
|
-
|
13
|
-
def fail_with(message)
|
14
|
-
raise_error(RSpec::Expectations::ExpectationNotMetError, message)
|
15
|
-
end
|
16
|
-
|
17
|
-
def fail_matching(message)
|
18
|
-
raise_error(RSpec::Expectations::ExpectationNotMetError, /#{Regexp.escape(message)}/)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
@@ -1,13 +0,0 @@
|
|
1
|
-
shared_examples_for "an RSpec matcher" do |options|
|
2
|
-
let(:valid_value) { options.fetch(:valid_value) }
|
3
|
-
let(:invalid_value) { options.fetch(:invalid_value) }
|
4
|
-
|
5
|
-
it 'matches a valid value when using #== so it can be composed' do
|
6
|
-
expect(matcher).to eq(valid_value)
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'does not match an invalid value when using #== so it can be composed' do
|
10
|
-
expect(matcher).not_to eq(invalid_value)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|