expectation 0.3.1 → 1.0.0
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.
- checksums.yaml +7 -0
- data/lib/contracts.rb +197 -0
- data/lib/core/exception.rb +15 -0
- data/lib/expectation/assertions.rb +19 -23
- data/lib/expectation/version.rb +1 -1
- data/lib/expectation.rb +59 -112
- data/test/assertions_test.rb +2 -1
- data/test/contracts_module_test.rb +48 -0
- data/test/contracts_singleton_test.rb +28 -0
- data/test/contracts_test.rb +88 -0
- data/test/coverage/assets/0.10.0/application.css +799 -0
- data/test/coverage/assets/0.10.0/application.js +1707 -0
- data/test/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/test/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/test/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/test/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/test/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/test/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/test/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/test/coverage/assets/0.10.0/loading.gif +0 -0
- data/test/coverage/assets/0.10.0/magnify.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/test/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/coverage/index.html +72 -0
- data/test/exception_extension_test.rb +19 -0
- data/test/expection_test.rb +46 -0
- data/test/matching_test.rb +77 -0
- data/test/test_helper.rb +20 -7
- metadata +42 -18
- data/test/expect_test.rb +0 -119
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>Code coverage for Test</title>
|
5
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
6
|
+
<script src='./assets/0.10.0/application.js' type='text/javascript'></script>
|
7
|
+
<link href='./assets/0.10.0/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="shortcut icon" type="image/png" href="./assets/0.10.0/favicon_green.png" />
|
9
|
+
<link rel="icon" type="image/png" href="./assets/0.10.0/favicon.png" />
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<div id="loading">
|
14
|
+
<img src="./assets/0.10.0/loading.gif" alt="loading"/>
|
15
|
+
</div>
|
16
|
+
<div id="wrapper" style="display:none;">
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2015-11-09T18:20:56+01:00">2015-11-09T18:20:56+01:00</abbr></div>
|
18
|
+
<ul class="group_tabs"></ul>
|
19
|
+
|
20
|
+
<div id="content">
|
21
|
+
<div class="file_list_container" id="AllFiles">
|
22
|
+
<h2>
|
23
|
+
<span class="group_name">All Files</span>
|
24
|
+
(<span class="covered_percent"><span class="green">100.0%</span></span>
|
25
|
+
covered at
|
26
|
+
<span class="covered_strength">
|
27
|
+
<span class="red">
|
28
|
+
0.0
|
29
|
+
</span>
|
30
|
+
</span> hits/line)
|
31
|
+
</h2>
|
32
|
+
<a name="AllFiles"></a>
|
33
|
+
<div>
|
34
|
+
<b>0</b> files in total.
|
35
|
+
<b>0.0</b> relevant lines.
|
36
|
+
<span class="green"><b>0.0</b> lines covered</span> and
|
37
|
+
<span class="red"><b>0.0</b> lines missed </span>
|
38
|
+
</div>
|
39
|
+
<table class="file_list">
|
40
|
+
<thead>
|
41
|
+
<tr>
|
42
|
+
<th>File</th>
|
43
|
+
<th>% covered</th>
|
44
|
+
<th>Lines</th>
|
45
|
+
<th>Relevant Lines</th>
|
46
|
+
<th>Lines covered</th>
|
47
|
+
<th>Lines missed</th>
|
48
|
+
<th>Avg. Hits / Line</th>
|
49
|
+
</tr>
|
50
|
+
</thead>
|
51
|
+
<tbody>
|
52
|
+
|
53
|
+
</tbody>
|
54
|
+
</table>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<div id="footer">
|
62
|
+
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.10.0
|
63
|
+
and simplecov-html v0.10.0<br/>
|
64
|
+
using Unit Tests
|
65
|
+
</div>
|
66
|
+
|
67
|
+
<div class="source_files">
|
68
|
+
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</body>
|
72
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Author:: radiospiel (mailto:eno@radiospiel.org)
|
2
|
+
# Copyright:: Copyright (c) 2011, 2012 radiospiel
|
3
|
+
# License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
|
4
|
+
require_relative 'test_helper'
|
5
|
+
|
6
|
+
class ExpensionExtensionTest < Test::Unit::TestCase
|
7
|
+
# Verify that the exception's backtrace is properly adjusted,
|
8
|
+
# i.e. points to this file.
|
9
|
+
def test_expectations_backtrace
|
10
|
+
backtrace = nil
|
11
|
+
|
12
|
+
begin
|
13
|
+
expect! 1 => 0
|
14
|
+
rescue
|
15
|
+
backtrace = $!.backtrace
|
16
|
+
end
|
17
|
+
assert backtrace.first.include?("/exception_extension_test.rb:")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Author:: radiospiel (mailto:eno@radiospiel.org)
|
2
|
+
# Copyright:: Copyright (c) 2011, 2012 radiospiel
|
3
|
+
# License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
|
4
|
+
require_relative 'test_helper'
|
5
|
+
|
6
|
+
class ExpectationTest < Test::Unit::TestCase
|
7
|
+
def test_expectation_inherits_argument_error
|
8
|
+
assert Expectation::Error < ArgumentError
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# This test covers the usual use case: expectations are
|
13
|
+
# passed in a single Hash.
|
14
|
+
def test_hash_expectation
|
15
|
+
assert_expectation! "1" => /1/
|
16
|
+
assert_failed_expectation! "1" => /2/
|
17
|
+
|
18
|
+
assert_expectation! 1 => 1, :a => :a
|
19
|
+
assert_failed_expectation! 1 => 2, :a => :a
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_simple_expectations
|
23
|
+
assert_expectation! "1" => /1/
|
24
|
+
assert_expectation! 1, 1, 1, /1/
|
25
|
+
assert_expectation! 1, 1, "1" => /1/
|
26
|
+
|
27
|
+
assert_failed_expectation! 1, 1, "1" => /2/
|
28
|
+
assert_failed_expectation! 1, 1, 1 => /2/
|
29
|
+
assert_failed_expectation! 1, nil, "1" => /1/
|
30
|
+
assert_failed_expectation! 1, false, "1" => /1/
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_block_expectations
|
34
|
+
assert_expectation! do true end
|
35
|
+
assert_failed_expectation! do false end
|
36
|
+
assert_failed_expectation! do nil end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_exception_message
|
40
|
+
e = assert_failed_expectation!({ 1 => 2 })
|
41
|
+
assert e.message.include?("1 does not match 2")
|
42
|
+
|
43
|
+
e = assert_failed_expectation!({ a: { b: "c" }} => { a: { b: "d" }})
|
44
|
+
assert e.message.include?("\"c\" does not match \"d\", at key :b")
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Author:: radiospiel (mailto:eno@radiospiel.org)
|
2
|
+
# Copyright:: Copyright (c) 2011, 2012 radiospiel
|
3
|
+
# License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
|
4
|
+
require_relative 'test_helper'
|
5
|
+
|
6
|
+
class MatchingTest < Test::Unit::TestCase
|
7
|
+
def assert_match(value, expectation)
|
8
|
+
assert_equal true, Expectation.match?(value, expectation)
|
9
|
+
end
|
10
|
+
|
11
|
+
def assert_mismatch(value, expectation)
|
12
|
+
assert_equal false, Expectation.match?(value, expectation)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_mismatches_raise_exceptions
|
16
|
+
assert_nothing_raised do
|
17
|
+
Expectation.match! 1, 1
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_raise(Expectation::Error) {
|
21
|
+
Expectation.match! 1, 2
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_int_expectations
|
26
|
+
assert_match 1, 1
|
27
|
+
assert_match 1, Fixnum
|
28
|
+
assert_match 1, Integer
|
29
|
+
assert_match 1, 0..2
|
30
|
+
assert_match 1, 0..1
|
31
|
+
assert_match 1, 1..10
|
32
|
+
assert_match 1, [0,1,2]
|
33
|
+
|
34
|
+
assert_mismatch 1, 2
|
35
|
+
assert_mismatch 1, Float
|
36
|
+
assert_mismatch 1, 0...1
|
37
|
+
assert_mismatch 1, 3..5
|
38
|
+
assert_mismatch 1, [3,4,5]
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_lambda_expectations
|
42
|
+
# passes in value?
|
43
|
+
assert_match 1, lambda { |i| i.odd? }
|
44
|
+
assert_mismatch 1, lambda { |i| i.even? }
|
45
|
+
|
46
|
+
# does not pass in a value
|
47
|
+
r = false
|
48
|
+
assert_mismatch 1, lambda { r }
|
49
|
+
|
50
|
+
r = true
|
51
|
+
assert_match 1, lambda { r }
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_regexp_expectations
|
55
|
+
assert_match " foo", /foo/
|
56
|
+
assert_mismatch " foo", /^foo/
|
57
|
+
|
58
|
+
assert_match "1", /1/
|
59
|
+
assert_mismatch "1", /2/
|
60
|
+
|
61
|
+
assert_mismatch 1, /1/
|
62
|
+
assert_mismatch 1, /2/
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_hash_expectations
|
66
|
+
assert_mismatch({}, { :key => "Foo" })
|
67
|
+
assert_match({ :key => "Foo" }, { :key => "Foo" })
|
68
|
+
|
69
|
+
assert_mismatch({ :other_key => "Foo" }, { :key => "Foo" })
|
70
|
+
assert_mismatch({ :key => "Bar" }, { :key => "Foo" })
|
71
|
+
|
72
|
+
assert_match({ :key => "Foo" }, { :key => String })
|
73
|
+
assert_match({ :key => "Foo" }, { :key => [Integer,String] })
|
74
|
+
assert_mismatch({ :key => "Foo" }, { :key => [Integer,"Bar"] })
|
75
|
+
assert_match({ :other_key => "Foo" }, { :key => [nil, "Foo"] })
|
76
|
+
end
|
77
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,17 +2,30 @@ require 'rubygems'
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
4
|
require 'simplecov'
|
5
|
+
require 'simplecov-console'
|
5
6
|
require 'test/unit'
|
6
|
-
require 'test/unit/ui/console/testrunner'
|
7
|
-
|
8
|
-
class Test::Unit::UI::Console::TestRunner
|
9
|
-
def guess_color_availability; true; end
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'mocha/setup'
|
13
7
|
|
14
8
|
SimpleCov.start do
|
15
9
|
add_filter "test/*.rb"
|
16
10
|
end
|
17
11
|
|
12
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
13
|
+
SimpleCov::Formatter::HTMLFormatter,
|
14
|
+
SimpleCov::Formatter::Console,
|
15
|
+
]
|
16
|
+
|
18
17
|
require "expectation"
|
18
|
+
|
19
|
+
class Test::Unit::TestCase
|
20
|
+
def assert_expectation!(*expectation, &block)
|
21
|
+
assert_nothing_raised do
|
22
|
+
expect! *expectation, &block
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def assert_failed_expectation!(*expectation, &block)
|
27
|
+
assert_raise(Expectation::Error) {
|
28
|
+
expect! *expectation, &block
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expectation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- radiospiel
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-11-09 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Defensive programming with expectations
|
15
14
|
email: eno@radiospiel.org
|
@@ -17,41 +16,66 @@ executables: []
|
|
17
16
|
extensions: []
|
18
17
|
extra_rdoc_files: []
|
19
18
|
files:
|
19
|
+
- README.md
|
20
|
+
- lib/contracts.rb
|
21
|
+
- lib/core/exception.rb
|
22
|
+
- lib/expectation.rb
|
20
23
|
- lib/expectation/assertions.rb
|
21
24
|
- lib/expectation/version.rb
|
22
|
-
- lib/expectation.rb
|
23
|
-
- README.md
|
24
25
|
- test/assertions_test.rb
|
25
|
-
- test/
|
26
|
+
- test/contracts_module_test.rb
|
27
|
+
- test/contracts_singleton_test.rb
|
28
|
+
- test/contracts_test.rb
|
29
|
+
- test/coverage/assets/0.10.0/application.css
|
30
|
+
- test/coverage/assets/0.10.0/application.js
|
31
|
+
- test/coverage/assets/0.10.0/colorbox/border.png
|
32
|
+
- test/coverage/assets/0.10.0/colorbox/controls.png
|
33
|
+
- test/coverage/assets/0.10.0/colorbox/loading.gif
|
34
|
+
- test/coverage/assets/0.10.0/colorbox/loading_background.png
|
35
|
+
- test/coverage/assets/0.10.0/favicon_green.png
|
36
|
+
- test/coverage/assets/0.10.0/favicon_red.png
|
37
|
+
- test/coverage/assets/0.10.0/favicon_yellow.png
|
38
|
+
- test/coverage/assets/0.10.0/loading.gif
|
39
|
+
- test/coverage/assets/0.10.0/magnify.png
|
40
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
41
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
42
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
43
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
44
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
45
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
46
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
47
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
48
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png
|
49
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png
|
50
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png
|
51
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png
|
52
|
+
- test/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png
|
53
|
+
- test/coverage/index.html
|
54
|
+
- test/exception_extension_test.rb
|
55
|
+
- test/expection_test.rb
|
56
|
+
- test/matching_test.rb
|
26
57
|
- test/test_helper.rb
|
27
58
|
homepage: http://github.com/radiospiel/expectation
|
28
59
|
licenses: []
|
60
|
+
metadata: {}
|
29
61
|
post_install_message:
|
30
62
|
rdoc_options: []
|
31
63
|
require_paths:
|
32
64
|
- lib
|
33
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
66
|
requirements:
|
36
|
-
- -
|
67
|
+
- - ">="
|
37
68
|
- !ruby/object:Gem::Version
|
38
69
|
version: '0'
|
39
|
-
segments:
|
40
|
-
- 0
|
41
|
-
hash: 4441031152163392854
|
42
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
71
|
requirements:
|
45
|
-
- -
|
72
|
+
- - ">="
|
46
73
|
- !ruby/object:Gem::Version
|
47
74
|
version: '0'
|
48
|
-
segments:
|
49
|
-
- 0
|
50
|
-
hash: 4441031152163392854
|
51
75
|
requirements: []
|
52
76
|
rubyforge_project:
|
53
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.4.6
|
54
78
|
signing_key:
|
55
|
-
specification_version:
|
79
|
+
specification_version: 4
|
56
80
|
summary: Defensive programming with expectations
|
57
81
|
test_files: []
|
data/test/expect_test.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
# Author:: radiospiel (mailto:eno@radiospiel.org)
|
2
|
-
# Copyright:: Copyright (c) 2011, 2012 radiospiel
|
3
|
-
# License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
|
4
|
-
require_relative 'test_helper'
|
5
|
-
|
6
|
-
class ExpectationTest < Test::Unit::TestCase
|
7
|
-
def assert_expectation!(*expectation, &block)
|
8
|
-
assert_nothing_raised do
|
9
|
-
expect! *expectation, &block
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def assert_failed_expectation!(*expectation, &block)
|
14
|
-
assert_raise(ArgumentError) {
|
15
|
-
expect! *expectation, &block
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def assert_expectation(*expectation, &block)
|
20
|
-
assert_nothing_raised do
|
21
|
-
expect *expectation, &block
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def assert_failed_expectation(*expectation, &block)
|
26
|
-
assert_raise(ArgumentError) {
|
27
|
-
expect *expectation, &block
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
# Verify that the exception's backtrace is properly adjusted,
|
32
|
-
# i.e. points to this file.
|
33
|
-
def test_expectations_backtrace
|
34
|
-
backtrace = nil
|
35
|
-
|
36
|
-
begin
|
37
|
-
expect! 1 => 0
|
38
|
-
rescue
|
39
|
-
backtrace = $!.backtrace
|
40
|
-
end
|
41
|
-
assert backtrace.first.include?("/expect_test.rb:")
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_int_expectations
|
45
|
-
assert_expectation! 1 => 1
|
46
|
-
assert_expectation! 1 => Fixnum
|
47
|
-
assert_expectation! 1 => Integer
|
48
|
-
assert_expectation! 1 => 0..2
|
49
|
-
assert_expectation! 1 => 0..1
|
50
|
-
assert_expectation! 1 => 1..10
|
51
|
-
assert_expectation! 1 => [0,1,2]
|
52
|
-
assert_expectation! 1 => lambda { |i| i.odd? }
|
53
|
-
|
54
|
-
assert_failed_expectation! 1 => 2
|
55
|
-
assert_failed_expectation! 1 => Float
|
56
|
-
assert_failed_expectation! 1 => 0...1
|
57
|
-
assert_failed_expectation! 1 => 3..5
|
58
|
-
assert_failed_expectation! 1 => [3,4,5]
|
59
|
-
assert_failed_expectation! 1 => lambda { |i| i.even? }
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_regexp_expectations
|
63
|
-
assert_expectation! " foo" => /foo/
|
64
|
-
assert_failed_expectation! " foo" => /^foo/
|
65
|
-
|
66
|
-
assert_expectation! "1" => /1/
|
67
|
-
assert_failed_expectation! "1" => /2/
|
68
|
-
|
69
|
-
assert_failed_expectation! 1 => /1/
|
70
|
-
assert_failed_expectation! 1 => /2/
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_multiple_expectations
|
74
|
-
assert_expectation! 1 => 1, :a => :a
|
75
|
-
assert_failed_expectation! 1 => 2, :a => :a
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_array_expectations
|
79
|
-
assert_expectation! 1, 1, 1, /1/
|
80
|
-
assert_expectation! 1, 1, "1" => /1/
|
81
|
-
|
82
|
-
assert_failed_expectation! 1, 1, "1" => /2/
|
83
|
-
assert_failed_expectation! 1, 1, 1 => /2/
|
84
|
-
assert_failed_expectation! 1, nil, "1" => /1/
|
85
|
-
assert_failed_expectation! 1, false, "1" => /1/
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_block_expectations
|
89
|
-
assert_expectation! do true end
|
90
|
-
assert_failed_expectation! do false end
|
91
|
-
assert_failed_expectation! do nil end
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_hash_expectations
|
95
|
-
assert_failed_expectation!({} => { :key => "Foo" })
|
96
|
-
assert_expectation!({ :key => "Foo" } => { :key => "Foo" })
|
97
|
-
|
98
|
-
assert_failed_expectation!({ :other_key => "Foo" } => { :key => "Foo" })
|
99
|
-
assert_failed_expectation!({ :key => "Bar" } => { :key => "Foo" })
|
100
|
-
|
101
|
-
assert_expectation!({ :key => "Foo" } => { :key => String })
|
102
|
-
assert_expectation!({ :key => "Foo" } => { :key => [Integer,String] })
|
103
|
-
assert_failed_expectation!({ :key => "Foo" } => { :key => [Integer,"Bar"] })
|
104
|
-
assert_expectation!({ :other_key => "Foo" } => { :key => [nil, "Foo"] })
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_enable_and_disable
|
108
|
-
assert_failed_expectation! "foo" => "bar"
|
109
|
-
assert_failed_expectation "foo" => "bar"
|
110
|
-
|
111
|
-
Expectation.disable
|
112
|
-
assert_failed_expectation! "foo" => "bar"
|
113
|
-
assert_expectation "foo" => "bar"
|
114
|
-
|
115
|
-
Expectation.enable
|
116
|
-
assert_failed_expectation! "foo" => "bar"
|
117
|
-
assert_failed_expectation "foo" => "bar"
|
118
|
-
end
|
119
|
-
end
|