colorcode_convert_rgb 0.1.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/Gemfile +7 -0
- data/Gemfile.lock +23 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/colorcode_convert_rgb.gemspec +30 -0
- data/exe/colorcode_convert_rgb +4 -0
- data/lib/colorcode_convert_rgb.rb +7 -0
- data/lib/colorcode_convert_rgb/cli.rb +13 -0
- data/lib/colorcode_convert_rgb/version.rb +3 -0
- data/vendor/bundle/ruby/2.5.0/bin/colorcode_convert_rgb +27 -0
- data/vendor/bundle/ruby/2.5.0/bin/rake +27 -0
- data/vendor/bundle/ruby/2.5.0/bin/thor +27 -0
- data/vendor/bundle/ruby/2.5.0/cache/minitest-5.14.2.gem +0 -0
- data/vendor/bundle/ruby/2.5.0/cache/rake-12.3.3.gem +0 -0
- data/vendor/bundle/ruby/2.5.0/cache/thor-1.0.1.gem +0 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/.autotest +34 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/History.rdoc +1397 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/Manifest.txt +27 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/README.rdoc +764 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/Rakefile +74 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/design_rationale.rb +52 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/hoe/minitest.rb +32 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest.rb +1056 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/assertions.rb +807 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/autorun.rb +13 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/benchmark.rb +455 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/expectations.rb +303 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/hell.rb +11 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/mock.rb +240 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/parallel.rb +70 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/pride.rb +4 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/pride_plugin.rb +142 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/spec.rb +342 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/test.rb +220 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/unit.rb +45 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/metametameta.rb +136 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_assertions.rb +1575 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_benchmark.rb +137 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_mock.rb +872 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_reporter.rb +299 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_spec.rb +1061 -0
- data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_test.rb +1084 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/CONTRIBUTING.rdoc +43 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/Gemfile +3 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/History.rdoc +2344 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/MIT-LICENSE +21 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/README.rdoc +156 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/Rakefile +41 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/azure-pipelines.yml +11 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/bundle +105 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/console +7 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/rake +29 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/rdoc +29 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/rubocop +29 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/setup +6 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/command_line_usage.rdoc +158 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/Rakefile1 +38 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/Rakefile2 +35 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/a.c +6 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/b.c +6 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/main.c +11 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/glossary.rdoc +42 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/jamis.rb +592 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/proto_rake.rdoc +127 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/rake.1 +156 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/rakefile.rdoc +622 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/rational.rdoc +151 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/exe/rake +27 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake.rb +71 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb +824 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/backtrace.rb +24 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/clean.rb +78 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/cloneable.rb +17 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/cpu_counter.rb +107 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/default_loader.rb +15 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/dsl_definition.rb +195 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/early_time.rb +22 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/ext/core.rb +26 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/ext/string.rb +176 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_creation_task.rb +25 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_list.rb +435 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_task.rb +54 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_utils.rb +137 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_utils_ext.rb +145 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/invocation_chain.rb +57 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/invocation_exception_mixin.rb +17 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/late_time.rb +18 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/linked_list.rb +112 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/loaders/makefile.rb +54 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/multi_task.rb +14 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/name_space.rb +38 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/packagetask.rb +207 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/phony.rb +16 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/private_reader.rb +21 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/promise.rb +100 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/pseudo_status.rb +30 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rake_module.rb +67 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rake_test_loader.rb +27 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/scope.rb +43 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task.rb +413 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task_argument_error.rb +8 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task_arguments.rb +109 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task_manager.rb +324 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/tasklib.rb +12 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/testtask.rb +224 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/thread_history_display.rb +49 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/thread_pool.rb +163 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/trace_output.rb +23 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/version.rb +10 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/win32.rb +51 -0
- data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/rake.gemspec +42 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/.document +5 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/CHANGELOG.md +220 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/CONTRIBUTING.md +15 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/LICENSE.md +20 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/README.md +51 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/bin/thor +6 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor.rb +517 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions.rb +336 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/create_file.rb +104 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/create_link.rb +61 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/directory.rb +108 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/empty_directory.rb +143 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/file_manipulation.rb +373 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/inject_into_file.rb +120 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/base.rb +699 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/command.rb +142 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/error.rb +110 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/group.rb +281 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/invocation.rb +178 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/line_editor.rb +17 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/line_editor/basic.rb +37 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/line_editor/readline.rb +88 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/nested_context.rb +29 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser.rb +4 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/argument.rb +70 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/arguments.rb +175 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/option.rb +159 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/options.rb +236 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/rake_compat.rb +72 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/runner.rb +325 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell.rb +81 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell/basic.rb +491 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell/color.rb +153 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell/html.rb +126 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/util.rb +284 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/version.rb +3 -0
- data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/thor.gemspec +28 -0
- data/vendor/bundle/ruby/2.5.0/specifications/minitest-5.14.2.gemspec +38 -0
- data/vendor/bundle/ruby/2.5.0/specifications/rake-12.3.3.gemspec +43 -0
- data/vendor/bundle/ruby/2.5.0/specifications/thor-1.0.1.gemspec +34 -0
- metadata +214 -0
@@ -0,0 +1,303 @@
|
|
1
|
+
##
|
2
|
+
# It's where you hide your "assertions".
|
3
|
+
#
|
4
|
+
# Please note, because of the way that expectations are implemented,
|
5
|
+
# all expectations (eg must_equal) are dependent upon a thread local
|
6
|
+
# variable +:current_spec+. If your specs rely on mixing threads into
|
7
|
+
# the specs themselves, you're better off using assertions or the new
|
8
|
+
# _(value) wrapper. For example:
|
9
|
+
#
|
10
|
+
# it "should still work in threads" do
|
11
|
+
# my_threaded_thingy do
|
12
|
+
# (1+1).must_equal 2 # bad
|
13
|
+
# assert_equal 2, 1+1 # good
|
14
|
+
# _(1 + 1).must_equal 2 # good
|
15
|
+
# value(1 + 1).must_equal 2 # good, also #expect
|
16
|
+
# _ { 1 + "1" }.must_raise TypeError # good
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
|
20
|
+
module Minitest::Expectations
|
21
|
+
|
22
|
+
##
|
23
|
+
# See Minitest::Assertions#assert_empty.
|
24
|
+
#
|
25
|
+
# _(collection).must_be_empty
|
26
|
+
#
|
27
|
+
# :method: must_be_empty
|
28
|
+
|
29
|
+
infect_an_assertion :assert_empty, :must_be_empty, :unary
|
30
|
+
|
31
|
+
##
|
32
|
+
# See Minitest::Assertions#assert_equal
|
33
|
+
#
|
34
|
+
# _(a).must_equal b
|
35
|
+
#
|
36
|
+
# :method: must_equal
|
37
|
+
|
38
|
+
infect_an_assertion :assert_equal, :must_equal
|
39
|
+
|
40
|
+
##
|
41
|
+
# See Minitest::Assertions#assert_in_delta
|
42
|
+
#
|
43
|
+
# _(n).must_be_close_to m [, delta]
|
44
|
+
#
|
45
|
+
# :method: must_be_close_to
|
46
|
+
|
47
|
+
infect_an_assertion :assert_in_delta, :must_be_close_to
|
48
|
+
|
49
|
+
infect_an_assertion :assert_in_delta, :must_be_within_delta # :nodoc:
|
50
|
+
|
51
|
+
##
|
52
|
+
# See Minitest::Assertions#assert_in_epsilon
|
53
|
+
#
|
54
|
+
# _(n).must_be_within_epsilon m [, epsilon]
|
55
|
+
#
|
56
|
+
# :method: must_be_within_epsilon
|
57
|
+
|
58
|
+
infect_an_assertion :assert_in_epsilon, :must_be_within_epsilon
|
59
|
+
|
60
|
+
##
|
61
|
+
# See Minitest::Assertions#assert_includes
|
62
|
+
#
|
63
|
+
# _(collection).must_include obj
|
64
|
+
#
|
65
|
+
# :method: must_include
|
66
|
+
|
67
|
+
infect_an_assertion :assert_includes, :must_include, :reverse
|
68
|
+
|
69
|
+
##
|
70
|
+
# See Minitest::Assertions#assert_instance_of
|
71
|
+
#
|
72
|
+
# _(obj).must_be_instance_of klass
|
73
|
+
#
|
74
|
+
# :method: must_be_instance_of
|
75
|
+
|
76
|
+
infect_an_assertion :assert_instance_of, :must_be_instance_of
|
77
|
+
|
78
|
+
##
|
79
|
+
# See Minitest::Assertions#assert_kind_of
|
80
|
+
#
|
81
|
+
# _(obj).must_be_kind_of mod
|
82
|
+
#
|
83
|
+
# :method: must_be_kind_of
|
84
|
+
|
85
|
+
infect_an_assertion :assert_kind_of, :must_be_kind_of
|
86
|
+
|
87
|
+
##
|
88
|
+
# See Minitest::Assertions#assert_match
|
89
|
+
#
|
90
|
+
# _(a).must_match b
|
91
|
+
#
|
92
|
+
# :method: must_match
|
93
|
+
|
94
|
+
infect_an_assertion :assert_match, :must_match
|
95
|
+
|
96
|
+
##
|
97
|
+
# See Minitest::Assertions#assert_nil
|
98
|
+
#
|
99
|
+
# _(obj).must_be_nil
|
100
|
+
#
|
101
|
+
# :method: must_be_nil
|
102
|
+
|
103
|
+
infect_an_assertion :assert_nil, :must_be_nil, :unary
|
104
|
+
|
105
|
+
##
|
106
|
+
# See Minitest::Assertions#assert_operator
|
107
|
+
#
|
108
|
+
# _(n).must_be :<=, 42
|
109
|
+
#
|
110
|
+
# This can also do predicates:
|
111
|
+
#
|
112
|
+
# _(str).must_be :empty?
|
113
|
+
#
|
114
|
+
# :method: must_be
|
115
|
+
|
116
|
+
infect_an_assertion :assert_operator, :must_be, :reverse
|
117
|
+
|
118
|
+
##
|
119
|
+
# See Minitest::Assertions#assert_output
|
120
|
+
#
|
121
|
+
# _ { ... }.must_output out_or_nil [, err]
|
122
|
+
#
|
123
|
+
# :method: must_output
|
124
|
+
|
125
|
+
infect_an_assertion :assert_output, :must_output, :block
|
126
|
+
|
127
|
+
##
|
128
|
+
# See Minitest::Assertions#assert_raises
|
129
|
+
#
|
130
|
+
# _ { ... }.must_raise exception
|
131
|
+
#
|
132
|
+
# :method: must_raise
|
133
|
+
|
134
|
+
infect_an_assertion :assert_raises, :must_raise, :block
|
135
|
+
|
136
|
+
##
|
137
|
+
# See Minitest::Assertions#assert_respond_to
|
138
|
+
#
|
139
|
+
# _(obj).must_respond_to msg
|
140
|
+
#
|
141
|
+
# :method: must_respond_to
|
142
|
+
|
143
|
+
infect_an_assertion :assert_respond_to, :must_respond_to, :reverse
|
144
|
+
|
145
|
+
##
|
146
|
+
# See Minitest::Assertions#assert_same
|
147
|
+
#
|
148
|
+
# _(a).must_be_same_as b
|
149
|
+
#
|
150
|
+
# :method: must_be_same_as
|
151
|
+
|
152
|
+
infect_an_assertion :assert_same, :must_be_same_as
|
153
|
+
|
154
|
+
##
|
155
|
+
# See Minitest::Assertions#assert_silent
|
156
|
+
#
|
157
|
+
# _ { ... }.must_be_silent
|
158
|
+
#
|
159
|
+
# :method: must_be_silent
|
160
|
+
|
161
|
+
infect_an_assertion :assert_silent, :must_be_silent, :block
|
162
|
+
|
163
|
+
##
|
164
|
+
# See Minitest::Assertions#assert_throws
|
165
|
+
#
|
166
|
+
# _ { ... }.must_throw sym
|
167
|
+
#
|
168
|
+
# :method: must_throw
|
169
|
+
|
170
|
+
infect_an_assertion :assert_throws, :must_throw, :block
|
171
|
+
|
172
|
+
##
|
173
|
+
# See Minitest::Assertions#assert_path_exists
|
174
|
+
#
|
175
|
+
# _(some_path).path_must_exist
|
176
|
+
#
|
177
|
+
# :method: path_must_exist
|
178
|
+
|
179
|
+
infect_an_assertion :assert_path_exists, :path_must_exist, :unary
|
180
|
+
|
181
|
+
##
|
182
|
+
# See Minitest::Assertions#refute_path_exists
|
183
|
+
#
|
184
|
+
# _(some_path).path_wont_exist
|
185
|
+
#
|
186
|
+
# :method: path_wont_exist
|
187
|
+
|
188
|
+
infect_an_assertion :refute_path_exists, :path_wont_exist, :unary
|
189
|
+
|
190
|
+
##
|
191
|
+
# See Minitest::Assertions#refute_empty
|
192
|
+
#
|
193
|
+
# _(collection).wont_be_empty
|
194
|
+
#
|
195
|
+
# :method: wont_be_empty
|
196
|
+
|
197
|
+
infect_an_assertion :refute_empty, :wont_be_empty, :unary
|
198
|
+
|
199
|
+
##
|
200
|
+
# See Minitest::Assertions#refute_equal
|
201
|
+
#
|
202
|
+
# _(a).wont_equal b
|
203
|
+
#
|
204
|
+
# :method: wont_equal
|
205
|
+
|
206
|
+
infect_an_assertion :refute_equal, :wont_equal
|
207
|
+
|
208
|
+
##
|
209
|
+
# See Minitest::Assertions#refute_in_delta
|
210
|
+
#
|
211
|
+
# _(n).wont_be_close_to m [, delta]
|
212
|
+
#
|
213
|
+
# :method: wont_be_close_to
|
214
|
+
|
215
|
+
infect_an_assertion :refute_in_delta, :wont_be_close_to
|
216
|
+
|
217
|
+
infect_an_assertion :refute_in_delta, :wont_be_within_delta # :nodoc:
|
218
|
+
|
219
|
+
##
|
220
|
+
# See Minitest::Assertions#refute_in_epsilon
|
221
|
+
#
|
222
|
+
# _(n).wont_be_within_epsilon m [, epsilon]
|
223
|
+
#
|
224
|
+
# :method: wont_be_within_epsilon
|
225
|
+
|
226
|
+
infect_an_assertion :refute_in_epsilon, :wont_be_within_epsilon
|
227
|
+
|
228
|
+
##
|
229
|
+
# See Minitest::Assertions#refute_includes
|
230
|
+
#
|
231
|
+
# _(collection).wont_include obj
|
232
|
+
#
|
233
|
+
# :method: wont_include
|
234
|
+
|
235
|
+
infect_an_assertion :refute_includes, :wont_include, :reverse
|
236
|
+
|
237
|
+
##
|
238
|
+
# See Minitest::Assertions#refute_instance_of
|
239
|
+
#
|
240
|
+
# _(obj).wont_be_instance_of klass
|
241
|
+
#
|
242
|
+
# :method: wont_be_instance_of
|
243
|
+
|
244
|
+
infect_an_assertion :refute_instance_of, :wont_be_instance_of
|
245
|
+
|
246
|
+
##
|
247
|
+
# See Minitest::Assertions#refute_kind_of
|
248
|
+
#
|
249
|
+
# _(obj).wont_be_kind_of mod
|
250
|
+
#
|
251
|
+
# :method: wont_be_kind_of
|
252
|
+
|
253
|
+
infect_an_assertion :refute_kind_of, :wont_be_kind_of
|
254
|
+
|
255
|
+
##
|
256
|
+
# See Minitest::Assertions#refute_match
|
257
|
+
#
|
258
|
+
# _(a).wont_match b
|
259
|
+
#
|
260
|
+
# :method: wont_match
|
261
|
+
|
262
|
+
infect_an_assertion :refute_match, :wont_match
|
263
|
+
|
264
|
+
##
|
265
|
+
# See Minitest::Assertions#refute_nil
|
266
|
+
#
|
267
|
+
# _(obj).wont_be_nil
|
268
|
+
#
|
269
|
+
# :method: wont_be_nil
|
270
|
+
|
271
|
+
infect_an_assertion :refute_nil, :wont_be_nil, :unary
|
272
|
+
|
273
|
+
##
|
274
|
+
# See Minitest::Assertions#refute_operator
|
275
|
+
#
|
276
|
+
# _(n).wont_be :<=, 42
|
277
|
+
#
|
278
|
+
# This can also do predicates:
|
279
|
+
#
|
280
|
+
# str.wont_be :empty?
|
281
|
+
#
|
282
|
+
# :method: wont_be
|
283
|
+
|
284
|
+
infect_an_assertion :refute_operator, :wont_be, :reverse
|
285
|
+
|
286
|
+
##
|
287
|
+
# See Minitest::Assertions#refute_respond_to
|
288
|
+
#
|
289
|
+
# _(obj).wont_respond_to msg
|
290
|
+
#
|
291
|
+
# :method: wont_respond_to
|
292
|
+
|
293
|
+
infect_an_assertion :refute_respond_to, :wont_respond_to, :reverse
|
294
|
+
|
295
|
+
##
|
296
|
+
# See Minitest::Assertions#refute_same
|
297
|
+
#
|
298
|
+
# _(a).wont_be_same_as b
|
299
|
+
#
|
300
|
+
# :method: wont_be_same_as
|
301
|
+
|
302
|
+
infect_an_assertion :refute_same, :wont_be_same_as
|
303
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
class MockExpectationError < StandardError; end # :nodoc:
|
2
|
+
|
3
|
+
module Minitest # :nodoc:
|
4
|
+
|
5
|
+
##
|
6
|
+
# A simple and clean mock object framework.
|
7
|
+
#
|
8
|
+
# All mock objects are an instance of Mock
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
alias :__respond_to? :respond_to?
|
12
|
+
|
13
|
+
overridden_methods = %w[
|
14
|
+
===
|
15
|
+
class
|
16
|
+
inspect
|
17
|
+
instance_eval
|
18
|
+
instance_variables
|
19
|
+
object_id
|
20
|
+
public_send
|
21
|
+
respond_to_missing?
|
22
|
+
send
|
23
|
+
to_s
|
24
|
+
]
|
25
|
+
|
26
|
+
instance_methods.each do |m|
|
27
|
+
undef_method m unless overridden_methods.include?(m.to_s) || m =~ /^__/
|
28
|
+
end
|
29
|
+
|
30
|
+
overridden_methods.map(&:to_sym).each do |method_id|
|
31
|
+
define_method method_id do |*args, &b|
|
32
|
+
if @expected_calls.key? method_id then
|
33
|
+
method_missing(method_id, *args, &b)
|
34
|
+
else
|
35
|
+
super(*args, &b)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize delegator = nil # :nodoc:
|
41
|
+
@delegator = delegator
|
42
|
+
@expected_calls = Hash.new { |calls, name| calls[name] = [] }
|
43
|
+
@actual_calls = Hash.new { |calls, name| calls[name] = [] }
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# Expect that method +name+ is called, optionally with +args+ or a
|
48
|
+
# +blk+, and returns +retval+.
|
49
|
+
#
|
50
|
+
# @mock.expect(:meaning_of_life, 42)
|
51
|
+
# @mock.meaning_of_life # => 42
|
52
|
+
#
|
53
|
+
# @mock.expect(:do_something_with, true, [some_obj, true])
|
54
|
+
# @mock.do_something_with(some_obj, true) # => true
|
55
|
+
#
|
56
|
+
# @mock.expect(:do_something_else, true) do |a1, a2|
|
57
|
+
# a1 == "buggs" && a2 == :bunny
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# +args+ is compared to the expected args using case equality (ie, the
|
61
|
+
# '===' operator), allowing for less specific expectations.
|
62
|
+
#
|
63
|
+
# @mock.expect(:uses_any_string, true, [String])
|
64
|
+
# @mock.uses_any_string("foo") # => true
|
65
|
+
# @mock.verify # => true
|
66
|
+
#
|
67
|
+
# @mock.expect(:uses_one_string, true, ["foo"])
|
68
|
+
# @mock.uses_one_string("bar") # => raises MockExpectationError
|
69
|
+
#
|
70
|
+
# If a method will be called multiple times, specify a new expect for each one.
|
71
|
+
# They will be used in the order you define them.
|
72
|
+
#
|
73
|
+
# @mock.expect(:ordinal_increment, 'first')
|
74
|
+
# @mock.expect(:ordinal_increment, 'second')
|
75
|
+
#
|
76
|
+
# @mock.ordinal_increment # => 'first'
|
77
|
+
# @mock.ordinal_increment # => 'second'
|
78
|
+
# @mock.ordinal_increment # => raises MockExpectationError "No more expects available for :ordinal_increment"
|
79
|
+
#
|
80
|
+
|
81
|
+
def expect name, retval, args = [], &blk
|
82
|
+
name = name.to_sym
|
83
|
+
|
84
|
+
if block_given?
|
85
|
+
raise ArgumentError, "args ignored when block given" unless args.empty?
|
86
|
+
@expected_calls[name] << { :retval => retval, :block => blk }
|
87
|
+
else
|
88
|
+
raise ArgumentError, "args must be an array" unless Array === args
|
89
|
+
@expected_calls[name] << { :retval => retval, :args => args }
|
90
|
+
end
|
91
|
+
self
|
92
|
+
end
|
93
|
+
|
94
|
+
def __call name, data # :nodoc:
|
95
|
+
case data
|
96
|
+
when Hash then
|
97
|
+
"#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}"
|
98
|
+
else
|
99
|
+
data.map { |d| __call name, d }.join ", "
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Verify that all methods were called as expected. Raises
|
105
|
+
# +MockExpectationError+ if the mock object was not called as
|
106
|
+
# expected.
|
107
|
+
|
108
|
+
def verify
|
109
|
+
@expected_calls.each do |name, expected|
|
110
|
+
actual = @actual_calls.fetch(name, nil)
|
111
|
+
raise MockExpectationError, "expected #{__call name, expected[0]}" unless actual
|
112
|
+
raise MockExpectationError, "expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
|
113
|
+
actual.size < expected.size
|
114
|
+
end
|
115
|
+
true
|
116
|
+
end
|
117
|
+
|
118
|
+
def method_missing sym, *args, &block # :nodoc:
|
119
|
+
unless @expected_calls.key?(sym) then
|
120
|
+
if @delegator && @delegator.respond_to?(sym)
|
121
|
+
return @delegator.public_send(sym, *args, &block)
|
122
|
+
else
|
123
|
+
raise NoMethodError, "unmocked method %p, expected one of %p" %
|
124
|
+
[sym, @expected_calls.keys.sort_by(&:to_s)]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
index = @actual_calls[sym].length
|
129
|
+
expected_call = @expected_calls[sym][index]
|
130
|
+
|
131
|
+
unless expected_call then
|
132
|
+
raise MockExpectationError, "No more expects available for %p: %p" %
|
133
|
+
[sym, args]
|
134
|
+
end
|
135
|
+
|
136
|
+
expected_args, retval, val_block =
|
137
|
+
expected_call.values_at(:args, :retval, :block)
|
138
|
+
|
139
|
+
if val_block then
|
140
|
+
# keep "verify" happy
|
141
|
+
@actual_calls[sym] << expected_call
|
142
|
+
|
143
|
+
raise MockExpectationError, "mocked method %p failed block w/ %p" %
|
144
|
+
[sym, args] unless val_block.call(*args, &block)
|
145
|
+
|
146
|
+
return retval
|
147
|
+
end
|
148
|
+
|
149
|
+
if expected_args.size != args.size then
|
150
|
+
raise ArgumentError, "mocked method %p expects %d arguments, got %d" %
|
151
|
+
[sym, expected_args.size, args.size]
|
152
|
+
end
|
153
|
+
|
154
|
+
zipped_args = expected_args.zip(args)
|
155
|
+
fully_matched = zipped_args.all? { |mod, a|
|
156
|
+
mod === a or mod == a
|
157
|
+
}
|
158
|
+
|
159
|
+
unless fully_matched then
|
160
|
+
raise MockExpectationError, "mocked method %p called with unexpected arguments %p" %
|
161
|
+
[sym, args]
|
162
|
+
end
|
163
|
+
|
164
|
+
@actual_calls[sym] << {
|
165
|
+
:retval => retval,
|
166
|
+
:args => zipped_args.map! { |mod, a| mod === a ? mod : a },
|
167
|
+
}
|
168
|
+
|
169
|
+
retval
|
170
|
+
end
|
171
|
+
|
172
|
+
def respond_to? sym, include_private = false # :nodoc:
|
173
|
+
return true if @expected_calls.key? sym.to_sym
|
174
|
+
return true if @delegator && @delegator.respond_to?(sym, include_private)
|
175
|
+
__respond_to?(sym, include_private)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
module Minitest::Assertions
|
181
|
+
##
|
182
|
+
# Assert that the mock verifies correctly.
|
183
|
+
|
184
|
+
def assert_mock mock
|
185
|
+
assert mock.verify
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
##
|
190
|
+
# Object extensions for Minitest::Mock.
|
191
|
+
|
192
|
+
class Object
|
193
|
+
|
194
|
+
##
|
195
|
+
# Add a temporary stubbed method replacing +name+ for the duration
|
196
|
+
# of the +block+. If +val_or_callable+ responds to #call, then it
|
197
|
+
# returns the result of calling it, otherwise returns the value
|
198
|
+
# as-is. If stubbed method yields a block, +block_args+ will be
|
199
|
+
# passed along. Cleans up the stub at the end of the +block+. The
|
200
|
+
# method +name+ must exist before stubbing.
|
201
|
+
#
|
202
|
+
# def test_stale_eh
|
203
|
+
# obj_under_test = Something.new
|
204
|
+
# refute obj_under_test.stale?
|
205
|
+
#
|
206
|
+
# Time.stub :now, Time.at(0) do
|
207
|
+
# assert obj_under_test.stale?
|
208
|
+
# end
|
209
|
+
# end
|
210
|
+
#
|
211
|
+
|
212
|
+
def stub name, val_or_callable, *block_args
|
213
|
+
new_name = "__minitest_stub__#{name}"
|
214
|
+
|
215
|
+
metaclass = class << self; self; end
|
216
|
+
|
217
|
+
if respond_to? name and not methods.map(&:to_s).include? name.to_s then
|
218
|
+
metaclass.send :define_method, name do |*args|
|
219
|
+
super(*args)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
metaclass.send :alias_method, new_name, name
|
224
|
+
|
225
|
+
metaclass.send :define_method, name do |*args, &blk|
|
226
|
+
if val_or_callable.respond_to? :call then
|
227
|
+
val_or_callable.call(*args, &blk)
|
228
|
+
else
|
229
|
+
blk.call(*block_args) if blk
|
230
|
+
val_or_callable
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
yield self
|
235
|
+
ensure
|
236
|
+
metaclass.send :undef_method, name
|
237
|
+
metaclass.send :alias_method, name, new_name
|
238
|
+
metaclass.send :undef_method, new_name
|
239
|
+
end
|
240
|
+
end
|