rspec-expectations 3.0.0.beta1 → 3.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +2 -2
- data/.yardopts +1 -0
- data/Changelog.md +138 -0
- data/README.md +75 -8
- data/features/README.md +2 -2
- data/features/built_in_matchers/README.md +12 -9
- data/features/built_in_matchers/comparisons.feature +2 -2
- data/features/built_in_matchers/contain_exactly.feature +46 -0
- data/features/built_in_matchers/expect_change.feature +2 -2
- data/features/built_in_matchers/include.feature +0 -48
- data/features/built_in_matchers/output.feature +70 -0
- data/features/composing_matchers.feature +250 -0
- data/features/compound_expectations.feature +45 -0
- data/features/custom_matchers/access_running_example.feature +1 -1
- data/features/custom_matchers/define_matcher.feature +6 -6
- data/features/custom_matchers/define_matcher_outside_rspec.feature +4 -8
- data/features/test_frameworks/{test_unit.feature → minitest.feature} +11 -11
- data/lib/rspec/expectations.rb +31 -42
- data/lib/rspec/expectations/diff_presenter.rb +141 -0
- data/lib/rspec/expectations/differ.rb +22 -132
- data/lib/rspec/expectations/encoded_string.rb +56 -0
- data/lib/rspec/expectations/expectation_target.rb +0 -30
- data/lib/rspec/expectations/fail_with.rb +2 -2
- data/lib/rspec/expectations/handler.rb +128 -31
- data/lib/rspec/expectations/minitest_integration.rb +16 -0
- data/lib/rspec/expectations/syntax.rb +4 -58
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/matchers.rb +298 -60
- data/lib/rspec/matchers/aliased_matcher.rb +35 -0
- data/lib/rspec/matchers/built_in.rb +37 -33
- data/lib/rspec/matchers/built_in/base_matcher.rb +25 -15
- data/lib/rspec/matchers/built_in/be.rb +23 -31
- data/lib/rspec/matchers/built_in/be_between.rb +55 -0
- data/lib/rspec/matchers/built_in/be_within.rb +15 -11
- data/lib/rspec/matchers/built_in/change.rb +198 -81
- data/lib/rspec/matchers/built_in/compound.rb +106 -0
- data/lib/rspec/matchers/built_in/contain_exactly.rb +245 -0
- data/lib/rspec/matchers/built_in/eq.rb +43 -4
- data/lib/rspec/matchers/built_in/eql.rb +2 -2
- data/lib/rspec/matchers/built_in/equal.rb +35 -18
- data/lib/rspec/matchers/built_in/has.rb +16 -15
- data/lib/rspec/matchers/built_in/include.rb +45 -23
- data/lib/rspec/matchers/built_in/match.rb +6 -3
- data/lib/rspec/matchers/built_in/operators.rb +103 -0
- data/lib/rspec/matchers/built_in/output.rb +108 -0
- data/lib/rspec/matchers/built_in/raise_error.rb +9 -15
- data/lib/rspec/matchers/built_in/respond_to.rb +5 -4
- data/lib/rspec/matchers/built_in/satisfy.rb +4 -3
- data/lib/rspec/matchers/built_in/start_and_end_with.rb +37 -16
- data/lib/rspec/matchers/built_in/throw_symbol.rb +6 -5
- data/lib/rspec/matchers/built_in/yield.rb +31 -29
- data/lib/rspec/matchers/composable.rb +138 -0
- data/lib/rspec/matchers/dsl.rb +330 -0
- data/lib/rspec/matchers/generated_descriptions.rb +6 -6
- data/lib/rspec/matchers/matcher_delegator.rb +33 -0
- data/lib/rspec/matchers/pretty.rb +13 -2
- data/spec/rspec/expectations/{differ_spec.rb → diff_presenter_spec.rb} +56 -36
- data/spec/rspec/expectations/encoded_string_spec.rb +74 -0
- data/spec/rspec/expectations/extensions/kernel_spec.rb +11 -11
- data/spec/rspec/expectations/fail_with_spec.rb +8 -8
- data/spec/rspec/expectations/handler_spec.rb +27 -49
- data/spec/rspec/expectations/minitest_integration_spec.rb +27 -0
- data/spec/rspec/expectations/syntax_spec.rb +17 -67
- data/spec/rspec/expectations_spec.rb +7 -52
- data/spec/rspec/matchers/aliased_matcher_spec.rb +48 -0
- data/spec/rspec/matchers/aliases_spec.rb +449 -0
- data/spec/rspec/matchers/{base_matcher_spec.rb → built_in/base_matcher_spec.rb} +24 -3
- data/spec/rspec/matchers/built_in/be_between_spec.rb +159 -0
- data/spec/rspec/matchers/{be_instance_of_spec.rb → built_in/be_instance_of_spec.rb} +0 -0
- data/spec/rspec/matchers/{be_kind_of_spec.rb → built_in/be_kind_of_spec.rb} +0 -0
- data/spec/rspec/matchers/{be_spec.rb → built_in/be_spec.rb} +76 -32
- data/spec/rspec/matchers/{be_within_spec.rb → built_in/be_within_spec.rb} +6 -2
- data/spec/rspec/matchers/{change_spec.rb → built_in/change_spec.rb} +310 -69
- data/spec/rspec/matchers/built_in/compound_spec.rb +292 -0
- data/spec/rspec/matchers/built_in/contain_exactly_spec.rb +441 -0
- data/spec/rspec/matchers/{cover_spec.rb → built_in/cover_spec.rb} +0 -0
- data/spec/rspec/matchers/built_in/eq_spec.rb +156 -0
- data/spec/rspec/matchers/{eql_spec.rb → built_in/eql_spec.rb} +2 -2
- data/spec/rspec/matchers/built_in/equal_spec.rb +106 -0
- data/spec/rspec/matchers/{exist_spec.rb → built_in/exist_spec.rb} +1 -1
- data/spec/rspec/matchers/{has_spec.rb → built_in/has_spec.rb} +39 -0
- data/spec/rspec/matchers/{include_spec.rb → built_in/include_spec.rb} +118 -109
- data/spec/rspec/matchers/{match_spec.rb → built_in/match_spec.rb} +30 -2
- data/spec/rspec/matchers/{operator_matcher_spec.rb → built_in/operators_spec.rb} +26 -26
- data/spec/rspec/matchers/built_in/output_spec.rb +165 -0
- data/spec/rspec/matchers/{raise_error_spec.rb → built_in/raise_error_spec.rb} +81 -11
- data/spec/rspec/matchers/{respond_to_spec.rb → built_in/respond_to_spec.rb} +0 -0
- data/spec/rspec/matchers/{satisfy_spec.rb → built_in/satisfy_spec.rb} +0 -0
- data/spec/rspec/matchers/{start_with_end_with_spec.rb → built_in/start_and_end_with_spec.rb} +82 -15
- data/spec/rspec/matchers/{throw_symbol_spec.rb → built_in/throw_symbol_spec.rb} +29 -10
- data/spec/rspec/matchers/{yield_spec.rb → built_in/yield_spec.rb} +90 -0
- data/spec/rspec/matchers/configuration_spec.rb +7 -39
- data/spec/rspec/matchers/description_generation_spec.rb +22 -6
- data/spec/rspec/matchers/dsl_spec.rb +838 -0
- data/spec/rspec/matchers/legacy_spec.rb +101 -0
- data/spec/rspec/matchers_spec.rb +74 -0
- data/spec/spec_helper.rb +35 -21
- data/spec/support/shared_examples.rb +26 -4
- metadata +172 -116
- metadata.gz.sig +3 -4
- checksums.yaml +0 -15
- checksums.yaml.gz.sig +0 -0
- data/features/built_in_matchers/match_array.feature +0 -37
- data/lib/rspec/expectations/errors.rb +0 -9
- data/lib/rspec/expectations/extensions.rb +0 -1
- data/lib/rspec/expectations/extensions/object.rb +0 -29
- data/lib/rspec/matchers/built_in/match_array.rb +0 -51
- data/lib/rspec/matchers/compatibility.rb +0 -14
- data/lib/rspec/matchers/matcher.rb +0 -301
- data/lib/rspec/matchers/method_missing.rb +0 -12
- data/lib/rspec/matchers/operator_matcher.rb +0 -99
- data/lib/rspec/matchers/test_unit_integration.rb +0 -11
- data/spec/rspec/matchers/eq_spec.rb +0 -60
- data/spec/rspec/matchers/equal_spec.rb +0 -78
- data/spec/rspec/matchers/include_matcher_integration_spec.rb +0 -30
- data/spec/rspec/matchers/match_array_spec.rb +0 -194
- data/spec/rspec/matchers/matcher_spec.rb +0 -706
- data/spec/rspec/matchers/matchers_spec.rb +0 -36
- data/spec/rspec/matchers/method_missing_spec.rb +0 -28
- data/spec/support/classes.rb +0 -56
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/ruby_version.rb +0 -10
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RSpec
|
4
|
-
describe Matchers do
|
5
|
-
|
6
|
-
let(:sample_matchers) do
|
7
|
-
[:be,
|
8
|
-
:be_instance_of,
|
9
|
-
:be_kind_of]
|
10
|
-
end
|
11
|
-
|
12
|
-
context "once required" do
|
13
|
-
include TestUnitIntegrationSupport
|
14
|
-
|
15
|
-
it "includes itself in Test::Unit::TestCase" do
|
16
|
-
with_test_unit_loaded do
|
17
|
-
test_unit_case = Test::Unit::TestCase.allocate
|
18
|
-
sample_matchers.each do |sample_matcher|
|
19
|
-
expect(test_unit_case).to respond_to(sample_matcher)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "includes itself in MiniTest::Unit::TestCase", :if => defined?(MiniTest) do
|
25
|
-
with_test_unit_loaded do
|
26
|
-
minitest_case = MiniTest::Unit::TestCase.allocate
|
27
|
-
sample_matchers.each do |sample_matcher|
|
28
|
-
expect(minitest_case).to respond_to(sample_matcher)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for "a well-behaved method_missing hook" do
|
4
|
-
include TestUnitIntegrationSupport
|
5
|
-
|
6
|
-
it "raises a NoMethodError (and not SystemStackError) for an undefined method" do
|
7
|
-
with_test_unit_loaded do
|
8
|
-
expect { subject.some_undefined_method }.to raise_error(NoMethodError)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "RSpec::Matchers method_missing hook" do
|
14
|
-
subject { self }
|
15
|
-
|
16
|
-
it_behaves_like "a well-behaved method_missing hook"
|
17
|
-
|
18
|
-
context 'when invoked in a Test::Unit::TestCase' do
|
19
|
-
subject { Test::Unit::TestCase.allocate }
|
20
|
-
it_behaves_like "a well-behaved method_missing hook"
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'when invoked in a MiniTest::Unit::TestCase', :if => defined?(MiniTest) do
|
24
|
-
subject { MiniTest::Unit::TestCase.allocate }
|
25
|
-
it_behaves_like "a well-behaved method_missing hook"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
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,37 +0,0 @@
|
|
1
|
-
module InSubProcess
|
2
|
-
if RUBY_PLATFORM == 'java'
|
3
|
-
def in_sub_process
|
4
|
-
pending "This spec requires forking to work properly, " +
|
5
|
-
"and JRuby does not support forking"
|
6
|
-
end
|
7
|
-
else
|
8
|
-
# Useful as a way to isolate a global change to a subprocess.
|
9
|
-
def in_sub_process
|
10
|
-
readme, writeme = IO.pipe
|
11
|
-
|
12
|
-
pid = Process.fork do
|
13
|
-
exception = nil
|
14
|
-
begin
|
15
|
-
yield
|
16
|
-
rescue Exception => e
|
17
|
-
exception = e
|
18
|
-
end
|
19
|
-
|
20
|
-
writeme.write Marshal.dump(exception)
|
21
|
-
|
22
|
-
readme.close
|
23
|
-
writeme.close
|
24
|
-
exit! # prevent at_exit hooks from running (e.g. minitest)
|
25
|
-
end
|
26
|
-
|
27
|
-
writeme.close
|
28
|
-
Process.waitpid(pid)
|
29
|
-
|
30
|
-
exception = Marshal.load(readme.read)
|
31
|
-
readme.close
|
32
|
-
|
33
|
-
raise exception if exception
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|