sublimetheme 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +230 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/sublimetheme.rb +6832 -0
- data/lib/sublimetheme/version.rb +3 -0
- data/path/bin/htmldiff +25 -0
- data/path/bin/htmldiff.bat +6 -0
- data/path/bin/ldiff +25 -0
- data/path/bin/ldiff.bat +6 -0
- data/path/bin/rspec +23 -0
- data/path/bin/rspec.bat +6 -0
- data/path/cache/diff-lcs-1.2.5.gem +0 -0
- data/path/cache/rspec-3.3.0.gem +0 -0
- data/path/cache/rspec-core-3.3.2.gem +0 -0
- data/path/cache/rspec-expectations-3.3.1.gem +0 -0
- data/path/cache/rspec-mocks-3.3.2.gem +0 -0
- data/path/cache/rspec-support-3.3.0.gem +0 -0
- data/path/gems/diff-lcs-1.2.5/.autotest +3 -0
- data/path/gems/diff-lcs-1.2.5/.gemtest +0 -0
- data/path/gems/diff-lcs-1.2.5/.hoerc +2 -0
- data/path/gems/diff-lcs-1.2.5/.rspec +2 -0
- data/path/gems/diff-lcs-1.2.5/.travis.yml +22 -0
- data/path/gems/diff-lcs-1.2.5/Contributing.rdoc +64 -0
- data/path/gems/diff-lcs-1.2.5/Gemfile +20 -0
- data/path/gems/diff-lcs-1.2.5/History.rdoc +152 -0
- data/path/gems/diff-lcs-1.2.5/License.rdoc +39 -0
- data/path/gems/diff-lcs-1.2.5/Manifest.txt +38 -0
- data/path/gems/diff-lcs-1.2.5/README.rdoc +85 -0
- data/path/gems/diff-lcs-1.2.5/Rakefile +41 -0
- data/path/gems/diff-lcs-1.2.5/autotest/discover.rb +1 -0
- data/path/gems/diff-lcs-1.2.5/bin/htmldiff +32 -0
- data/path/gems/diff-lcs-1.2.5/bin/ldiff +6 -0
- data/path/gems/diff-lcs-1.2.5/docs/COPYING.txt +339 -0
- data/path/gems/diff-lcs-1.2.5/docs/artistic.txt +127 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff-lcs.rb +3 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs.rb +805 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/array.rb +7 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb +37 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/callbacks.rb +322 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/change.rb +177 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/htmldiff.rb +149 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/hunk.rb +276 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/internals.rb +301 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/ldiff.rb +195 -0
- data/path/gems/diff-lcs-1.2.5/lib/diff/lcs/string.rb +5 -0
- data/path/gems/diff-lcs-1.2.5/spec/change_spec.rb +65 -0
- data/path/gems/diff-lcs-1.2.5/spec/diff_spec.rb +47 -0
- data/path/gems/diff-lcs-1.2.5/spec/hunk_spec.rb +72 -0
- data/path/gems/diff-lcs-1.2.5/spec/issues_spec.rb +24 -0
- data/path/gems/diff-lcs-1.2.5/spec/lcs_spec.rb +54 -0
- data/path/gems/diff-lcs-1.2.5/spec/patch_spec.rb +414 -0
- data/path/gems/diff-lcs-1.2.5/spec/sdiff_spec.rb +214 -0
- data/path/gems/diff-lcs-1.2.5/spec/spec_helper.rb +290 -0
- data/path/gems/diff-lcs-1.2.5/spec/traverse_balanced_spec.rb +310 -0
- data/path/gems/diff-lcs-1.2.5/spec/traverse_sequences_spec.rb +139 -0
- data/path/gems/rspec-3.3.0/License.txt +24 -0
- data/path/gems/rspec-3.3.0/README.md +34 -0
- data/path/gems/rspec-3.3.0/lib/rspec.rb +3 -0
- data/path/gems/rspec-3.3.0/lib/rspec/version.rb +5 -0
- data/path/gems/rspec-core-3.3.2/.document +5 -0
- data/path/gems/rspec-core-3.3.2/.yardopts +8 -0
- data/path/gems/rspec-core-3.3.2/Changelog.md +1856 -0
- data/path/gems/rspec-core-3.3.2/License.txt +25 -0
- data/path/gems/rspec-core-3.3.2/README.md +369 -0
- data/path/gems/rspec-core-3.3.2/exe/rspec +4 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/autorun.rb +3 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core.rb +181 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/backtrace_formatter.rb +64 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/coordinator.rb +66 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/example_minimizer.rb +130 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/runner.rb +139 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/server.rb +61 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/bisect/subset_enumerator.rb +39 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb +1807 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/configuration_options.rb +191 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/drb.rb +111 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/dsl.rb +96 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/example.rb +573 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/example_group.rb +796 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/example_status_persister.rb +235 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/filter_manager.rb +231 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/flat_map.rb +20 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters.rb +254 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/base_formatter.rb +70 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/base_text_formatter.rb +77 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/bisect_formatter.rb +68 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/bisect_progress_formatter.rb +115 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/documentation_formatter.rb +70 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/exception_presenter.rb +393 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/helpers.rb +109 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/html_formatter.rb +151 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/html_printer.rb +415 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/json_formatter.rb +96 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/profile_formatter.rb +68 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/progress_formatter.rb +28 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/protocol.rb +172 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/formatters/snippet_extractor.rb +116 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/hooks.rb +638 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/memoized_helpers.rb +532 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/metadata.rb +490 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/metadata_filter.rb +235 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/null.rb +14 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/rr.rb +31 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/mutex.rb +63 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/notifications.rb +498 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/option_parser.rb +301 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/ordering.rb +158 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/pending.rb +165 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/profiler.rb +32 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer.rb +48 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer/.rspec +2 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/project_initializer/spec/spec_helper.rb +96 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/rake_task.rb +158 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/reentrant_mutex.rb +52 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/reporter.rb +220 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/ruby_project.rb +53 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb +179 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/sandbox.rb +37 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/set.rb +49 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/shared_context.rb +55 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/shared_example_group.rb +210 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/shell_escape.rb +49 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/version.rb +9 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/warnings.rb +40 -0
- data/path/gems/rspec-core-3.3.2/lib/rspec/core/world.rb +178 -0
- data/path/gems/rspec-expectations-3.3.1/.document +5 -0
- data/path/gems/rspec-expectations-3.3.1/.yardopts +6 -0
- data/path/gems/rspec-expectations-3.3.1/Changelog.md +953 -0
- data/path/gems/rspec-expectations-3.3.1/License.txt +24 -0
- data/path/gems/rspec-expectations-3.3.1/README.md +289 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations.rb +81 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/configuration.rb +164 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/expectation_target.rb +113 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/fail_with.rb +31 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/failure_aggregator.rb +194 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/handler.rb +170 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/minitest_integration.rb +31 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/syntax.rb +132 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/expectations/version.rb +8 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers.rb +1009 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/aliased_matcher.rb +116 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in.rb +52 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/all.rb +85 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/base_matcher.rb +181 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be.rb +285 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_between.rb +77 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_instance_of.rb +22 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_kind_of.rb +16 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/be_within.rb +72 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/change.rb +337 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/compound.rb +293 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/contain_exactly.rb +253 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/cover.rb +24 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/eq.rb +40 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/eql.rb +34 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/equal.rb +81 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/exist.rb +86 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/has.rb +103 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/include.rb +130 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/match.rb +37 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/operators.rb +128 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/output.rb +200 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/raise_error.rb +216 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/respond_to.rb +90 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/satisfy.rb +37 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/start_or_end_with.rb +94 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/throw_symbol.rb +132 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/built_in/yield.rb +418 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/composable.rb +184 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/dsl.rb +453 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/english_phrasing.rb +42 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +73 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/fail_matchers.rb +42 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/generated_descriptions.rb +42 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/matcher_delegator.rb +35 -0
- data/path/gems/rspec-expectations-3.3.1/lib/rspec/matchers/matcher_protocol.rb +99 -0
- data/path/gems/rspec-mocks-3.3.2/.document +5 -0
- data/path/gems/rspec-mocks-3.3.2/.yardopts +6 -0
- data/path/gems/rspec-mocks-3.3.2/Changelog.md +965 -0
- data/path/gems/rspec-mocks-3.3.2/License.txt +24 -0
- data/path/gems/rspec-mocks-3.3.2/README.md +430 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks.rb +126 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance.rb +11 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/chain.rb +110 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/error_generator.rb +31 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/expect_chain_chain.rb +35 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/expectation_chain.rb +48 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/message_chains.rb +83 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/proxy.rb +116 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/recorder.rb +264 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/stub_chain.rb +46 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/any_instance/stub_chain_chain.rb +27 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/argument_list_matcher.rb +100 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/argument_matchers.rb +320 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/configuration.rb +188 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/error_generator.rb +362 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/example_methods.rb +421 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/instance_method_stasher.rb +135 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/marshal_extension.rb +41 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/have_received.rb +116 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive.rb +130 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive_message_chain.rb +80 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/matchers/receive_messages.rb +75 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/message_chain.rb +87 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/message_expectation.rb +717 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/method_double.rb +287 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/method_reference.rb +192 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/mutate_const.rb +335 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/mutex.rb +73 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/object_reference.rb +149 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/order_group.rb +81 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/proxy.rb +439 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/reentrant_mutex.rb +53 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/space.rb +238 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/standalone.rb +3 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/syntax.rb +325 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/targets.rb +97 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/test_double.rb +170 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_double.rb +129 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_message_expecation.rb +54 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/verifying_proxy.rb +213 -0
- data/path/gems/rspec-mocks-3.3.2/lib/rspec/mocks/version.rb +9 -0
- data/path/gems/rspec-support-3.3.0/Changelog.md +125 -0
- data/path/gems/rspec-support-3.3.0/LICENSE.txt +22 -0
- data/path/gems/rspec-support-3.3.0/README.md +26 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support.rb +111 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/caller_filter.rb +83 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/differ.rb +215 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/directory_maker.rb +63 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/encoded_string.rb +155 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/fuzzy_matcher.rb +48 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/hunk_generator.rb +47 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/matcher_definition.rb +42 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/method_signature_verifier.rb +273 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/object_formatter.rb +93 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/recursive_const_methods.rb +76 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/ruby_features.rb +118 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec.rb +81 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/deprecation_helpers.rb +64 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/formatting_support.rb +9 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/in_sub_process.rb +52 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/library_wide_checks.rb +145 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/shell_out.rb +71 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/stderr_splitter.rb +63 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/string_matcher.rb +46 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/with_isolated_directory.rb +9 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/version.rb +7 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/version_checker.rb +53 -0
- data/path/gems/rspec-support-3.3.0/lib/rspec/support/warnings.rb +39 -0
- data/path/specifications/diff-lcs-1.2.5.gemspec +68 -0
- data/path/specifications/rspec-3.3.0.gemspec +42 -0
- data/path/specifications/rspec-core-3.3.2.gemspec +68 -0
- data/path/specifications/rspec-expectations-3.3.1.gemspec +50 -0
- data/path/specifications/rspec-mocks-3.3.2.gemspec +53 -0
- data/path/specifications/rspec-support-3.3.0.gemspec +38 -0
- data/sublimetheme.gemspec +32 -0
- metadata +363 -0
@@ -0,0 +1,418 @@
|
|
1
|
+
RSpec::Support.require_rspec_support "method_signature_verifier"
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Matchers
|
5
|
+
module BuiltIn
|
6
|
+
# @private
|
7
|
+
# Object that is yielded to `expect` when one of the
|
8
|
+
# yield matchers is used. Provides information about
|
9
|
+
# the yield behavior of the object-under-test.
|
10
|
+
class YieldProbe
|
11
|
+
def self.probe(block)
|
12
|
+
probe = new(block)
|
13
|
+
return probe unless probe.has_block?
|
14
|
+
probe.assert_valid_expect_block!
|
15
|
+
block.call(probe)
|
16
|
+
probe.assert_used!
|
17
|
+
probe
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_accessor :num_yields, :yielded_args
|
21
|
+
|
22
|
+
def initialize(block)
|
23
|
+
@block = block
|
24
|
+
@used = false
|
25
|
+
self.num_yields, self.yielded_args = 0, []
|
26
|
+
end
|
27
|
+
|
28
|
+
def has_block?
|
29
|
+
Proc === @block
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_proc
|
33
|
+
@used = true
|
34
|
+
|
35
|
+
probe = self
|
36
|
+
Proc.new do |*args|
|
37
|
+
probe.num_yields += 1
|
38
|
+
probe.yielded_args << args
|
39
|
+
nil # to indicate the block does not return a meaningful value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def single_yield_args
|
44
|
+
yielded_args.first
|
45
|
+
end
|
46
|
+
|
47
|
+
def yielded_once?(matcher_name)
|
48
|
+
case num_yields
|
49
|
+
when 1 then true
|
50
|
+
when 0 then false
|
51
|
+
else
|
52
|
+
raise "The #{matcher_name} matcher is not designed to be used with a " \
|
53
|
+
"method that yields multiple times. Use the yield_successive_args " \
|
54
|
+
"matcher for that case."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def successive_yield_args
|
59
|
+
yielded_args.map do |arg_array|
|
60
|
+
arg_array.size == 1 ? arg_array.first : arg_array
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def assert_used!
|
65
|
+
return if @used
|
66
|
+
raise "You must pass the argument yielded to your expect block on " \
|
67
|
+
"to the method-under-test as a block. It acts as a probe that " \
|
68
|
+
"allows the matcher to detect whether or not the method-under-test " \
|
69
|
+
"yields, and, if so, how many times, and what the yielded arguments " \
|
70
|
+
"are."
|
71
|
+
end
|
72
|
+
|
73
|
+
if RUBY_VERSION.to_f > 1.8
|
74
|
+
def assert_valid_expect_block!
|
75
|
+
block_signature = RSpec::Support::BlockSignature.new(@block)
|
76
|
+
return if RSpec::Support::StrictSignatureVerifier.new(block_signature, [self]).valid?
|
77
|
+
raise "Your expect block must accept an argument to be used with this " \
|
78
|
+
"matcher. Pass the argument as a block on to the method you are testing."
|
79
|
+
end
|
80
|
+
else
|
81
|
+
# :nocov:
|
82
|
+
# On 1.8.7, `lambda { }.arity` and `lambda { |*a| }.arity` both return -1,
|
83
|
+
# so we can't distinguish between accepting no args and an arg splat.
|
84
|
+
# It's OK to skip, this, though; it just provides a nice error message
|
85
|
+
# when the user forgets to accept an arg in their block. They'll still get
|
86
|
+
# the `assert_used!` error message from above, which is sufficient.
|
87
|
+
def assert_valid_expect_block!
|
88
|
+
# nothing to do
|
89
|
+
end
|
90
|
+
# :nocov:
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# @api private
|
95
|
+
# Provides the implementation for `yield_control`.
|
96
|
+
# Not intended to be instantiated directly.
|
97
|
+
class YieldControl < BaseMatcher
|
98
|
+
def initialize
|
99
|
+
at_least(:once)
|
100
|
+
end
|
101
|
+
|
102
|
+
# @api public
|
103
|
+
# Specifies that the method is expected to yield once.
|
104
|
+
def once
|
105
|
+
exactly(1)
|
106
|
+
self
|
107
|
+
end
|
108
|
+
|
109
|
+
# @api public
|
110
|
+
# Specifies that the method is expected to yield twice.
|
111
|
+
def twice
|
112
|
+
exactly(2)
|
113
|
+
self
|
114
|
+
end
|
115
|
+
|
116
|
+
# @api public
|
117
|
+
# Specifies that the method is expected to yield thrice.
|
118
|
+
def thrice
|
119
|
+
exactly(3)
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
# @api public
|
124
|
+
# Specifies that the method is expected to yield the given number of times.
|
125
|
+
def exactly(number)
|
126
|
+
set_expected_yields_count(:==, number)
|
127
|
+
self
|
128
|
+
end
|
129
|
+
|
130
|
+
# @api public
|
131
|
+
# Specifies the maximum number of times the method is expected to yield
|
132
|
+
def at_most(number)
|
133
|
+
set_expected_yields_count(:<=, number)
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
137
|
+
# @api public
|
138
|
+
# Specifies the minimum number of times the method is expected to yield
|
139
|
+
def at_least(number)
|
140
|
+
set_expected_yields_count(:>=, number)
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
# @api public
|
145
|
+
# No-op. Provides syntactic sugar.
|
146
|
+
def times
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
# @private
|
151
|
+
def matches?(block)
|
152
|
+
@probe = YieldProbe.probe(block)
|
153
|
+
return false unless @probe.has_block?
|
154
|
+
|
155
|
+
@probe.num_yields.__send__(@expectation_type, @expected_yields_count)
|
156
|
+
end
|
157
|
+
|
158
|
+
# @private
|
159
|
+
def does_not_match?(block)
|
160
|
+
!matches?(block) && @probe.has_block?
|
161
|
+
end
|
162
|
+
|
163
|
+
# @api private
|
164
|
+
# @return [String]
|
165
|
+
def failure_message
|
166
|
+
'expected given block to yield control' + failure_reason
|
167
|
+
end
|
168
|
+
|
169
|
+
# @api private
|
170
|
+
# @return [String]
|
171
|
+
def failure_message_when_negated
|
172
|
+
'expected given block not to yield control' + failure_reason
|
173
|
+
end
|
174
|
+
|
175
|
+
# @private
|
176
|
+
def supports_block_expectations?
|
177
|
+
true
|
178
|
+
end
|
179
|
+
|
180
|
+
private
|
181
|
+
|
182
|
+
def set_expected_yields_count(relativity, n)
|
183
|
+
@expectation_type = relativity
|
184
|
+
@expected_yields_count = case n
|
185
|
+
when Numeric then n
|
186
|
+
when :once then 1
|
187
|
+
when :twice then 2
|
188
|
+
when :thrice then 3
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def failure_reason
|
193
|
+
return " but was not a block" unless @probe.has_block?
|
194
|
+
return '' unless @expected_yields_count
|
195
|
+
" #{human_readable_expectation_type}#{human_readable_count(@expected_yields_count)}" \
|
196
|
+
" but yielded #{human_readable_count(@probe.num_yields)}"
|
197
|
+
end
|
198
|
+
|
199
|
+
def human_readable_expectation_type
|
200
|
+
case @expectation_type
|
201
|
+
when :<= then 'at most '
|
202
|
+
when :>= then 'at least '
|
203
|
+
else ''
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def human_readable_count(count)
|
208
|
+
case count
|
209
|
+
when 1 then "once"
|
210
|
+
when 2 then "twice"
|
211
|
+
else "#{count} times"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# @api private
|
217
|
+
# Provides the implementation for `yield_with_no_args`.
|
218
|
+
# Not intended to be instantiated directly.
|
219
|
+
class YieldWithNoArgs < BaseMatcher
|
220
|
+
# @private
|
221
|
+
def matches?(block)
|
222
|
+
@probe = YieldProbe.probe(block)
|
223
|
+
return false unless @probe.has_block?
|
224
|
+
@probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.empty?
|
225
|
+
end
|
226
|
+
|
227
|
+
# @private
|
228
|
+
def does_not_match?(block)
|
229
|
+
!matches?(block) && @probe.has_block?
|
230
|
+
end
|
231
|
+
|
232
|
+
# @private
|
233
|
+
def failure_message
|
234
|
+
"expected given block to yield with no arguments, but #{positive_failure_reason}"
|
235
|
+
end
|
236
|
+
|
237
|
+
# @private
|
238
|
+
def failure_message_when_negated
|
239
|
+
"expected given block not to yield with no arguments, but #{negative_failure_reason}"
|
240
|
+
end
|
241
|
+
|
242
|
+
# @private
|
243
|
+
def supports_block_expectations?
|
244
|
+
true
|
245
|
+
end
|
246
|
+
|
247
|
+
private
|
248
|
+
|
249
|
+
def positive_failure_reason
|
250
|
+
return "was not a block" unless @probe.has_block?
|
251
|
+
return "did not yield" if @probe.num_yields.zero?
|
252
|
+
"yielded with arguments: #{description_of @probe.single_yield_args}"
|
253
|
+
end
|
254
|
+
|
255
|
+
def negative_failure_reason
|
256
|
+
return "was not a block" unless @probe.has_block?
|
257
|
+
"did"
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
# @api private
|
262
|
+
# Provides the implementation for `yield_with_args`.
|
263
|
+
# Not intended to be instantiated directly.
|
264
|
+
class YieldWithArgs < BaseMatcher
|
265
|
+
def initialize(*args)
|
266
|
+
@expected = args
|
267
|
+
end
|
268
|
+
|
269
|
+
# @private
|
270
|
+
def matches?(block)
|
271
|
+
@probe = YieldProbe.probe(block)
|
272
|
+
return false unless @probe.has_block?
|
273
|
+
@actual = @probe.single_yield_args
|
274
|
+
@probe.yielded_once?(:yield_with_args) && args_match?
|
275
|
+
end
|
276
|
+
|
277
|
+
# @private
|
278
|
+
def does_not_match?(block)
|
279
|
+
!matches?(block) && @probe.has_block?
|
280
|
+
end
|
281
|
+
|
282
|
+
# @private
|
283
|
+
def failure_message
|
284
|
+
"expected given block to yield with arguments, but #{positive_failure_reason}"
|
285
|
+
end
|
286
|
+
|
287
|
+
# @private
|
288
|
+
def failure_message_when_negated
|
289
|
+
"expected given block not to yield with arguments, but #{negative_failure_reason}"
|
290
|
+
end
|
291
|
+
|
292
|
+
# @private
|
293
|
+
def description
|
294
|
+
desc = "yield with args"
|
295
|
+
desc << "(#{expected_arg_description})" unless @expected.empty?
|
296
|
+
desc
|
297
|
+
end
|
298
|
+
|
299
|
+
# @private
|
300
|
+
def supports_block_expectations?
|
301
|
+
true
|
302
|
+
end
|
303
|
+
|
304
|
+
private
|
305
|
+
|
306
|
+
def positive_failure_reason
|
307
|
+
return "was not a block" unless @probe.has_block?
|
308
|
+
return "did not yield" if @probe.num_yields.zero?
|
309
|
+
@positive_args_failure
|
310
|
+
end
|
311
|
+
|
312
|
+
def expected_arg_description
|
313
|
+
@expected.map { |e| description_of e }.join(", ")
|
314
|
+
end
|
315
|
+
|
316
|
+
def negative_failure_reason
|
317
|
+
if !@probe.has_block?
|
318
|
+
"was not a block"
|
319
|
+
elsif all_args_match?
|
320
|
+
"yielded with expected arguments" \
|
321
|
+
"\nexpected not: #{surface_descriptions_in(@expected).inspect}" +
|
322
|
+
"\n got: #{actual_formatted}"
|
323
|
+
else
|
324
|
+
"did"
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
def args_match?
|
329
|
+
if @expected.empty? # expect {...}.to yield_with_args
|
330
|
+
@positive_args_failure = "yielded with no arguments" if @actual.empty?
|
331
|
+
return !@actual.empty?
|
332
|
+
end
|
333
|
+
|
334
|
+
unless (match = all_args_match?)
|
335
|
+
@positive_args_failure = "yielded with unexpected arguments" \
|
336
|
+
"\nexpected: #{surface_descriptions_in(@expected).inspect}" +
|
337
|
+
"\n got: #{actual_formatted}"
|
338
|
+
end
|
339
|
+
|
340
|
+
match
|
341
|
+
end
|
342
|
+
|
343
|
+
def all_args_match?
|
344
|
+
values_match?(@expected, @actual)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
# @api private
|
349
|
+
# Provides the implementation for `yield_successive_args`.
|
350
|
+
# Not intended to be instantiated directly.
|
351
|
+
class YieldSuccessiveArgs < BaseMatcher
|
352
|
+
def initialize(*args)
|
353
|
+
@expected = args
|
354
|
+
end
|
355
|
+
|
356
|
+
# @private
|
357
|
+
def matches?(block)
|
358
|
+
@probe = YieldProbe.probe(block)
|
359
|
+
return false unless @probe.has_block?
|
360
|
+
@actual = @probe.successive_yield_args
|
361
|
+
args_match?
|
362
|
+
end
|
363
|
+
|
364
|
+
def does_not_match?(block)
|
365
|
+
!matches?(block) && @probe.has_block?
|
366
|
+
end
|
367
|
+
|
368
|
+
# @private
|
369
|
+
def failure_message
|
370
|
+
"expected given block to yield successively with arguments, but #{positive_failure_reason}"
|
371
|
+
end
|
372
|
+
|
373
|
+
# @private
|
374
|
+
def failure_message_when_negated
|
375
|
+
"expected given block not to yield successively with arguments, but #{negative_failure_reason}"
|
376
|
+
end
|
377
|
+
|
378
|
+
# @private
|
379
|
+
def description
|
380
|
+
desc = "yield successive args"
|
381
|
+
desc << "(#{expected_arg_description})"
|
382
|
+
desc
|
383
|
+
end
|
384
|
+
|
385
|
+
# @private
|
386
|
+
def supports_block_expectations?
|
387
|
+
true
|
388
|
+
end
|
389
|
+
|
390
|
+
private
|
391
|
+
|
392
|
+
def args_match?
|
393
|
+
values_match?(@expected, @actual)
|
394
|
+
end
|
395
|
+
|
396
|
+
def expected_arg_description
|
397
|
+
@expected.map { |e| description_of e }.join(", ")
|
398
|
+
end
|
399
|
+
|
400
|
+
def positive_failure_reason
|
401
|
+
return "was not a block" unless @probe.has_block?
|
402
|
+
|
403
|
+
"yielded with unexpected arguments" \
|
404
|
+
"\nexpected: #{surface_descriptions_in(@expected).inspect}" \
|
405
|
+
"\n got: #{actual_formatted}"
|
406
|
+
end
|
407
|
+
|
408
|
+
def negative_failure_reason
|
409
|
+
return "was not a block" unless @probe.has_block?
|
410
|
+
|
411
|
+
"yielded with expected arguments" \
|
412
|
+
"\nexpected not: #{surface_descriptions_in(@expected).inspect}" \
|
413
|
+
"\n got: #{actual_formatted}"
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
RSpec::Support.require_rspec_support "fuzzy_matcher"
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Matchers
|
5
|
+
# Mixin designed to support the composable matcher features
|
6
|
+
# of RSpec 3+. Mix it into your custom matcher classes to
|
7
|
+
# allow them to be used in a composable fashion.
|
8
|
+
#
|
9
|
+
# @api public
|
10
|
+
module Composable
|
11
|
+
# Creates a compound `and` expectation. The matcher will
|
12
|
+
# only pass if both sub-matchers pass.
|
13
|
+
# This can be chained together to form an arbitrarily long
|
14
|
+
# chain of matchers.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# expect(alphabet).to start_with("a").and end_with("z")
|
18
|
+
# expect(alphabet).to start_with("a") & end_with("z")
|
19
|
+
#
|
20
|
+
# @note The negative form (`expect(...).not_to matcher.and other`)
|
21
|
+
# is not supported at this time.
|
22
|
+
def and(matcher)
|
23
|
+
BuiltIn::Compound::And.new self, matcher
|
24
|
+
end
|
25
|
+
alias & and
|
26
|
+
|
27
|
+
# Creates a compound `or` expectation. The matcher will
|
28
|
+
# pass if either sub-matcher passes.
|
29
|
+
# This can be chained together to form an arbitrarily long
|
30
|
+
# chain of matchers.
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
|
34
|
+
# expect(stoplight.color).to eq("red") | eq("green") | eq("yellow")
|
35
|
+
#
|
36
|
+
# @note The negative form (`expect(...).not_to matcher.or other`)
|
37
|
+
# is not supported at this time.
|
38
|
+
def or(matcher)
|
39
|
+
BuiltIn::Compound::Or.new self, matcher
|
40
|
+
end
|
41
|
+
alias | or
|
42
|
+
|
43
|
+
# Delegates to `#matches?`. Allows matchers to be used in composable
|
44
|
+
# fashion and also supports using matchers in case statements.
|
45
|
+
def ===(value)
|
46
|
+
matches?(value)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# This provides a generic way to fuzzy-match an expected value against
|
52
|
+
# an actual value. It understands nested data structures (e.g. hashes
|
53
|
+
# and arrays) and is able to match against a matcher being used as
|
54
|
+
# the expected value or within the expected value at any level of
|
55
|
+
# nesting.
|
56
|
+
#
|
57
|
+
# Within a custom matcher you are encouraged to use this whenever your
|
58
|
+
# matcher needs to match two values, unless it needs more precise semantics.
|
59
|
+
# For example, the `eq` matcher _does not_ use this as it is meant to
|
60
|
+
# use `==` (and only `==`) for matching.
|
61
|
+
#
|
62
|
+
# @param expected [Object] what is expected
|
63
|
+
# @param actual [Object] the actual value
|
64
|
+
#
|
65
|
+
# @!visibility public
|
66
|
+
def values_match?(expected, actual)
|
67
|
+
expected = with_matchers_cloned(expected)
|
68
|
+
Support::FuzzyMatcher.values_match?(expected, actual)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns the description of the given object in a way that is
|
72
|
+
# aware of composed matchers. If the object is a matcher with
|
73
|
+
# a `description` method, returns the description; otherwise
|
74
|
+
# returns `object.inspect`.
|
75
|
+
#
|
76
|
+
# You are encouraged to use this in your custom matcher's
|
77
|
+
# `description`, `failure_message` or
|
78
|
+
# `failure_message_when_negated` implementation if you are
|
79
|
+
# supporting matcher arguments.
|
80
|
+
#
|
81
|
+
# @!visibility public
|
82
|
+
def description_of(object)
|
83
|
+
RSpec::Support::ObjectFormatter.format(object)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Transforms the given data structue (typically a hash or array)
|
87
|
+
# into a new data structure that, when `#inspect` is called on it,
|
88
|
+
# will provide descriptions of any contained matchers rather than
|
89
|
+
# the normal `#inspect` output.
|
90
|
+
#
|
91
|
+
# You are encouraged to use this in your custom matcher's
|
92
|
+
# `description`, `failure_message` or
|
93
|
+
# `failure_message_when_negated` implementation if you are
|
94
|
+
# supporting any arguments which may be a data structure
|
95
|
+
# containing matchers.
|
96
|
+
#
|
97
|
+
# @!visibility public
|
98
|
+
def surface_descriptions_in(item)
|
99
|
+
if Matchers.is_a_describable_matcher?(item)
|
100
|
+
DescribableItem.new(item)
|
101
|
+
elsif Hash === item
|
102
|
+
Hash[surface_descriptions_in(item.to_a)]
|
103
|
+
elsif Struct === item
|
104
|
+
RSpec::Support::ObjectFormatter.format(item)
|
105
|
+
elsif should_enumerate?(item)
|
106
|
+
begin
|
107
|
+
item.map { |subitem| surface_descriptions_in(subitem) }
|
108
|
+
rescue IOError # STDOUT is enumerable but `map` raises an error
|
109
|
+
RSpec::Support::ObjectFormatter.format(item)
|
110
|
+
end
|
111
|
+
else
|
112
|
+
item
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# @private
|
117
|
+
# Historically, a single matcher instance was only checked
|
118
|
+
# against a single value. Given that the matcher was only
|
119
|
+
# used once, it's been common to memoize some intermediate
|
120
|
+
# calculation that is derived from the `actual` value in
|
121
|
+
# order to reuse that intermediate result in the failure
|
122
|
+
# message.
|
123
|
+
#
|
124
|
+
# This can cause a problem when using such a matcher as an
|
125
|
+
# argument to another matcher in a composed matcher expression,
|
126
|
+
# since the matcher instance may be checked against multiple
|
127
|
+
# values and produce invalid results due to the memoization.
|
128
|
+
#
|
129
|
+
# To deal with this, we clone any matchers in `expected` via
|
130
|
+
# this method when using `values_match?`, so that any memoization
|
131
|
+
# does not "leak" between checks.
|
132
|
+
def with_matchers_cloned(object)
|
133
|
+
if Matchers.is_a_matcher?(object)
|
134
|
+
object.clone
|
135
|
+
elsif Hash === object
|
136
|
+
Hash[with_matchers_cloned(object.to_a)]
|
137
|
+
elsif Struct === object
|
138
|
+
object
|
139
|
+
elsif should_enumerate?(object)
|
140
|
+
begin
|
141
|
+
object.map { |subobject| with_matchers_cloned(subobject) }
|
142
|
+
rescue IOError # STDOUT is enumerable but `map` raises an error
|
143
|
+
object
|
144
|
+
end
|
145
|
+
else
|
146
|
+
object
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
if String.ancestors.include?(Enumerable) # 1.8.7
|
151
|
+
# :nocov:
|
152
|
+
# Strings are not enumerable on 1.9, and on 1.8 they are an infinitely
|
153
|
+
# nested enumerable: since ruby lacks a character class, it yields
|
154
|
+
# 1-character strings, which are themselves enumerable, composed of a
|
155
|
+
# a single 1-character string, which is an enumerable, etc.
|
156
|
+
#
|
157
|
+
# @api private
|
158
|
+
def should_enumerate?(item)
|
159
|
+
return false if String === item
|
160
|
+
Enumerable === item && !(Range === item)
|
161
|
+
end
|
162
|
+
# :nocov:
|
163
|
+
else
|
164
|
+
# @api private
|
165
|
+
def should_enumerate?(item)
|
166
|
+
Enumerable === item && !(Range === item)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
module_function :surface_descriptions_in, :should_enumerate?
|
170
|
+
|
171
|
+
# Wraps an item in order to surface its `description` via `inspect`.
|
172
|
+
# @api private
|
173
|
+
DescribableItem = Struct.new(:item) do
|
174
|
+
def inspect
|
175
|
+
"(#{item.description})"
|
176
|
+
end
|
177
|
+
|
178
|
+
def pretty_print(pp)
|
179
|
+
pp.text "(#{item.description})"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|