mspec 1.5.17 → 1.5.18
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/.gitignore +27 -0
- data/Gemfile +4 -0
- data/README +39 -159
- data/Rakefile +4 -44
- data/bin/mkspec.bat +1 -0
- data/bin/mspec-ci.bat +1 -0
- data/bin/mspec-run.bat +1 -0
- data/bin/mspec-tag.bat +1 -0
- data/bin/mspec.bat +1 -0
- data/lib/mspec/commands/mkspec.rb +2 -2
- data/lib/mspec/commands/mspec-run.rb +4 -0
- data/lib/mspec/commands/mspec.rb +18 -3
- data/lib/mspec/guards.rb +1 -0
- data/lib/mspec/guards/block_device.rb +22 -0
- data/lib/mspec/guards/guard.rb +14 -2
- data/lib/mspec/helpers.rb +5 -5
- data/lib/mspec/helpers/const_lookup.rb +6 -1
- data/lib/mspec/helpers/datetime.rb +28 -0
- data/lib/mspec/helpers/ducktype.rb +4 -4
- data/lib/mspec/helpers/environment.rb +19 -2
- data/lib/mspec/helpers/fs.rb +5 -1
- data/lib/mspec/helpers/io.rb +39 -1
- data/lib/mspec/helpers/numeric.rb +89 -0
- data/lib/mspec/helpers/pack.rb +3 -0
- data/lib/mspec/helpers/ruby_exe.rb +53 -15
- data/lib/mspec/helpers/singleton_class.rb +7 -0
- data/lib/mspec/helpers/stasy.rb +33 -0
- data/lib/mspec/helpers/tmp.rb +16 -3
- data/lib/mspec/matchers.rb +8 -0
- data/lib/mspec/matchers/be_computed_by.rb +37 -0
- data/lib/mspec/matchers/be_computed_by_function.rb +35 -0
- data/lib/mspec/matchers/be_nan.rb +20 -0
- data/lib/mspec/matchers/be_valid_dns_name.rb +25 -0
- data/lib/mspec/matchers/have_data.rb +6 -5
- data/lib/mspec/matchers/have_private_method.rb +24 -0
- data/lib/mspec/matchers/have_singleton_method.rb +24 -0
- data/lib/mspec/matchers/infinity.rb +28 -0
- data/lib/mspec/matchers/match_yaml.rb +5 -5
- data/lib/mspec/matchers/raise_error.rb +5 -3
- data/lib/mspec/matchers/signed_zero.rb +28 -0
- data/lib/mspec/mocks/mock.rb +15 -9
- data/lib/mspec/mocks/object.rb +4 -0
- data/lib/mspec/mocks/proxy.rb +26 -1
- data/lib/mspec/runner/actions.rb +0 -1
- data/lib/mspec/runner/context.rb +18 -16
- data/lib/mspec/runner/formatters.rb +2 -0
- data/lib/mspec/runner/formatters/dotted.rb +13 -1
- data/lib/mspec/runner/formatters/junit.rb +96 -0
- data/lib/mspec/runner/formatters/profile.rb +70 -0
- data/lib/mspec/runner/mspec.rb +11 -0
- data/lib/mspec/runner/shared.rb +1 -1
- data/lib/mspec/utils/options.rb +33 -9
- data/lib/mspec/utils/ruby_name.rb +1 -1
- data/lib/mspec/utils/script.rb +2 -1
- data/lib/mspec/version.rb +1 -1
- data/mspec.gemspec +40 -0
- data/spec/commands/mkspec_spec.rb +4 -3
- data/spec/commands/mspec_ci_spec.rb +1 -6
- data/spec/commands/mspec_run_spec.rb +1 -6
- data/spec/commands/mspec_spec.rb +14 -6
- data/spec/commands/mspec_tag_spec.rb +28 -27
- data/spec/expectations/expectations_spec.rb +1 -1
- data/spec/expectations/should_spec.rb +4 -4
- data/spec/guards/background_spec.rb +2 -2
- data/spec/guards/block_device_spec.rb +46 -0
- data/spec/guards/bug_spec.rb +2 -3
- data/spec/guards/compliance_spec.rb +2 -2
- data/spec/guards/conflict_spec.rb +2 -2
- data/spec/guards/endian_spec.rb +2 -2
- data/spec/guards/extensions_spec.rb +2 -2
- data/spec/guards/feature_spec.rb +2 -2
- data/spec/guards/guard_spec.rb +80 -22
- data/spec/guards/noncompliance_spec.rb +2 -2
- data/spec/guards/platform_spec.rb +2 -2
- data/spec/guards/quarantine_spec.rb +2 -2
- data/spec/guards/runner_spec.rb +2 -2
- data/spec/guards/specified_spec.rb +2 -2
- data/spec/guards/superuser_spec.rb +2 -2
- data/spec/guards/support_spec.rb +2 -2
- data/spec/guards/tty_spec.rb +2 -2
- data/spec/guards/user_spec.rb +2 -2
- data/spec/guards/version_spec.rb +2 -2
- data/spec/helpers/argv_spec.rb +3 -2
- data/spec/helpers/const_lookup_spec.rb +3 -2
- data/spec/helpers/datetime_spec.rb +44 -0
- data/spec/helpers/ducktype_spec.rb +3 -2
- data/spec/helpers/encode_spec.rb +3 -2
- data/spec/helpers/enumerator_class_spec.rb +5 -5
- data/spec/helpers/environment_spec.rb +15 -3
- data/spec/helpers/fixture_spec.rb +3 -2
- data/spec/helpers/flunk_spec.rb +4 -3
- data/spec/helpers/fs_spec.rb +35 -18
- data/spec/helpers/hash_spec.rb +3 -2
- data/spec/helpers/io_spec.rb +75 -6
- data/spec/helpers/language_version_spec.rb +3 -2
- data/spec/helpers/mock_to_path_spec.rb +3 -2
- data/spec/helpers/numeric_spec.rb +25 -0
- data/spec/helpers/ruby_exe_spec.rb +115 -29
- data/spec/helpers/scratch_spec.rb +3 -1
- data/spec/helpers/stasy_spec.rb +59 -0
- data/spec/helpers/tmp_spec.rb +21 -4
- data/spec/matchers/base_spec.rb +2 -2
- data/spec/matchers/be_an_instance_of_spec.rb +2 -2
- data/spec/matchers/be_ancestor_of_spec.rb +2 -2
- data/spec/matchers/be_close_spec.rb +2 -2
- data/spec/matchers/be_computed_by_function_spec.rb +36 -0
- data/spec/matchers/be_computed_by_spec.rb +42 -0
- data/spec/matchers/be_empty_spec.rb +2 -2
- data/spec/matchers/be_false_spec.rb +3 -3
- data/spec/matchers/be_kind_of_spec.rb +2 -2
- data/spec/matchers/be_nan_spec.rb +28 -0
- data/spec/matchers/be_nil_spec.rb +3 -3
- data/spec/matchers/be_true_spec.rb +3 -3
- data/spec/matchers/be_valid_dns_name_spec.rb +50 -0
- data/spec/matchers/complain_spec.rb +2 -2
- data/spec/matchers/eql_spec.rb +2 -2
- data/spec/matchers/equal_element_spec.rb +2 -2
- data/spec/matchers/equal_spec.rb +2 -2
- data/spec/matchers/equal_utf16_spec.rb +2 -2
- data/spec/matchers/have_class_variable_spec.rb +3 -3
- data/spec/matchers/have_constant_spec.rb +2 -2
- data/spec/matchers/have_data_spec.rb +8 -5
- data/spec/matchers/have_instance_method_spec.rb +2 -2
- data/spec/matchers/have_instance_variable_spec.rb +3 -3
- data/spec/matchers/have_method_spec.rb +2 -2
- data/spec/matchers/have_private_instance_method_spec.rb +3 -3
- data/spec/matchers/have_private_method_spec.rb +44 -0
- data/spec/matchers/have_protected_instance_method_spec.rb +2 -2
- data/spec/matchers/have_public_instance_method_spec.rb +2 -2
- data/spec/matchers/have_singleton_method_spec.rb +45 -0
- data/spec/matchers/include_spec.rb +2 -2
- data/spec/matchers/infinity_spec.rb +34 -0
- data/spec/matchers/match_yaml_spec.rb +3 -3
- data/spec/matchers/output_spec.rb +2 -2
- data/spec/matchers/output_to_fd_spec.rb +2 -2
- data/spec/matchers/raise_error_spec.rb +24 -3
- data/spec/matchers/respond_to_spec.rb +2 -2
- data/spec/matchers/signed_zero_spec.rb +32 -0
- data/spec/matchers/stringsymboladapter_spec.rb +2 -2
- data/spec/mocks/mock_spec.rb +12 -12
- data/spec/mocks/proxy_spec.rb +1 -1
- data/spec/runner/actions/gdb_spec.rb +1 -1
- data/spec/runner/actions/tag_spec.rb +1 -1
- data/spec/runner/actions/taglist_spec.rb +1 -1
- data/spec/runner/context_spec.rb +27 -27
- data/spec/runner/example_spec.rb +1 -1
- data/spec/runner/exception_spec.rb +1 -1
- data/spec/runner/filters/tag_spec.rb +2 -2
- data/spec/runner/formatters/describe_spec.rb +1 -1
- data/spec/runner/formatters/dotted_spec.rb +2 -2
- data/spec/runner/formatters/html_spec.rb +2 -2
- data/spec/runner/formatters/junit_spec.rb +147 -0
- data/spec/runner/formatters/unit_spec.rb +2 -2
- data/spec/runner/formatters/yaml_spec.rb +3 -3
- data/spec/runner/mspec_spec.rb +22 -21
- data/spec/runner/shared_spec.rb +9 -1
- data/spec/runner/tag_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -7
- data/spec/utils/name_map_spec.rb +1 -2
- data/spec/utils/options_spec.rb +58 -27
- data/spec/utils/script_spec.rb +5 -13
- data/spec/utils/version_spec.rb +1 -1
- metadata +254 -64
- data/lib/mspec/helpers/bignum.rb +0 -5
- data/lib/mspec/helpers/fmode.rb +0 -15
- data/lib/mspec/helpers/infinity.rb +0 -5
- data/lib/mspec/helpers/metaclass.rb +0 -7
- data/lib/mspec/helpers/nan.rb +0 -5
- data/lib/mspec/runner/actions/debug.rb +0 -17
- data/spec/helpers/bignum_spec.rb +0 -11
- data/spec/helpers/fmode_spec.rb +0 -14
- data/spec/helpers/infinity_spec.rb +0 -8
- data/spec/helpers/nan_spec.rb +0 -8
- data/spec/runner/actions/debug_spec.rb +0 -62
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
describe BeFalseMatcher do
|
|
6
6
|
it "matches when actual is false" do
|
|
@@ -25,4 +25,4 @@ describe BeFalseMatcher do
|
|
|
25
25
|
matcher.matches?(false)
|
|
26
26
|
matcher.negative_failure_message.should == ["Expected false", "not to be false"]
|
|
27
27
|
end
|
|
28
|
-
end
|
|
28
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
describe BeKindOfMatcher do
|
|
6
6
|
it "matches when actual is a kind_of? expected" do
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mspec/expectations/expectations'
|
|
3
|
+
require 'mspec/guards'
|
|
4
|
+
require 'mspec/helpers'
|
|
5
|
+
require 'mspec/matchers'
|
|
6
|
+
|
|
7
|
+
describe BeNaNMatcher do
|
|
8
|
+
it "matches when actual is NaN" do
|
|
9
|
+
BeNaNMatcher.new.matches?(nan_value).should == true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "does not match when actual is not NaN" do
|
|
13
|
+
BeNaNMatcher.new.matches?(1.0).should == false
|
|
14
|
+
BeNaNMatcher.new.matches?(0).should == false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "provides a useful failure message" do
|
|
18
|
+
matcher = BeNaNMatcher.new
|
|
19
|
+
matcher.matches?(0)
|
|
20
|
+
matcher.failure_message.should == ["Expected 0", "to be NaN"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "provides a useful negative failure message" do
|
|
24
|
+
matcher = BeNaNMatcher.new
|
|
25
|
+
matcher.matches?(nan_value)
|
|
26
|
+
matcher.negative_failure_message.should == ["Expected NaN", "not to be NaN"]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
describe BeNilMatcher do
|
|
6
6
|
it "matches when actual is nil" do
|
|
@@ -24,4 +24,4 @@ describe BeNilMatcher do
|
|
|
24
24
|
matcher.matches?(nil)
|
|
25
25
|
matcher.negative_failure_message.should == ["Expected nil", "not to be nil"]
|
|
26
26
|
end
|
|
27
|
-
end
|
|
27
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
describe BeTrueMatcher do
|
|
6
6
|
it "matches when actual is true" do
|
|
@@ -25,4 +25,4 @@ describe BeTrueMatcher do
|
|
|
25
25
|
matcher.matches?(true)
|
|
26
26
|
matcher.negative_failure_message.should == ["Expected true", "not to be true"]
|
|
27
27
|
end
|
|
28
|
-
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mspec/expectations/expectations'
|
|
3
|
+
require 'mspec/matchers'
|
|
4
|
+
|
|
5
|
+
describe BeValidDNSName do
|
|
6
|
+
it "matches when actual is 'localhost'" do
|
|
7
|
+
BeValidDNSName.new.matches?("localhost").should be_true
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "matches when actual is 'localhost.localdomain'" do
|
|
11
|
+
BeValidDNSName.new.matches?("localhost.localdomain").should be_true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "matches when actual is hyphenated" do
|
|
15
|
+
BeValidDNSName.new.matches?("local-host").should be_true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "matches when actual is 'a.b.c'" do
|
|
19
|
+
BeValidDNSName.new.matches?("a.b.c").should be_true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "matches when actual has a trailing '.'" do
|
|
23
|
+
BeValidDNSName.new.matches?("a.com.").should be_true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "does not match when actual is not a valid dns name" do
|
|
27
|
+
BeValidDNSName.new.matches?(".").should be_false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "does not match when actual contains a hyphen at the beginning" do
|
|
31
|
+
BeValidDNSName.new.matches?("-localhost").should be_false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "does not match when actual contains a hyphen at the end" do
|
|
35
|
+
BeValidDNSName.new.matches?("localhost-").should be_false
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "provides a failure message" do
|
|
39
|
+
matcher = BeValidDNSName.new
|
|
40
|
+
matcher.matches?(".")
|
|
41
|
+
matcher.failure_message.should == ["Expected '.'", "to be a valid DNS name"]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "provides a negative failure message" do
|
|
45
|
+
matcher = BeValidDNSName.new
|
|
46
|
+
matcher.matches?("localhost")
|
|
47
|
+
matcher.negative_failure_message.should ==
|
|
48
|
+
["Expected 'localhost'", "not to be a valid DNS name"]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
describe ComplainMatcher do
|
|
6
6
|
it "matches when executing the proc results in output to $stderr" do
|
data/spec/matchers/eql_spec.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
describe EqualElementMatcher do
|
|
6
6
|
it "matches if it finds an element with the passed name, no matter what attributes/content" do
|
data/spec/matchers/equal_spec.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
class IVarModMock; end
|
|
6
6
|
|
|
@@ -72,4 +72,4 @@ describe HaveClassVariableMatcher, "on RUBY_VERSION >= 1.9" do
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it_should_behave_like "have_class_variable, on all Ruby versions"
|
|
75
|
-
end
|
|
75
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/
|
|
4
|
-
require 'mspec/helpers
|
|
5
|
-
require 'mspec/
|
|
3
|
+
require 'mspec/guards'
|
|
4
|
+
require 'mspec/helpers'
|
|
5
|
+
require 'mspec/matchers'
|
|
6
6
|
|
|
7
7
|
describe HaveDataMatcher do
|
|
8
8
|
before :each do
|
|
@@ -26,13 +26,16 @@ describe HaveDataMatcher do
|
|
|
26
26
|
|
|
27
27
|
it "does not match when the named file begins with fewer bytes than data" do
|
|
28
28
|
HaveDataMatcher.new("123abcPQR").matches?(@name).should be_false
|
|
29
|
-
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
it "does not match when the named file begins with different bytes than data" do
|
|
33
32
|
HaveDataMatcher.new("abc1").matches?(@name).should be_false
|
|
34
33
|
end
|
|
35
34
|
|
|
35
|
+
it "accepts an optional mode argument to open the data file" do
|
|
36
|
+
HaveDataMatcher.new("123a", "r").matches?(@name).should be_true
|
|
37
|
+
end
|
|
38
|
+
|
|
36
39
|
it "provides a useful failure message" do
|
|
37
40
|
matcher = HaveDataMatcher.new("abc1")
|
|
38
41
|
matcher.matches?(@name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
shared_examples_for "have_instance_variable, on all Ruby versions" do
|
|
6
6
|
after :all do
|
|
@@ -72,4 +72,4 @@ describe HaveInstanceVariableMatcher, "on RUBY_VERSION >= 1.9" do
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it_should_behave_like "have_instance_variable, on all Ruby versions"
|
|
75
|
-
end
|
|
75
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'mspec/expectations/expectations'
|
|
3
|
-
require 'mspec/matchers
|
|
3
|
+
require 'mspec/matchers'
|
|
4
4
|
|
|
5
5
|
class HPIMMSpecs
|
|
6
6
|
private
|
|
@@ -46,7 +46,7 @@ describe HavePrivateInstanceMethodMatcher do
|
|
|
46
46
|
]
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
it "provides a failure
|
|
49
|
+
it "provides a failure message for #should_not" do
|
|
50
50
|
matcher = HavePrivateInstanceMethodMatcher.new :some_method
|
|
51
51
|
matcher.matches?(HPIMMSpecs)
|
|
52
52
|
matcher.negative_failure_message.should == [
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mspec/expectations/expectations'
|
|
3
|
+
require 'mspec/matchers'
|
|
4
|
+
|
|
5
|
+
class HPMMSpecs
|
|
6
|
+
def self.private_method
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
private_class_method :private_method
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe HavePrivateMethodMatcher do
|
|
13
|
+
it "inherits from MethodMatcher" do
|
|
14
|
+
HavePrivateMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "matches when mod has the private method" do
|
|
18
|
+
matcher = HavePrivateMethodMatcher.new :private_method
|
|
19
|
+
matcher.matches?(HPMMSpecs).should be_true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "does not match when mod does not have the private method" do
|
|
23
|
+
matcher = HavePrivateMethodMatcher.new :another_method
|
|
24
|
+
matcher.matches?(HPMMSpecs).should be_false
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "provides a failure message for #should" do
|
|
28
|
+
matcher = HavePrivateMethodMatcher.new :some_method
|
|
29
|
+
matcher.matches?(HPMMSpecs)
|
|
30
|
+
matcher.failure_message.should == [
|
|
31
|
+
"Expected HPMMSpecs to have private method 'some_method'",
|
|
32
|
+
"but it does not"
|
|
33
|
+
]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "provides a failure message for #should_not" do
|
|
37
|
+
matcher = HavePrivateMethodMatcher.new :private_method
|
|
38
|
+
matcher.matches?(HPMMSpecs)
|
|
39
|
+
matcher.negative_failure_message.should == [
|
|
40
|
+
"Expected HPMMSpecs NOT to have private method 'private_method'",
|
|
41
|
+
"but it does"
|
|
42
|
+
]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mspec/expectations/expectations'
|
|
3
|
+
require 'mspec/matchers'
|
|
4
|
+
|
|
5
|
+
class HSMMSpecs
|
|
6
|
+
def self.singleton_method
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe HaveSingletonMethodMatcher do
|
|
11
|
+
it "inherits from MethodMatcher" do
|
|
12
|
+
HaveSingletonMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "matches when the class has a singleton method" do
|
|
16
|
+
matcher = HaveSingletonMethodMatcher.new :singleton_method
|
|
17
|
+
matcher.matches?(HSMMSpecs).should be_true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "matches when the object has a singleton method" do
|
|
21
|
+
obj = mock("HSMMSpecs")
|
|
22
|
+
def obj.singleton_method; end
|
|
23
|
+
|
|
24
|
+
matcher = HaveSingletonMethodMatcher.new :singleton_method
|
|
25
|
+
matcher.matches?(obj).should be_true
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "provides a failure message for #should" do
|
|
29
|
+
matcher = HaveSingletonMethodMatcher.new :some_method
|
|
30
|
+
matcher.matches?(HSMMSpecs)
|
|
31
|
+
matcher.failure_message.should == [
|
|
32
|
+
"Expected HSMMSpecs to have singleton method 'some_method'",
|
|
33
|
+
"but it does not"
|
|
34
|
+
]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "provides a failure message for #should_not" do
|
|
38
|
+
matcher = HaveSingletonMethodMatcher.new :singleton_method
|
|
39
|
+
matcher.matches?(HSMMSpecs)
|
|
40
|
+
matcher.negative_failure_message.should == [
|
|
41
|
+
"Expected HSMMSpecs NOT to have singleton method 'singleton_method'",
|
|
42
|
+
"but it does"
|
|
43
|
+
]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'mspec/expectations/expectations'
|
|
3
|
+
require 'mspec/guards'
|
|
4
|
+
require 'mspec/helpers'
|
|
5
|
+
require 'mspec/matchers'
|
|
6
|
+
|
|
7
|
+
describe InfinityMatcher do
|
|
8
|
+
it "matches when actual is infinite and has the correct sign" do
|
|
9
|
+
InfinityMatcher.new(1).matches?(infinity_value).should == true
|
|
10
|
+
InfinityMatcher.new(-1).matches?(-infinity_value).should == true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "does not match when actual is not infinite" do
|
|
14
|
+
InfinityMatcher.new(1).matches?(1.0).should == false
|
|
15
|
+
InfinityMatcher.new(-1).matches?(-1.0).should == false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "does not match when actual is infinite but has the incorrect sign" do
|
|
19
|
+
InfinityMatcher.new(1).matches?(-infinity_value).should == false
|
|
20
|
+
InfinityMatcher.new(-1).matches?(infinity_value).should == false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "provides a useful failure message" do
|
|
24
|
+
matcher = InfinityMatcher.new(-1)
|
|
25
|
+
matcher.matches?(0)
|
|
26
|
+
matcher.failure_message.should == ["Expected 0", "to be -Infinity"]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "provides a useful negative failure message" do
|
|
30
|
+
matcher = InfinityMatcher.new(1)
|
|
31
|
+
matcher.matches?(infinity_value)
|
|
32
|
+
matcher.negative_failure_message.should == ["Expected Infinity", "not to be Infinity"]
|
|
33
|
+
end
|
|
34
|
+
end
|