From 011c1b86e323ec1b85732ddf0e1693ddfaf77ef7 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 18 Dec 2014 09:36:36 +1100 Subject: [PATCH 1/2] 3.1 documentation --- .../documentation/3.1/rspec-core/RSpec.html | 578 ++ .../3.1/rspec-core/RSpec/Core.html | 153 + .../rspec-core/RSpec/Core/Configuration.html | 6496 +++++++++++++++++ .../RSpec/Core/ConfigurationOptions.html | 530 ++ .../3.1/rspec-core/RSpec/Core/DSL.html | 322 + .../3.1/rspec-core/RSpec/Core/Example.html | 1357 ++++ .../RSpec/Core/Example/ExecutionResult.html | 957 +++ .../rspec-core/RSpec/Core/Example/Procsy.html | 550 ++ .../rspec-core/RSpec/Core/ExampleGroup.html | 3627 +++++++++ .../3.1/rspec-core/RSpec/Core/Formatters.html | 354 + .../RSpec/Core/Formatters/BaseFormatter.html | 672 ++ .../Core/Formatters/BaseTextFormatter.html | 524 ++ .../RSpec/Core/Formatters/ConsoleCodes.html | 387 + .../RSpec/Core/Formatters/Helpers.html | 533 ++ .../RSpec/Core/Formatters/Loader.html | 601 ++ .../Core/Formatters/ProfileFormatter.html | 316 + .../RSpec/Core/Formatters/Protocol.html | 1485 ++++ .../Core/Formatters/SnippetExtractor.html | 681 ++ .../3.1/rspec-core/RSpec/Core/Hooks.html | 1230 ++++ .../RSpec/Core/MemoizedHelpers.html | 603 ++ .../Core/MemoizedHelpers/ClassMethods.html | 693 ++ .../3.1/rspec-core/RSpec/Core/Metadata.html | 309 + .../rspec-core/RSpec/Core/MetadataFilter.html | 120 + .../rspec-core/RSpec/Core/Notifications.html | 127 + .../DeprecationNotification.html | 498 ++ .../Notifications/ExampleNotification.html | 248 + .../Notifications/ExamplesNotification.html | 861 +++ .../FailedExampleNotification.html | 937 +++ .../Core/Notifications/GroupNotification.html | 245 + .../Notifications/MessageNotification.html | 233 + .../Core/Notifications/NullNotification.html | 133 + .../PendingExampleFixedNotification.html | 550 ++ .../Notifications/ProfileNotification.html | 410 ++ .../Core/Notifications/SeedNotification.html | 321 + .../Core/Notifications/StartNotification.html | 322 + .../Notifications/SummaryNotification.html | 586 ++ .../3.1/rspec-core/RSpec/Core/Pending.html | 469 ++ .../Core/Pending/SkipDeclaredInExample.html | 299 + .../3.1/rspec-core/RSpec/Core/RakeTask.html | 942 +++ .../3.1/rspec-core/RSpec/Core/Reporter.html | 468 ++ .../3.1/rspec-core/RSpec/Core/Runner.html | 929 +++ .../rspec-core/RSpec/Core/SharedContext.html | 136 + .../RSpec/Core/SharedExampleGroup.html | 457 ++ .../Core/SharedExampleGroup/TopLevelDSL.html | 295 + .../3.1/rspec-core/RSpec/Core/Version.html | 139 + .../3.1/rspec-core/RSpec/Core/World.html | 980 +++ .../documentation/3.1/rspec-core/_index.html | 557 ++ .../3.1/rspec-core/class_list.html | 58 + .../3.1/rspec-core/file.Changelog.html | 2566 +++++++ .../3.1/rspec-core/file.License.html | 73 + .../3.1/rspec-core/file.README.html | 315 + .../3.1/rspec-core/file_list.html | 66 + .../documentation/3.1/rspec-core/frames.html | 26 + .../documentation/3.1/rspec-core/index.html | 315 + .../3.1/rspec-core/method_list.html | 1683 +++++ .../3.1/rspec-core/top-level-namespace.html | 112 + .../3.1/rspec-expectations/BasicObject.html | 392 + .../3.1/rspec-expectations/RSpec.html | 128 + .../RSpec/Expectations.html | 407 ++ .../RSpec/Expectations/Configuration.html | 896 +++ .../RSpec/Expectations/ExpectationTarget.html | 515 ++ .../RSpec/Expectations/Syntax.html | 838 +++ .../rspec-expectations/RSpec/Matchers.html | 3910 ++++++++++ .../RSpec/Matchers/AliasedMatcher.html | 545 ++ .../RSpec/Matchers/BuiltIn.html | 133 + .../RSpec/Matchers/BuiltIn/All.html | 454 ++ .../RSpec/Matchers/BuiltIn/BaseMatcher.html | 799 ++ .../BaseMatcher/DefaultFailureMessages.html | 304 + .../RSpec/Matchers/BuiltIn/Be.html | 437 ++ .../RSpec/Matchers/BuiltIn/BeAKindOf.html | 196 + .../Matchers/BuiltIn/BeAnInstanceOf.html | 291 + .../RSpec/Matchers/BuiltIn/BeBetween.html | 684 ++ .../RSpec/Matchers/BuiltIn/BeComparedTo.html | 607 ++ .../RSpec/Matchers/BuiltIn/BeFalsey.html | 364 + .../RSpec/Matchers/BuiltIn/BeNil.html | 364 + .../RSpec/Matchers/BuiltIn/BePredicate.html | 683 ++ .../RSpec/Matchers/BuiltIn/BeTruthy.html | 364 + .../RSpec/Matchers/BuiltIn/BeWithin.html | 648 ++ .../RSpec/Matchers/BuiltIn/Change.html | 843 +++ .../Matchers/BuiltIn/ChangeFromValue.html | 357 + .../Matchers/BuiltIn/ChangeRelatively.html | 279 + .../RSpec/Matchers/BuiltIn/ChangeToValue.html | 357 + .../RSpec/Matchers/BuiltIn/Compound.html | 533 ++ .../RSpec/Matchers/BuiltIn/Compound/And.html | 311 + .../BuiltIn/Compound/NestedEvaluator.html | 333 + .../RSpec/Matchers/BuiltIn/Compound/Or.html | 299 + .../BuiltIn/Compound/SequentialEvaluator.html | 302 + .../Matchers/BuiltIn/ContainExactly.html | 460 ++ .../RSpec/Matchers/BuiltIn/Cover.html | 440 ++ .../RSpec/Matchers/BuiltIn/EndWith.html | 209 + .../RSpec/Matchers/BuiltIn/Eq.html | 520 ++ .../RSpec/Matchers/BuiltIn/Eql.html | 442 ++ .../RSpec/Matchers/BuiltIn/Equal.html | 464 ++ .../RSpec/Matchers/BuiltIn/Exist.html | 605 ++ .../Matchers/BuiltIn/Exist/ExistenceTest.html | 583 ++ .../RSpec/Matchers/BuiltIn/Has.html | 509 ++ .../Matchers/BuiltIn/HaveAttributes.html | 677 ++ .../RSpec/Matchers/BuiltIn/Include.html | 749 ++ .../RSpec/Matchers/BuiltIn/Match.html | 369 + .../Matchers/BuiltIn/OperatorMatcher.html | 304 + .../RSpec/Matchers/BuiltIn/Output.html | 973 +++ .../RSpec/Matchers/BuiltIn/RaiseError.html | 634 ++ .../RSpec/Matchers/BuiltIn/RespondTo.html | 661 ++ .../RSpec/Matchers/BuiltIn/Satisfy.html | 509 ++ .../BuiltIn/SpecificValuesChange.html | 281 + .../Matchers/BuiltIn/StartAndEndWith.html | 456 ++ .../RSpec/Matchers/BuiltIn/StartWith.html | 209 + .../RSpec/Matchers/BuiltIn/ThrowSymbol.html | 716 ++ .../RSpec/Matchers/BuiltIn/YieldControl.html | 886 +++ .../Matchers/BuiltIn/YieldSuccessiveArgs.html | 353 + .../RSpec/Matchers/BuiltIn/YieldWithArgs.html | 269 + .../Matchers/BuiltIn/YieldWithNoArgs.html | 191 + .../RSpec/Matchers/Composable.html | 779 ++ .../Matchers/Composable/DescribableItem.html | 137 + .../RSpec/Matchers/DSL.html | 224 + .../Matchers/DSL/DefaultImplementations.html | 450 ++ .../RSpec/Matchers/DSL/Macros.html | 982 +++ .../RSpec/Matchers/DSL/Macros/Deprecated.html | 402 + .../RSpec/Matchers/DSL/Matcher.html | 923 +++ .../RSpec/Matchers/MatcherProtocol.html | 1068 +++ .../RSpec/Matchers/Pretty.html | 446 ++ .../3.1/rspec-expectations/_index.html | 677 ++ .../3.1/rspec-expectations/class_list.html | 54 + .../rspec-expectations/file.Changelog.html | 1092 +++ .../3.1/rspec-expectations/file.License.html | 73 + .../3.1/rspec-expectations/file.README.html | 338 + .../3.1/rspec-expectations/file_list.html | 62 + .../3.1/rspec-expectations/frames.html | 26 + .../3.1/rspec-expectations/index.html | 338 + .../3.1/rspec-expectations/method_list.html | 1745 +++++ .../top-level-namespace.html | 129 + .../3.1/rspec-mocks/BasicObject.html | 720 ++ .../documentation/3.1/rspec-mocks/Class.html | 271 + .../documentation/3.1/rspec-mocks/RSpec.html | 129 + .../3.1/rspec-mocks/RSpec/Mocks.html | 860 +++ .../RSpec/Mocks/ArgumentListMatcher.html | 397 + .../RSpec/Mocks/ArgumentMatchers.html | 918 +++ .../RSpec/Mocks/Configuration.html | 1265 ++++ .../3.1/rspec-mocks/RSpec/Mocks/Constant.html | 952 +++ .../RSpec/Mocks/ConstantMutator.html | 537 ++ .../3.1/rspec-mocks/RSpec/Mocks/Double.html | 157 + .../RSpec/Mocks/ExampleMethods.html | 2711 +++++++ .../Mocks/ExampleMethods/ExpectHost.html | 117 + .../3.1/rspec-mocks/RSpec/Mocks/Matchers.html | 118 + .../3.1/rspec-mocks/RSpec/Mocks/Syntax.html | 929 +++ .../rspec-mocks/RSpec/Mocks/TestDouble.html | 613 ++ .../Mocks/VerifyingMessageExpectation.html | 324 + .../3.1/rspec-mocks/RSpec/Mocks/Version.html | 139 + .../documentation/3.1/rspec-mocks/_index.html | 299 + .../3.1/rspec-mocks/class_list.html | 58 + .../3.1/rspec-mocks/file.Changelog.html | 1292 ++++ .../3.1/rspec-mocks/file.License.html | 73 + .../3.1/rspec-mocks/file.README.html | 471 ++ .../3.1/rspec-mocks/file_list.html | 66 + .../documentation/3.1/rspec-mocks/frames.html | 26 + .../documentation/3.1/rspec-mocks/index.html | 471 ++ .../3.1/rspec-mocks/method_list.html | 615 ++ .../3.1/rspec-mocks/top-level-namespace.html | 140 + 158 files changed, 94089 insertions(+) create mode 100644 source/documentation/3.1/rspec-core/RSpec.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Configuration.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/ConfigurationOptions.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/DSL.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Example.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Example/ExecutionResult.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Example/Procsy.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/ExampleGroup.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseFormatter.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Helpers.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Loader.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Protocol.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Hooks.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Metadata.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/MetadataFilter.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExampleNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/GroupNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/MessageNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/NullNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ProfileNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SeedNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/StartNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SummaryNotification.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Pending.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/RakeTask.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Reporter.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Runner.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/SharedContext.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/Version.html create mode 100644 source/documentation/3.1/rspec-core/RSpec/Core/World.html create mode 100644 source/documentation/3.1/rspec-core/_index.html create mode 100644 source/documentation/3.1/rspec-core/class_list.html create mode 100644 source/documentation/3.1/rspec-core/file.Changelog.html create mode 100644 source/documentation/3.1/rspec-core/file.License.html create mode 100644 source/documentation/3.1/rspec-core/file.README.html create mode 100644 source/documentation/3.1/rspec-core/file_list.html create mode 100644 source/documentation/3.1/rspec-core/frames.html create mode 100644 source/documentation/3.1/rspec-core/index.html create mode 100644 source/documentation/3.1/rspec-core/method_list.html create mode 100644 source/documentation/3.1/rspec-core/top-level-namespace.html create mode 100644 source/documentation/3.1/rspec-expectations/BasicObject.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Expectations.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Expectations/Configuration.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Expectations/ExpectationTarget.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Expectations/Syntax.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/AliasedMatcher.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/All.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher/DefaultFailureMessages.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/NestedEvaluator.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/SequentialEvaluator.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/HaveAttributes.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Matcher.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/MatcherProtocol.html create mode 100644 source/documentation/3.1/rspec-expectations/RSpec/Matchers/Pretty.html create mode 100644 source/documentation/3.1/rspec-expectations/_index.html create mode 100644 source/documentation/3.1/rspec-expectations/class_list.html create mode 100644 source/documentation/3.1/rspec-expectations/file.Changelog.html create mode 100644 source/documentation/3.1/rspec-expectations/file.License.html create mode 100644 source/documentation/3.1/rspec-expectations/file.README.html create mode 100644 source/documentation/3.1/rspec-expectations/file_list.html create mode 100644 source/documentation/3.1/rspec-expectations/frames.html create mode 100644 source/documentation/3.1/rspec-expectations/index.html create mode 100644 source/documentation/3.1/rspec-expectations/method_list.html create mode 100644 source/documentation/3.1/rspec-expectations/top-level-namespace.html create mode 100644 source/documentation/3.1/rspec-mocks/BasicObject.html create mode 100644 source/documentation/3.1/rspec-mocks/Class.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/Configuration.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/Constant.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/ConstantMutator.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/Double.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/Matchers.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/Syntax.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/TestDouble.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html create mode 100644 source/documentation/3.1/rspec-mocks/RSpec/Mocks/Version.html create mode 100644 source/documentation/3.1/rspec-mocks/_index.html create mode 100644 source/documentation/3.1/rspec-mocks/class_list.html create mode 100644 source/documentation/3.1/rspec-mocks/file.Changelog.html create mode 100644 source/documentation/3.1/rspec-mocks/file.License.html create mode 100644 source/documentation/3.1/rspec-mocks/file.README.html create mode 100644 source/documentation/3.1/rspec-mocks/file_list.html create mode 100644 source/documentation/3.1/rspec-mocks/frames.html create mode 100644 source/documentation/3.1/rspec-mocks/index.html create mode 100644 source/documentation/3.1/rspec-mocks/method_list.html create mode 100644 source/documentation/3.1/rspec-mocks/top-level-namespace.html diff --git a/source/documentation/3.1/rspec-core/RSpec.html b/source/documentation/3.1/rspec-core/RSpec.html new file mode 100644 index 000000000..4d195626e --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec.html @@ -0,0 +1,578 @@ + + + + + + Module: RSpec + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core.rb,
+ lib/rspec/core/drb.rb,
lib/rspec/core/dsl.rb,
lib/rspec/core/world.rb,
lib/rspec/core/hooks.rb,
lib/rspec/core/runner.rb,
lib/rspec/core/example.rb,
lib/rspec/core/pending.rb,
lib/rspec/core/version.rb,
lib/rspec/core/warnings.rb,
lib/rspec/core/ordering.rb,
lib/rspec/core/flat_map.rb,
lib/rspec/core/metadata.rb,
lib/rspec/core/rake_task.rb,
lib/rspec/core/ruby_project.rb,
lib/rspec/core/example_group.rb,
lib/rspec/core/configuration.rb,
lib/rspec/core/shared_context.rb,
lib/rspec/core/filter_manager.rb,
lib/rspec/core/backport_random.rb,
lib/rspec/core/metadata_filter.rb,
lib/rspec/core/memoized_helpers.rb,
lib/rspec/core/formatters/helpers.rb,
lib/rspec/core/backtrace_formatter.rb,
lib/rspec/core/formatters/protocol.rb,
lib/rspec/core/project_initializer.rb,
lib/rspec/core/mocking_adapters/rr.rb,
lib/rspec/core/shared_example_group.rb,
lib/rspec/core/mocking_adapters/null.rb,
lib/rspec/core/configuration_options.rb,
lib/rspec/core/mocking_adapters/rspec.rb,
lib/rspec/core/mocking_adapters/mocha.rb,
lib/rspec/core/formatters/html_printer.rb,
lib/rspec/core/formatters/console_codes.rb,
lib/rspec/core/formatters/json_formatter.rb,
lib/rspec/core/mocking_adapters/flexmock.rb,
lib/rspec/core/formatters/html_formatter.rb,
lib/rspec/core/formatters/base_formatter.rb,
lib/rspec/core/minitest_assertions_adapter.rb,
lib/rspec/core/test_unit_assertions_adapter.rb,
lib/rspec/core/formatters/profile_formatter.rb,
lib/rspec/core/formatters/snippet_extractor.rb,
lib/rspec/core/formatters/progress_formatter.rb,
lib/rspec/core/formatters/base_text_formatter.rb,
lib/rspec/core/formatters/deprecation_formatter.rb,
lib/rspec/core/formatters/documentation_formatter.rb
+
+ +
+
+ +

Overview

+
+ +

Namespace for all core RSpec code.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Core + + + + +

+ +

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + + + + + + + +
+

Class Method Details

+ + +
+

+ + + (void) configuration + + + + + +

+
+ +

Returns the global Configuration +object. While you can use this method to access the configuration, +the more common convention is to use RSpec.configure.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configuration.drb_port = 1234
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+64
+65
+66
+67
+68
+69
+70
+
+
# File 'lib/rspec/core.rb', line 64
+
+def self.configuration
+  @configuration ||= begin
+                       config = RSpec::Core::Configuration.new
+                       config.expose_dsl_globally = true
+                       config
+                     end
+end
+
+
+ +
+

+ + + (void) configure {|Configuration| ... } + + + + + +

+
+ +

Yields the global configuration to a block.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.add_formatter 'documentation'
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Configuration) + + + + — +
    +

    global configuration

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+80
+81
+82
+
+
# File 'lib/rspec/core.rb', line 80
+
+def self.configure
+  yield configuration if block_given?
+end
+
+
+ +
+

+ + + (void) current_example + + + + + +

+
+ +

The example being executed.

+ +

The primary audience for this method is library authors who need access to +the example currently being executed and also want to support all versions +of RSpec 2 and 3.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |c|
+  # context.example is deprecated, but RSpec.current_example is not
+  # available until RSpec 3.0.
+  fetch_current_example = RSpec.respond_to?(:current_example) ?
+    proc { RSpec.current_example } : proc { |context| context.example }
+
+  c.before(:example) do
+    example = fetch_current_example.call(self)
+
+    # ...
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+105
+106
+107
+
+
# File 'lib/rspec/core.rb', line 105
+
+def self.current_example
+  [:current_example]
+end
+
+
+ +
+

+ + + (void) current_example=(example) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Set the current example being executed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+111
+112
+113
+
+
# File 'lib/rspec/core.rb', line 111
+
+def self.current_example=(example)
+  [:current_example] = example
+end
+
+
+ +
+

+ + + (void) reset + + + + + +

+
+ +

Used to ensure examples get reloaded between multiple runs in the same +process.

+ +

Users must invoke this if they want to have the configuration reset when +they use runner multiple times within the same process.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+51
+52
+53
+54
+
+
# File 'lib/rspec/core.rb', line 51
+
+def self.reset
+  @world = nil
+  @configuration = nil
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core.html b/source/documentation/3.1/rspec-core/RSpec/Core.html new file mode 100644 index 000000000..4e766bce9 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core.html @@ -0,0 +1,153 @@ + + + + + + Module: RSpec::Core + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core.rb,
+ lib/rspec/core/drb.rb,
lib/rspec/core/dsl.rb,
lib/rspec/core/world.rb,
lib/rspec/core/hooks.rb,
lib/rspec/core/runner.rb,
lib/rspec/core/example.rb,
lib/rspec/core/pending.rb,
lib/rspec/core/version.rb,
lib/rspec/core/reporter.rb,
lib/rspec/core/warnings.rb,
lib/rspec/core/ordering.rb,
lib/rspec/core/flat_map.rb,
lib/rspec/core/metadata.rb,
lib/rspec/core/rake_task.rb,
lib/rspec/core/ruby_project.rb,
lib/rspec/core/option_parser.rb,
lib/rspec/core/example_group.rb,
lib/rspec/core/configuration.rb,
lib/rspec/core/notifications.rb,
lib/rspec/core/shared_context.rb,
lib/rspec/core/filter_manager.rb,
lib/rspec/core/backport_random.rb,
lib/rspec/core/metadata_filter.rb,
lib/rspec/core/memoized_helpers.rb,
lib/rspec/core/formatters/helpers.rb,
lib/rspec/core/backtrace_formatter.rb,
lib/rspec/core/formatters/protocol.rb,
lib/rspec/core/project_initializer.rb,
lib/rspec/core/mocking_adapters/rr.rb,
lib/rspec/core/shared_example_group.rb,
lib/rspec/core/mocking_adapters/null.rb,
lib/rspec/core/configuration_options.rb,
lib/rspec/core/mocking_adapters/rspec.rb,
lib/rspec/core/mocking_adapters/mocha.rb,
lib/rspec/core/formatters/html_printer.rb,
lib/rspec/core/formatters/console_codes.rb,
lib/rspec/core/formatters/json_formatter.rb,
lib/rspec/core/mocking_adapters/flexmock.rb,
lib/rspec/core/formatters/html_formatter.rb,
lib/rspec/core/formatters/base_formatter.rb,
lib/rspec/core/minitest_assertions_adapter.rb,
lib/rspec/core/test_unit_assertions_adapter.rb,
lib/rspec/core/formatters/profile_formatter.rb,
lib/rspec/core/formatters/snippet_extractor.rb,
lib/rspec/core/formatters/progress_formatter.rb,
lib/rspec/core/formatters/base_text_formatter.rb,
lib/rspec/core/formatters/deprecation_formatter.rb,
lib/rspec/core/formatters/documentation_formatter.rb
+
+ +
+
+ +

Overview

+
+ +

Namespace for the rspec-core code.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: DSL, Formatters, Hooks, MemoizedHelpers, Metadata, MetadataFilter, Notifications, Pending, SharedContext, SharedExampleGroup, Version + + + + Classes: Configuration, ConfigurationOptions, Example, ExampleGroup, RakeTask, Reporter, Runner, World + + +

+ +

Constant Summary

+ +
+ +
DeprecationError = +
+
+ +

Deprecation Error

+ + +
+
+
+ + +
+
+
Class.new(StandardError)
+ +
+ + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Configuration.html b/source/documentation/3.1/rspec-core/RSpec/Core/Configuration.html new file mode 100644 index 000000000..a9f5ac33c --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Configuration.html @@ -0,0 +1,6496 @@ + + + + + + Class: RSpec::Core::Configuration + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Configuration + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Hooks
+ + + + + +
Defined in:
+
lib/rspec/core/configuration.rb
+ +
+
+ +

Overview

+
+ +

Stores runtime configuration information.

+ +

Configuration options are loaded from ~/.rspec, +.rspec, .rspec-local, command line switches, and +the SPEC_OPTS environment variable (listed in lowest to +highest precedence; for example, an option in ~/.rspec can be +overridden by an option in .rspec-local).

+ + +
+
+
+ +
+

Examples:

+ + +

+

Standard settings

+

+ +
RSpec.configure do |c|
+  c.drb          = true
+  c.drb_port     = 1234
+  c.default_path = 'behavior'
+end
+ + +

+

Hooks

+

+ +
RSpec.configure do |c|
+  c.before(:suite)   { establish_connection }
+  c.before(:example) {  :authorized }
+  c.around(:example) { |ex| Database.transaction(&ex) }
+end
+ +
+ + +

See Also:

+ + +
+

Constant Summary

+ + + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Hooks

+

#after, #append_after, #around, #before, #prepend_before

+
+

Constructor Details

+ +
+

+ + - (Configuration) initialize + + + + + +

+
+ +

Returns a new instance of Configuration

+ + +
+
+
+ + +
+ + + + +
+
+
+
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+
+
# File 'lib/rspec/core/configuration.rb', line 284
+
+def initialize
+  # rubocop:disable Style/GlobalVars
+  @start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
+  # rubocop:enable Style/GlobalVars
+  @expectation_frameworks = []
+  @include_or_extend_modules = []
+  @mock_framework = nil
+  @files_or_directories_to_run = []
+  @color = false
+  @pattern = '**{,/*/**}/*_spec.rb'
+  @exclude_pattern = ''
+  @failure_exit_code = 1
+  @spec_files_loaded = false
+
+  @backtrace_formatter = BacktraceFormatter.new
+
+  @default_path = 'spec'
+  @deprecation_stream = $stderr
+  @output_stream = $stdout
+  @reporter = nil
+  @reporter_buffer = nil
+  @filter_manager = FilterManager.new
+  @ordering_manager = Ordering::ConfigurationManager.new
+  @preferred_options = {}
+  @failure_color = :red
+  @success_color = :green
+  @pending_color = :yellow
+  @default_color = :white
+  @fixed_color = :blue
+  @detail_color = :cyan
+  @profile_examples = false
+  @requires = []
+  @libs = []
+  @derived_metadata_blocks = []
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) default_color + + + + + +

+
+ +

The default output color.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :white but can be set to one of the +following:[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+243
+
+
# File 'lib/rspec/core/configuration.rb', line 243
+
+add_setting :default_color
+
+
+ + + +
+

+ + - (void) default_path + + + + + +

+
+ +

Path to use if no path is provided to the rspec command +(default: "spec"). Allows you to just type +rspec instead of rspec spec to run all the +examples in the spec directory.

+ +

Note: Other scripts invoking rspec indirectly will ignore this +setting.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+95
+
+
# File 'lib/rspec/core/configuration.rb', line 95
+
+add_setting :default_path
+
+
+ + + +
+

+ + - (void) detail_color + + + + + +

+
+ +

Color used to print details.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :cyan but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+257
+
+
# File 'lib/rspec/core/configuration.rb', line 257
+
+add_setting :detail_color
+
+
+ + + +
+

+ + - (void) drb + + + + + +

+
+ +

Run examples over DRb (default: false). RSpec doesn't +supply the DRb server, but you can use tools like spork.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+100
+
+
# File 'lib/rspec/core/configuration.rb', line 100
+
+add_setting :drb
+
+
+ + + +
+

+ + - (void) drb_port + + + + + +

+
+ +

The drb_port (default: nil).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+104
+
+
# File 'lib/rspec/core/configuration.rb', line 104
+
+add_setting :drb_port
+
+
+ + + +
+

+ + - (void) dry_run + + + + + +

+
+ +

Prints the formatter output of your suite without running any examples or +hooks.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+156
+
+
# File 'lib/rspec/core/configuration.rb', line 156
+
+add_setting :dry_run
+
+
+ + + +
+

+ + - (void) error_stream + + + + + +

+
+ +

Default: $stderr.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+108
+
+
# File 'lib/rspec/core/configuration.rb', line 108
+
+add_setting :error_stream
+
+
+ + + +
+

+ + - (void) exclude_pattern + + + + + +

+
+ +

Exclude files matching this pattern

+ + +
+
+
+ + +
+ + + + +
+
+
+
+200
+
+
# File 'lib/rspec/core/configuration.rb', line 200
+
+define_reader :exclude_pattern
+
+
+ + + +
+

+ + - (void) fail_fast + + + + + +

+
+ +

Clean up and exit after the first failure (default: false).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+151
+
+
# File 'lib/rspec/core/configuration.rb', line 151
+
+add_setting :fail_fast
+
+
+ + + +
+

+ + - (void) failure_color + + + + + +

+
+ +

Color to use to indicate failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :red but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+236
+
+
# File 'lib/rspec/core/configuration.rb', line 236
+
+add_setting :failure_color
+
+
+ + + +
+

+ + - (void) failure_exit_code + + + + + +

+
+ +

The exit code to return if there are any failures (default: 1).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+160
+
+
# File 'lib/rspec/core/configuration.rb', line 160
+
+add_setting :failure_exit_code
+
+
+ + + +
+

+ + - (Array) files_to_run + + + + + +

+
+ +

The spec files RSpec will run

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    specified files about to run

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+767
+768
+769
+
+
# File 'lib/rspec/core/configuration.rb', line 767
+
+def files_to_run
+  @files_to_run ||= get_files_to_run(@files_or_directories_to_run)
+end
+
+
+ + + +
+

+ + - (void) fixed_color + + + + + +

+
+ +

Color used when a pending example is fixed.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :blue but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+250
+
+
# File 'lib/rspec/core/configuration.rb', line 250
+
+add_setting :fixed_color
+
+
+ + + +
+

+ + - (void) libs + + + + + +

+
+ +

Returns dirs that have been prepended to the load path by the +-I command line option

+ + +
+
+
+ + +
+ + + + +
+
+
+
+168
+
+
# File 'lib/rspec/core/configuration.rb', line 168
+
+define_reader :libs
+
+
+ + + +
+

+ + - (void) output_stream + + + + + +

+
+ +

Determines where RSpec will send its output. Default: $stdout.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+173
+
+
# File 'lib/rspec/core/configuration.rb', line 173
+
+define_reader :output_stream
+
+
+ + + +
+

+ + - (void) pattern + + + + + +

+
+ +

Load files matching this pattern (default: +'**{,//*}/*_spec.rb')

+ + +
+
+
+ + +
+ + + + +
+
+
+
+190
+
+
# File 'lib/rspec/core/configuration.rb', line 190
+
+define_reader :pattern
+
+
+ + + +
+

+ + - (void) pending_color + + + + + +

+
+ +

Color to use to print pending examples.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :yellow but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+229
+
+
# File 'lib/rspec/core/configuration.rb', line 229
+
+add_setting :pending_color
+
+
+ + + +
+

+ + - (void) profile_examples + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Defaults profile_examples to 10 examples when +@profile_examples is true.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+211
+
+
# File 'lib/rspec/core/configuration.rb', line 211
+
+add_setting :profile_examples
+
+
+ + + +
+

+ + - (void) requires + + + + + +

+
+ +

Indicates files configured to be required

+ + +
+
+
+ + +
+ + + + +
+
+
+
+164
+
+
# File 'lib/rspec/core/configuration.rb', line 164
+
+define_reader :requires
+
+
+ + + +
+

+ + - (void) run_all_when_everything_filtered + + + + + +

+
+ +

Run all examples if none match the configured filters (default: +false).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+215
+
+
# File 'lib/rspec/core/configuration.rb', line 215
+
+add_setting :run_all_when_everything_filtered
+
+
+ + + +
+

+ + - (void) success_color + + + + + +

+
+ +

Color to use to indicate success.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :green but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+222
+
+
# File 'lib/rspec/core/configuration.rb', line 222
+
+add_setting :success_color
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) add_formatter(formatter) + + + + Also known as: + formatter= + + + + +

+
+ +

Adds a formatter to the formatters collection. formatter can +be a string representing any of the built-in formatters (see +built_in_formatter), or a custom formatter class.

+ +

Note

+ +

For internal purposes, add_formatter also accepts the name of +a class and paths to use for output streams, but you should consider that a +private api that may change at any time without notice.

+ + +
+
+
+ + + + +
+ + + + +
+
+
+
+670
+671
+672
+673
+
+
# File 'lib/rspec/core/configuration.rb', line 670
+
+def add_formatter(formatter_to_use, *paths)
+  paths << output_stream if paths.empty?
+  formatter_loader.add formatter_to_use, *paths
+end
+
+
+ +
+

+ + + - (void) add_setting(name) + + - (void) add_setting(name, opts) + + + + + + +

+
+ +

Adds a custom setting to the RSpec.configuration object.

+ +
RSpec.configuration.add_setting :foo
+ +

Used internally and by extension frameworks like rspec-rails, so they can +add config settings that are domain specific. For example:

+ +
RSpec.configure do |c|
+  c.add_setting :use_transactional_fixtures,
+    :default => true,
+    :alias_with => :use_transactional_examples
+end
+
+ +

add_setting creates three methods on the configuration object, +a setter, a getter, and a predicate:

+ +
RSpec.configuration.foo=(value)
+RSpec.configuration.foo
+RSpec.configuration.foo? # returns true if foo returns anything but nil or false
+ + +
+
+
+

Parameters:

+
    + +
  • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
    +

    a customizable set of options

    +
    + +
  • + +
+ + + + + + +

Options Hash (opts):

+
    + +
  • + :default + (Symbol) + + + + + —
    +

    set a default value for the generated getter and predicate methods:

    + +
    add_setting(:foo, :default => "default value")
    +
    +
    + +
  • + +
  • + :alias_with + (Symbol) + + + + + —
    +

    Use :alias_with to alias the setter, getter, and predicate to +another name, or names:

    + +
    add_setting(:foo, :alias_with => :bar)
    +add_setting(:foo, :alias_with => [:bar, :baz])
    +
    +
    + +
  • + +
+ + + +
+ + + + +
+
+
+
+370
+371
+372
+373
+374
+375
+376
+
+
# File 'lib/rspec/core/configuration.rb', line 370
+
+def add_setting(name, opts={})
+  default = opts.delete(:default)
+  (class << self; self; end).class_exec do
+    add_setting(name, opts)
+  end
+  __send__("#{name}=", default) if default
+end
+
+
+ +
+

+ + - (void) alias_example_group_to(new_name, *args) + + + + + +

+
+ +
+ Note: +
+

The defined aliased will also be added to the top level (e.g. +main and from within modules) if +expose_dsl_globally is set to true.

+
+
+ + +

Creates a method that defines an example group with the provided metadata. +Can be used to define example group/metadata shortcuts.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.alias_example_group_to :describe_model, :type => :model
+end
+
+shared_context_for "model tests", :type => :model do
+  # define common model test helper methods, `let` declarations, etc
+end
+
+# This lets you do this:
+
+RSpec.describe_model User do
+end
+
+# ... which is the equivalent of
+
+RSpec.describe User, :type => :model do
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+835
+836
+837
+838
+
+
# File 'lib/rspec/core/configuration.rb', line 835
+
+def alias_example_group_to(new_name, *args)
+  extra_options = Metadata.build_hash_from(args)
+  RSpec::Core::ExampleGroup.define_example_group_method(new_name, extra_options)
+end
+
+
+ +
+

+ + - (void) alias_example_to(name, *args) + + + + + +

+
+ +
+ Note: +
+

The specific example alias below (pending) is already defined +for you.

+
+
+ +
+ Note: +
+

Use with caution. This extends the language used in your specs, but does +not add any additional documentation. We use this in rspec to define +methods like focus and xit, but we also add docs +for those methods.

+
+
+ + +

Creates a method that delegates to example including the +submitted args. Used internally to add variants of +example like pending:

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.alias_example_to :pending, :pending => true
+end
+
+# This lets you do this:
+
+describe Thing do
+  pending "does something" do
+    thing = Thing.new
+  end
+end
+
+# ... which is the equivalent of
+
+describe Thing do
+  it "does something", :pending => true do
+    thing = Thing.new
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    example name alias

    +
    + +
  • + +
  • + + args + + + (Array<Symbol>, Hash) + + + + — +
    +

    metadata for the generated example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+803
+804
+805
+806
+
+
# File 'lib/rspec/core/configuration.rb', line 803
+
+def alias_example_to(name, *args)
+  extra_options = Metadata.build_hash_from(args)
+  RSpec::Core::ExampleGroup.define_example_method(name, extra_options)
+end
+
+
+ +
+

+ + - (void) alias_it_behaves_like_to(new_name, report_label = '') + + + + Also known as: + alias_it_should_behave_like_to + + + + +

+
+ +
+ Note: +
+

Use with caution. This extends the language used in your specs, but does +not add any additional documentation. We use this in rspec to define +it_should_behave_like (for backward compatibility), but we +also add docs for that method.

+
+
+ + +

Define an alias for it_should_behave_like that allows different language +(like “it_has_behavior” or “it_behaves_like”) to be employed when including +shared examples.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.alias_it_behaves_like_to(:it_has_behavior, 'has behavior:')
+end
+
+# allows the user to include a shared example group like:
+
+describe Entity do
+  it_has_behavior 'sortability' do
+    let(:sortable) { Entity.new }
+  end
+end
+
+# which is reported in the output as:
+# Entity
+#   has behavior: sortability
+#     ...sortability examples here
+ +
+ + +
+ + + + +
+
+
+
+866
+867
+868
+
+
# File 'lib/rspec/core/configuration.rb', line 866
+
+def alias_it_behaves_like_to(new_name, report_label='')
+  RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label)
+end
+
+
+ +
+

+ + - (void) backtrace_exclusion_patterns + + + + + +

+
+ +

Regexps used to exclude lines from backtraces.

+ +

Excludes lines from ruby (and jruby) source, installed gems, anything in +any “bin” directory, and any of the rspec libs (outside gem installs) by +default.

+ +

You can modify the list via the getter, or replace it with the setter.

+ +

To override this behaviour and display a full backtrace, use +--backtraceon the command line, in a .rspec file, +or in the rspec_options attribute of RSpec's rake task.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+406
+407
+408
+
+
# File 'lib/rspec/core/configuration.rb', line 406
+
+def backtrace_exclusion_patterns
+  @backtrace_formatter.exclusion_patterns
+end
+
+
+ +
+

+ + - (void) backtrace_exclusion_patterns=(patterns) + + + + + +

+
+ +

Set regular expressions used to exclude lines in backtrace

+ + +
+
+
+

Parameters:

+
    + +
  • + + patterns + + + (Regexp) + + + + — +
    +

    set the backtrace exlusion pattern

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+412
+413
+414
+
+
# File 'lib/rspec/core/configuration.rb', line 412
+
+def backtrace_exclusion_patterns=(patterns)
+  @backtrace_formatter.exclusion_patterns = patterns
+end
+
+
+ +
+

+ + - (void) backtrace_inclusion_patterns + + + + + +

+
+ +

Regexps used to include lines in backtraces.

+ +

Defaults to [Regexp.new Dir.getwd].

+ +

Lines that match an exclusion and an inclusion pattern will be +included.

+ +

You can modify the list via the getter, or replace it with the setter.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+424
+425
+426
+
+
# File 'lib/rspec/core/configuration.rb', line 424
+
+def backtrace_inclusion_patterns
+  @backtrace_formatter.inclusion_patterns
+end
+
+
+ +
+

+ + - (void) backtrace_inclusion_patterns=(patterns) + + + + + +

+
+ +

Set regular expressions used to include lines in backtrace

+ + +
+
+
+ + +
+ + + + +
+
+
+
+430
+431
+432
+
+
# File 'lib/rspec/core/configuration.rb', line 430
+
+def backtrace_inclusion_patterns=(patterns)
+  @backtrace_formatter.inclusion_patterns = patterns
+end
+
+
+ +
+

+ + - (Boolean) color + + + + + +

+
+ +

Returns the configuration option for color, but should not be used to check +if color is supported.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +

See Also:

+
    + +
  • color_enabled?
  • + +
+ +
+ + + + +
+
+
+
+615
+616
+617
+
+
# File 'lib/rspec/core/configuration.rb', line 615
+
+def color
+  value_for(:color, @color)
+end
+
+
+ +
+

+ + - (void) color=(true_or_false) + + + + + +

+
+ +

Toggle output color

+ + +
+
+
+ + +
+ + + + +
+
+
+
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+
+
# File 'lib/rspec/core/configuration.rb', line 629
+
+def color=(true_or_false)
+  return unless true_or_false
+
+  if RSpec.world.windows_os? && !ENV['ANSICON']
+    RSpec.warning "You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows"
+    @color = false
+  else
+    @color = true
+  end
+end
+
+
+ +
+

+ + - (Boolean) color_enabled?(output = output_stream) + + + + + +

+
+ +

Check if color is enabled for a particular output

+ + +
+
+
+

Parameters:

+
    + +
  • + + output + + + (IO) + + + (defaults to: output_stream) + + + — +
    +

    an output stream to use, defaults to the current output_stream

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+623
+624
+625
+
+
# File 'lib/rspec/core/configuration.rb', line 623
+
+def color_enabled?(output=output_stream)
+  output_to_tty?(output) && color
+end
+
+
+ +
+

+ + - (void) default_formatter + + + + + +

+
+ +

The formatter that will be used if no formatter has been set. Defaults to +'progress'.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+678
+679
+680
+
+
# File 'lib/rspec/core/configuration.rb', line 678
+
+def default_formatter
+  formatter_loader.default_formatter
+end
+
+
+ +
+

+ + - (void) default_formatter=(value) + + + + + +

+
+ +

Sets a fallback formatter to use if none other has been set.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.default_formatter = 'doc'
+end
+ +
+ + +
+ + + + +
+
+
+
+689
+690
+691
+
+
# File 'lib/rspec/core/configuration.rb', line 689
+
+def default_formatter=(value)
+  formatter_loader.default_formatter = value
+end
+
+
+ +
+

+ + - (void) define_derived_metadata(*filters) {|metadata| ... } + + + + + +

+
+ +

Defines a callback that can assign derived metadata values.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  # Tag all groups and examples in the spec/unit directory with :type => :unit
+  config.(:file_path => %r{/spec/unit/}) do ||
+    [:type] = :unit
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + filters + + + (Array<Symbol>, Hash) + + + + — +
    +

    metadata filters that determine which example or group metadata hashes the +callback will be triggered for. If none are given, the callback will be run +against the metadata hashes of all groups and examples.

    +
    + +
  • + +
+ +

Yield Parameters:

+
    + +
  • + + metadata + + + (Hash) + + + + — +
    +

    original metadata hash from an example or group. Mutate this in your block +as needed.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+1311
+1312
+1313
+1314
+
+
# File 'lib/rspec/core/configuration.rb', line 1311
+
+def (*filters, &block)
+  meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
+  @derived_metadata_blocks << [meta, block]
+end
+
+
+ +
+

+ + - (IO, String) deprecation_stream + + + + + +

+
+ +

Determines where deprecation warnings are printed. Defaults to +$stderr.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (IO, String) + + + + — +
    +

    IO to write to or filename to write to

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+133
+
+
# File 'lib/rspec/core/configuration.rb', line 133
+
+define_reader :deprecation_stream
+
+
+ +
+

+ + - (void) deprecation_stream=(value) + + + + + +

+
+ +

Determines where deprecation warnings are printed.

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + (IO, String) + + + + — +
    +

    IO to write to or filename to write to

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+
+
# File 'lib/rspec/core/configuration.rb', line 137
+
+def deprecation_stream=(value)
+  if @reporter && !value.equal?(@deprecation_stream)
+    warn "RSpec's reporter has already been initialized with " \
+      "#{deprecation_stream.inspect} as the deprecation stream, so your change to "\
+      "`deprecation_stream` will be ignored. You should configure it earlier for " \
+      "it to take effect, or use the `--deprecation-out` CLI option. " \
+      "(Called from #{CallerFilter.first_non_rspec_line})"
+  else
+    @deprecation_stream = value
+  end
+end
+
+
+ +
+

+ + - (void) disable_monkey_patching! + + + + + +

+
+ +
+ Note: +
+

It configures rspec-mocks and rspec-expectations only if the user is using +those (either explicitly or implicitly by not setting +mock_with or expect_with to anything else).

+
+
+ +
+ Note: +
+

If the user uses this options with mock_with :mocha (or +similiar) they will still have monkey patching active in their test +environment from mocha.

+
+
+ + +

Enables zero monkey patching mode for RSpec. It removes monkey patching of +the top-level DSL methods (describe, +shared_examples_for, etc) onto main and +Module, instead requiring you to prefix these methods with +RSpec.. It enables expect-only syntax for rspec-mocks and +rspec-expectations. It simply disables monkey patching on whatever pieces +of rspec the user is using.

+ + +
+
+
+ +
+

Examples:

+ + +

+# It disables all monkey patching
+RSpec.configure do |config|
+  config.disable_monkey_patching!
+end
+
+# Is an equivalent to
+RSpec.configure do |config|
+  config.expose_dsl_globally = false
+
+  config.mock_with :rspec do |mocks|
+    mocks.syntax = :expect
+    mocks.patch_marshal_to_support_partial_doubles = false
+  end
+
+  config.mock_with :rspec do |expectations|
+    expectations.syntax = :expect
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+1286
+1287
+1288
+1289
+1290
+1291
+
+
# File 'lib/rspec/core/configuration.rb', line 1286
+
+def disable_monkey_patching!
+  self.expose_dsl_globally = false
+  self.disable_monkey_patching = true
+  conditionally_disable_mocks_monkey_patching
+  conditionally_disable_expectations_monkey_patching
+end
+
+
+ +
+

+ + - (void) exclusion_filter + + + + + +

+
+ +

Returns the exclusion_filter. If none has been set, returns an +empty hash.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+977
+978
+979
+
+
# File 'lib/rspec/core/configuration.rb', line 977
+
+def exclusion_filter
+  filter_manager.exclusions
+end
+
+
+ +
+

+ + - (void) exclusion_filter=(filter) + + + + + +

+
+ +

Clears and reassigns the exclusion_filter. Set to +nil if you don't want any exclusion filter at all.

+ +

Warning

+ +

This overrides any exclusion filters/tags set on the command line or in +configuration files.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+970
+971
+972
+973
+
+
# File 'lib/rspec/core/configuration.rb', line 970
+
+def exclusion_filter=(filter)
+  meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
+  filter_manager.exclude_only meta
+end
+
+
+ +
+

+ + - (void) expect_with(*frameworks) + + + + + +

+
+ +

Sets the expectation framework module(s) to be included in each example +group.

+ +

frameworks can be :rspec, +:test_unit, :minitest, a custom module, or any +combination thereof:

+ +
config.expect_with :rspec
+config.expect_with :test_unit
+config.expect_with :minitest
+config.expect_with :rspec, :minitest
+config.expect_with OtherExpectationFramework
+ +

RSpec will translate :rspec, :minitest, and +:test_unit into the appropriate modules.

+ +

Configuration

+ +

If the module responds to configuration, +expect_with will yield the configuration object +if given a block:

+ +
config.expect_with OtherExpectationFramework do |custom_config|
+  custom_config.custom_setting = true
+end
+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+
+
# File 'lib/rspec/core/configuration.rb', line 565
+
+def expect_with(*frameworks)
+  modules = frameworks.map do |framework|
+    case framework
+    when Module
+      framework
+    when :rspec
+      require 'rspec/expectations'
+      self.expecting_with_rspec = true
+      ::RSpec::Matchers
+    when :test_unit
+      require 'rspec/core/test_unit_assertions_adapter'
+      ::RSpec::Core::TestUnitAssertionsAdapter
+    when :minitest
+      require 'rspec/core/minitest_assertions_adapter'
+      ::RSpec::Core::MinitestAssertionsAdapter
+    else
+      raise ArgumentError, "#{framework.inspect} is not supported"
+    end
+  end
+
+  if (modules - @expectation_frameworks).any?
+    assert_no_example_groups_defined(:expect_with)
+  end
+
+  if block_given?
+    raise "expect_with only accepts a block with a single argument. Call expect_with #{modules.length} times, once with each argument, instead." if modules.length > 1
+    raise "#{modules.first} must respond to `configuration` so that expect_with can yield it." unless modules.first.respond_to?(:configuration)
+    yield modules.first.configuration
+  end
+
+  @expectation_frameworks.push(*modules)
+end
+
+
+ +
+

+ + - (void) expectation_framework=(framework) + + + + + +

+
+ +

Delegates to expect_with(framework)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+538
+539
+540
+
+
# File 'lib/rspec/core/configuration.rb', line 538
+
+def expectation_framework=(framework)
+  expect_with(framework)
+end
+
+
+ +
+

+ + - (void) expectation_frameworks + + + + + +

+
+ +

Returns the configured expectation framework adapter module(s)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+
+
# File 'lib/rspec/core/configuration.rb', line 526
+
+def expectation_frameworks
+  if @expectation_frameworks.empty?
+    begin
+      expect_with :rspec
+    rescue LoadError
+      expect_with Module.new
+    end
+  end
+  @expectation_frameworks
+end
+
+
+ +
+

+ + - (void) expose_current_running_example_as(method_name) + + + + + +

+
+ +

Exposes the current running example via the named helper method. RSpec 2.x +exposed this via example, but in RSpec 3.0, the example is +instead exposed via an arg yielded to it, before, +let, etc. However, some extension gems (such as Capybara) +depend on the RSpec 2.x's example method, so this config +option can be used to maintain compatibility.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.expose_current_running_example_as :example
+end
+
+describe MyClass do
+  before do
+    # `example` can be used here because of the above config.
+    do_something if example.[:type] == "foo"
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + method_name + + + (Symbol) + + + + — +
    +

    the name of the helper method

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+
+
# File 'lib/rspec/core/configuration.rb', line 1224
+
+def expose_current_running_example_as(method_name)
+  ExposeCurrentExample.module_exec do
+    extend RSpec::SharedContext
+    let(method_name) { |ex| ex }
+  end
+
+  include ExposeCurrentExample
+end
+
+
+ +
+

+ + - (void) expose_dsl_globally=(value) + + + + + +

+
+ +

Use this to expose the core RSpec DSL via Module and the +main object. It will be set automatically but you can override +it to remove the DSL. Default: true

+ + +
+
+
+ + +
+ + + + +
+
+
+
+120
+121
+122
+123
+124
+125
+126
+127
+128
+
+
# File 'lib/rspec/core/configuration.rb', line 120
+
+def expose_dsl_globally=(value)
+  if value
+    Core::DSL.expose_globally!
+    Core::SharedExampleGroup::TopLevelDSL.expose_globally!
+  else
+    Core::DSL.remove_globally!
+    Core::SharedExampleGroup::TopLevelDSL.remove_globally!
+  end
+end
+
+
+ +
+

+ + - (Boolean) expose_dsl_globally? + + + + + +

+
+ +

Indicates if the DSL has been exposed off of modules and main. +Default: true

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+112
+113
+114
+
+
# File 'lib/rspec/core/configuration.rb', line 112
+
+def expose_dsl_globally?
+  Core::DSL.exposed_globally?
+end
+
+
+ +
+

+ + - (void) extend(mod, *filters) + + + + + +

+
+ +

Tells RSpec to extend example groups with mod. Methods defined +in mod are exposed to example groups (not examples). Use +filters to constrain the groups to extend.

+ +

Similar to include, but behavior is added to example groups, +which are classes, rather than the examples, which are instances of those +classes.

+ + +
+
+
+ +
+

Examples:

+ + +

+module UiHelpers
+  def run_in_browser
+    # ...
+  end
+end
+
+RSpec.configure do |config|
+  config.extend(UiHelpers, :type => :request)
+end
+
+describe "edit profile", :type => :request do
+  run_in_browser
+
+  it "does stuff in the client" do
+    # ...
+  end
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+1047
+1048
+1049
+1050
+
+
# File 'lib/rspec/core/configuration.rb', line 1047
+
+def extend(mod, *filters)
+  meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
+  include_or_extend_modules << [:extend, mod, meta]
+end
+
+
+ +
+

+ + - (void) filter_gems_from_backtrace(*gem_names) + + + + + +

+
+ +
+ Note: +
+

The patterns this adds will match the named gems in their common locations +(e.g. system gems, vendored with bundler, installed as a :git dependency +with bundler, etc) but is not guaranteed to work for all possible gem +locations. For example, if you have the gem source in a directory with a +completely unrelated name, and use bundler's :path option, this will +not filter it.

+
+
+ + +

Adds #backtrace_exclusion_patterns that will filter lines from the named +gems from backtraces.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.filter_gems_from_backtrace "rack", "rake"
+end
+ +
+

Parameters:

+
    + +
  • + + gem_names + + + (Array<String>) + + + + — +
    +

    Names of the gems to filter

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+450
+451
+452
+453
+454
+
+
# File 'lib/rspec/core/configuration.rb', line 450
+
+def filter_gems_from_backtrace(*gem_names)
+  gem_names.each do |name|
+    @backtrace_formatter.filter_gem(name)
+  end
+end
+
+
+ +
+

+ + - (void) filter_run_excluding(*args) + + + + + +

+
+ +

Adds key/value pairs to the exclusion_filter. If +args includes any symbols that are not part of the hash, each +symbol is treated as a key in the hash with the value true.

+ +

Note

+ +

Filters set using this method can be overridden from the command line or +config files (e.g. .rspec).

+ + +
+
+
+ +
+

Examples:

+ + +
# given this declaration
+describe "something", :foo => 'bar' do
+  # ...
+end
+
+# any of the following will exclude that group
+config.filter_run_excluding :foo => 'bar'
+config.filter_run_excluding :foo => /^ba/
+config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
+config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+# given a proc with an arity of 1, the lambda is passed the value related to the key, e.g.
+config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
+
+# given a proc with an arity of 2, the lambda is passed the value related to the key,
+# and the metadata itself e.g.
+config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+filter_run_excluding :foo # same as filter_run_excluding :foo => true
+ +
+ + +
+ + + + +
+
+
+
+958
+959
+960
+961
+
+
# File 'lib/rspec/core/configuration.rb', line 958
+
+def filter_run_excluding(*args)
+  meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
+  filter_manager.exclude_with_low_priority meta
+end
+
+
+ +
+

+ + - (void) filter_run_including(*args) + + + + Also known as: + filter_run + + + + +

+
+ +

Adds key/value pairs to the inclusion_filter. If +args includes any symbols that are not part of the hash, each +symbol is treated as a key in the hash with the value true.

+ +

Note

+ +

Filters set using this method can be overridden from the command line or +config files (e.g. .rspec).

+ + +
+
+
+ +
+

Examples:

+ + +
# given this declaration
+describe "something", :foo => 'bar' do
+  # ...
+end
+
+# any of the following will include that group
+config.filter_run_including :foo => 'bar'
+config.filter_run_including :foo => /^ba/
+config.filter_run_including :foo => lambda {|v| v == 'bar'}
+config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+# given a proc with an arity of 1, the lambda is passed the value related to the key, e.g.
+config.filter_run_including :foo => lambda {|v| v == 'bar'}
+
+# given a proc with an arity of 2, the lambda is passed the value related to the key,
+# and the metadata itself e.g.
+config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+filter_run_including :foo # same as filter_run_including :foo => true
+ +
+ + +
+ + + + +
+
+
+
+900
+901
+902
+903
+
+
# File 'lib/rspec/core/configuration.rb', line 900
+
+def filter_run_including(*args)
+  meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
+  filter_manager.include_with_low_priority meta
+end
+
+
+ +
+

+ + - (void) format_docstrings(&block) + + + + + +

+
+ +

Formats the docstring output using the block provided.

+ + +
+
+
+ +
+

Examples:

+ + +
# This will strip the descriptions of both examples and example groups.
+RSpec.configure do |config|
+  config.format_docstrings { |s| s.strip }
+end
+ +
+ + +
+ + + + +
+
+
+
+1119
+1120
+1121
+
+
# File 'lib/rspec/core/configuration.rb', line 1119
+
+def format_docstrings(&block)
+  @format_docstrings_block = block_given? ? block : DEFAULT_FORMATTER
+end
+
+
+ +
+

+ + - (Array) formatters + + + + + +

+
+ +

Returns a duplicate of the formatters currently loaded in the +FormatterLoader for introspection.

+ +

Note as this is a duplicate, any mutations will be disregarded.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    the formatters currently loaded

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+699
+700
+701
+
+
# File 'lib/rspec/core/configuration.rb', line 699
+
+def formatters
+  formatter_loader.formatters.dup
+end
+
+
+ +
+

+ + - (void) full_backtrace=(true_or_false) + + + + + +

+
+ +

Toggle full backtrace

+ + +
+
+
+ + +
+ + + + +
+
+
+
+606
+607
+608
+
+
# File 'lib/rspec/core/configuration.rb', line 606
+
+def full_backtrace=(true_or_false)
+  @backtrace_formatter.full_backtrace = true_or_false
+end
+
+
+ +
+

+ + - (Boolean) full_backtrace? + + + + + +

+
+ +

Check if full backtrace is enabled

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    is full backtrace enabled

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+600
+601
+602
+
+
# File 'lib/rspec/core/configuration.rb', line 600
+
+def full_backtrace?
+  @backtrace_formatter.full_backtrace?
+end
+
+
+ +
+

+ + - (Array) full_description + + + + + +

+
+ +

Returns full description filter

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    full description filter

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+655
+656
+657
+
+
# File 'lib/rspec/core/configuration.rb', line 655
+
+def full_description
+  filter.fetch :full_description, nil
+end
+
+
+ +
+

+ + - (void) full_description=(description) + + + + + +

+
+ +

Run examples matching on description in all files to run.

+ + +
+
+
+

Parameters:

+
    + +
  • + + description + + + (String, Regexp) + + + + — +
    +

    the pattern to filter on

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+650
+651
+652
+
+
# File 'lib/rspec/core/configuration.rb', line 650
+
+def full_description=(description)
+  filter_run :full_description => Regexp.union(*Array(description).map { |d| Regexp.new(d) })
+end
+
+
+ +
+

+ + - (void) include(mod, *filters) + + + + + +

+
+ +

Tells RSpec to include mod in example groups. Methods defined +in mod are exposed to examples (not example groups). Use +filters to constrain the groups in which to include the +module.

+ + +
+
+
+ +
+

Examples:

+ + +

+module AuthenticationHelpers
+  def (user)
+    # ...
+  end
+end
+
+module UserHelpers
+  def users(username)
+    # ...
+  end
+end
+
+RSpec.configure do |config|
+  config.include(UserHelpers) # included in all modules
+  config.include(AuthenticationHelpers, :type => :request)
+end
+
+describe "edit profile", :type => :request do
+  it "can be viewed by owning user" do
+     users(:jdoe)
+    get "/profiles/jdoe"
+    assert_select ".username", :text => 'jdoe'
+  end
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+1013
+1014
+1015
+1016
+
+
# File 'lib/rspec/core/configuration.rb', line 1013
+
+def include(mod, *filters)
+  meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
+  include_or_extend_modules << [:include, mod, meta]
+end
+
+
+ +
+

+ + - (void) inclusion_filter + + + + Also known as: + filter + + + + +

+
+ +

Returns the inclusion_filter. If none has been set, returns an +empty hash.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+923
+924
+925
+
+
# File 'lib/rspec/core/configuration.rb', line 923
+
+def inclusion_filter
+  filter_manager.inclusions
+end
+
+
+ +
+

+ + - (void) inclusion_filter=(filter) + + + + Also known as: + filter= + + + + +

+
+ +

Clears and reassigns the inclusion_filter. Set to +nil if you don't want any inclusion filter at all.

+ +

Warning

+ +

This overrides any inclusion filters/tags set on the command line or in +configuration files.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+914
+915
+916
+917
+
+
# File 'lib/rspec/core/configuration.rb', line 914
+
+def inclusion_filter=(filter)
+  meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
+  filter_manager.include_only meta
+end
+
+
+ +
+

+ + - (void) mock_framework + + + + + +

+
+ +

Returns the configured mock framework adapter module

+ + +
+
+
+ + +
+ + + + +
+
+
+
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+
+
# File 'lib/rspec/core/configuration.rb', line 379
+
+def mock_framework
+  if @mock_framework.nil?
+    begin
+      mock_with :rspec
+    rescue LoadError
+      mock_with :nothing
+    end
+  end
+  @mock_framework
+end
+
+
+ +
+

+ + - (void) mock_framework=(framework) + + + + + +

+
+ +

Delegates to mock_framework=(framework)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+391
+392
+393
+
+
# File 'lib/rspec/core/configuration.rb', line 391
+
+def mock_framework=(framework)
+  mock_with framework
+end
+
+
+ +
+

+ + - (void) mock_with(framework) + + + + + +

+
+ +

Sets the mock framework adapter module.

+ +

framework can be a Symbol or a Module.

+ +

Given any of :rspec, :mocha, +:flexmock, or :rr, configures the named +framework.

+ +

Given :nothing, configures no framework. Use this if you +don't use any mocking framework to save a little bit of overhead.

+ +

Given a Module, includes that module in every example group. The module +should adhere to RSpec's mock framework adapter API:

+ +
setup_mocks_for_rspec
+  - called before each example
+
+verify_mocks_for_rspec
+  - called after each example if the example hasn't yet failed.
+    Framework should raise an exception when expectations fail
+
+teardown_mocks_for_rspec
+  - called after verify_mocks_for_rspec (even if there are errors)
+ +

If the module responds to configuration and +mock_with receives a block, it will yield the configuration +object to the block e.g.

+ +
config.mock_with OtherMockFrameworkAdapter do |mod_config|
+  mod_config.custom_setting = true
+end
+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+
+
# File 'lib/rspec/core/configuration.rb', line 494
+
+def mock_with(framework)
+  framework_module =
+    if framework.is_a?(Module)
+      framework
+    else
+      const_name = MOCKING_ADAPTERS.fetch(framework) do
+        raise ArgumentError,
+              "Unknown mocking framework: #{framework.inspect}. " \
+              "Pass a module or one of #{MOCKING_ADAPTERS.keys.inspect}"
+      end
+
+      RSpec::Support.require_rspec_core "mocking_adapters/#{const_name.to_s.downcase}"
+      RSpec::Core::MockingAdapters.const_get(const_name)
+    end
+
+  new_name, old_name = [framework_module, @mock_framework].map do |mod|
+    mod.respond_to?(:framework_name) ?  mod.framework_name : :unnamed
+  end
+
+  unless new_name == old_name
+    assert_no_example_groups_defined(:mock_framework)
+  end
+
+  if block_given?
+    raise "#{framework_module} must respond to `configuration` so that mock_with can yield it." unless framework_module.respond_to?(:configuration)
+    yield framework_module.configuration
+  end
+
+  @mock_framework = framework_module
+end
+
+
+ +
+

+ + - (void) order= + + + + + +

+
+ +

Sets the default global order and, if order is +'rand:<seed>', also sets the seed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1161
+
+
# File 'lib/rspec/core/configuration.rb', line 1161
+
+delegate_to_ordering_manager :order=
+
+
+ +
+

+ + - (void) raise_errors_for_deprecations! + + + + + +

+
+ +

Turns deprecation warnings into errors, in order to surface the full +backtrace of the call site. This can be useful when you need more context +to address a deprecation than the single-line call site normally provided.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.raise_errors_for_deprecations!
+end
+ +
+ + +
+ + + + +
+
+
+
+1246
+1247
+1248
+
+
# File 'lib/rspec/core/configuration.rb', line 1246
+
+def raise_errors_for_deprecations!
+  self.deprecation_stream = Formatters::DeprecationFormatter::RaiseErrorStream.new
+end
+
+
+ +
+

+ + - (void) register_ordering {|list| ... } + + + + + +

+
+ +
+ Note: +
+

Pass the symbol :global to set the ordering strategy that will +be used to order the top-level example groups and any example groups that +do not have declared :order metadata.

+
+
+ + +

Registers a named ordering strategy that can later be used to order an +example group's subgroups by adding :order => +<name> metadata to the example group.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |rspec|
+  rspec.register_ordering :reverse do |list|
+    list.reverse
+  end
+end
+
+describe MyClass, :order => :reverse do
+  # ...
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (Symbol) + + + + — +
    +

    The name of the ordering.

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    Block that will order the given examples or example groups

    +
    + +
  • + +
+

Yield Parameters:

+ +

Yield Returns:

+ + +
+ + + + +
+
+
+
+1187
+
+
# File 'lib/rspec/core/configuration.rb', line 1187
+
+delegate_to_ordering_manager :register_ordering
+
+
+ +
+

+ + - (void) seed + + + + + +

+
+ +

Seed for random ordering (default: generated randomly each run).

+ +

When you run specs with --order random, RSpec generates a +random seed for the randomization and prints it to the +output_stream (assuming you're using RSpec's built-in +formatters). If you discover an ordering dependency (i.e. examples fail +intermittently depending on order), set this (on Configuration or on the +command line with --seed) to run using the same seed while you +debug the issue.

+ +

We recommend, actually, that you use the command line approach so you +don't accidentally leave the seed encoded.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1156
+
+
# File 'lib/rspec/core/configuration.rb', line 1156
+
+delegate_to_ordering_manager :seed
+
+
+ +
+

+ + - (void) seed= + + + + + +

+
+ +

Sets the seed value and sets the default global ordering to random.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1142
+
+
# File 'lib/rspec/core/configuration.rb', line 1142
+
+delegate_to_ordering_manager :seed=
+
+
+ +
+

+ + - (void) treat_symbols_as_metadata_keys_with_true_values=(_value) + + + + + +

+
+ +

Deprecated. This config option was added in RSpec 2 to pave the way for +this being the default behavior in RSpec 3. Now this option is a no-op.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+262
+263
+264
+265
+266
+
+
# File 'lib/rspec/core/configuration.rb', line 262
+
+def (_value)
+  RSpec.deprecate("RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=",
+                  :message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= " \
+                              "is deprecated, it is now set to true as default and setting it to false has no effect.")
+end
+
+
+ +
+

+ + - (void) warnings=(value) + + + + + +

+
+ +

Set Ruby warnings on or off

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1193
+1194
+1195
+
+
# File 'lib/rspec/core/configuration.rb', line 1193
+
+def warnings=(value)
+  $VERBOSE = !!value
+end
+
+
+ +
+

+ + - (Boolean) warnings? + + + + + +

+
+ +

Returns Whether or not ruby warnings are enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not ruby warnings are enabled.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+1198
+1199
+1200
+
+
# File 'lib/rspec/core/configuration.rb', line 1198
+
+def warnings?
+  $VERBOSE
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/ConfigurationOptions.html b/source/documentation/3.1/rspec-core/RSpec/Core/ConfigurationOptions.html new file mode 100644 index 000000000..9630a0099 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/ConfigurationOptions.html @@ -0,0 +1,530 @@ + + + + + + Class: RSpec::Core::ConfigurationOptions + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::ConfigurationOptions + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/configuration_options.rb
+ +
+
+ +

Overview

+
+ +

Responsible for utilizing externally provided configuration options, +whether via the command line, .rspec, ~/.rspec, +.rspec-local or a custom options file.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ConfigurationOptions) initialize(args) + + + + + +

+
+ +

Returns a new instance of ConfigurationOptions

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array<String>) + + + + — +
    +

    command line arguments

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+
+
# File 'lib/rspec/core/configuration_options.rb', line 12
+
+def initialize(args)
+  @args = args.dup
+  organize_options
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (Hash) options (readonly) + + + + + +

+
+ +

Returns the final merged options, drawn from all external sources

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Hash) + + + + — +
    +

    the final merged options, drawn from all external sources

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+37
+38
+39
+
+
# File 'lib/rspec/core/configuration_options.rb', line 37
+
+def options
+  @options
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) configure(config) + + + + + +

+
+ +

Updates the provided RSpec::Core::Configuration instance based on the provided +external configuration options.

+ + +
+
+
+

Parameters:

+
    + +
  • + + config + + + (Configuration) + + + + — +
    +

    the configuration instance to update

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+25
+
+
# File 'lib/rspec/core/configuration_options.rb', line 21
+
+def configure(config)
+  process_options_into config
+  configure_filter_manager config.filter_manager
+  load_formatters_into config
+end
+
+
+ +
+

+ + - (void) configure_filter_manager(filter_manager) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Updates the provided FilterManager based on the filter options.

+ + +
+
+
+

Parameters:

+
    + +
  • + + filter_manager + + + (FilterManager) + + + + — +
    +

    instance to update

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+30
+31
+32
+33
+34
+
+
# File 'lib/rspec/core/configuration_options.rb', line 30
+
+def configure_filter_manager(filter_manager)
+  @filter_manager_options.each do |command, value|
+    filter_manager.__send__ command, value
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/DSL.html b/source/documentation/3.1/rspec-core/RSpec/Core/DSL.html new file mode 100644 index 000000000..ba60fc43b --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/DSL.html @@ -0,0 +1,322 @@ + + + + + + Module: RSpec::Core::DSL + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::DSL + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/dsl.rb
+ +
+
+ +

Overview

+
+ +

DSL defines methods to group examples, most notably describe, +and exposes them as class methods of RSpec. They can also be exposed +globally (on main and instances of Module) +through the Configuration option expose_dsl_globally.

+ +

By default the methods describe, context and +example_group are exposed. These methods define a named +context for one or more examples. The given block is evaluated in the +context of a generated subclass of ExampleGroup

+ +

Examples:

+ +
RSpec.describe "something" do
+  context "when something is a certain way" do
+    it "does something" do
+      # example code goes here
+    end
+  end
+end
+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (void) expose_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Adds the describe method to Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+54
+55
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib/rspec/core/dsl.rb', line 54
+
+def self.expose_globally!
+  return if exposed_globally?
+
+  example_group_aliases.each do |method_name|
+    expose_example_group_alias_globally(method_name)
+  end
+
+  @exposed_globally = true
+end
+
+
+ +
+

+ + + (void) remove_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Removes the describe method from Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+66
+67
+68
+69
+70
+71
+72
+73
+74
+
+
# File 'lib/rspec/core/dsl.rb', line 66
+
+def self.remove_globally!
+  return unless exposed_globally?
+
+  example_group_aliases.each do |method_name|
+    change_global_dsl { undef_method method_name }
+  end
+
+  @exposed_globally = false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Example.html b/source/documentation/3.1/rspec-core/RSpec/Core/Example.html new file mode 100644 index 000000000..5f2dce085 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Example.html @@ -0,0 +1,1357 @@ + + + + + + Class: RSpec::Core::Example + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Example + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/example.rb
+ +
+
+ +

Overview

+
+ +
+ Note: +
+

Example blocks are evaluated in the context of an instance of an +ExampleGroup, not in the context of an instance of +Example.

+
+
+ + +

Wrapper for an instance of a subclass of ExampleGroup. An instance of +RSpec::Core::Example is returned by example definition methods +such as it and is yielded to the it, +before, after, around, +let and +subject blocks.

+ +

This allows us to provide rich metadata about each individual example +without adding tons of methods directly to the ExampleGroup that users may +inadvertantly redefine.

+ +

Useful for configuring logging and/or taking some action based on the state +of an example's metadata.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |config|
+  config.before do |example|
+    log example.description
+  end
+
+  config.after do |example|
+    log example.description
+  end
+
+  config.around do |example|
+    log example.description
+    example.run
+  end
+end
+
+shared_examples "auditable" do
+  it "does something" do
+    log "#{example.full_description}: #{auditable.inspect}"
+    auditable.should do_something
+  end
+end
+ +
+ + +

See Also:

+ + +

Defined Under Namespace

+

+ + + + + Classes: ExecutionResult, Procsy + + +

+ + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Example) initialize(example_group_class, description, user_metadata, example_block = nil) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Creates a new instance of Example.

+ + +
+
+
+

Parameters:

+
    + +
  • + + example_group_class + + + (Class) + + + + — +
    +

    the subclass of ExampleGroup in which this Example is declared

    +
    + +
  • + +
  • + + description + + + (String) + + + + — +
    +

    the String passed to the it method (or alias)

    +
    + +
  • + +
  • + + user_metadata + + + (Hash) + + + + — +
    +

    additional args passed to it to be used as metadata

    +
    + +
  • + +
  • + + example_block + + + (Proc) + + + (defaults to: nil) + + + — +
    +

    the block of code that represents the example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+
+
# File 'lib/rspec/core/example.rb', line 113
+
+def initialize(example_group_class, description, , example_block=nil)
+  @example_group_class = example_group_class
+  @example_block       = example_block
+
+  @metadata = Metadata::ExampleHash.create(
+    @example_group_class., , description, example_block
+  )
+
+  @example_group_instance = @exception = nil
+  @clock = RSpec::Core::Time
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) exception (readonly) + + + + + +

+
+ +

Returns the first exception raised in the context of running this example +(nil if no exception is raised)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+89
+90
+91
+
+
# File 'lib/rspec/core/example.rb', line 89
+
+def exception
+  @exception
+end
+
+
+ + + +
+

+ + - (void) metadata (readonly) + + + + + +

+
+ +

Returns the metadata object associated with this example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+94
+95
+96
+
+
# File 'lib/rspec/core/example.rb', line 94
+
+def 
+  @metadata
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) description + + + + + +

+
+ +

Returns the string submitted to example or its aliases (e.g. +specify, it, etc). If no string is submitted +(e.g. it { is_expected.to do_something }) it returns the +message generated by the matcher if there is one, otherwise returns a +message including the location of the example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
+
# File 'lib/rspec/core/example.rb', line 75
+
+def description
+  description = if [:description].to_s.empty?
+                  "example at #{location}"
+                else
+                  [:description]
+                end
+
+  RSpec.configuration.format_docstrings_block.call(description)
+end
+
+
+ +
+

+ + - (void) example_group + + + + + +

+
+ +

Returns the example group class that provides the context for running this +example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+127
+128
+129
+
+
# File 'lib/rspec/core/example.rb', line 127
+
+def example_group
+  @example_group_class
+end
+
+
+ +
+

+ + - (ExecutionResult) execution_result + + + + + +

+
+ +

Returns represents the result of running this example.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (ExecutionResult) + + + + — +
    +

    represents the result of running this example.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+53
+
+
# File 'lib/rspec/core/example.rb', line 53
+
+ :execution_result
+
+
+ +
+

+ + - (String) file_path + + + + + +

+
+ +

Returns the relative path to the file where this example was defined.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the relative path to the file where this example was defined.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+55
+
+
# File 'lib/rspec/core/example.rb', line 55
+
+ :file_path
+
+
+ +
+

+ + - (String) full_description + + + + + +

+
+ +

Returns the full description (including the docstrings of all parent +example groups).

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the full description (including the docstrings of all parent example +groups).

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+58
+
+
# File 'lib/rspec/core/example.rb', line 58
+
+ :full_description
+
+
+ +
+

+ + - (String) location + + + + + +

+
+ +

Returns the exact source location of this example in a form like +./path/to/spec.rb:17

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the exact source location of this example in a form like +./path/to/spec.rb:17

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+61
+
+
# File 'lib/rspec/core/example.rb', line 61
+
+ :location
+
+
+ +
+

+ + - (Boolean) pending + + + + Also known as: + pending? + + + + +

+
+ +

Returns flag that indicates that the example is not expected to pass. It +will be run and will either have a pending result (if a failure occurs) or +a failed result (if no failure occurs).

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    flag that indicates that the example is not expected to pass. It will be +run and will either have a pending result (if a failure occurs) or a failed +result (if no failure occurs).

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+65
+
+
# File 'lib/rspec/core/example.rb', line 65
+
+ :pending
+
+
+ +
+

+ + - (void) run(example_group_instance, reporter) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

instance_execs the block passed to the constructor in the context of the +instance of RSpec::Core::ExampleGroup.

+ + +
+
+
+

Parameters:

+
    + +
  • + + example_group_instance + + + + + + + — +
    +

    the instance of an ExampleGroup subclass

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+
+
# File 'lib/rspec/core/example.rb', line 138
+
+def run(example_group_instance, reporter)
+  @example_group_instance = example_group_instance
+  RSpec.current_example = self
+
+  start(reporter)
+  Pending.mark_pending!(self, pending) if pending?
+
+  begin
+    if skipped?
+      Pending.mark_pending! self, skip
+    elsif !RSpec.configuration.dry_run?
+      with_around_example_hooks do
+        begin
+          run_before_example
+          @example_group_instance.instance_exec(self, &@example_block)
+
+          if pending?
+            Pending.mark_fixed! self
+
+            raise Pending::PendingExampleFixedError,
+                  'Expected example to fail since it is pending, but it passed.',
+                  [location]
+          end
+        rescue Pending::SkipDeclaredInExample
+          # no-op, required metadata has already been set by the `skip`
+          # method.
+        rescue Exception => e
+          set_exception(e)
+        ensure
+          run_after_example
+        end
+      end
+    end
+  rescue Exception => e
+    set_exception(e)
+  ensure
+    @example_group_instance.instance_variables.each do |ivar|
+      @example_group_instance.instance_variable_set(ivar, nil)
+    end
+    @example_group_instance = nil
+  end
+
+  finish(reporter)
+ensure
+  RSpec.current_example = nil
+end
+
+
+ +
+

+ + - (Boolean) skip + + + + Also known as: + skipped? + + + + +

+
+ +

Returns flag that will cause the example to not run. The ExecutionResult +status will be :pending.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    flag that will cause the example to not run. The ExecutionResult status +will be :pending.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+68
+
+
# File 'lib/rspec/core/example.rb', line 68
+
+ :skip
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Example/ExecutionResult.html b/source/documentation/3.1/rspec-core/RSpec/Core/Example/ExecutionResult.html new file mode 100644 index 000000000..5869e25b9 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Example/ExecutionResult.html @@ -0,0 +1,957 @@ + + + + + + Class: RSpec::Core::Example::ExecutionResult + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Example::ExecutionResult + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/example.rb
+ +
+
+ +

Overview

+
+ +

Represents the result of executing an example. Behaves like a hash for +backwards compatibility.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Exception?) exception + + + + + +

+
+ +

Returns The failure, if there was one.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Exception, nil) + + + + — +
    +

    The failure, if there was one.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+424
+425
+426
+
+
# File 'lib/rspec/core/example.rb', line 424
+
+def exception
+  @exception
+end
+
+
+ + + +
+

+ + - (Time) finished_at + + + + + +

+
+ +

Returns When the example finished.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Time) + + + + — +
    +

    When the example finished.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+430
+431
+432
+
+
# File 'lib/rspec/core/example.rb', line 430
+
+def finished_at
+  @finished_at
+end
+
+
+ + + +
+

+ + - (Exception?) pending_exception + + + + + +

+
+ +

Returns The exception triggered while executing the pending example. If no +exception was triggered it would no longer get a status of +:pending unless it was tagged with :skip.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Exception, nil) + + + + — +
    +

    The exception triggered while executing the pending example. If no +exception was triggered it would no longer get a status of +:pending unless it was tagged with :skip.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+443
+444
+445
+
+
# File 'lib/rspec/core/example.rb', line 443
+
+def pending_exception
+  @pending_exception
+end
+
+
+ + + +
+

+ + - (Boolean) pending_fixed + + + + Also known as: + pending_fixed? + + + + +

+
+ +

Returns For examples tagged with :pending, this indicates +whether or not it now passes.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    For examples tagged with :pending, this indicates whether or +not it now passes.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+447
+448
+449
+
+
# File 'lib/rspec/core/example.rb', line 447
+
+def pending_fixed
+  @pending_fixed
+end
+
+
+ + + +
+

+ + - (String?) pending_message + + + + + +

+
+ +

Returns The reason the example was pending, or nil if the example was not +pending.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String, nil) + + + + — +
    +

    The reason the example was pending, or nil if the example was not pending.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+437
+438
+439
+
+
# File 'lib/rspec/core/example.rb', line 437
+
+def pending_message
+  @pending_message
+end
+
+
+ + + +
+

+ + - (Float) run_time + + + + + +

+
+ +

Returns How long the example took in seconds.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    How long the example took in seconds.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+433
+434
+435
+
+
# File 'lib/rspec/core/example.rb', line 433
+
+def run_time
+  @run_time
+end
+
+
+ + + +
+

+ + - (Time) started_at + + + + + +

+
+ +

Returns When the example started.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Time) + + + + — +
    +

    When the example started.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+427
+428
+429
+
+
# File 'lib/rspec/core/example.rb', line 427
+
+def started_at
+  @started_at
+end
+
+
+ + + +
+

+ + - (Symbol) status + + + + + +

+
+ +

Returns :passed, :failed or +:pending.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Symbol) + + + + — +
    +

    :passed, :failed or :pending.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+421
+422
+423
+
+
# File 'lib/rspec/core/example.rb', line 421
+
+def status
+  @status
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) record_finished(status, finished_at) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Records the finished status of the example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+453
+454
+455
+456
+457
+
+
# File 'lib/rspec/core/example.rb', line 453
+
+def record_finished(status, finished_at)
+  self.status      = status
+  self.finished_at = finished_at
+  self.run_time    = (finished_at - started_at).to_f
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Example/Procsy.html b/source/documentation/3.1/rspec-core/RSpec/Core/Example/Procsy.html new file mode 100644 index 000000000..1c964ee29 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Example/Procsy.html @@ -0,0 +1,550 @@ + + + + + + Class: RSpec::Core::Example::Procsy + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Example::Procsy + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/example.rb
+ +
+
+ +

Overview

+
+ +
+ Note: +
+

This class also exposes the instance methods of RSpec::Core::Example, proxying them +through to the wrapped RSpec::Core::Example instance.

+
+
+ + +

Wraps both a Proc and an RSpec::Core::Example for use in around hooks. In around hooks we need to yield this special kind of object +(rather than the raw RSpec::Core::Example) because when there are multiple +around hooks we have to wrap them recursively.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |c|
+  c.around do |ex| # Procsy which wraps the example
+    if ex.[:key] == :some_value && some_global_condition
+      raise "some message"
+    end
+    ex.run         # run delegates to ex.call
+  end
+end
+ +
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Procsy) initialize(example, &block) + + + + + +

+
+ +

Returns a new instance of Procsy

+ + +
+
+
+ + +
+ + + + +
+
+
+
+231
+232
+233
+234
+235
+
+
# File 'lib/rspec/core/example.rb', line 231
+
+def initialize(example, &block)
+  @example  = example
+  @proc     = block
+  @executed = false
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) example (readonly) + + + + + +

+
+ +

The RSpec::Core::Example instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+205
+206
+207
+
+
# File 'lib/rspec/core/example.rb', line 205
+
+def example
+  @example
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) call(*args, &block) + + + + Also known as: + run + + + + +

+
+ +

Calls the proc and notes that the example has been executed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+220
+221
+222
+223
+
+
# File 'lib/rspec/core/example.rb', line 220
+
+def call(*args, &block)
+  @executed = true
+  @proc.call(*args, &block)
+end
+
+
+ +
+

+ + - (Boolean) executed? + + + + + +

+
+ +

Indicates whether or not the around hook has executed the example.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+243
+244
+245
+
+
# File 'lib/rspec/core/example.rb', line 243
+
+def executed?
+  @executed
+end
+
+
+ +
+

+ + - (void) to_proc + + + + + +

+
+ +

Provides a wrapped proc that will update our executed? state +when executed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+227
+228
+229
+
+
# File 'lib/rspec/core/example.rb', line 227
+
+def to_proc
+  method(:call).to_proc
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/ExampleGroup.html b/source/documentation/3.1/rspec-core/RSpec/Core/ExampleGroup.html new file mode 100644 index 000000000..fd50bb4ec --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/ExampleGroup.html @@ -0,0 +1,3627 @@ + + + + + + Class: RSpec::Core::ExampleGroup + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::ExampleGroup + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + +
Extended by:
+
Hooks, MemoizedHelpers::ClassMethods, SharedExampleGroup
+ + + + +
Includes:
+
MemoizedHelpers, Pending
+ + + + + +
Defined in:
+
lib/rspec/core/example_group.rb
+ +
+
+ +

Overview

+
+ +

ExampleGroup and Example are the main structural elements of rspec-core. +Consider this example:

+ +
describe Thing do
+  it "does something" do
+  end
+end
+ +

The object returned by describe Thing is a subclass of +ExampleGroup. The object returned by it "does +something" is an instance of Example, which serves as a wrapper +for an instance of the ExampleGroup in which it is declared.

+ +

Example group bodies (e.g. describe or context +blocks) are evaluated in the context of a new subclass of ExampleGroup. +Individual examples are evaluated in the context of an instance of the +specific ExampleGroup subclass to which they belong.

+ +

Besides the class methods defined here, there are other interesting macros +defined in Hooks, MemoizedHelpers::ClassMethods and +SharedExampleGroup. There are additional instance methods available to +your examples defined in MemoizedHelpers and Pending.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Metadata + (collapse) +

+ + + +

+ Defining Examples + (collapse) +

+ + + +

+ Defining Example Groups + (collapse) +

+ + + +

+ Including Shared Example Groups + (collapse) +

+ + + +

+ Class Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from SharedExampleGroup

+

shared_examples

+ + + + + + + + + +

Methods included from MemoizedHelpers::ClassMethods

+

let, let!, subject, subject!

+ + + + + + + + + +

Methods included from Hooks

+

after, append_after, around, before, prepend_before

+ + + + + + + + + +

Methods included from Pending

+

#pending, #skip

+ + + + + + + + + +

Methods included from MemoizedHelpers

+

#is_expected, #should, #should_not, #subject

+ + +
+

Class Method Details

+ + +
+

+ + + (void) context { ... } + + + + + +

+
+ +

An alias of example_group. Generally used when grouping +examples contextually (e.g. “with xyz”, “when xyz” or “if xyz”). Generates +a subclass of this example group which inherits everything except the +examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  context "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+241
+
+
# File 'lib/rspec/core/example_group.rb', line 241
+
+define_example_group_method :context
+
+
+ +
+

+ + + (void) describe { ... } + + + + + +

+
+ +

An alias of example_group. Generally used when grouping +examples by a thing you are describing (e.g. an object, class or method). +Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  describe "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+236
+
+
# File 'lib/rspec/core/example_group.rb', line 236
+
+define_example_group_method :describe
+
+
+ +
+

+ + + (String) description + + + + + +

+
+ +

Returns the current example group description

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current example group description

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+69
+
+
# File 'lib/rspec/core/example_group.rb', line 66
+
+def self.description
+  description = [:description]
+  RSpec.configuration.format_docstrings_block.call(description)
+end
+
+
+ +
+

+ + + (void) example {|Example| ... } + + + + + +

+
+ +

Defines an example within a group.

+ + +
+
+
+ +
+

Examples:

+ + +
example do
+end
+
+example "does something" do
+end
+
+example "does something", :with => 'additional metadata' do
+end
+
+example "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+123
+
+
# File 'lib/rspec/core/example_group.rb', line 123
+
+define_example_method :example
+
+
+ +
+

+ + + (void) example_group { ... } + + + + + +

+
+ +

Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  example_group "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+231
+
+
# File 'lib/rspec/core/example_group.rb', line 231
+
+define_example_group_method :example_group
+
+
+ +
+

+ + + (void) fcontext { ... } + + + + + +

+
+ +

Shortcut to define an example group with :focus => true. +Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  fcontext "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+257
+
+
# File 'lib/rspec/core/example_group.rb', line 257
+
+define_example_group_method :fcontext,  :focus => true
+
+
+ +
+

+ + + (void) fdescribe { ... } + + + + + +

+
+ +

Shortcut to define an example group with :focus => true. +Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  fdescribe "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+253
+
+
# File 'lib/rspec/core/example_group.rb', line 253
+
+define_example_group_method :fdescribe, :focus => true
+
+
+ +
+

+ + + (void) fexample {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
fexample do
+end
+
+fexample "does something" do
+end
+
+fexample "does something", :with => 'additional metadata' do
+end
+
+fexample "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+142
+
+
# File 'lib/rspec/core/example_group.rb', line 142
+
+define_example_method :fexample, :focus => true
+
+
+ +
+

+ + + (void) fit {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
fit do
+end
+
+fit "does something" do
+end
+
+fit "does something", :with => 'additional metadata' do
+end
+
+fit "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+145
+
+
# File 'lib/rspec/core/example_group.rb', line 145
+
+define_example_method :fit,      :focus => true
+
+
+ +
+

+ + + (void) focus {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
focus do
+end
+
+focus "does something" do
+end
+
+focus "does something", :with => 'additional metadata' do
+end
+
+focus "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+139
+
+
# File 'lib/rspec/core/example_group.rb', line 139
+
+define_example_method :focus,    :focus => true
+
+
+ +
+

+ + + (void) fspecify {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
fspecify do
+end
+
+fspecify "does something" do
+end
+
+fspecify "does something", :with => 'additional metadata' do
+end
+
+fspecify "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+148
+
+
# File 'lib/rspec/core/example_group.rb', line 148
+
+define_example_method :fspecify, :focus => true
+
+
+ +
+

+ + + (void) include_context(name, *args, &block) + + + + + +

+
+ +

Includes shared content mapped to name directly in the group +in which it is declared, as opposed to it_behaves_like, which +creates a nested group. If given a block, that block is also eval'd in +the current context.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+293
+294
+295
+
+
# File 'lib/rspec/core/example_group.rb', line 293
+
+def self.include_context(name, *args, &block)
+  find_and_eval_shared("context", name, *args, &block)
+end
+
+
+ +
+

+ + + (void) include_examples(name, *args, &block) + + + + + +

+
+ +

Includes shared content mapped to name directly in the group +in which it is declared, as opposed to it_behaves_like, which +creates a nested group. If given a block, that block is also eval'd in +the current context.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+302
+303
+304
+
+
# File 'lib/rspec/core/example_group.rb', line 302
+
+def self.include_examples(name, *args, &block)
+  find_and_eval_shared("examples", name, *args, &block)
+end
+
+
+ +
+

+ + + (void) it {|Example| ... } + + + + + +

+
+ +

Defines an example within a group. This is the primary API to define a code +example.

+ + +
+
+
+ +
+

Examples:

+ + +
it do
+end
+
+it "does something" do
+end
+
+it "does something", :with => 'additional metadata' do
+end
+
+it "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+126
+
+
# File 'lib/rspec/core/example_group.rb', line 126
+
+define_example_method :it
+
+
+ +
+

+ + + (void) it_behaves_like + + + + + +

+
+ +

Generates a nested example group and includes the shared content mapped to +name in the nested group.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+283
+
+
# File 'lib/rspec/core/example_group.rb', line 283
+
+define_nested_shared_group_method :it_behaves_like, "behaves like"
+
+
+ +
+

+ + + (void) it_should_behave_like + + + + + +

+
+ +

Generates a nested example group and includes the shared content mapped to +name in the nested group.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+286
+
+
# File 'lib/rspec/core/example_group.rb', line 286
+
+define_nested_shared_group_method :it_should_behave_like
+
+
+ +
+

+ + + (void) metadata + + + + + +

+
+ +

The Metadata object associated with this group.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/rspec/core/example_group.rb', line 46
+
+def self.
+  @metadata if defined?(@metadata)
+end
+
+
+ +
+

+ + + (void) pending {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :pending => true

+ + +
+
+
+ +
+

Examples:

+ + +
pending do
+end
+
+pending "does something" do
+end
+
+pending "does something", :with => 'additional metadata' do
+end
+
+pending "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+163
+
+
# File 'lib/rspec/core/example_group.rb', line 163
+
+define_example_method :pending,  :pending => true
+
+
+ +
+

+ + + (void) run(reporter) + + + + + +

+
+ +

Runs all the examples in this group

+ + +
+
+
+ + +
+ + + + +
+
+
+
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+
+
# File 'lib/rspec/core/example_group.rb', line 444
+
+def self.run(reporter)
+  if RSpec.world.wants_to_quit
+    RSpec.world.clear_remaining_example_groups if top_level?
+    return
+  end
+  reporter.example_group_started(self)
+
+  begin
+    run_before_context_hooks(new)
+    result_for_this_group = run_examples(reporter)
+    results_for_descendants = ordering_strategy.order(children).map { |child| child.run(reporter) }.all?
+    result_for_this_group && results_for_descendants
+  rescue Pending::SkipDeclaredInExample => ex
+    for_filtered_examples(reporter) { |example| example.skip_with_exception(reporter, ex) }
+  rescue Exception => ex
+    RSpec.world.wants_to_quit = true if fail_fast?
+    for_filtered_examples(reporter) { |example| example.fail_with_exception(reporter, ex) }
+  ensure
+    run_after_context_hooks(new)
+    before_context_ivars.clear
+    reporter.example_group_finished(self)
+  end
+end
+
+
+ +
+

+ + + (void) skip {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => true

+ + +
+
+
+ +
+

Examples:

+ + +
skip do
+end
+
+skip "does something" do
+end
+
+skip "does something", :with => 'additional metadata' do
+end
+
+skip "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+160
+
+
# File 'lib/rspec/core/example_group.rb', line 160
+
+define_example_method :skip,     :skip => true
+
+
+ +
+

+ + + (void) specify {|Example| ... } + + + + + +

+
+ +

Defines an example within a group. Useful for when your docstring does not +read well off of it.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.describe MyClass do
+  specify "#do_something is deprecated" do
+    # ...
+  end
+end
+ + +
specify do
+end
+
+specify "does something" do
+end
+
+specify "does something", :with => 'additional metadata' do
+end
+
+specify "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+135
+
+
# File 'lib/rspec/core/example_group.rb', line 135
+
+define_example_method :specify
+
+
+ +
+

+ + + (void) xcontext { ... } + + + + + +

+
+ +

Shortcut to temporarily make an example group skipped. Generates a subclass +of this example group which inherits everything except the examples +themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  xcontext "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+249
+
+
# File 'lib/rspec/core/example_group.rb', line 249
+
+define_example_group_method :xcontext,  :skip => "Temporarily skipped with xcontext"
+
+
+ +
+

+ + + (void) xdescribe { ... } + + + + + +

+
+ +

Shortcut to temporarily make an example group skipped. Generates a subclass +of this example group which inherits everything except the examples +themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  xdescribe "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+245
+
+
# File 'lib/rspec/core/example_group.rb', line 245
+
+define_example_group_method :xdescribe, :skip => "Temporarily skipped with xdescribe"
+
+
+ +
+

+ + + (void) xexample {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => 'Temporarily +skipped with xexample'

+ + +
+
+
+ +
+

Examples:

+ + +
xexample do
+end
+
+xexample "does something" do
+end
+
+xexample "does something", :with => 'additional metadata' do
+end
+
+xexample "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+151
+
+
# File 'lib/rspec/core/example_group.rb', line 151
+
+define_example_method :xexample, :skip => 'Temporarily skipped with xexample'
+
+
+ +
+

+ + + (void) xit {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => 'Temporarily +skipped with xit'

+ + +
+
+
+ +
+

Examples:

+ + +
xit do
+end
+
+xit "does something" do
+end
+
+xit "does something", :with => 'additional metadata' do
+end
+
+xit "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+154
+
+
# File 'lib/rspec/core/example_group.rb', line 154
+
+define_example_method :xit,      :skip => 'Temporarily skipped with xit'
+
+
+ +
+

+ + + (void) xspecify {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => 'Temporarily +skipped with xspecify'

+ + +
+
+
+ +
+

Examples:

+ + +
xspecify do
+end
+
+xspecify "does something" do
+end
+
+xspecify "does something", :with => 'additional metadata' do
+end
+
+xspecify "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+157
+
+
# File 'lib/rspec/core/example_group.rb', line 157
+
+define_example_method :xspecify, :skip => 'Temporarily skipped with xspecify'
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (void) described_class + + + + + +

+
+ +

Returns the class or module passed to the describe method (or +alias). Returns nil if the subject is not a class or module.

+ + +
+
+
+ +
+

Examples:

+ + +
describe Thing do
+  it "does something" do
+    described_class == Thing
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+81
+82
+83
+
+
# File 'lib/rspec/core/example_group.rb', line 81
+
+def described_class
+  self.class.described_class
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters.html new file mode 100644 index 000000000..303d14fa9 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters.html @@ -0,0 +1,354 @@ + + + + + + Module: RSpec::Core::Formatters + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Formatters + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/formatters.rb,
+ lib/rspec/core/formatters/helpers.rb,
lib/rspec/core/formatters/protocol.rb,
lib/rspec/core/formatters/html_printer.rb,
lib/rspec/core/formatters/console_codes.rb,
lib/rspec/core/formatters/json_formatter.rb,
lib/rspec/core/formatters/html_formatter.rb,
lib/rspec/core/formatters/base_formatter.rb,
lib/rspec/core/formatters/profile_formatter.rb,
lib/rspec/core/formatters/snippet_extractor.rb,
lib/rspec/core/formatters/progress_formatter.rb,
lib/rspec/core/formatters/base_text_formatter.rb,
lib/rspec/core/formatters/deprecation_formatter.rb,
lib/rspec/core/formatters/documentation_formatter.rb
+
+ +
+
+ +

Overview

+
+ +

Built-in Formatters

+
  • +

    progress (default) - prints dots for passing examples, F for +failures, * for pending

    +
  • +

    documentation - prints the docstrings passed to describe and +it methods (and their aliases)

    +
  • +

    html

    +
  • +

    json - useful for archiving data for subsequent analysis

    +
+ +

The progress formatter is the default, but you can choose any one or more +of the other formatters by passing with the --format (or +-f for short) command-line option, e.g.

+ +
rspec --format documentation
+ +

You can also send the output of multiple formatters to different streams, +e.g.

+ +
rspec --format documentation --format html --out results.html
+ +

This example sends the output of the documentation formatter to +$stdout, and the output of the html formatter to results.html.

+ +

Custom Formatters

+ +

You can tell RSpec to use a custom formatter by passing its path and name +to the rspec commmand. For example, if you define +MyCustomFormatter in path/to/my_custom_formatter.rb, you would type this +command:

+ +
rspec --require path/to/my_custom_formatter.rb --format MyCustomFormatter
+
+ +

The reporter calls every formatter with this protocol:

+
  • +

    To start

    +
  • +

    start(StartNotification)

    +
  • +

    Once per example group

    +
  • +

    example_group_started(GroupNotification)

    +
  • +

    Once per example

    +
  • +

    example_started(ExampleNotification)

    +
  • +

    One of these per example, depending on outcome

    +
  • +

    example_passed(ExampleNotification)

    +
  • +

    example_failed(FailedExampleNotification)

    +
  • +

    example_pending(ExampleNotification)

    +
  • +

    Optionally at any time

    +
  • +

    message(MessageNotification)

    +
  • +

    At the end of the suite

    +
  • +

    stop(ExamplesNotification)

    +
  • +

    start_dump(NullNotification)

    +
  • +

    dump_pending(ExamplesNotification)

    +
  • +

    dump_failures(ExamplesNotification)

    +
  • +

    dump_summary(SummaryNotification)

    +
  • +

    seed(SeedNotification)

    +
  • +

    close(NullNotification)

    +
+ +

Only the notifications to which you subscribe your formatter will be called +on your formatter. To subscribe your formatter use: +RSpec::Core::Formatters#register e.g.

+ +

RSpec::Core::Formatters.register FormatterClassName, :example_passed, +:example_failed

+ +

We recommend you implement the methods yourself; for simplicity we provide +the default formatter output via our notification objects but if you prefer +you can subclass RSpec::Core::Formatters::BaseTextFormatter +and override the methods you wish to enhance.

+ + +
+
+
+ + +

See Also:

+ + +

Defined Under Namespace

+

+ + + Modules: ConsoleCodes, Helpers + + + + Classes: BaseFormatter, BaseTextFormatter, Loader, ProfileFormatter, Protocol, SnippetExtractor + + +

+ + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (void) register(formatter_class, *notifications) + + + + + +

+
+ +

Register the formatter class

+ + +
+
+
+

Parameters:

+
    + +
  • + + formatter_class + + + (Class) + + + + — +
    +

    formatter class to register

    +
    + +
  • + +
  • + + notifications + + + (Symbol, ...) + + + + — +
    +

    one or more notifications to be registered to the specified formatter

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+78
+79
+80
+
+
# File 'lib/rspec/core/formatters.rb', line 78
+
+def self.register(formatter_class, *notifications)
+  Loader.formatters[formatter_class] = notifications
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseFormatter.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseFormatter.html new file mode 100644 index 000000000..833a40a22 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseFormatter.html @@ -0,0 +1,672 @@ + + + + + + Class: RSpec::Core::Formatters::BaseFormatter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::BaseFormatter + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/base_formatter.rb
+ +
+
+ +

Overview

+
+ +

RSpec's built-in formatters are all subclasses of +RSpec::Core::Formatters::BaseTextFormatter.

+ + +
+
+
+ + +

See Also:

+ + +
+

Direct Known Subclasses

+

BaseTextFormatter

+
+ + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (BaseFormatter) initialize(output) + + + + + +

+
+ +

Returns a new instance of BaseFormatter

+ + +
+
+
+

Parameters:

+
    + +
  • + + output + + + (IO) + + + + — +
    +

    the formatter output

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 21
+
+def initialize(output)
+  @output = output || StringIO.new
+  @example_group = nil
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) example_group + + + + + +

+
+ +

Returns the value of attribute example_group

+ + +
+
+
+ + +
+ + + + +
+
+
+
+15
+16
+17
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 15
+
+def example_group
+  @example_group
+end
+
+
+ + + +
+

+ + - (void) output (readonly) + + + + + +

+
+ +

Returns the value of attribute output

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 16
+
+def output
+  @output
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) close(_notification) + + + + + +

+
+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 47
+
+def close(_notification)
+  restore_sync_output
+end
+
+
+ +
+

+ + - (void) example_group_started(notification) + + + + + +

+
+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (GroupNotification) + + + + — +
    +

    containing example_group subclass of RSpec::Core::ExampleGroup

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+39
+40
+41
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 39
+
+def example_group_started(notification)
+  @example_group = notification.group
+end
+
+
+ +
+

+ + - (void) start(notification) + + + + + +

+
+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (StartNotification) + + + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+30
+31
+32
+33
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 30
+
+def start(notification)
+  start_sync_output
+  @example_count = notification.count
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html new file mode 100644 index 000000000..2cfae410c --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html @@ -0,0 +1,524 @@ + + + + + + Class: RSpec::Core::Formatters::BaseTextFormatter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::BaseTextFormatter + + + +

+ +
+ +
Inherits:
+
+ BaseFormatter + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/base_text_formatter.rb
+ +
+
+ +

Overview

+
+ +

Base for all of RSpec's built-in formatters. See +RSpec::Core::Formatters::BaseFormatter to learn more about all of the +methods called by the reporter.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + +

Instance Attribute Summary

+ +

Attributes inherited from BaseFormatter

+

#example_group, #output

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseFormatter

+

#example_group_started, #initialize, #start

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Core::Formatters::BaseFormatter

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) close(_notification) + + + + + +

+
+ +

Invoked at the very end, close allows the formatter to clean +up resources, e.g. open streams, etc.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+67
+68
+69
+70
+71
+72
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 67
+
+def close(_notification)
+  return unless IO === output
+  return if output.closed? || output == $stdout
+
+  output.close
+end
+
+
+ +
+

+ + - (void) dump_failures + + + + + +

+
+ +

Dumps detailed information about each example failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+32
+33
+34
+35
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 32
+
+def dump_failures(notification)
+  return if notification.failure_notifications.empty?
+  output.puts notification.fully_formatted_failed_examples
+end
+
+
+ +
+

+ + - (void) dump_summary + + + + + +

+
+ +

This method is invoked after the dumping of examples and failures. Each +parameter is assigned to a corresponding attribute.

+ + +
+
+
+

Parameters:

+
    + +
  • + + summary + + + (SummaryNotification) + + + + — +
    +

    containing duration, example_count, failure_count and pending_count

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 45
+
+def dump_summary(summary)
+  output.puts summary.fully_formatted
+end
+
+
+ +
+

+ + - (void) message + + + + + +

+
+ +

Used by the reporter to send messages to the output stream.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (MessageNotification) + + + + — +
    +

    containing message

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 22
+
+def message(notification)
+  output.puts notification.message
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html new file mode 100644 index 000000000..49d32fc8f --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html @@ -0,0 +1,387 @@ + + + + + + Module: RSpec::Core::Formatters::ConsoleCodes + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Formatters::ConsoleCodes + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/console_codes.rb
+ +
+
+ +

Overview

+
+ +

ConsoleCodes provides helpers for formatting console output with ANSI +codes, e.g. color's and bold.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Fixnum) console_code_for(code_or_symbol) + + + + + +

+
+ +

Fetches the correct code for the supplied symbol, or checks that a code is +valid. Defaults to white (37).

+ + +
+
+
+

Parameters:

+
    + +
  • + + code_or_symbol + + + (Symbol, Fixnum) + + + + — +
    +

    Symbol or code to check

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    a console code

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+
+
# File 'lib/rspec/core/formatters/console_codes.rb', line 30
+
+def console_code_for(code_or_symbol)
+  if RSpec.configuration.respond_to?(:#{code_or_symbol}_color")
+    console_code_for configuration_color(code_or_symbol)
+  elsif VT100_CODE_VALUES.key?(code_or_symbol)
+    code_or_symbol
+  else
+    VT100_CODES.fetch(code_or_symbol) do
+      console_code_for(:white)
+    end
+  end
+end
+
+
+ +
+

+ + + (String) wrap(text, code_or_symbol) + + + + + +

+
+ +

Wraps a piece of text in ANSI codes with the supplied code. Will only apply +the control code if RSpec.configuration.color_enabled? returns +true.

+ + +
+
+
+

Parameters:

+
    + +
  • + + text + + + (String) + + + + — +
    +

    the text to wrap

    +
    + +
  • + +
  • + + code_or_symbol + + + (Symbol, Fixnum) + + + + — +
    +

    the desired control code

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the wrapped text

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+49
+50
+51
+52
+53
+54
+55
+
+
# File 'lib/rspec/core/formatters/console_codes.rb', line 49
+
+def wrap(text, code_or_symbol)
+  if RSpec.configuration.color_enabled?
+    "\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m"
+  else
+    text
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Helpers.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Helpers.html new file mode 100644 index 000000000..4ffea39a5 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Helpers.html @@ -0,0 +1,533 @@ + + + + + + Module: RSpec::Core::Formatters::Helpers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Formatters::Helpers + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/helpers.rb
+ +
+
+ +

Overview

+
+ +

Formatters helpers

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (String) format_duration(duration) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Formats seconds into a human-readable string.

+ + +
+
+
+ +
+

Examples:

+ + +
format_duration(1) #=>  "1 minute 1 second"
+format_duration(135.14) #=> "2 minutes 15.14 seconds"
+ +
+

Parameters:

+
    + +
  • + + duration + + + (Float, Fixnum) + + + + — +
    +

    in seconds

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    human-readable time

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+
+
# File 'lib/rspec/core/formatters/helpers.rb', line 22
+
+def self.format_duration(duration)
+  precision = case
+              when duration < 1 then    SUB_SECOND_PRECISION
+              when duration < 120 then  DEFAULT_PRECISION
+              when duration < 300 then  1
+              else                  0
+              end
+
+  if duration > 60
+    minutes = (duration.to_i / 60).to_i
+    seconds = duration - minutes * 60
+
+    "#{pluralize(minutes, 'minute')} #{pluralize(format_seconds(seconds, precision), 'second')}"
+  else
+    pluralize(format_seconds(duration, precision), 'second')
+  end
+end
+
+
+ +
+

+ + + (String) format_seconds(float, precision = nil) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Formats seconds to have 5 digits of precision with trailing zeros removed +if the number is less than 1 or with 2 digits of precision if the number is +greater than zero.

+ +

The precision used is set in SUB_SECOND_PRECISION and +DEFAULT_PRECISION.

+ + +
+
+
+ +
+

Examples:

+ + +
format_seconds(0.000006) #=> "0.00001"
+format_seconds(0.020000) #=> "0.02"
+format_seconds(1.00000000001) #=> "1"
+ +
+

Parameters:

+
    + +
  • + + float + + + (Float) + + + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    formatted float

    +
    + +
  • + +
+ +

See Also:

+
    + +
  • #strip_trailing_zeroes
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+
+
# File 'lib/rspec/core/formatters/helpers.rb', line 56
+
+def self.format_seconds(float, precision=nil)
+  precision ||= (float < 1) ? SUB_SECOND_PRECISION : DEFAULT_PRECISION
+  formatted = "%.#{precision}f" % float
+  strip_trailing_zeroes(formatted)
+end
+
+
+ +
+

+ + + (String) pluralize(count, string) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Pluralize a word based on a count.

+ + +
+
+
+

Parameters:

+
    + +
  • + + count + + + (Fixnum) + + + + — +
    +

    number of objects

    +
    + +
  • + +
  • + + string + + + (String) + + + + — +
    +

    word to be pluralized

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    pluralized word

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+81
+82
+83
+
+
# File 'lib/rspec/core/formatters/helpers.rb', line 81
+
+def self.pluralize(count, string)
+  "#{count} #{string}#{'s' unless count.to_f == 1}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Loader.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Loader.html new file mode 100644 index 000000000..2f65e7b17 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Loader.html @@ -0,0 +1,601 @@ + + + + + + Class: RSpec::Core::Formatters::Loader + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::Loader + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

RSpec::Core::Formatters::Loader is an internal class for +managing formatters used by a particular configuration. It is not expected +to be used directly, but only through the configuration interface.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Loader) initialize(reporter) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of Loader

+ + +
+
+
+ + +
+ + + + +
+
+
+
+97
+98
+99
+100
+101
+
+
# File 'lib/rspec/core/formatters.rb', line 97
+
+def initialize(reporter)
+  @formatters = []
+  @reporter = reporter
+  self.default_formatter = 'progress'
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (String) default_formatter + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns the default formatter to setup, defaults to progress

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the default formatter to setup, defaults to progress

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+110
+111
+112
+
+
# File 'lib/rspec/core/formatters.rb', line 110
+
+def default_formatter
+  @default_formatter
+end
+
+
+ + + +
+

+ + - (Array) formatters (readonly) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns the loaded formatters

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    the loaded formatters

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+104
+105
+106
+
+
# File 'lib/rspec/core/formatters.rb', line 104
+
+def formatters
+  @formatters
+end
+
+
+ + + +
+

+ + - (Reporter) reporter (readonly) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns the reporter

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Reporter) + + + + — +
    +

    the reporter

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+107
+108
+109
+
+
# File 'lib/rspec/core/formatters.rb', line 107
+
+def reporter
+  @reporter
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (void) formatters + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Internal formatters are stored here when loaded

+ + +
+
+
+ + +
+ + + + +
+
+
+
+92
+93
+94
+
+
# File 'lib/rspec/core/formatters.rb', line 92
+
+def self.formatters
+  @formatters ||= {}
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html new file mode 100644 index 000000000..5699a267b --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html @@ -0,0 +1,316 @@ + + + + + + Class: RSpec::Core::Formatters::ProfileFormatter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::ProfileFormatter + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/profile_formatter.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

Formatter for providing profile output

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ProfileFormatter) initialize(output) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of ProfileFormatter

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lib/rspec/core/formatters/profile_formatter.rb', line 11
+
+def initialize(output)
+  @output = output
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) dump_profile + + + + + +

+
+ +

This method is invoked after the dumping the summary if profiling is +enabled.

+ + +
+
+
+

Parameters:

+
    + +
  • + + profile + + + (ProfileNotification) + + + + — +
    +

    containing duration, slowest_examples and slowest_example_groups

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+26
+27
+28
+29
+
+
# File 'lib/rspec/core/formatters/profile_formatter.rb', line 26
+
+def dump_profile(profile)
+  dump_profile_slowest_examples(profile)
+  dump_profile_slowest_example_groups(profile)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Protocol.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Protocol.html new file mode 100644 index 000000000..4a5c5d26d --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/Protocol.html @@ -0,0 +1,1485 @@ + + + + + + Class: RSpec::Core::Formatters::Protocol + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::Protocol + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/protocol.rb
+ +
+
+ +

Overview

+
+ +

This class isn't loaded at runtime but serves to document all of the +notifications implemented as part of the standard interface. The reporter +will issue these during a normal test suite run, but a formatter will only +receive those notifications it has registered itself to receive. To +register a formatter call:

+ +

::RSpec::Core::Formatters.register class, :list, :of, +:notifications

+ +

e.g.

+ +

::RSpec::Core::Formatters.register self, :start, +:example_started

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Suite Notifications + (collapse) +

+ + + +

+ Group Notifications + (collapse) +

+ + + +

+ Example Notifications + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (void) initialize + + + + + +

+
+ + +
+
+
+

Parameters:

+
    + +
  • + + output + + + (IO) + + + + — +
    +

    the formatter output

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 20
+
+
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) close + + + + + +

+
+ +

Invoked at the very end, close allows the formatter to clean +up resources, e.g. open streams, etc.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 160
+
+
+
+
+ +
+

+ + - (void) dump_failures + + + + + +

+
+ +

Dumps detailed information about each example failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 115
+
+
+
+
+ +
+

+ + - (void) dump_pending + + + + + +

+
+ +

Outputs a report of pending examples. This gets invoked after the summary +if option is set to do so.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 143
+
+
+
+
+ +
+

+ + - (void) dump_profile + + + + + +

+
+ +

This method is invoked after the dumping the summary if profiling is +enabled.

+ + +
+
+
+

Parameters:

+
    + +
  • + + profile + + + (ProfileNotification) + + + + — +
    +

    containing duration, slowest_examples and slowest_example_groups

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 133
+
+
+
+
+ +
+

+ + - (void) dump_summary + + + + + +

+
+ +

This method is invoked after the dumping of examples and failures. Each +parameter is assigned to a corresponding attribute.

+ + +
+
+
+

Parameters:

+
    + +
  • + + summary + + + (SummaryNotification) + + + + — +
    +

    containing duration, example_count, failure_count and pending_count

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 123
+
+
+
+
+ +
+

+ + - (void) example_failed + + + + + +

+
+ +

Invoked when an example fails.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 81
+
+
+
+
+ +
+

+ + - (void) example_group_finished + + + + + +

+
+ +

Invoked at the end of the execution of each example group.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (GroupNotification) + + + + — +
    +

    containing example_group subclass of RSpec::Core::ExampleGroup

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 49
+
+
+
+
+ +
+

+ + - (void) example_group_started + + + + + +

+
+ +

This method is invoked at the beginning of the execution of each example +group.

+ +

The next method to be invoked after this is #example_passed, +#example_pending, or #example_group_finished.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (GroupNotification) + + + + — +
    +

    containing example_group subclass of RSpec::Core::ExampleGroup

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 38
+
+
+
+
+ +
+

+ + - (void) example_passed + + + + + +

+
+ +

Invoked when an example passes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 65
+
+
+
+
+ +
+

+ + - (void) example_pending + + + + + +

+
+ +

Invoked when an example is pending.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 73
+
+
+
+
+ +
+

+ + - (void) example_started + + + + + +

+
+ +

Invoked at the beginning of the execution of each example.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 57
+
+
+
+
+ +
+

+ + - (void) message + + + + + +

+
+ +

Used by the reporter to send messages to the output stream.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (MessageNotification) + + + + — +
    +

    containing message

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 89
+
+
+
+
+ +
+

+ + - (void) start + + + + + +

+
+ +

This method is invoked before any examples are run, right after they have +all been collected. This can be useful for special formatters that need to +provide progress on feedback (graphical ones).

+ +

This will only be invoked once, and the next one to be invoked is +#example_group_started.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (StartNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 25
+
+
+
+
+ +
+

+ + - (void) start_dump + + + + + +

+
+ +

This method is invoked after all of the examples have executed. The next +method to be invoked after this one is #dump_failures (BaseTextFormatter +then calls #dump_failure once for each failed example.)

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 105
+
+
+
+
+ +
+

+ + - (void) stop + + + + + +

+
+ +

Invoked after all examples have executed, before dumping post-run reports.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/protocol.rb', line 97
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html new file mode 100644 index 000000000..4869fc717 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html @@ -0,0 +1,681 @@ + + + + + + Class: RSpec::Core::Formatters::SnippetExtractor + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::SnippetExtractor + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/snippet_extractor.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

Extracts code snippets by looking at the backtrace of the passed error and +applies synax highlighting and line numbers using html.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (String) lines_around(file, line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Extract lines of code centered around a particular line within a source +file.

+ + +
+
+
+

Parameters:

+
    + +
  • + + file + + + (String) + + + + — +
    +

    filename

    +
    + +
  • + +
  • + + line + + + (Fixnum) + + + + — +
    +

    line number

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    lines around the target line within the file (2 above and 1 below).

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 70
+
+def lines_around(file, line)
+  if File.file?(file)
+    lines = File.read(file).split("\n")
+    min = [0, line - 3].max
+    max = [line + 1, lines.length - 1].min
+    selected_lines = []
+    selected_lines.join("\n")
+    lines[min..max].join("\n")
+  else
+    "# Couldn't get snippet for #{file}"
+  end
+rescue SecurityError
+  "# Couldn't get snippet for #{file}"
+end
+
+
+ +
+

+ + - (String) post_process(highlighted, offending_line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Adds line numbers to all lines and highlights the line where the failure +occurred using html span tags.

+ + +
+
+
+

Parameters:

+
    + +
  • + + highlighted + + + (String) + + + + — +
    +

    syntax-highlighted snippet surrounding the offending line of code

    +
    + +
  • + +
  • + + offending_line + + + (Fixnum) + + + + — +
    +

    line where failure occured

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    completed snippet

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+92
+93
+94
+95
+96
+97
+98
+99
+100
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 92
+
+def post_process(highlighted, offending_line)
+  new_lines = []
+  highlighted.split("\n").each_with_index do |line, i|
+    new_line = "<span class=\"linenum\">#{offending_line + i - 2}</span>#{line}"
+    new_line = "<span class=\"offending\">#{new_line}</span>" if i == 2
+    new_lines << new_line
+  end
+  new_lines.join("\n")
+end
+
+
+ +
+

+ + - (String) snippet(backtrace) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Extract lines of code corresponding to a backtrace.

+ + +
+
+
+

Parameters:

+
    + +
  • + + backtrace + + + (String) + + + + — +
    +

    the backtrace from a test failure

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    highlighted code snippet indicating where the test failure occured

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+39
+40
+41
+42
+43
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 39
+
+def snippet(backtrace)
+  raw_code, line = snippet_for(backtrace[0])
+  highlighted = @@converter.convert(raw_code)
+  post_process(highlighted, line)
+end
+
+
+ +
+

+ + - (String) snippet_for(error_line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Create a snippet from a line of code.

+ + +
+
+
+

Parameters:

+
    + +
  • + + error_line + + + (String) + + + + — +
    +

    file name with line number (i.e. 'foo_spec.rb:12')

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    lines around the target line within the file

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+53
+54
+55
+56
+57
+58
+59
+60
+61
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 53
+
+def snippet_for(error_line)
+  if error_line =~ /(.*):(\d+)/
+    file = Regexp.last_match[1]
+    line = Regexp.last_match[2].to_i
+    [lines_around(file, line), line]
+  else
+    ["# Couldn't get snippet for #{error_line}", 1]
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Hooks.html b/source/documentation/3.1/rspec-core/RSpec/Core/Hooks.html new file mode 100644 index 000000000..4e96379c5 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Hooks.html @@ -0,0 +1,1230 @@ + + + + + + Module: RSpec::Core::Hooks + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Hooks + + + +

+ +
+ + + + + + + +
Included in:
+
Configuration, ExampleGroup, World
+ + + +
Defined in:
+
lib/rspec/core/hooks.rb
+ +
+
+ +

Overview

+
+ +

Provides before, after and around +hooks as a means of supporting common setup and teardown. This module is +extended onto ExampleGroup, making the methods available from any +describe or context block and included in +Configuration, making them available off of the configuration object to +define global setup or teardown logic.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + + - (void) after(&block) + + - (void) after(scope, &block) + + - (void) after(scope, conditions, &block) + + - (void) after(conditions, &block) + + + + + Also known as: + prepend_after + + + + +

+
+ +
+ Note: +
+

The :example and :context scopes are also +available as :each and :all, respectively. Use +whichever you prefer.

+
+
+ + +

Declare a block of code to be run after each example (using +:example) or once after all examples n the context (using +:context). See #before for more information about ordering.

+ +

Exceptions

+ +

after hooks are guaranteed to run even when there are +exceptions in before hooks or examples. When an exception is +raised in an after block, the exception is captured for later reporting, +and subsequent after blocks are run.

+ +

Order

+ +

after hooks are stored in three scopes, which are run in +order: :example, :context, and +:suite. They can also be declared in several different places: +RSpec.configure, a parent group, the current group. They are +run in the following order:

+ +
after(:example) # declared in the current group
+after(:example) # declared in a parent group
+after(:example) # declared in RSpec.configure
+after(:context) # declared in the current group
+after(:context) # declared in a parent group
+after(:context) # declared in RSpec.configure
+after(:suite)   # declared in RSpec.configure
+ +

This is the reverse of the order in which before hooks are +run. Similarly, if more than one after is declared within any +one scope, they are run in reverse order of that in which they are +declared.

+ + +
+
+
+ +

Overloads:

+
    + + + +
  • + - (void) after(scope, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) after(scope, conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +after(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) after(conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +after(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+253
+254
+255
+
+
# File 'lib/rspec/core/hooks.rb', line 253
+
+def after(*args, &block)
+  hooks.register :prepend, :after, *args, &block
+end
+
+
+ +
+

+ + - (void) append_after(*args, &block) + + + + + +

+
+ +

Adds block to the back of the list of after +blocks in the same scope (:example, :context, or +:suite).

+ +

See #after for scoping semantics.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+263
+264
+265
+
+
# File 'lib/rspec/core/hooks.rb', line 263
+
+def append_after(*args, &block)
+  hooks.register :append, :after, *args, &block
+end
+
+
+ +
+

+ + + - (void) around(&block) + + - (void) around(scope, &block) + + - (void) around(scope, conditions, &block) + + - (void) around(conditions, &block) + + + + + + +

+
+ +
+ Note: +
+

the syntax of around is similar to that of before +and after but the semantics are quite different. +before and after hooks are run in the context of +of the examples with which they are associated, whereas around +hooks are actually responsible for running the examples. Consequently, +around hooks do not have direct access to resources that are +made available within the examples and their associated before +and after hooks.

+
+
+ +
+ Note: +
+

:example/:each is the only supported scope.

+
+
+ + +

Declare a block of code, parts of which will be run before and parts after +the example. It is your responsibility to run the example:

+ +
around(:example) do |ex|
+  # do some stuff before
+  ex.run
+  # do some stuff after
+end
+
+ +

The yielded example aliases run with call, which +lets you treat it like a Proc. This is especially handy when +working with libaries that manage their own setup and teardown using a +block or proc syntax, e.g.

+ +
around(:example) {|ex| Database.transaction(&ex)}
+around(:example) {|ex| FakeFS(&ex)}
+
+ + +
+
+
+ +

Overloads:

+
    + + + +
  • + - (void) around(scope, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example (defaults to :example) present for +syntax parity with before and after, but +:example/:each is the only supported value.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) around(scope, conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example (defaults to :example) present for +syntax parity with before and after, but +:example/:each is the only supported value.

      +
      + +
    • + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +around(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) around(conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +around(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example to run

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+316
+317
+318
+
+
# File 'lib/rspec/core/hooks.rb', line 316
+
+def around(*args, &block)
+  hooks.register :prepend, :around, *args, &block
+end
+
+
+ +
+

+ + + - (void) before(&block) + + - (void) before(scope, &block) + + - (void) before(scope, conditions, &block) + + - (void) before(conditions, &block) + + + + + Also known as: + append_before + + + + +

+
+ +
+ Note: +
+

The :example and :context scopes are also +available as :each and :all, respectively. Use +whichever you prefer.

+
+
+ + +

Declare a block of code to be run before each example (using +:example) or once before any example (using +:context). These are usually declared directly in the +ExampleGroup to which they apply, but they can also be shared across +multiple groups.

+ +

You can also use before(:suite) to run a block of code before +any example groups are run. This should be declared in RSpec.configure

+ +

Instance variables declared in before(:example) or +before(:context) are accessible within each example.

+ +

Order

+ +

before hooks are stored in three scopes, which are run in +order: :suite, :context, and +:example. They can also be declared in several different +places: RSpec.configure, a parent group, the current group. +They are run in the following order:

+ +
before(:suite)    # declared in RSpec.configure
+before(:context)  # declared in RSpec.configure
+before(:context)  # declared in a parent group
+before(:context)  # declared in the current group
+before(:example)  # declared in RSpec.configure
+before(:example)  # declared in a parent group
+before(:example)  # declared in the current group
+ +

If more than one before is declared within any one scope, they +are run in the order in which they are declared.

+ +

Conditions

+ +

When you add a conditions hash to before(:example) or +before(:context), RSpec will only apply that hook to groups or +examples that match the conditions. e.g.

+ +
RSpec.configure do |config|
+  config.before(:example, :authorized => true) do
+     :authorized_user
+  end
+end
+
+describe Something, :authorized => true do
+  # the before hook will run in before each example in this group
+end
+
+describe SomethingElse do
+  it "does something", :authorized => true do
+    # the before hook will run before this example
+  end
+
+  it "does something else" do
+    # the hook will not run before this example
+  end
+end
+
+ +

Warning: before(:suite, :with => :conditions)

+ +

The conditions hash is used to match against specific examples. Since +before(:suite) is not run in relation to any specific example +or group, conditions passed along with :suite are effectively +ignored.

+ +

Exceptions

+ +

When an exception is raised in a before block, RSpec skips any +subsequent before blocks and the example, but runs all of the +after(:example) and after(:context) hooks.

+ +

Warning: implicit before blocks

+ +

before hooks can also be declared in shared contexts which get +included implicitly either by you or by extension libraries. Since RSpec +runs these in the order in which they are declared within each scope, load +order matters, and can lead to confusing results when one before block +depends on state that is prepared in another before block that gets run +later.

+ +

Warning: before(:context)

+ +

It is very tempting to use before(:context) to speed things +up, but we recommend that you avoid this as there are a number of gotchas, +as well as things that simply don't work.

+ +

context

+ +

before(:context) is run in an example that is generated to +provide group context for the block.

+ +

instance variables

+ +

Instance variables declared in before(:context) are shared +across all the examples in the group. This means that each example can +change the state of a shared object, resulting in an ordering dependency +that can make it difficult to reason about failures.

+ +

unsupported rspec constructs

+ +

RSpec has several constructs that reset state between each example +automatically. These are not intended for use from within +before(:context):

+
  • +

    let declarations

    +
  • +

    subject declarations

    +
  • +

    Any mocking, stubbing or test double declaration

    +
+ +

other frameworks

+ +

Mock object frameworks and database transaction managers (like +ActiveRecord) are typically designed around the idea of setting up before +an example, running that one example, and then tearing down. This means +that mocks and stubs can (sometimes) be declared in +before(:context), but get torn down before the first real +example is ever run.

+ +

You can create database-backed model objects in a +before(:context) in rspec-rails, but it will not be wrapped in +a transaction for you, so you are on your own to clean up in an +after(:context) block.

+ + +
+
+
+ +
+

Examples:

+ + +

+

before(:example) declared in an ExampleGroup

+

+ +

+describe Thing do
+  before(:example) do
+    @thing = Thing.new
+  end
+
+  it "does something" do
+    # here you can access @thing
+  end
+end
+ + +

+

before(:context) declared in an ExampleGroup

+

+ +

+describe Parser do
+  before(:context) do
+    File.open(file_to_parse, 'w') do |f|
+      f.write <<-CONTENT
+        stuff in the file
+      CONTENT
+    end
+  end
+
+  it "parses the file" do
+    Parser.parse(file_to_parse)
+  end
+
+  after(:context) do
+    File.delete(file_to_parse)
+  end
+end
+ +
+ +

Overloads:

+
    + + + +
  • + - (void) before(scope, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) before(scope, conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +before(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) before(conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +before(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+184
+185
+186
+
+
# File 'lib/rspec/core/hooks.rb', line 184
+
+def before(*args, &block)
+  hooks.register :append, :before, *args, &block
+end
+
+
+ +
+

+ + - (void) prepend_before(*args, &block) + + + + + +

+
+ +

Adds block to the front of the list of before +blocks in the same scope (:example, :context, or +:suite).

+ +

See #before for scoping semantics.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+194
+195
+196
+
+
# File 'lib/rspec/core/hooks.rb', line 194
+
+def prepend_before(*args, &block)
+  hooks.register :prepend, :before, *args, &block
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers.html b/source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers.html new file mode 100644 index 000000000..27be27819 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers.html @@ -0,0 +1,603 @@ + + + + + + Module: RSpec::Core::MemoizedHelpers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::MemoizedHelpers + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/memoized_helpers.rb
+ +
+
+ +

Overview

+
+ +

This module is included in ExampleGroup, making the methods available to +be called from within example blocks.

+ + +
+
+
+ + +

See Also:

+ + +

Defined Under Namespace

+

+ + + Modules: ClassMethods + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (void) is_expected + + + + + +

+
+ +
+ Note: +
+

This only works if you are using rspec-expectations.

+
+
+ + +

Wraps the subject in expect to make it the target +of an expectation. Designed to read nicely for one-liners.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe [1, 2, 3] do
+  it { is_expected.to be_an Array }
+  it { is_expected.not_to include 4 }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+118
+119
+120
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 118
+
+def is_expected
+  expect(subject)
+end
+
+
+ +
+

+ + - (void) should(matcher = nil, message = nil) + + + + + +

+
+ +
+ Note: +
+

This only works if you are using rspec-expectations.

+
+
+ +
+ Note: +
+

If you are using RSpec's newer expect-based syntax you may want to use +is_expected.to instead of should.

+
+
+ + +

When should is called with no explicit receiver, the call is +delegated to the object returned by subject. Combined with an +implicit subject this supports very concise expressions.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe Person do
+  it { should be_eligible_to_vote }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+80
+81
+82
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 80
+
+def should(matcher=nil, message=nil)
+  RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
+end
+
+
+ +
+

+ + - (void) should_not(matcher = nil, message = nil) + + + + + +

+
+ +
+ Note: +
+

This only works if you are using rspec-expectations.

+
+
+ +
+ Note: +
+

If you are using RSpec's newer expect-based syntax you may want to use +is_expected.to_not instead of should_not.

+
+
+ + +

Just like should, should_not delegates to the +subject (implicit or explicit) of the example group.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe Person do
+  it { should_not be_eligible_to_vote }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+99
+100
+101
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 99
+
+def should_not(matcher=nil, message=nil)
+  RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
+end
+
+
+ +
+

+ + - (void) subject + + + + + +

+
+ +
+ Note: +
+

subject was contributed by Joe Ferris to support the one-liner +syntax embraced by shoulda matchers:

+ +
describe Widget do
+  it { is_expected.to validate_presence_of(:name) }
+  # or
+  it { should validate_presence_of(:name) }
+end
+ +

While the examples below demonstrate how to use subject +explicitly in examples, we recommend that you define a method with an +intention revealing name instead.

+
+
+ +
+ Note: +
+

Because subject is designed to create state that is reset +between each example, and before(:context) is designed to +setup state that is shared across all examples in an example +group, subject is not intended to be used in a +before(:context) hook.

+
+
+ + + +
+
+
+ +
+

Examples:

+ + +

+# explicit declaration of subject
+describe Person do
+  subject { Person.new(:birthdate => 19.years.ago) }
+  it "should be eligible to vote" do
+    subject.should be_eligible_to_vote
+    # ^ ^ explicit reference to subject not recommended
+  end
+end
+
+# implicit subject => { Person.new }
+describe Person do
+  it "should be eligible to vote" do
+    subject.should be_eligible_to_vote
+    # ^ ^ explicit reference to subject not recommended
+  end
+end
+
+# one-liner syntax - expectation is set on the subject
+describe Person do
+  it { is_expected.to be_eligible_to_vote }
+  # or
+  it { should be_eligible_to_vote }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 55
+
+def subject
+  __memoized.fetch(:subject) do
+    __memoized[:subject] = begin
+      described = described_class || self.class..fetch(:description_args).first
+      Class === described ? described.new : described
+    end
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html b/source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html new file mode 100644 index 000000000..b013c2806 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html @@ -0,0 +1,693 @@ + + + + + + Module: RSpec::Core::MemoizedHelpers::ClassMethods + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::MemoizedHelpers::ClassMethods + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/memoized_helpers.rb
+ +
+
+ +

Overview

+
+ +

This module is extended onto ExampleGroup, making the methods available +to be called from within example group blocks. You can think of them as +being analagous to class macros.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (void) let(name, &block) + + + + + +

+
+ +
+ Note: +
+

let can enhance readability when used sparingly (1,2, +or maybe 3 declarations) in any given example group, but that can quickly +degrade with overuse. YMMV.

+
+
+ +
+ Note: +
+

let uses an ||= conditional that has the +potential to behave in surprising ways in examples that spawn separate +threads, though we have yet to see this in practice. You've been +warned.

+
+
+ +
+ Note: +
+

Because let is designed to create state that is reset between +each example, and before(:context) is designed to setup state +that is shared across all examples in an example group, +let is not intended to be used in a +before(:context) hook.

+
+
+ + +

Generates a method whose return value is memoized after the first call. +Useful for reducing duplication between examples that assign values to the +same local variable.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe Thing do
+  let(:thing) { Thing.new }
+
+  it "does something" do
+    # first invocation, executes block, memoizes and returns result
+    thing.do_something
+
+    # second invocation, returns the memoized value
+    thing.should be_something
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 231
+
+def let(name, &block)
+  # We have to pass the block directly to `define_method` to
+  # allow it to use method constructs like `super` and `return`.
+  raise "#let or #subject called without a block" if block.nil?
+  MemoizedHelpers.module_for(self).__send__(:define_method, name, &block)
+
+  # Apply the memoization. The method has been defined in an ancestor
+  # module so we can use `super` here to get the value.
+  if block.arity == 1
+    define_method(name) { __memoized.fetch(name) { |k| __memoized[k] = super(RSpec.current_example, &nil) } }
+  else
+    define_method(name) { __memoized.fetch(name) { |k| __memoized[k] = super(&nil) } }
+  end
+end
+
+
+ +
+

+ + - (void) let!(name, &block) + + + + + +

+
+ +

Just like let, except the block is invoked by an implicit +before hook. This serves a dual purpose of setting up state +and providing a memoized reference to that state.

+ + +
+
+
+ +
+

Examples:

+ + +

+class Thing
+  def self.count
+    @count ||= 0
+  end
+
+  def self.count=(val)
+    @count += val
+  end
+
+  def self.reset_count
+    @count = 0
+  end
+
+  def initialize
+    self.class.count += 1
+  end
+end
+
+describe Thing do
+  after(:example) { Thing.reset_count }
+
+  context "using let" do
+    let(:thing) { Thing.new }
+
+    it "is not invoked implicitly" do
+      Thing.count.should eq(0)
+    end
+
+    it "can be invoked explicitly" do
+      thing
+      Thing.count.should eq(1)
+    end
+  end
+
+  context "using let!" do
+    let!(:thing) { Thing.new }
+
+    it "is invoked implicitly" do
+      Thing.count.should eq(1)
+    end
+
+    it "returns memoized version on first invocation" do
+      thing
+      Thing.count.should eq(1)
+    end
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+299
+300
+301
+302
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 299
+
+def let!(name, &block)
+  let(name, &block)
+  before { __send__(name) }
+end
+
+
+ +
+

+ + - (void) subject(name = nil, &block) + + + + + +

+
+ +

Declares a subject for an example group which can then be +wrapped with expect using is_expected to make it +the target of an expectation in a concise, one-line example.

+ +

Given a name, defines a method with that name which returns +the subject. This lets you declare the subject once and access +it implicitly in one-liners and explicitly using an intention revealing +name.

+ +

When given a name, calling super in the block is +not supported.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe CheckingAccount, "with $50" do
+  subject { CheckingAccount.new(Money.new(50, :USD)) }
+  it { is_expected.to have_a_balance_of(Money.new(50, :USD)) }
+  it { is_expected.not_to be_overdrawn }
+end
+
+describe CheckingAccount, "with a non-zero starting balance" do
+  subject(:account) { CheckingAccount.new(Money.new(50, :USD)) }
+  it { is_expected.not_to be_overdrawn }
+  it "has a balance equal to the starting balance" do
+    .balance.should eq(Money.new(50, :USD))
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String, Symbol) + + + (defaults to: nil) + + + — +
    +

    used to define an accessor with an intention revealing name

    +
    + +
  • + +
  • + + block + + + + + + + — +
    +

    defines the value to be returned by subject in examples

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 338
+
+def subject(name=nil, &block)
+  if name
+    let(name, &block)
+    alias_method :subject, name
+
+    self::NamedSubjectPreventSuper.__send__(:define_method, name) do
+      raise NotImplementedError, "`super` in named subjects is not supported"
+    end
+  else
+    let(:subject, &block)
+  end
+end
+
+
+ +
+

+ + - (void) subject!(name = nil, &block) + + + + + +

+
+ +

Just like subject, except the block is invoked by an implicit +before hook. This serves a dual purpose of setting up state +and providing a memoized reference to that state.

+ + +
+
+
+ +
+

Examples:

+ + +

+class Thing
+  def self.count
+    @count ||= 0
+  end
+
+  def self.count=(val)
+    @count += val
+  end
+
+  def self.reset_count
+    @count = 0
+  end
+
+  def initialize
+    self.class.count += 1
+  end
+end
+
+describe Thing do
+  after(:example) { Thing.reset_count }
+
+  context "using subject" do
+    subject { Thing.new }
+
+    it "is not invoked implicitly" do
+      Thing.count.should eq(0)
+    end
+
+    it "can be invoked explicitly" do
+      subject
+      Thing.count.should eq(1)
+    end
+  end
+
+  context "using subject!" do
+    subject!(:thing) { Thing.new }
+
+    it "is invoked implicitly" do
+      Thing.count.should eq(1)
+    end
+
+    it "returns memoized version on first invocation" do
+      subject
+      Thing.count.should eq(1)
+    end
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+404
+405
+406
+407
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 404
+
+def subject!(name=nil, &block)
+  subject(name, &block)
+  before { subject }
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Metadata.html b/source/documentation/3.1/rspec-core/RSpec/Core/Metadata.html new file mode 100644 index 000000000..c9eeb3f15 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Metadata.html @@ -0,0 +1,309 @@ + + + + + + Module: RSpec::Core::Metadata + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Metadata + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/metadata.rb
+ +
+
+ +

Overview

+
+ +

Each ExampleGroup class and Example instance owns an instance of Metadata, +which is Hash extended to support lazy evaluation of values associated with +keys that may or may not be used by any example or group.

+ +

In addition to metadata that is used internally, this also stores +user-supplied metadata, e.g.

+ +
describe Something, :type => :ui do
+  it "does something", :slow => true do
+    # ...
+  end
+end
+
+ +

:type => :ui is stored in the Metadata owned by the example +group, and :slow => true is stored in the Metadata owned by +the example. These can then be used to select which examples are run using +the --tag option on the command line, or several methods on +Configuration used to filter a run (e.g. +filter_run_including, filter_run_excluding, etc).

+ + +
+
+ +

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (String) relative_path(line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns relative path to line

+ + +
+
+
+

Parameters:

+
    + +
  • + + line + + + (String) + + + + — +
    +

    current code line

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    relative path to line

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+
+
# File 'lib/rspec/core/metadata.rb', line 32
+
+def self.relative_path(line)
+  # Matches strings either at the beginning of the input or prefixed with a whitespace,
+  # containing the current path, either postfixed with the separator, or at the end of the string.
+  # Match groups are the character before and the character after the string if any.
+  #
+  # http://rubular.com/r/fT0gmX6VJX
+  # http://rubular.com/r/duOrD4i3wb
+  # http://rubular.com/r/sbAMHFrOx1
+  #
+
+  regex = /(\A|\s)#{File.expand_path('.')}(#{File::SEPARATOR}|\s|\Z)/
+
+  line = line.sub(regex, "\\1.\\2")
+  line = line.sub(/\A([^:]+:\d+)$/, '\\1')
+  return nil if line == '-e:1'
+  line
+rescue SecurityError
+  nil
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/MetadataFilter.html b/source/documentation/3.1/rspec-core/RSpec/Core/MetadataFilter.html new file mode 100644 index 000000000..0aa271747 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/MetadataFilter.html @@ -0,0 +1,120 @@ + + + + + + Module: RSpec::Core::MetadataFilter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::MetadataFilter + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/metadata_filter.rb
+ +
+
+ +

Overview

+
+ +

Contains metadata filtering logic. This has been extracted from the +metadata classes because it operates ON a metadata hash but does not manage +any of the state in the hash. We're moving towards having metadata be a +raw hash (not a custom subclass), so externalizing this filtering logic +helps us move in that direction.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications.html new file mode 100644 index 000000000..a2e48bb2d --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications.html @@ -0,0 +1,127 @@ + + + + + + Module: RSpec::Core::Notifications + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Notifications + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

Notifications are value objects passed to formatters to provide them with +information about a particular event of interest.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: DeprecationNotification, ExampleNotification, ExamplesNotification, FailedExampleNotification, GroupNotification, MessageNotification, NullNotification, PendingExampleFixedNotification, ProfileNotification, SeedNotification, StartNotification, SummaryNotification + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html new file mode 100644 index 000000000..c6eb6672e --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html @@ -0,0 +1,498 @@ + + + + + + Class: RSpec::Core::Notifications::DeprecationNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::DeprecationNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The DeprecationNotification is issued by the reporter when a +deprecated part of RSpec is encountered. It represents information about +the deprecated call site.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (String) call_site + + + + + +

+
+ +

An optional call site from which the deprecation was issued

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of call_site

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+527
+528
+529
+
+
# File 'lib/rspec/core/notifications.rb', line 527
+
+def call_site
+  @call_site
+end
+
+
+ + + +
+

+ + - (String) deprecated + + + + + +

+
+ +

A custom message about the deprecation (alias of message)

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of deprecated

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+527
+528
+529
+
+
# File 'lib/rspec/core/notifications.rb', line 527
+
+def deprecated
+  @deprecated
+end
+
+
+ + + +
+

+ + - (String) message + + + + + +

+
+ +

A custom message about the deprecation

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+527
+528
+529
+
+
# File 'lib/rspec/core/notifications.rb', line 527
+
+def message
+  @message
+end
+
+
+ + + +
+

+ + - (String) replacement + + + + + +

+
+ +

An optional replacement for the deprecation

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of replacement

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+527
+528
+529
+
+
# File 'lib/rspec/core/notifications.rb', line 527
+
+def replacement
+  @replacement
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExampleNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExampleNotification.html new file mode 100644 index 000000000..d8c7c6544 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExampleNotification.html @@ -0,0 +1,248 @@ + + + + + + Class: RSpec::Core::Notifications::ExampleNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::ExampleNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The ExampleNotification represents notifications sent by the +reporter which contain information about the current (or soon to be) +example. It is used by formatters to access information about that example.

+ + +
+
+
+ +
+

Examples:

+ + +
def example_started(notification)
+  puts "Hey I started #{notification.example.description}"
+end
+ +
+ + +
+

Direct Known Subclasses

+

FailedExampleNotification

+
+ + + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::Example) example + + + + + +

+
+ +

the current example

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/rspec/core/notifications.rb', line 35
+
+def example
+  @example
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html new file mode 100644 index 000000000..b0921bfab --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html @@ -0,0 +1,861 @@ + + + + + + Class: RSpec::Core::Notifications::ExamplesNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::ExamplesNotification + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The ExamplesNotification represents notifications sent by the +reporter which contain information about the suites examples.

+ + +
+
+
+ +
+

Examples:

+ + +
def stop(notification)
+  puts "Hey I ran #{notification.examples.size}"
+end
+ +
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ExamplesNotification) initialize(reporter) + + + + + +

+
+ +

Returns a new instance of ExamplesNotification

+ + +
+
+
+ + +
+ + + + +
+
+
+
+58
+59
+60
+
+
# File 'lib/rspec/core/notifications.rb', line 58
+
+def initialize(reporter)
+  @reporter = reporter
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Array(RSpec::Core::Example)) examples + + + + + +

+
+ +

Returns list of examples

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+63
+64
+65
+
+
# File 'lib/rspec/core/notifications.rb', line 63
+
+def examples
+  @reporter.examples
+end
+
+
+ +
+

+ + - (Array(RSpec::Core::Example)) failed_examples + + + + + +

+
+ +

Returns list of failed examples

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+68
+69
+70
+
+
# File 'lib/rspec/core/notifications.rb', line 68
+
+def failed_examples
+  @reporter.failed_examples
+end
+
+
+ +
+

+ + - (Array(Rspec::Core::Notifications::FailedExampleNotification] +returns failed examples as notifications) failure_notifications + + + + + +

+
+ +

Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed +examples as notifications

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(Rspec::Core::Notifications::FailedExampleNotification] +returns failed examples as notifications) + + + + — +
    +

    Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed +examples as notifications

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+85
+86
+87
+
+
# File 'lib/rspec/core/notifications.rb', line 85
+
+def failure_notifications
+  @failed_notifications ||= format_examples(failed_examples)
+end
+
+
+ +
+

+ + - (String) fully_formatted_failed_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns The list of failed examples, fully formatted in the way that +RSpec's built-in formatters emit.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The list of failed examples, fully formatted in the way that RSpec's +built-in formatters emit.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+91
+92
+93
+94
+95
+96
+97
+98
+99
+
+
# File 'lib/rspec/core/notifications.rb', line 91
+
+def fully_formatted_failed_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
+  formatted = "\nFailures:\n"
+
+  failure_notifications.each_with_index do |failure, index|
+    formatted << failure.fully_formatted(index.next, colorizer)
+  end
+
+  formatted
+end
+
+
+ +
+

+ + - (String) fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns The list of pending examples, fully formatted in the way that +RSpec's built-in formatters emit.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The list of pending examples, fully formatted in the way that RSpec's +built-in formatters emit.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+
+
# File 'lib/rspec/core/notifications.rb', line 103
+
+def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
+  formatted = "\nPending:\n"
+
+  pending_examples.each do |example|
+    formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location)
+
+    formatted <<
+      "  #{colorizer.wrap(example.full_description, :pending)}\n" \
+      "    # #{colorizer.wrap(example.execution_result.pending_message, :detail)}\n" \
+      "    # #{colorizer.wrap(formatted_caller, :detail)}\n"
+  end
+
+  formatted
+end
+
+
+ +
+

+ + - (Array(Rspec::Core::Notifications::ExampleNotification] +returns examples as notifications) notifications + + + + + +

+
+ +

Array(Rspec::Core::Notifications::ExampleNotification] returns examples as +notifications

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(Rspec::Core::Notifications::ExampleNotification] +returns examples as notifications) + + + + — +
    +

    Array(Rspec::Core::Notifications::ExampleNotification] returns examples as +notifications

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+79
+80
+81
+
+
# File 'lib/rspec/core/notifications.rb', line 79
+
+def notifications
+  @notifications ||= format_examples(examples)
+end
+
+
+ +
+

+ + - (Array(RSpec::Core::Example)) pending_examples + + + + + +

+
+ +

Returns list of pending examples

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+73
+74
+75
+
+
# File 'lib/rspec/core/notifications.rb', line 73
+
+def pending_examples
+  @reporter.pending_examples
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html new file mode 100644 index 000000000..62717fe8c --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html @@ -0,0 +1,937 @@ + + + + + + Class: RSpec::Core::Notifications::FailedExampleNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::FailedExampleNotification + + + +

+ +
+ +
Inherits:
+
+ ExampleNotification + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The FailedExampleNotification extends +ExampleNotification with things useful for failed specs.

+ + +
+
+
+ +
+

Examples:

+ + +
def example_failed(notification)
+  puts "Hey I failed :("
+  puts "Here's my stack trace"
+  puts notification.exception.backtrace.join("\n")
+end
+ +
+ + +

See Also:

+ + +
+

Direct Known Subclasses

+

PendingExampleFixedNotification

+
+ + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::Example) example + + + + + +

+
+ +

the current example

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+139
+140
+141
+
+
# File 'lib/rspec/core/notifications.rb', line 139
+
+def example
+  @example
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Array(String)) colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns the failures colorized formatted backtrace.

+ + +
+
+
+

Parameters:

+
    + +
  • + + colorizer + + + (#wrap) + + + (defaults to: ::RSpec::Core::Formatters::ConsoleCodes) + + + — +
    +

    An object to colorize the message_lines by

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    the examples colorized backtrace lines

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+180
+181
+182
+183
+184
+
+
# File 'lib/rspec/core/notifications.rb', line 180
+
+def colorized_formatted_backtrace(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
+  formatted_backtrace.map do |backtrace_info|
+    colorizer.wrap "# #{backtrace_info}", RSpec.configuration.detail_color
+  end
+end
+
+
+ +
+

+ + - (Array(String)) colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns the message generated for this failure colorized line by line.

+ + +
+
+
+

Parameters:

+
    + +
  • + + colorizer + + + (#wrap) + + + (defaults to: ::RSpec::Core::Formatters::ConsoleCodes) + + + — +
    +

    An object to colorize the message_lines by

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message colorized

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+163
+164
+165
+166
+167
+
+
# File 'lib/rspec/core/notifications.rb', line 163
+
+def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
+  add_shared_group_line(failure_lines, colorizer).map do |line|
+    colorizer.wrap line, RSpec.configuration.failure_color
+  end
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+ +

Returns The example description

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The example description

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+148
+149
+150
+
+
# File 'lib/rspec/core/notifications.rb', line 148
+
+def description
+  example.full_description
+end
+
+
+ +
+

+ + - (Exception) exception + + + + + +

+
+ +

Returns The example failure

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Exception) + + + + — +
    +

    The example failure

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+143
+144
+145
+
+
# File 'lib/rspec/core/notifications.rb', line 143
+
+def exception
+  example.execution_result.exception
+end
+
+
+ +
+

+ + - (Array(String)) formatted_backtrace + + + + + +

+
+ +

Returns the failures formatted backtrace.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    the examples backtrace lines

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+172
+173
+174
+
+
# File 'lib/rspec/core/notifications.rb', line 172
+
+def formatted_backtrace
+  backtrace_formatter.format_backtrace(exception.backtrace, example.)
+end
+
+
+ +
+

+ + - (String) fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns The failure information fully formatted in the way that RSpec's +built-in formatters emit.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The failure information fully formatted in the way that RSpec's +built-in formatters emit.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+
+
# File 'lib/rspec/core/notifications.rb', line 188
+
+def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
+  formatted = "\n  #{failure_number}) #{description}\n"
+
+  colorized_message_lines(colorizer).each do |line|
+    formatted << RSpec::Support::EncodedString.new("     #{line}\n", encoding_of(formatted))
+  end
+
+  colorized_formatted_backtrace(colorizer).each do |line|
+    formatted << RSpec::Support::EncodedString.new("     #{line}\n", encoding_of(formatted))
+  end
+
+  formatted
+end
+
+
+ +
+

+ + - (Array(String)) message_lines + + + + + +

+
+ +

Returns the message generated for this failure line by line.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+155
+156
+157
+
+
# File 'lib/rspec/core/notifications.rb', line 155
+
+def message_lines
+  add_shared_group_line(failure_lines, NullColorizer)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/GroupNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/GroupNotification.html new file mode 100644 index 000000000..51fdaab5c --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/GroupNotification.html @@ -0,0 +1,245 @@ + + + + + + Class: RSpec::Core::Notifications::GroupNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::GroupNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The GroupNotification represents notifications sent by the +reporter which contain information about the currently running (or soon to +be) example group It is used by formatters to access information about that +group.

+ + +
+
+
+ +
+

Examples:

+ + +
def example_group_started(notification)
+  puts "Hey I started #{notification.group.description}"
+end
+ +
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::ExampleGroup) group + + + + + +

+
+ +

the current group

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+327
+328
+329
+
+
# File 'lib/rspec/core/notifications.rb', line 327
+
+def group
+  @group
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/MessageNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/MessageNotification.html new file mode 100644 index 000000000..650419a57 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/MessageNotification.html @@ -0,0 +1,233 @@ + + + + + + Class: RSpec::Core::Notifications::MessageNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::MessageNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The MessageNotification encapsulates generic messages that the +reporter sends to formatters.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (String) message + + + + + +

+
+ +

the message

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+333
+334
+335
+
+
# File 'lib/rspec/core/notifications.rb', line 333
+
+def message
+  @message
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/NullNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/NullNotification.html new file mode 100644 index 000000000..f88095f0b --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/NullNotification.html @@ -0,0 +1,133 @@ + + + + + + Class: RSpec::Core::Notifications::NullNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::NullNotification + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

NullNotification represents a placeholder value for +notifications that currently require no information, but we may wish to +extend in future.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html new file mode 100644 index 000000000..cfd395eb0 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html @@ -0,0 +1,550 @@ + + + + + + Class: RSpec::Core::Notifications::PendingExampleFixedNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::PendingExampleFixedNotification + + + +

+ +
+ +
Inherits:
+
+ FailedExampleNotification + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The PendingExampleFixedNotification extends +ExampleNotification with things useful for specs that pass +when they are expected to fail.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from FailedExampleNotification

+

#colorized_formatted_backtrace, #exception, #formatted_backtrace, #fully_formatted

+ + + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::Example) example + + + + + +

+
+ +

the current example

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+292
+293
+294
+
+
# File 'lib/rspec/core/notifications.rb', line 292
+
+def example
+  @example
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Array(String)) colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns the message generated for this failure colorized line by line.

+ + +
+
+
+

Parameters:

+
    + +
  • + + colorizer + + + (#wrap) + + + (defaults to: ::RSpec::Core::Formatters::ConsoleCodes) + + + — +
    +

    An object to colorize the message_lines by

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message colorized

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+313
+314
+315
+
+
# File 'lib/rspec/core/notifications.rb', line 313
+
+def colorized_message_lines(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
+  message_lines.map { |line| colorizer.wrap(line, RSpec.configuration.fixed_color) }
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+ +

Returns the examples description

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The example description

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+298
+299
+300
+
+
# File 'lib/rspec/core/notifications.rb', line 298
+
+def description
+  "#{example.full_description} FIXED"
+end
+
+
+ +
+

+ + - (Array(String)) message_lines + + + + + +

+
+ +

Returns the message generated for this failure line by line.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+305
+306
+307
+
+
# File 'lib/rspec/core/notifications.rb', line 305
+
+def message_lines
+  ["Expected pending '#{example.execution_result.pending_message}' to fail. No Error was raised."]
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ProfileNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ProfileNotification.html new file mode 100644 index 000000000..12acab5a8 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/ProfileNotification.html @@ -0,0 +1,410 @@ + + + + + + Class: RSpec::Core::Notifications::ProfileNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::ProfileNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The ProfileNotification holds information about the results of +running a test suite when profiling is enabled. It is used by formatters to +provide information at the end of the test run for profiling information.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Float) duration + + + + + +

+
+ +

the time taken (in seconds) to run the suite

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of duration

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+461
+462
+463
+
+
# File 'lib/rspec/core/notifications.rb', line 461
+
+def duration
+  @duration
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) examples + + + + + +

+
+ +

the examples run

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+461
+462
+463
+
+
# File 'lib/rspec/core/notifications.rb', line 461
+
+def examples
+  @examples
+end
+
+
+ + + +
+

+ + - (Fixnum) number_of_examples + + + + + +

+
+ +

the number of examples to profile

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    the current value of number_of_examples

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+461
+462
+463
+
+
# File 'lib/rspec/core/notifications.rb', line 461
+
+def number_of_examples
+  @number_of_examples
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SeedNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SeedNotification.html new file mode 100644 index 000000000..df9a2baf3 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SeedNotification.html @@ -0,0 +1,321 @@ + + + + + + Class: RSpec::Core::Notifications::SeedNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::SeedNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The SeedNotification holds the seed used to randomize examples +and wether that seed has been used or not.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Fixnum) seed + + + + + +

+
+ +

the seed used to randomize ordering

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    the current value of seed

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+340
+341
+342
+
+
# File 'lib/rspec/core/notifications.rb', line 340
+
+def seed
+  @seed
+end
+
+
+ + + +
+

+ + - (Boolean) used + + + + + +

+
+ +

wether the seed has been used or not

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    the current value of used

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+340
+341
+342
+
+
# File 'lib/rspec/core/notifications.rb', line 340
+
+def used
+  @used
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/StartNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/StartNotification.html new file mode 100644 index 000000000..5c8407897 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/StartNotification.html @@ -0,0 +1,322 @@ + + + + + + Class: RSpec::Core::Notifications::StartNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::StartNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The StartNotification represents a notification sent by the +reporter when the suite is started. It contains the expected amount of +examples to be executed, and the load time of RSpec.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Fixnum) count + + + + + +

+
+ +

the number counted

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    the current value of count

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/core/notifications.rb', line 23
+
+def count
+  @count
+end
+
+
+ + + +
+

+ + - (Float) load_time + + + + + +

+
+ +

the number of seconds taken to boot RSpec and load the spec files

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of load_time

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/core/notifications.rb', line 23
+
+def load_time
+  @load_time
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SummaryNotification.html b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SummaryNotification.html new file mode 100644 index 000000000..a40f731bb --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Notifications/SummaryNotification.html @@ -0,0 +1,586 @@ + + + + + + Class: RSpec::Core::Notifications::SummaryNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::SummaryNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The SummaryNotification holds information about the results of +running a test suite. It is used by formatters to provide information at +the end of the test run.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Float) duration + + + + + +

+
+ +

the time taken (in seconds) to run the suite

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of duration

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+365
+366
+367
+
+
# File 'lib/rspec/core/notifications.rb', line 365
+
+def duration
+  @duration
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) examples + + + + + +

+
+ +

the examples run

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+365
+366
+367
+
+
# File 'lib/rspec/core/notifications.rb', line 365
+
+def examples
+  @examples
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) failed_examples + + + + + +

+
+ +

the failed examples

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(RSpec::Core::Example)) + + + + — +
    +

    the current value of failed_examples

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+365
+366
+367
+
+
# File 'lib/rspec/core/notifications.rb', line 365
+
+def failed_examples
+  @failed_examples
+end
+
+
+ + + +
+

+ + - (Float) load_time + + + + + +

+
+ +

the number of seconds taken to boot RSpec and load the spec files

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of load_time

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+365
+366
+367
+
+
# File 'lib/rspec/core/notifications.rb', line 365
+
+def load_time
+  @load_time
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) pending_examples + + + + + +

+
+ +

the pending examples

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(RSpec::Core::Example)) + + + + — +
    +

    the current value of pending_examples

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+365
+366
+367
+
+
# File 'lib/rspec/core/notifications.rb', line 365
+
+def pending_examples
+  @pending_examples
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Pending.html b/source/documentation/3.1/rspec-core/RSpec/Core/Pending.html new file mode 100644 index 000000000..5c1030d86 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Pending.html @@ -0,0 +1,469 @@ + + + + + + Module: RSpec::Core::Pending + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Pending + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/pending.rb
+ +
+
+ +

Overview

+
+ +

Provides methods to mark examples as pending. These methods are available +to be called from within any example or hook.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: SkipDeclaredInExample + + +

+ +

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + + - (void) pending + + - (void) pending(message) + + + + + + +

+
+ +
+ Note: +
+

before(:example) hooks are eval'd when you use the +pending method within an example. If you want to declare an +example pending and bypass the before hooks as +well, you can pass :pending => true to the it +method:

+ +
it "does something", :pending => true do
+  # ...
+end
+
+ +

or pass :pending => "something else getting +finished" to add a message to the summary report:

+ +
it "does something", :pending => "something else getting finished" do
+  # ...
+end
+
+
+
+ + +

Marks an example as pending. The rest of the example will still be +executed, and if it passes the example will fail to indicate that the +pending can be removed.

+ + +
+
+
+ +
+

Examples:

+ + +
describe "an example" do
+  # reported as "Pending: no reason given"
+  it "is pending with no message" do
+    pending
+    raise "broken"
+  end
+
+  # reported as "Pending: something else getting finished"
+  it "is pending with a custom message" do
+    pending("something else getting finished")
+    raise "broken"
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + message + + + (String) + + + (defaults to: nil) + + + — +
    +

    optional message to add to the summary report.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+
+
# File 'lib/rspec/core/pending.rb', line 68
+
+def pending(message=nil)
+  current_example = RSpec.current_example
+
+  if block_given?
+    raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '')
+      |The semantics of `RSpec::Core::Pending#pending` have changed in
+      |RSpec 3.  In RSpec 2.x, it caused the example to be skipped. In
+      |RSpec 3, the rest of the example is still run but is expected to
+      |fail, and will be marked as a failure (rather than as pending) if
+      |the example passes.
+      |
+      |Passing a block within an example is now deprecated. Marking the
+      |example as pending provides the same behavior in RSpec 3 which was
+      |provided only by the block in RSpec 2.x.
+      |
+      |Move the code in the block provided to `pending` into the rest of
+      |the example body.
+      |
+      |Called from #{CallerFilter.first_non_rspec_line}.
+      |
+    EOS
+  elsif current_example
+    Pending.mark_pending! current_example, message
+  else
+    raise "`pending` may not be used outside of examples, such as in " \
+          "before(:context). Maybe you want `skip`?"
+  end
+end
+
+
+ +
+

+ + + - (void) skip + + - (void) skip(message) + + + + + + +

+
+ +

Marks an example as pending and skips execution.

+ + +
+
+
+ +
+

Examples:

+ + +
describe "an example" do
+  # reported as "Pending: no reason given"
+  it "is skipped with no message" do
+    skip
+  end
+
+  # reported as "Pending: something else getting finished"
+  it "is skipped with a custom message" do
+    skip "something else getting finished"
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + message + + + (String) + + + (defaults to: nil) + + + — +
    +

    optional message to add to the summary report.

    +
    + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+116
+117
+118
+119
+120
+121
+122
+
+
# File 'lib/rspec/core/pending.rb', line 116
+
+def skip(message=nil)
+  current_example = RSpec.current_example
+
+  Pending.mark_skipped!(current_example, message) if current_example
+
+  raise SkipDeclaredInExample.new(message)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html b/source/documentation/3.1/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html new file mode 100644 index 000000000..ae87b0289 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html @@ -0,0 +1,299 @@ + + + + + + Exception: RSpec::Core::Pending::SkipDeclaredInExample + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Exception: RSpec::Core::Pending::SkipDeclaredInExample + + + +

+ +
+ +
Inherits:
+
+ StandardError + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/pending.rb
+ +
+
+ +

Overview

+
+ +

Raised in the middle of an example to indicate that it should be marked as +skipped.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + +
+

Constructor Details

+ +
+

+ + - (SkipDeclaredInExample) initialize(argument) + + + + + +

+
+ +

Returns a new instance of SkipDeclaredInExample

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/core/pending.rb', line 10
+
+def initialize(argument)
+  @argument = argument
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) argument (readonly) + + + + + +

+
+ +

Returns the value of attribute argument

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/core/pending.rb', line 8
+
+def argument
+  @argument
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/RakeTask.html b/source/documentation/3.1/rspec-core/RSpec/Core/RakeTask.html new file mode 100644 index 000000000..cae0e63b0 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/RakeTask.html @@ -0,0 +1,942 @@ + + + + + + Class: RSpec::Core::RakeTask + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::RakeTask + + + +

+ +
+ +
Inherits:
+
+ Rake::TaskLib + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + +
Includes:
+
Rake::DSL
+ + + + + +
Defined in:
+
lib/rspec/core/rake_task.rb
+ +
+
+ +

Overview

+
+ +

Rspec rake task

+ + +
+
+
+ + +

See Also:

+
    + +
  • Rakefile
  • + +
+ +
+

Constant Summary

+ +
+ +
DEFAULT_RSPEC_PATH = +
+
+ +

Default path to the rspec executable

+ + +
+
+
+ + +
+
+
File.expand_path('../../../../exe/rspec', __FILE__)
+ +
DEFAULT_PATTERN = +
+
+ +

Default pattern for spec files.

+ + +
+
+
+ + +
+
+
'spec/**{,/*/**}/*_spec.rb'
+ +
+ + + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Constructor Details

+ +
+

+ + - (RakeTask) initialize(*args, &task_block) + + + + + +

+
+ +

Returns a new instance of RakeTask

+ + +
+
+
+ + +
+ + + + +
+
+
+
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+
+
# File 'lib/rspec/core/rake_task.rb', line 71
+
+def initialize(*args, &task_block)
+  @name          = args.shift || :spec
+  @ruby_opts     = nil
+  @rspec_opts    = nil
+  @verbose       = true
+  @fail_on_error = true
+  @rspec_path    = DEFAULT_RSPEC_PATH
+  @pattern       = DEFAULT_PATTERN
+
+  define(args, &task_block)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) exclude_pattern + + + + + +

+
+ +

Files matching this pattern will be excluded.

+ +

default: 'spec/*_/__spec.rb'

+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/rspec/core/rake_task.rb', line 35
+
+def exclude_pattern
+  @exclude_pattern
+end
+
+
+ + + +
+

+ + - (void) fail_on_error + + + + + +

+
+ +

Whether or not to fail Rake when an error occurs (typically when examples +fail).

+ +

default: true

+ + +
+
+
+ + +
+ + + + +
+
+
+
+41
+42
+43
+
+
# File 'lib/rspec/core/rake_task.rb', line 41
+
+def fail_on_error
+  @fail_on_error
+end
+
+
+ + + +
+

+ + - (void) failure_message + + + + + +

+
+ +

A message to print to stderr when there are failures.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+44
+45
+46
+
+
# File 'lib/rspec/core/rake_task.rb', line 44
+
+def failure_message
+  @failure_message
+end
+
+
+ + + +
+

+ + - (void) name + + + + + +

+
+ +

Name of task.

+ +

default: :spec

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/core/rake_task.rb', line 23
+
+def name
+  @name
+end
+
+
+ + + +
+

+ + - (void) pattern + + + + + +

+
+ +

Files matching this pattern will be loaded.

+ +

default: 'spec/,///_spec.rb'

+ + +
+
+
+ + +
+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'lib/rspec/core/rake_task.rb', line 29
+
+def pattern
+  @pattern
+end
+
+
+ + + +
+

+ + - (void) rspec_opts + + + + + +

+
+ +

Command line options to pass to rspec.

+ +

default: nil

+ + +
+
+
+ + +
+ + + + +
+
+
+
+69
+70
+71
+
+
# File 'lib/rspec/core/rake_task.rb', line 69
+
+def rspec_opts
+  @rspec_opts
+end
+
+
+ + + +
+

+ + - (void) rspec_path + + + + + +

+
+ +

Path to rspec

+ +

default: 'rspec'

+ + +
+
+
+ + +
+ + + + +
+
+
+
+63
+64
+65
+
+
# File 'lib/rspec/core/rake_task.rb', line 63
+
+def rspec_path
+  @rspec_path
+end
+
+
+ + + +
+

+ + - (void) ruby_opts + + + + + +

+
+ +

Command line options to pass to ruby.

+ +

default: nil

+ + +
+
+
+ + +
+ + + + +
+
+
+
+57
+58
+59
+
+
# File 'lib/rspec/core/rake_task.rb', line 57
+
+def ruby_opts
+  @ruby_opts
+end
+
+
+ + + +
+

+ + - (void) verbose + + + + + +

+
+ +

Use verbose output. If this is set to true, the task will print the +executed spec command to stdout.

+ +

default: true

+ + +
+
+
+ + +
+ + + + +
+
+
+
+51
+52
+53
+
+
# File 'lib/rspec/core/rake_task.rb', line 51
+
+def verbose
+  @verbose
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Reporter.html b/source/documentation/3.1/rspec-core/RSpec/Core/Reporter.html new file mode 100644 index 000000000..dbf6a5aa5 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Reporter.html @@ -0,0 +1,468 @@ + + + + + + Class: RSpec::Core::Reporter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Reporter + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/reporter.rb
+ +
+
+ +

Overview

+
+ +

A reporter will send notifications to listeners, usually formatters for the +spec suite run.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Reporter) initialize(configuration) + + + + + +

+
+ +

Returns a new instance of Reporter

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+12
+
+
# File 'lib/rspec/core/reporter.rb', line 5
+
+def initialize(configuration)
+  @configuration = configuration
+  @listeners = Hash.new { |h, k| h[k] = Set.new }
+  @examples = []
+  @failed_examples = []
+  @pending_examples = []
+  @duration = @start = @load_time = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) register_listener(listener, *notifications) + + + + + +

+
+ +

Registers a listener to a list of notifications. The reporter will send +notification of events to all registered listeners

+ + +
+
+
+

Parameters:

+
    + +
  • + + listener + + + (Object) + + + + — +
    +

    An obect that wishes to be notified of reporter events

    +
    + +
  • + +
  • + + notifications + + + (Array) + + + + — +
    +

    Array of symbols represents the events a listener wishes to subscribe too

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+
+
# File 'lib/rspec/core/reporter.rb', line 22
+
+def register_listener(listener, *notifications)
+  notifications.each do |notification|
+    @listeners[notification.to_sym] << listener
+  end
+  true
+end
+
+
+ +
+

+ + + - (void) report(count, &block) + + - (void) report(count, &block) + + + + + + +

+
+ +

Initializes the report run and yields itself for further reporting. The +block is required, so that the reporter can manage cleaning up after the +run.

+ + +
+
+
+ +
+

Examples:

+ + +

+reporter.report(group.examples.size) do |r|
+  example_groups.map {|g| g.run(r) }
+end
+ +
+

Parameters:

+
    + +
  • + + expected_example_count + + + (Integer) + + + + — +
    +

    the number of examples being run

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Block) + + + + — +
    +

    block yields itself for further reporting.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+50
+51
+52
+53
+54
+55
+56
+57
+
+
# File 'lib/rspec/core/reporter.rb', line 50
+
+def report(expected_example_count)
+  start(expected_example_count)
+  begin
+    yield self
+  ensure
+    finish
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Runner.html b/source/documentation/3.1/rspec-core/RSpec/Core/Runner.html new file mode 100644 index 000000000..d3f25b8d6 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Runner.html @@ -0,0 +1,929 @@ + + + + + + Class: RSpec::Core::Runner + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Runner + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/runner.rb
+ +
+
+ +

Overview

+
+ +

Provides the main entry point to run a suite of RSpec examples.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Runner) initialize(options, configuration = RSpec.configuration, world = RSpec.world) + + + + + +

+
+ +

Returns a new instance of Runner

+ + +
+
+
+ + +
+ + + + +
+
+
+
+73
+74
+75
+76
+77
+
+
# File 'lib/rspec/core/runner.rb', line 73
+
+def initialize(options, configuration=RSpec.configuration, world=RSpec.world)
+  @options       = options
+  @configuration = configuration
+  @world         = world
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (void) autorun + + + + + +

+
+ +
+ Note: +
+

This is not generally needed. The rspec command takes care of +running examples for you without involving an at_exit hook. +This is only needed if you are running specs using the ruby +command, and even then, the normal way to invoke this is by requiring +rspec/autorun.

+
+
+ + +

Register an at_exit hook that runs the suite when the process +exits.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+
+
# File 'lib/rspec/core/runner.rb', line 12
+
+def self.autorun
+  if autorun_disabled?
+    RSpec.deprecate("Requiring `rspec/autorun` when running RSpec via the `rspec` command")
+    return
+  elsif installed_at_exit? || running_in_drb?
+    return
+  end
+
+  at_exit do
+    # Don't bother running any specs and just let the program terminate
+    # if we got here due to an unrescued exception (anything other than
+    # SystemExit, which is raised when somebody calls Kernel#exit).
+    next unless $!.nil? || $!.is_a?(SystemExit)
+
+    # We got here because either the end of the program was reached or
+    # somebody called Kernel#exit.  Run the specs and then override any
+    # existing exit status with RSpec's exit status if any specs failed.
+    invoke
+  end
+  @installed_at_exit = true
+end
+
+
+ +
+

+ + + (void) invoke + + + + + +

+
+ +

Runs the suite of specs and exits the process with an appropriate exit +code.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+38
+39
+
+
# File 'lib/rspec/core/runner.rb', line 35
+
+def self.invoke
+  disable_autorun!
+  status = run(ARGV, $stderr, $stdout).to_i
+  exit(status) if status != 0
+end
+
+
+ +
+

+ + + (Fixnum) run(args, err = $stderr, out = $stdout) + + + + + +

+
+ +

Run a suite of RSpec examples. Does not exit.

+ +

This is used internally by RSpec to run a suite, but is available for use +by any other automation tool.

+ +

If you want to run this multiple times in the same process, and you want +files like spec_helper.rb to be reloaded, be sure to load +load instead of require.

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array) + + + + — +
    +

    command-line-supported arguments

    +
    + +
  • + +
  • + + err + + + (IO) + + + (defaults to: $stderr) + + + — +
    +

    error stream

    +
    + +
  • + +
  • + + out + + + (IO) + + + (defaults to: $stdout) + + + — +
    +

    output stream

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    exit status code. 0 if all specs passed, or the configured failure exit +code (1 by default) if specs failed.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+
+
# File 'lib/rspec/core/runner.rb', line 56
+
+def self.run(args, err=$stderr, out=$stdout)
+  trap_interrupt
+  options = ConfigurationOptions.new(args)
+
+  if options.options[:drb]
+    require 'rspec/core/drb'
+    begin
+      DRbRunner.new(options).run(err, out)
+    rescue DRb::DRbConnError
+      err.puts "No DRb server is running. Running in local process instead ..."
+      new(options).run(err, out)
+    end
+  else
+    new(options).run(err, out)
+  end
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (void) run(err, out) + + + + + +

+
+ +

Configures and runs a spec suite.

+ + +
+
+
+

Parameters:

+
    + +
  • + + err + + + (IO) + + + + — +
    +

    error stream

    +
    + +
  • + +
  • + + out + + + (IO) + + + + — +
    +

    output stream

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+83
+84
+85
+86
+
+
# File 'lib/rspec/core/runner.rb', line 83
+
+def run(err, out)
+  setup(err, out)
+  run_specs(@world.ordered_example_groups)
+end
+
+
+ +
+

+ + - (Fixnum) run_specs(example_groups) + + + + + +

+
+ +

Runs the provided example groups.

+ + +
+
+
+

Parameters:

+ + +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    exit status code. 0 if all specs passed, or the configured failure exit +code (1 by default) if specs failed.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+
+
# File 'lib/rspec/core/runner.rb', line 106
+
+def run_specs(example_groups)
+  @configuration.reporter.report(@world.example_count(example_groups)) do |reporter|
+    begin
+      hook_context = SuiteHookContext.new
+      @configuration.hooks.run(:before, :suite, hook_context)
+      example_groups.map { |g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
+    ensure
+      @configuration.hooks.run(:after, :suite, hook_context)
+    end
+  end
+end
+
+
+ +
+

+ + - (void) setup(err, out) + + + + + +

+
+ +

Wires together the various configuration objects and state holders.

+ + +
+
+
+

Parameters:

+
    + +
  • + + err + + + (IO) + + + + — +
    +

    error stream

    +
    + +
  • + +
  • + + out + + + (IO) + + + + — +
    +

    output stream

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+92
+93
+94
+95
+96
+97
+98
+
+
# File 'lib/rspec/core/runner.rb', line 92
+
+def setup(err, out)
+  @configuration.error_stream = err
+  @configuration.output_stream = out if @configuration.output_stream == $stdout
+  @options.configure(@configuration)
+  @configuration.load_spec_files
+  @world.announce_filters
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/SharedContext.html b/source/documentation/3.1/rspec-core/RSpec/Core/SharedContext.html new file mode 100644 index 000000000..5fe962fbf --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/SharedContext.html @@ -0,0 +1,136 @@ + + + + + + Module: RSpec::Core::SharedContext + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::SharedContext + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/shared_context.rb
+ +
+
+ +

Overview

+
+ +

Exposes ExampleGroup-level methods to a module, so you can include that +module in an ExampleGroup.

+ + +
+
+
+ +
+

Examples:

+ + +

+module LoggedInAsAdmin
+  extend RSpec::Core::SharedContext
+  before(:example) do
+     :admin
+  end
+end
+
+describe "admin section" do
+  include LoggedInAsAdmin
+  # ...
+end
+ +
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup.html b/source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup.html new file mode 100644 index 000000000..f62f144e2 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup.html @@ -0,0 +1,457 @@ + + + + + + Module: RSpec::Core::SharedExampleGroup + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::SharedExampleGroup + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/shared_example_group.rb
+ +
+
+ +

Overview

+
+ +

Shared example groups let you define common context and/or common examples +that you wish to use in multiple example groups.

+ +

When defined, the shared group block is stored for later evaluation. It can +later be included in an example group either explicitly (using +include_examples, include_context or +it_behaves_like) or implicitly (via matching metadata).

+ +

Named shared example groups are scoped based on where they are defined. +Shared groups defined in an example group are available for inclusion in +that example group or any child example groups, but not in any parent or +sibling example groups. Shared example groups defined at the top level can +be included from any example group.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: TopLevelDSL + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + + - (void) shared_examples(name, &block) + + - (void) shared_examples(name, metadata, &block) + + - (void) shared_examples(metadata, &block) + + + + + Also known as: + shared_context, shared_examples_for + + + + +

+
+ +

Stores the block for later use. The block will be evaluated in the context +of an example group via include_examples, +include_context, or it_behaves_like.

+ + +
+
+
+ +
+

Examples:

+ + +
shared_examples "auditable" do
+  it "stores an audit record on save!" do
+    expect { auditable.save! }.to change(Audit, :count).by(1)
+  end
+end
+
+describe Account do
+  it_behaves_like "auditable" do
+    let(:auditable) { Account.new }
+  end
+end
+ +
+ +

Overloads:

+
    + + +
  • + - (void) shared_examples(name, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String, Symbol, Module) + + + + — +
      +

      identifer to use when looking up this shared group

      +
      + +
    • + +
    • + + block + + + + + + + — +
      +

      The block to be eval'd

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) shared_examples(name, metadata, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String, Symbol, Module) + + + + — +
      +

      identifer to use when looking up this shared group

      +
      + +
    • + +
    • + + metadata + + + (Array<Symbol>, Hash) + + + + — +
      +

      metadata to attach to this group; any example group with matching metadata +will automatically include this shared example group.

      +
      + +
    • + +
    • + + block + + + + + + + — +
      +

      The block to be eval'd

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) shared_examples(metadata, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + metadata + + + (Array<Symbol>, Hash) + + + + — +
      +

      metadata to attach to this group; any example group with matching metadata +will automatically include this shared example group.

      +
      + +
    • + +
    • + + block + + + + + + + — +
      +

      The block to be eval'd

      +
      + +
    • + +
    + + +
    +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+
+
# File 'lib/rspec/core/shared_example_group.rb', line 50
+
+def shared_examples(name, *args, &block)
+  top_level = self == ExampleGroup
+  if top_level && RSpec.[:in_example_group]
+    raise "Creating isolated shared examples from within a context is " \
+          "not allowed. Remove `RSpec.` prefix or move this to a " \
+          "top-level scope."
+  end
+
+  RSpec.world.shared_example_group_registry.add(self, name, *args, &block)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html b/source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html new file mode 100644 index 000000000..084056623 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html @@ -0,0 +1,295 @@ + + + + + + Module: RSpec::Core::SharedExampleGroup::TopLevelDSL + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::SharedExampleGroup::TopLevelDSL + + + Private +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/shared_example_group.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+ +

Shared examples top level DSL

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (void) expose_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Adds the top level DSL methods to Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+86
+87
+88
+89
+90
+
+
# File 'lib/rspec/core/shared_example_group.rb', line 86
+
+def self.expose_globally!
+  return if exposed_globally?
+  Core::DSL.change_global_dsl(&definitions)
+  @exposed_globally = true
+end
+
+
+ +
+

+ + + (void) remove_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Removes the top level DSL methods to Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+
+
# File 'lib/rspec/core/shared_example_group.rb', line 95
+
+def self.remove_globally!
+  return unless exposed_globally?
+
+  Core::DSL.change_global_dsl do
+    undef shared_examples
+    undef shared_context
+    undef shared_examples_for
+  end
+
+  @exposed_globally = false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/Version.html b/source/documentation/3.1/rspec-core/RSpec/Core/Version.html new file mode 100644 index 000000000..9ca7fbe29 --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/Version.html @@ -0,0 +1,139 @@ + + + + + + Module: RSpec::Core::Version + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Version + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/version.rb
+ +
+
+ +

Overview

+
+ +

Version information for RSpec Core.

+ + +
+
+
+ + +
+

Constant Summary

+ +
+ +
STRING = +
+
+ +

Current version of RSpec Core, in semantic versioning format.

+ + +
+
+
+ + +
+
+
'3.1.7'
+ +
+ + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/RSpec/Core/World.html b/source/documentation/3.1/rspec-core/RSpec/Core/World.html new file mode 100644 index 000000000..f216d078b --- /dev/null +++ b/source/documentation/3.1/rspec-core/RSpec/Core/World.html @@ -0,0 +1,980 @@ + + + + + + Class: RSpec::Core::World + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::World + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Hooks
+ + + + + +
Defined in:
+
lib/rspec/core/world.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

Internal container for global non-configuration data

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Hooks

+

#after, #append_after, #around, #before, #prepend_before

+
+

Constructor Details

+ +
+

+ + - (World) initialize(configuration = RSpec.configuration) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of World

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+
+
# File 'lib/rspec/core/world.rb', line 17
+
+def initialize(configuration=RSpec.configuration)
+  @configuration = configuration
+  @example_groups = []
+  @filtered_examples = Hash.new do |hash, group|
+    hash[group] = begin
+      examples = group.examples.dup
+      examples = filter_manager.prune(examples)
+      examples.uniq!
+      examples
+    end
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) wants_to_quit + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Used internally to determine what to do when a SIGINT is received

+ + +
+
+
+ + +
+ + + + +
+
+
+
+15
+16
+17
+
+
# File 'lib/rspec/core/world.rb', line 15
+
+def wants_to_quit
+  @wants_to_quit
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) announce_exclusion_filter(announcements) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Add exclusion filters to announcement message

+ + +
+
+
+ + +
+ + + + +
+
+
+
+168
+169
+170
+171
+172
+
+
# File 'lib/rspec/core/world.rb', line 168
+
+def announce_exclusion_filter(announcements)
+  return if exclusion_filter.empty?
+
+  announcements << "exclude #{exclusion_filter.description}"
+end
+
+
+ +
+

+ + - (void) announce_filters + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Notify reporter of filters

+ + +
+
+
+ + +
+ + + + +
+
+
+
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+
+
# File 'lib/rspec/core/world.rb', line 115
+
+def announce_filters
+  filter_announcements = []
+
+  announce_inclusion_filter filter_announcements
+  announce_exclusion_filter filter_announcements
+
+  unless filter_manager.empty?
+    if filter_announcements.length == 1
+      reporter.message("Run options: #{filter_announcements[0]}")
+    else
+      reporter.message("Run options:\n  #{filter_announcements.join("\n  ")}")
+    end
+  end
+
+  if @configuration.run_all_when_everything_filtered? && example_count.zero?
+    reporter.message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}")
+    filtered_examples.clear
+    inclusion_filter.clear
+  end
+
+  return unless example_count.zero?
+
+  example_groups.clear
+  if filter_manager.empty?
+    reporter.message("No examples found.")
+  elsif exclusion_filter.empty?
+    message = everything_filtered_message
+    if @configuration.run_all_when_everything_filtered?
+      message << "; ignoring #{inclusion_filter.description}"
+    end
+    reporter.message(message)
+  elsif inclusion_filter.empty?
+    reporter.message(everything_filtered_message)
+  end
+end
+
+
+ +
+

+ + - (void) announce_inclusion_filter(announcements) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Add inclusion filters to announcement message

+ + +
+
+
+ + +
+ + + + +
+
+
+
+159
+160
+161
+162
+163
+
+
# File 'lib/rspec/core/world.rb', line 159
+
+def announce_inclusion_filter(announcements)
+  return if inclusion_filter.empty?
+
+  announcements << "include #{inclusion_filter.description}"
+end
+
+
+ +
+

+ + - (void) example_count(groups = example_groups) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Get count of examples to be run

+ + +
+
+
+ + +
+ + + + +
+
+
+
+93
+94
+95
+96
+
+
# File 'lib/rspec/core/world.rb', line 93
+
+def example_count(groups=example_groups)
+  FlatMap.flat_map(groups) { |g| g.descendants }.
+    inject(0) { |a, e| a + e.filtered_examples.size }
+end
+
+
+ +
+

+ + - (void) ordered_example_groups + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Apply ordering strategy from configuration to example groups

+ + +
+
+
+ + +
+ + + + +
+
+
+
+44
+45
+46
+47
+
+
# File 'lib/rspec/core/world.rb', line 44
+
+def ordered_example_groups
+  ordering_strategy = @configuration.ordering_registry.fetch(:global)
+  ordering_strategy.order(@example_groups)
+end
+
+
+ +
+

+ + - (void) preceding_declaration_line(filter_line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Find line number of previous declaration

+ + +
+
+
+ + +
+ + + + +
+
+
+
+101
+102
+103
+104
+105
+
+
# File 'lib/rspec/core/world.rb', line 101
+
+def preceding_declaration_line(filter_line)
+  declaration_line_numbers.sort.inject(nil) do |highest_prior_declaration_line, line|
+    line <= filter_line ? line : highest_prior_declaration_line
+  end
+end
+
+
+ +
+

+ + - (void) register(example_group) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Register an example group

+ + +
+
+
+ + +
+ + + + +
+
+
+
+65
+66
+67
+68
+
+
# File 'lib/rspec/core/world.rb', line 65
+
+def register(example_group)
+  example_groups << example_group
+  example_group
+end
+
+
+ +
+

+ + - (void) reset + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Reset world to 'scratch' before running suite

+ + +
+
+
+ + +
+ + + + +
+
+
+
+52
+53
+54
+55
+
+
# File 'lib/rspec/core/world.rb', line 52
+
+def reset
+  example_groups.clear
+  @shared_example_group_registry = nil
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/_index.html b/source/documentation/3.1/rspec-core/_index.html new file mode 100644 index 000000000..4dc82f799 --- /dev/null +++ b/source/documentation/3.1/rspec-core/_index.html @@ -0,0 +1,557 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Documentation by YARD 0.8.7.6

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
    +
  • H
  • +
      + +
    • + Helpers + + (RSpec::Core::Formatters) + +
    • + +
    • + Hooks + + (RSpec::Core) + +
    • + +
    +
+ + +
+ + +
    +
  • L
  • +
      + +
    • + Loader + + (RSpec::Core::Formatters) + +
    • + +
    +
+ + + + + + + + + + + +
    +
  • R
  • + +
+ + + + + +
    +
  • T
  • +
      + +
    • + TopLevelDSL + + (RSpec::Core::SharedExampleGroup) + +
    • + +
    +
+ + +
    +
  • V
  • +
      + +
    • + Version + + (RSpec::Core) + +
    • + +
    +
+ + +
+ + +
    +
  • W
  • +
      + +
    • + World + + (RSpec::Core) + +
    • + +
    +
+ +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/class_list.html b/source/documentation/3.1/rspec-core/class_list.html new file mode 100644 index 000000000..3aa45b86d --- /dev/null +++ b/source/documentation/3.1/rspec-core/class_list.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + Class List + + + + +
+

Class List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-core/file.Changelog.html b/source/documentation/3.1/rspec-core/file.Changelog.html new file mode 100644 index 000000000..056d9c848 --- /dev/null +++ b/source/documentation/3.1/rspec-core/file.Changelog.html @@ -0,0 +1,2566 @@ + + + + + + File: Changelog + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

3.1.8 Development

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Apply --seed before loading --require files so +that required files can access the provided seed. (Myron Marston, #1745)

    +
  • +

    Handle +RSpec::Core::Formatters::DeprecationFormatter::FileStream +being reopened with an IO stream, which sometimes happens with spring. +(Kevin Mook, #1757)

    +
+ +

3.1.7 / 2014-10-11

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix Metadata.relative_path so that for a current directory of +/foo/bar, /foo/bar_1 is not wrongly converted to +._1. (Akos Vandra, #1730)

    +
  • +

    Prevent constant lookup mistakenly finding +RSpec::ExampleGroups generated constants on 1.9.2 by +appending a trailing _ to the generated names. (Jon Rowe, +#1737)

    +
  • +

    Fix bug in :pending metadata. If it got set in any way besides +passing it as part of the metadata literal passed to it (such +as by using define_derived_metadata), it did not have the +desired effect, instead marking the example as :passed. +(Myron Marston, #1739)

    +
+ +

3.1.6 / 2014-10-08

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix regression in rake task pattern handling, that prevented patterns that +were relative from the current directory rather than from spec +from working properly. (Myron Marston, #1734)

    +
  • +

    Prevent rake task from generating duplicate load path entries. (Myron +Marston, #1735)

    +
+ +

3.1.5 / 2014-09-29

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix issue with the rake task incorrectly escaping strings on Windows. (Jon +Rowe #1718)

    +
  • +

    Support absolute path patterns. While this wasn't officially supported +previously, setting rake_task.pattern to an absolute path +pattern in RSpec 3.0 and before worked since it delegated to +FileList internally (but now just forwards the pattern on to +the rspec command). (Myron Marston, #1726)

    +
+ +

3.1.4 / 2014-09-18

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix implicit subject when using describe false or +describe nil so that it returns the provided primitive rather +than the string representation. (Myron Marston, #1710)

    +
  • +

    Fix backtrace filtering to allow code in subdirectories of your current +working directory (such as vendor/bundle/…) to be filtered from +backtraces. (Myron Marston, #1708)

    +
+ +

3.1.3 / 2014-09-15

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix yet another regression in rake task pattern handling, to allow +task.pattern = FileList["..."] to work. That was never +intended to be supported but accidentally worked in 3.0 and earlier. +(Myron Marston, #1701)

    +
  • +

    Fix pattern handling so that files are normalized to absolute paths before +subtracting the --exclude-pattern matched files from the +--pattern matched files so that it still works even if the +patterns are in slightly different forms (e.g. one starting with +./). (Christian Nelson, #1698)

    +
+ +

3.1.2 / 2014-09-08

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix another regression in rake task pattern handling, so that patterns +that start with ./ still work. (Christian Nelson, #1696)

    +
+ +

3.1.1 / 2014-09-05

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix a regression in rake task pattern handling, so that +rake_task.pattern = array works again. While we never +intended to support array values (or even knew that worked!), the +implementation from 3.0 and earlier used FileList internally, +which allows arrays. The fix restores the old behavior. (Myron Marston, +#1694)

    +
+ +

3.1.0 / 2014-09-04

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Update files generated by rspec --init so that warnings are +enabled in commented out section of spec_helper rather than +.rspec so users have to consciously opt-in to the setting. +(Andrew Hooker, #1572)

    +
  • +

    Update spec_helper generated by rspec --init so +that it sets the new rspec-expectations +include_chain_clauses_in_custom_matcher_descriptions config +option (which will be on by default in RSpec 4) and also sets the +rspec-mocks verify_partial_doubles option (which will also +default to on in RSpec 4). (Myron Marston, #1647)

    +
  • +

    Provide an inspect output for example procsy objects (used in +around hooks) that doesn't make them look like procs. (Jon Rowe, +#1620)

    +
  • +

    Remove a few unneeded require statements from +rspec/core/rake_task.rb, making it even more lighterweight. +(Myron Marston, #1640)

    +
  • +

    Allow rspec-core to be used when neither rspec-mocks or rspec-expectations +are installed, without requiring any user configuration. (Sam Phippen, +Myron Marston, #1615)

    +
  • +

    Don't filter out gems from backtraces by default. (The RSpec gems will +still be filtered). User feedback has indicated that including gems in +default backtraces will be useful. (Myron Marston, #1641)

    +
  • +

    Add new config.filter_gems_from_backtrace "rack", +"rake" API to easily filter the named gems from +backtraces. (Myron Marston, #1682)

    +
  • +

    Fix default backtrace filters so that the RSpec binary is excluded when +installing RSpec as a bundler :git dependency. (Myron +Marston, #1648)

    +
  • +

    Simplify command generated by the rake task so that it no longer includes +unnecessary -S. (Myron Marston, #1559)

    +
  • +

    Add --exclude-pattern CLI option, config.exclude_pattern += config option and task.exclude_pattern = rake task +config option. Matching files will be excluded. (John Gesimondo, Myron +Marston, #1651, #1671)

    +
  • +

    When an around hook fails to execute the example, mark it as pending +(rather than passing) so the user is made aware of the fact that the +example did not actually run. (Myron Marston, #1660)

    +
  • +

    Remove dependency on FileUtils from the standard library so +that users do not get false positives where their code relies on it but +they are not requiring it. (Sam Phippen, #1565)

    +
+ +

Bug Fixes:

+
  • +

    Fix rake task t.pattern = option so that it does not run all +specs when it matches no files, by passing along a --pattern +option to the rspec command, rather than resolving the file +list and passing along the files individually. (Evgeny Zislis, #1653)

    +
  • +

    Fix rake task default pattern so that it follows symlinks properly. (Myron +Marston, #1672)

    +
  • +

    Fix default pattern used with rspec command so that it follows +symlinks properly. (Myron Marston, #1672)

    +
  • +

    Change how we assign constant names to example group classes so that it +avoids a problem with describe "Core". (Daniela +Wellisz, #1679)

    +
  • +

    Handle rendering exceptions that have a different encoding than that of +their original source file. (Jon Rowe, #1681)

    +
  • +

    Allow access to message_lines without colour for failed examples even when +they're part of a shared example group. (tomykaira, #1689)

    +
+ +

3.0.4 / 2014-08-14

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix processing order of CLI options so that if +config.files_to_run is accessed from a file loaded by +--require, --pattern is still applied. (Myron +Marston, #1652)

    +
  • +

    Fix config.pattern= so that it still takes affect even if +config.files_to_run has already been accessed. (Myron Marston, +#1652)

    +
+ +

3.0.3 / 2014-07-21

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Properly convert both parts of a description into strings before +concatenation. (@nicklink483, #1636)

    +
  • +

    Exclude the working directory when figuring out folders to ignore. (Jon +Rowe, Myron Marston, #1616)

    +
  • +

    Allow +::RSpec::Core::Notifications::FailedExampleNotification#message_lines +to be accessed without a colouriser. (@tomykaira, #1637)

    +
+ +

3.0.2 / 2014-06-19

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix regression in CLI option handling that prevented --tag +slow passed at the command line from overriding --tag +~slow in .rspec. (Colin Jones, #1602)

    +
  • +

    Fix metadata :example_group deprecation warning so that it +gets issued at the call site of the configuration that specified it as a +filter rather than later when an example group is defined. (Myron Marston, +#1562)

    +
  • +

    Make the line that is printed when a shared example group fails indicating +where the concrete example group is white, separating it from the stack +trace that is produced for the failure. (Sam Phippen, Jon Rowe, #1606)

    +
+ +

3.0.1 / 2014-06-12

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix a couple ruby warnings caused by rspec-core when loaded. (Prem +Sichanugrist, #1584)

    +
  • +

    Example groups named Config will no longer cause a Ruby +warning to be issued. (Jimmy Cuadra, #1580)

    +
+ +

3.0.0 / 2014-06-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix BaseTextFormatter so that it does not re-close a closed +output stream. (Myron Marston)

    +
  • +

    Fix regression in metadata that caused the metadata hash of a top-level +example group to have a :parent_example_group key even though +it has no parent example group. (Myron Marston)

    +
+ +

Enhancements:

+
  • +

    Alter the default spec_helper.rb to no longer recommend +config.full_backtrace = true see #1536 for discussion. (Jon +Rowe)

    +
+ +

3.0.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Change described_class so that in a nested group like +describe MyClass, it returns MyClass rather +than the outer group's described class. (Myron Marston)

    +
  • +

    Refactor filter manager so that it no longer subclasses Hash and has a +tighter, more domain-specific interface. (Sergey Pchelincev)

    +
  • +

    Remove legacy colours definitions from BaseTextFormatter. (Jon +Rowe)

    +
  • +

    Remove console color definitions from BaseTextFormatter. (Jon +Rowe)

    +
  • +

    Restructure example group metadata so that the computed keys are exposed +directly off of the metadata hash rather than being on a nested +:example_group subhash. In addition, the parent example group +metadata is now available as [:parent_example_group] rather +than [:example_group][:example_group]. Deprecated access via +the old key structure is still provided. (Myron Marston)

    +
  • +

    Remove :describes metadata key. It duplicates +:described_class for no good reason. Deprecated access via +:describes is still provided. (Myron Marston)

    +
  • +

    Rename :example_group_block metadata key to +:block. (Myron Marston)

    +
  • +

    Remove deprecated RSpec::Core::Example#options. (Myron +Marston)

    +
  • +

    Move BaseTextFormatter#colorize_summary to +SummaryNotification#colorize_with (Jon Rowe).

    +
  • +

    describe some_hash treated some_hash as metadata +in RSpec 2.x but will treat it as the described object in RSpec 3.0. +Metadata must always come after the description args. (Myron Marston)

    +
  • +

    Remove deprecated display_name alias of +ExampleGroup.description. (Myron Marston)

    +
  • +

    Remove deprecated describes alias of +ExampleGroup.described_class. (Myron Marston)

    +
  • +

    Remove deprecated +RSpec::Core::ExampleGroup.alias_it_behaves_like_to. Use +RSpec::Core::Configuration#alias_it_behaves_like_to instead. +(Myron Marston)

    +
  • +

    Remove deprecated RSpec::Core::ExampleGroup.alias_example_to. +Use RSpec::Core::Configuration#alias_example_to instead. +(Myron Marston)

    +
  • +

    Removed focused example alias and change example/group aliases +fit, focus, fcontext and +fdescribe to no longer include :focused => +true metadata. They only contain :focus => true +metadata now. This means that you will need to filter them with +filter_run :focus, not filter_run :focused. +(Myron Marston)

    +
  • +

    Remove --line-number filtering. It's semantically dubious +since it's a global filter (potentially applied to multiple files) but +there's no meaningful connection between the same line number in +multiple files. Instead use the rspec path/to/spec.rb:23:46 +form, which is terser and makes more sense as it is scoped to a file. +(Myron Marston)

    +
  • +

    Remove --default_path as an alias for +--default-path. (Jon Rowe)

    +
  • +

    Remove deprecated share_examples_for. There's still +shared_examples and shared_examples_for. (Myron +Marston)

    +
  • +

    Rename RSpec::Core::Configuration#warnings to +RSpec::Core::Configuration#warnings? since it's a boolean +flag. (Myron Marston)

    +
  • +

    RSpec's global state is no longer reset after a spec run. This gives +more flexibility to alternate runners to decide when and if they want the +state reset. Alternate runners are now responsible for calling this (or +doing a similar reset) if they are going to run the spec suite multiple +times in the same process. (Sam Phippen)

    +
  • +

    Merge RSpec::Core::CommandLine (never formally declared +public) into RSpec::Core::Runner. (Myron Marston)

    +
  • +

    Remove color_enabled as an alias of color. (Jon +Rowe)

    +
  • +

    Remove backtrace_cleaner as an alias of +backtrace_formatter. (Jon Rowe)

    +
  • +

    Remove filename_pattern as an alias of pattern. +(Jon Rowe)

    +
  • +

    Extract support for legacy formatters to +rspec-legacy_formatters. (Jon Rowe)

    +
  • +

    RSpec::Configuration#formatters now returns a dup to prevent +mutation. (Jon Rowe)

    +
  • +

    Replace stdlib as an available expectation framework with +test_unit and minitest. (Aaron Kromer)

    +
  • +

    Remove backtrace formatting helpers from BaseTextFormatter. +(Jon Rowe)

    +
  • +

    Extract profiler support to ProfileFormatter and +ProfileNotification. Formatters should implement +dump_profile if they wish to respond to +--profile. (Jon Rowe)

    +
  • +

    Extract remaining formatter state to reporter and notifications. Introduce +ExamplesNotification to share information about examples that +was previously held in BaseFormatter. (Jon Rowe)

    +
+ +

Enhancements:

+
  • +

    Add config.default_formatter attribute, which can be used to +set a formatter which will only be used if no other formatter is set +(e.g. via --formatter). (Myron Marston)

    +
  • +

    Support legacy colour definitions in LegacyFormatterAdaptor. +(Jon Rowe)

    +
  • +

    Migrate execution_result (exposed by metadata) from a hash to +a first-class object with appropriate attributes. status is +now stored and returned as a symbol rather than a string. It retains +deprecated hash behavior for backwards compatibility. (Myron Marston)

    +
  • +

    Provide console code helper for formatters. (Jon Rowe)

    +
  • +

    Use raw ruby hashes for the metadata hashes rather than a subclass of a +hash. Computed metadata entries are now computed in advance rather than +being done lazily on first access. (Myron Marston)

    +
  • +

    Add :block metadata entry to the example metadata, bringing +parity with :block in the example group metadata. (Myron +Marston)

    +
  • +

    Add fspecify and fexample as aliases of +specify and example with :focus => +true metadata for parity with fit. (Myron Marston)

    +
  • +

    Add legacy support for colorize_summary. (Jon Rowe)

    +
  • +

    Restructure runner so it can be more easily customized in a subclass for +an alternate runner. (Ben Hoskings)

    +
  • +

    Document RSpec::Core::ConfigurationOptions as an officially +supported public API. (Myron Marston)

    +
  • +

    Add --deprecation-out CLI option which directs deprecation +warnings to the named file. (Myron Marston)

    +
  • +

    Minitest 5 compatability for expect_with :stdlib (now +available as expect_with :minitest). (Xavier Shay)

    +
  • +

    Reporter now notifies formatters of the load time of RSpec and your specs +via StartNotification and SummaryNotification. +(Jon Rowe)

    +
  • +

    Add disable_monkey_patching! config option that disables all +monkey patching from whatever pieces of RSpec you use. (Alexey Fedorov)

    +
  • +

    Add Pathname support for setting all output streams. (Aaron +Kromer)

    +
  • +

    Add config.define_derived_metadata, which can be used to apply +additional metadata to all groups or examples that match a given filter. +(Myron Marston)

    +
  • +

    Provide formatted and colorized backtraces via +FailedExampleNotification and send +PendingExampleFixedNotifications when the error is due to a +passing spec you expect to fail. (Jon Rowe)

    +
  • +

    Add dump_profile to formatter API to allow formatters to +implement support for --profile. (Jon Rowe)

    +
  • +

    Allow colourising text via ConsoleCodes with RSpec +'states' (e.g. :success, :failure) +rather than direct colour codes. (Jon Rowe)

    +
  • +

    Expose fully_formatted methods off the formatter notification +objects that make it easy for a custom formatter to produce formatted +output like rspec-core's. (Myron Marston)

    +
+ +

Bug Fixes:

+
  • +

    Fix spec_helper.rb file generated by rspec --init +so that the recommended settings correctly use the documentation formatter +when running one file. (Myron Marston)

    +
  • +

    Fix ordering problem where descriptions were generated after tearing down +mocks, which resulted in unexpected exceptions. (Bradley Schaefer, Aaron +Kromer, Andrey Savchenko)

    +
  • +

    Allow a symbol to be used as an implicit subject (e.g. describe +:foo). (Myron Marston)

    +
  • +

    Prevent creating an isolated context (i.e. using +RSpec.describe) when already inside a context. There is no +reason to do this, and it could potentially cause unexpected bugs. (Xavier +Shay)

    +
  • +

    Fix shared example group scoping so that when two shared example groups +share the same name at different levels of nested contexts, the one in the +nearest context is used. (Myron Marston)

    +
  • +

    Fix --warnings option so that it enables warnings immediately +so that it applies to files loaded by --require. (Myron +Marston)

    +
  • +

    Issue a warning when you set config.deprecation_stream too +late for it to take effect because the reporter has already been setup. +(Myron Marston)

    +
  • +

    Add the full RSpec::Core::Example interface to the argument +yielded to around hooks. (Myron Marston)

    +
  • +

    Line number always takes precendence when running specs with filters. +(Xavier Shay)

    +
  • +

    Ensure :if and :unless metadata filters are treated as a special case and +are always in-effect. (Bradley Schaefer)

    +
  • +

    Ensure the currently running installation of RSpec is used when the rake +task shells out to rspec, even if a newer version is also +installed. (Postmodern)

    +
  • +

    Using a legacy formatter as default no longer causes an infinite loop. +(Xavier Shay)

    +
+ +

3.0.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Make mock_with option more strict. Strings are no longer +supported (e.g. mock_with "mocha") – use a symbol +instead. Also, unrecognized values will now result in an error rather than +falling back to the null mocking adapter. If you want to use the null +mocking adapter, use mock_with :nothing (as has been +documented for a long time). (Myron Marston)

    +
  • +

    Remove support for overriding RSpec's built-in :if and +:unless filters. (Ashish Dixit)

    +
  • +

    Custom formatters are now required to call +RSpec::Core::Formatters.register(formatter_class, +*notifications) where notifications is the list of +events the formatter wishes to be notified about. Notifications are +handled by methods matching the names on formatters. This allows us to add +or remove notifications without breaking existing formatters. (Jon Rowe)

    +
  • +

    Change arguments passed to formatters. Rather than passing multiple +arguments (which limits are ability to add additional arguments as doing +so would break existing formatters), we now pass a notification value +object that exposes the same data via attributes. This will allow us to +add new bits of data to a notification event without breaking existing +formatters. (Jon Rowe)

    +
  • +

    Remove support for deprecated :alias option for +RSpec.configuration.add_setting. (Myron Marston)

    +
  • +

    Remove support for deprecated RSpec.configuration.requires = +[...]. (Myron Marston)

    +
  • +

    Remove support for deprecated --formatter CLI option. (Myron +Marston)

    +
  • +

    Remove support for deprecated --configure CLI option. (Myron +Marston)

    +
  • +

    Remove support for deprecated +RSpec::Core::RakeTask#spec_opts=. (Myron Marston)

    +
  • +

    An example group level pending block or :pending +metadata now executes the example and cause a failure if it passes, +otherwise it will be pending if it fails. The old “never run” behaviour is +still used for xexample, xit, and +xspecify, or via a new skip method or +:skip metadata option. (Xavier Shay)

    +
  • +

    After calling pending inside an example, the remainder of the +example will now be run. If it passes a failure is raised, otherwise the +example is marked pending. The old “never run” behaviour is provided a by +a new skip method. (Xavier Shay)

    +
  • +

    Pending blocks inside an example have been removed as a feature with no +direct replacement. Use skip or pending without a +block. (Xavier Shay)

    +
  • +

    Pending statement is no longer allowed in before(:all) hooks. +Use skip instead. (Xavier Shay)

    +
  • +

    Remove show_failures_in_pending_blocks configuration option. +(Xavier Shay)

    +
  • +

    Remove support for specifying the documentation formatter using +'s', 'n', 'spec' or 'nested'. (Jon Rowe)

    +
+ +

Enhancements:

+
  • +

    Add example run time to JSON formatter output. (Karthik Kastury)

    +
  • +

    Add more suggested settings to the files generated by rspec +--init. (Myron Marston)

    +
  • +

    Add config.alias_example_group_to, which can be used to define +a new method that defines an example group with the provided metadata. +(Michi Huber)

    +
  • +

    Add xdescribe and xcontext as shortcuts to skip +an example group. (Myron Marston)

    +
  • +

    Add fdescribe and fcontext as shortcuts to focus +an example group. (Myron Marston)

    +
  • +

    Don't autorun specs via #at_exit by default. require +'rspec/autorun' is only needed when running specs via +ruby, as it always has been. Running specs via +rake or rspec are both unaffected. (Ben Hoskings)

    +
  • +

    Add expose_dsl_globally config option, defaulting to true. +When disabled it will remove the monkey patches rspec-core adds to +main and Module (e.g. describe, +shared_examples_for, etc). (Jon Rowe)

    +
  • +

    Expose RSpec DSL entry point methods (describe, +shared_examples_for, etc) on the RSpec constant. +Intended for use when expose_dsl_globally is set to +false. (Jon Rowe)

    +
  • +

    For consistency, expose all example group aliases (including +context) on the RSpec constant. If +expose_dsl_globally is set to true, also expose +them on main and Module. Historically, only +describe was exposed. (Jon Rowe, Michi Huber)

    +
  • +

    Add hook scope :example as an alias for :each, +and :context as an alias for :all. (John +Feminella)

    +
+ +

Bug Fixes:

+
  • +

    Fix failure (undefined method path) in end-of-run summary +when raise_errors_for_deprecations! is configured. (Myron +Marston)

    +
  • +

    Issue error when attempting to use -i or --I on +command line, too close to -I to be considered short hand for +--init. (Jon Rowe)

    +
  • +

    Prevent adding formatters to an output target if the same formatter has +already been added to that output. (Alex Peattie)

    +
  • +

    Allow a matcher-generated example description to be used when the example +is pending. (Myron Marston)

    +
  • +

    Ensure the configured failure_exit_code is used by the rake +task when there is a failure. (Jon Rowe)

    +
  • +

    Restore behaviour whereby system exclusion filters take priority over +working directory (was broken in beta1). (Jon Rowe)

    +
  • +

    Prevent RSpec mangling file names that have substrings containing +line_number or default_path. (Matijs van +Zuijlen)

    +
+ +

3.0.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Remove explicit support for 1.8.6. (Jon Rowe)

    +
  • +

    Remove RSpec::Core::ExampleGroup#example and +RSpec::Core::ExampleGroup#running_example methods. If you need +access to the example (e.g. to get its metadata), use a block arg instead. +(David Chelimsky)

    +
  • +

    Remove TextMateFormatter, it has been moved to +rspec-tmbundle. (Aaron Kromer)

    +
  • +

    Remove RCov integration. (Jon Rowe)

    +
  • +

    Remove deprecated support for RSpec 1 constructs (Myron Marston):

    +
  • +

    The Spec and Rspec constants (rather than +RSpec).

    +
  • +

    Spec::Runner.configure rather than +RSpec.configure.

    +
  • +

    Rake::SpecTask rather than RSpec::Core::RakeTask.

    +
  • +

    Remove deprecated support for share_as. (Myron Marston)

    +
  • +

    Remove --debug option (and corresponding option on +RSpec::Core::Configuration). Instead, use -r<debugger +gem name> to load whichever debugger gem you wish to use (e.g. +ruby-debug, debugger, or pry). +(Myron Marston)

    +
  • +

    Extract Autotest support to a seperate gem. (Jon Rowe)

    +
  • +

    Raise an error when a let or subject declaration +is accessed in a before(:all) or after(:all) +hook. (Myron Marston)

    +
  • +

    Extract its support to a separate gem. (Peter Alfvin)

    +
  • +

    Disallow use of a shared example group from sibling contexts, making them +fully isolated. 2.14 and 2.99 allowed this but printed a deprecation +warning. (Jon Rowe)

    +
  • +

    Remove RSpec::Core::Configuration#output and +RSpec::Core::Configuration#out aliases of +RSpec::Core::Configuration#output_stream. (Myron Marston)

    +
  • +

    Remove legacy ordering APIs deprecated in 2.99.0.beta1. (Myron Marston)

    +
+ +

Enhancements:

+
  • +

    Replace unmaintained syntax gem with coderay gem. (Xavier Shay)

    +
  • +

    Times in profile output are now bold instead of failure_color. +(Matthew Boedicker)

    +
  • +

    Add --no-fail-fast command line option. (Gonzalo +Rodríguez-Baltanás Díaz)

    +
  • +

    Runner now considers the local system ip address when running under Drb. +(Adrian CB)

    +
  • +

    JsonFormatter now includes --profile information. (Alex / +@MasterLambaster)

    +
  • +

    Always treat symbols passed as metadata args as hash keys with true +values. RSpec 2 supported this with the +treat_symbols_as_metadata_keys_with_true_values but now this +behavior is always enabled. (Myron Marston)

    +
  • +

    Add --dry-run option, which prints the formatter output of +your suite without running any examples or hooks. (Thomas Stratmann, Myron +Marston)

    +
  • +

    Document the configuration options and default values in the +spec_helper.rb file that is generated by RSpec. (Parker +Selbert)

    +
  • +

    Give generated example group classes a friendly name derived from the +docstring, rather than something like “Nested_2”. (Myron Marston)

    +
  • +

    Avoid affecting randomization of user code when shuffling examples so that +users can count on their own seeds working. (Travis Herrick)

    +
  • +

    Ordering is no longer a single global property of the test suite. Each +group can pick an ordering using :order metadata. (Andy +Lindeman, Sam Phippen, Myron Marston)

    +
  • +

    Allow named custom ordering strategies to be registered, which can then be +used on individual example groups. (Andy Lindeman, Sam Phippen, Myron +Marston)

    +
+ +

Deprecations:

+
  • +

    treat_symbols_as_metadata_keys_with_true_values is deprecated +and no longer has an affect now that the behavior it enabled is always +enabled. (Myron Marston)

    +
+ +

2.99.2 / 2014-08-19

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Improve deprecation warning for RSpec 3 change in describe <a +symbol> behavior. (Jon Rowe, #1667)

    +
+ +

2.99.1 / 2014-06-19

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Add missing deprecation warning for when RSpec::Core::Runner +is used multiple times in the same process. In 2.x RSpec's global +state was automatically cleared between runs but in 3.0 you need to call +RSpec.reset manually in these situations. (Sam Phippen, +#1587)

    +
  • +

    Prevent deprecation being accidentally issues when doubles used with +be_ matchers due to automatically generated descriptions. +(Jon Rowe, #1573)

    +
  • +

    Load rspec/core when loading rspec/core/rake_task +to ensure we can issue deprecations correctly. (Jon Rowe, #1612)

    +
+ +

2.99.0 / 2014-06-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix BaseTextFormatter so that it does not re-close a closed +output stream. (Myron Marston)

    +
  • +

    Use RSpec::Configuration#backtrace_exclusion_patterns rather +than the deprecated +RSpec::Configuration#backtrace_clean_patterns when mocking +with rr. (David Dollar)

    +
+ +

2.99.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Add --deprecation-out CLI option which directs deprecation +warnings to the named file. (Myron Marston)

    +
  • +

    Backport support for skip in metadata to skip execution of an +example. (Xavier Shay, #1472)

    +
  • +

    Add Pathname support for setting all output streams. (Aaron +Kromer)

    +
  • +

    Add test_unit and minitest expectation +frameworks. (Aaron Kromer)

    +
+ +

Deprecations:

+
  • +

    Deprecate RSpec::Core::Pending::PendingDeclaredInExample, use +SkipDeclaredInExample instead. (Xavier Shay)

    +
  • +

    Issue a deprecation when described_class is accessed from +within a nested describe <SomeClass> example group, +since described_class will return the innermost described +class in RSpec 3 rather than the outermost described class, as it behaved +in RSpec 2. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::FilterManager::DEFAULT_EXCLUSIONS, +RSpec::Core::FilterManager::STANDALONE_FILTERS and use of +#empty_without_conditional_filters? on those filters. (Sergey +Pchelincev)

    +
  • +

    Deprecate RSpec::Core::Example#options in favor of +RSpec::Core::Example#metadata. (Myron Marston)

    +
  • +

    Issue warning when passing a symbol or hash to describe or +context as the first argument. In RSpec 2.x this would be +treated as metadata but in RSpec 3 it'll be treated as the described +object. To continue having it treated as metadata, pass a description +before the symbol or hash. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::BaseTextFormatter::VT100_COLORS and +RSpec::Core::BaseTextFormatter::VT100_COLOR_CODES in favour +of RSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODES +and +RSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODE_VALUES. +(Jon Rowe)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.display_name in favor of +RSpec::Core::ExampleGroup.description. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.describes in favor of +RSpec::Core::ExampleGroup.described_class. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.alias_example_to in favor +of RSpec::Core::Configuration#alias_example_to. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.alias_it_behaves_like_to +in favor of +RSpec::Core::Configuration#alias_it_behaves_like_to. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.focused in favor of +RSpec::Core::ExampleGroup.focus. (Myron Marston)

    +
  • +

    Add deprecation warning for config.filter_run :focused since +example aliases fit and focus will no longer +include :focused metadata but will continue to include +:focus. (Myron Marston)

    +
  • +

    Deprecate filtering by :line_number (e.g. +--line-number from the CLI). Use location filtering instead. +(Myron Marston)

    +
  • +

    Deprecate --default_path as an alternative to +--default-path. (Jon Rowe)

    +
  • +

    Deprecate RSpec::Core::Configuration#warnings in favor of +RSpec::Core::Configuration#warnings?. (Myron Marston)

    +
  • +

    Deprecate share_examples_for in favor of +shared_examples_for or just shared_examples. +(Myron Marston)

    +
  • +

    Deprecate RSpec::Core::CommandLine in favor of +RSpec::Core::Runner. (Myron Marston)

    +
  • +

    Deprecate #color_enabled, #color_enabled= and +#color? in favour of #color, +#color= and #color_enabled? output. (Jon Rowe)

    +
  • +

    Deprecate #filename_pattern in favour of +#pattern. (Jon Rowe)

    +
  • +

    Deprecate #backtrace_cleaner in favour of +#backtrace_formatter. (Jon Rowe)

    +
  • +

    Deprecate mutating RSpec::Configuration#formatters. (Jon Rowe)

    +
  • +

    Deprecate stdlib as an available expectation framework in +favour of test_unit and minitest. (Aaron Kromer)

    +
+ +

Bug Fixes:

+
  • +

    Issue a warning when you set config.deprecation_stream too +late for it to take effect because the reporter has already been setup. +(Myron Marston)

    +
  • +

    skip with a block should not execute the block. (Xavier Shay)

    +
+ +

2.99.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Add is_expected for one-liners that read well with the +expect-based syntax. is_expected is simply +defined as expect(subject) and can be used in an expression +like: it { is_expected.to read_well }. (Myron Marston)

    +
  • +

    Backport skip from RSpec 3, which acts like +pending did in RSpec 2 when not given a block, since the +behavior of pending is changing in RSpec 3. (Xavier Shay)

    +
+ +

Deprecations:

+
  • +

    Deprecate inexact mock_with config options. RSpec 3 will only +support the exact symbols :rspec, :mocha, +:flexmock, :rr or :nothing (or any +module that implements the adapter interface). RSpec 2 did fuzzy matching +but this will not be supported going forward. (Myron Marston)

    +
  • +

    Deprecate show_failures_in_pending_blocks config option. To +achieve the same behavior as the option enabled, you can use a custom +formatter instead. (Xavier Shay)

    +
  • +

    Add a deprecation warning for the fact that the behavior of +pending is changing in RSpec 3 – rather than skipping the +example (as it did in 2.x when no block was provided), it will run the +example and mark it as failed if no exception is raised. Use +skip instead to preserve the old behavior. (Xavier Shay)

    +
  • +

    Deprecate 's', 'n', 'spec' and 'nested' as +aliases for documentation formatter. (Jon Rowe)

    +
  • +

    Deprecate RSpec::Core::Reporter#abort in favor of +RSpec::Core::Reporter#finish. (Jon Rowe)

    +
+ +

Bug Fixes:

+
  • +

    Fix failure (undefined method path) in end-of-run summary +when raise_errors_for_deprecations! is configured. (Myron +Marston)

    +
  • +

    Fix issue were overridding spec ordering from the command line wasn't +fully recognised interally. (Jon Rowe)

    +
+ +

2.99.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Block-based DSL methods that run in the context of an example +(it, before(:each), after(:each), +let and subject) now yield the example as a +block argument. (David Chelimsky)

    +
  • +

    Warn when the name of more than one example group is submitted to +include_examples and it's aliases. (David Chelimsky)

    +
  • +

    Add expose_current_running_example_as config option for use +during the upgrade process when external gems use the deprecated +RSpec::Core::ExampleGroup#example and +RSpec::Core::ExampleGroup#running_example methods. (Myron +Marston)

    +
  • +

    Limit spamminess of deprecation messages. (Bradley Schaefer, Loren Segal)

    +
  • +

    Add config.raise_errors_for_deprecations! option, which turns +deprecations warnings into errors to surface the full backtrace of the +call site. (Myron Marston)

    +
+ +

Deprecations

+
  • +

    Deprecate RSpec::Core::ExampleGroup#example and +RSpec::Core::ExampleGroup#running_example methods. If you need +access to the example (e.g. to get its metadata), use a block argument +instead. (David Chelimsky)

    +
  • +

    Deprecate use of autotest/rspec2 in favour of +rspec-autotest. (Jon Rowe)

    +
  • +

    Deprecate RSpec's built-in debugger support. Use a CLI option like +-rruby-debug (for the ruby-debug gem) or +-rdebugger (for the debugger gem) instead. (Myron Marston)

    +
  • +

    Deprecate +RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values = +false. RSpec 3 will not support having this option set to +false. (Myron Marston)

    +
  • +

    Deprecate accessing a let or subject declaration +in a after(:all) hook. (Myron Marston, Jon Rowe)

    +
  • +

    Deprecate built-in its usage in favor of +rspec-its gem due to planned removal in RSpec 3. (Peter +Alfvin)

    +
  • +

    Deprecate RSpec::Core::PendingExampleFixedError in favor of +RSpec::Core::Pending::PendingExampleFixedError. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Core::Configuration#out and +RSpec::Core::Configuration#output in favor of +RSpec::Core::Configuration#output_stream. (Myron Marston)

    +
  • +

    Deprecate legacy ordering APIs.

    +
  • +

    You should use register_ordering(:global) instead of these:

    +
    • +

      RSpec::Core::Configuration#order_examples

      +
    • +

      RSpec::Core::Configuration#order_groups

      +
    • +

      RSpec::Core::Configuration#order_groups_and_examples

      +
    +
  • +

    These are deprecated with no replacement because in RSpec 3 ordering is a +property of individual example groups rather than just a global property of +the entire test suite:

    +
    • +

      RSpec::Core::Configuration#order

      +
    • +

      RSpec::Core::Configuration#randomize?

      +
    +
  • +

    --order default is deprecated in favor of --order +defined (Myron Marston)

    +
+ +

2.14.8 / 2014-02-27

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Fix regression with the textmateformatter that prevented +backtrace links from being clickable. (Stefan Daschek)

    +
+ +

2.14.7 / 2013-10-29

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Fix regression in 2.14.6 that broke the Fivemat formatter. It depended +upon either +example.execution_result[:exception].pending_fixed? (which +was removed in 2.14.6 to fix an issue with frozen error objects) or +RSpec::Core::PendingExampleFixedError (which was renamed to +RSpec::Core::Pending::PendingExampleFixedError in 2.8. This +fix makes a constant alias for the old error name. (Myron Marston)

    +
+ +

2.14.6 / 2013-10-15

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Format stringified numbers correctly when mathn library is loaded. (Jay +Hayes)

    +
  • +

    Fix an issue that prevented the use of frozen error objects. (Lars Gierth)

    +
+ +

2.14.5 / 2013-08-13

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Fix a NoMethodError that was being raised when there were no +shared examples or contexts declared and RSpec.world.reset is +invoked. (thepoho, Jon Rowe, Myron Marston)

    +
  • +

    Fix a deprecation warning that was being incorrectly displayed when +shared_examples are declared at top level in a +module scope. (Jon Rowe)

    +
  • +

    Fix after(:all) hooks so consecutive (same context) scopes will run even if +one raises an error. (Jon Rowe, Trejkaz)

    +
  • +

    JsonFormatter no longer dies if dump_profile isn't defined +(Alex / @MasterLambaster, Jon Rowe)

    +
+ +

2.14.4 / 2013-07-21

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix regression in 2.14: ensure configured requires (via -r +option) are loaded before spec files are loaded. This allows the spec +files to programatically change the file pattern (Jon Rowe).

    +
  • +

    Autoload RSpec::Mocks and RSpec::Expectations +when referenced if they are not already loaded +(RSpec::Matches has been autoloaded for a while). In the +rspec gem, we changed it recently to stop loading +rspec/mocks and rspec/expectations by default, as +some users reported problems where they were intending to use mocha, not +rspec-mocks, but rspec-mocks was loaded and causing a conflict. rspec-core +loads mocks and expectations at the appropriate time, so it seemed like a +safe change – but caused a problem for some authors of libraries that +integrate with RSpec. This fixes that problem. (Myron Marston)

    +
  • +

    Gracefully handle a command like rspec --profile +path/to/spec.rb: the path/to/spec.rb arg was being +wrongly treated as the profile integer arg, which got cast +0 using to_i, causing no profiled examples to be +printed. (Jon Rowe)

    +
+ +

2.14.3 / 2013-07-13

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix deprecation notices issued from RSpec::Core::RakeTask so +that they work properly when all of rspec-core is not loaded. (This was a +regression in 2.14) (Jon Rowe)

    +
+ +

2.14.2 / 2013-07-09

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix regression caused by 2.14.1 release: formatters that report that they +respond_to? a notification, but had no corresponding method +would raise an error when registered. The new fix is to just implement +start on the deprecation formatter to fix the original +JRuby/ruby-debug issue. (Jon Rowe)

    +
+ +

2.14.1 / 2013-07-08

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Address deprecation formatter failure when using ruby-debug on +JRuby: fix RSpec::Core::Reporter to not send a notification +when the formatter's implementation of the notification method comes +from Kernel (Alex Portnov, Jon Rowe).

    +
+ +

2.14.0 / 2013-07-06

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Apply focus to examples defined with fit (equivalent of +it "description", focus: true) (Michael de Silva)

    +
+ +

Bug fix

+
  • +

    Ensure methods defined by let take precedence over others +when there is a name collision (e.g. from an included module). (Jon Rowe, +Andy Lindeman and Myron Marston)

    +
+ +

2.14.0.rc1 / 2013-05-27

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Improved Windows detection inside Git Bash, for better --color +handling.

    +
  • +

    Add profiling of the slowest example groups to --profile +option. The output is sorted by the slowest average example groups.

    +
  • +

    Don't show slow examples if there's a failure and both +--fail-fast and --profile options are used +(Paweł Gościcki).

    +
  • +

    Rather than always adding spec to the load path, add the +configured --default-path to the load path (which defaults to +spec). This better supports folks who choose to put their +specs in a different directory (John Feminella).

    +
  • +

    Add some logic to test time duration precision. Make it a function of +time, dropping precision as the time increases. (Aaron Kromer)

    +
  • +

    Add new backtrace_inclusion_patterns config option. Backtrace +lines that match one of these patterns will always be included in +the backtrace, even if they match an exclusion pattern, too (Sam Phippen).

    +
  • +

    Support ERB trim mode using the - when parsing +.rspec as ERB (Gabor Garami).

    +
  • +

    Give a better error message when let and subject are called without a +block. (Sam Phippen).

    +
  • +

    List the precedence of .rspec-local in the configuration +documentation (Sam Phippen)

    +
  • +

    Support {a,b} shell expansion syntax in --pattern +option (Konstantin Haase).

    +
  • +

    Add cucumber documentation for –require command line option (Bradley +Schaefer)

    +
  • +

    Expose configuration options via config:

    +
  • +

    config.libs returns the libs configured to be added onto the +load path

    +
  • +

    full_backtrace? returns the state of the backtrace cleaner

    +
  • +

    debug? returns true when the debugger is loaded

    +
  • +

    line_numbers returns the line numbers we are filtering by (if +any)

    +
  • +

    full_description returns the RegExp used to filter +descriptions (Jon Rowe)

    +
  • +

    Add setters for RSpec.world and RSpec.configuration (Alex Soulim)

    +
  • +

    Configure ruby's warning behaviour with --warnings (Jon +Rowe)

    +
  • +

    Fix an obscure issue on old versions of 1.8.7 where +Time.dup wouldn't allow access to Time.now +(Jon Rowe)

    +
  • +

    Make shared_examples_for context aware, so that keys may be +safely reused in multiple contexts without colliding. (Jon Rowe)

    +
  • +

    Add a configurable deprecation_stream (Jon Rowe)

    +
  • +

    Publish deprecations through a formatter (David Chelimsky)

    +
+ +

Bug fixes

+
  • +

    Make JSON formatter behave the same when it comes to --profile +as the text formatter (Paweł Gościcki).

    +
  • +

    Fix named subjects so that if an inner group defines a method that +overrides the named method, subject still retains the +originally declared value (Myron Marston).

    +
  • +

    Fix random ordering so that it does not cause rand in examples +in nested sibling contexts to return the same value (Max Shytikov).

    +
  • +

    Use the new backtrace_inclusion_patterns config option to +ensure that folks who develop code in a directory matching one of the +default exclusion patterns (e.g. gems) still get the normal +backtrace filtering (Sam Phippen).

    +
  • +

    Fix ordering of before hooks so that before hooks +declared in RSpec.configure run before before +hooks declared in a shared context (Michi Huber and Tejas Dinkar).

    +
  • +

    Fix Example#full_description so that it gets filled in by the +last matcher description (as Example#description already did) +when no doc string has been provided (David Chelimsky).

    +
  • +

    Fix the memoized methods (let and subject) +leaking define_method as a public method. +(Thomas Holmes and Jon Rowe) (#873)

    +
  • +

    Fix warnings coming from the test suite. (Pete Higgins)

    +
+ +

Deprecations

+
  • +

    Deprecate Configuration#backtrace_clean_patterns in favor of +Configuration#backtrace_exclusion_patterns for greater +consistency and symmetry with new +backtrace_inclusion_patterns config option (Sam Phippen).

    +
  • +

    Deprecate Configuration#requires= in favor of using ruby's +require. Requires specified by the command line can still be +accessed by the Configuration#require reader. (Bradley +Schaefer)

    +
  • +

    Deprecate calling SharedExampleGroups defined across sibling +contexts (Jon Rowe)

    +
+ +

2.13.1 / 2013-03-12

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Use hook classes as proxies rather than extending hook blocks to support +lambdas for before/after/around hooks. (David Chelimsky)

    +
  • +

    Fix regression in 2.13.0 that caused confusing behavior when overriding a +named subject with an unnamed subject in an inner group and then +referencing the outer group subject's name. The fix for this required +us to disallow using super in a named subject (which is +confusing, anyway – named subjects create 2 methods, so which method on +the parent example group are you supering to?) but +super in an unnamed subject continues to work (Myron +Marston).

    +
  • +

    Do not allow a referenced let or subject in +before(:all) to cause other let declarations to +leak across examples (Myron Marston).

    +
  • +

    Work around odd ruby 1.9 bug with String#match that was +triggered by passing it a regex from a let declaration. For +more info, see bugs.ruby-lang.org/issues/8059 +(Aaron Kromer).

    +
  • +

    Add missing require 'set' to +base_text_formatter.rb (Tom Anderson).

    +
+ +

Deprecations

+
  • +

    Deprecate accessing let or subject declarations +in before(:all). These were not intended to be called in a +before(:all) hook, as they exist to define state that is +reset between each example, while before(:all) exists to +define state that is shared across examples in an example group (Myron +Marston).

    +
+ +

2.13.0 / 2013-02-23

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Allow --profile option to take a count argument that +determines the number of slow examples to dump (Greggory Rothmeier).

    +
  • +

    Add subject! that is the analog to let!. It +defines an explicit subject and sets a before hook that will +invoke the subject (Zubin Henner).

    +
  • +

    Fix let and subject declaration so that +super and return can be used in them, just like +in a normal method. (Myron Marston)

    +
  • +

    Allow output colors to be configured individually. (Charlie Maffitt)

    +
  • +

    Always dump slow examples when --profile option is given, +even when an example failed (Myron Marston).

    +
+ +

Bug fixes

+
  • +

    Don't blow up when dumping error output for instances of anonymous +error classes (Myron Marston).

    +
  • +

    Fix default backtrace filters so lines from projects containing “gems” in +the name are not filtered, but lines from installed gems still are (Myron +Marston).

    +
  • +

    Fix autotest command so that is uses double quotes rather than single +quotes for windows compatibility (Jonas Tingeborn).

    +
  • +

    Fix its so that uses of subject in a +before or let declaration in the parent group +continue to reference the parent group's subject. (Olek Janiszewski)

    +
+ +

2.12.2 / 2012-12-13

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix RSpec::Core::RakeTask so that it is compatible with rake +0.8.7 on ruby 1.8.7. We had accidentally broke it in the 2.12 release +(Myron Marston).

    +
  • +

    Fix RSpec::Core::RakeTask so it is tolerant of the +Rspec constant for backwards compatibility (Patrick Van Stee)

    +
+ +

2.12.1 / 2012-12-01

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Specs are run even if another at_exit hook calls exit. This +allows Test::Unit and RSpec to run together. (Suraj N. Kurapati)

    +
  • +

    Fix full doc string concatenation so that it handles the case of a method +string (e.g. “#foo”) being nested under a context string (e.g. “when it is +tuesday”), so that we get “when it is tuesday #foo” rather than “when it +is tuesday#foo”. (Myron Marston)

    +
  • +

    Restore public API I unintentionally broke in 2.12.0: +RSpec::Core::Formatters::BaseFormatter#format_backtrce(backtrace, +example) (Myron Marston).

    +
+ +

2.12.0 / 2012-11-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Add support for custom ordering strategies for groups and examples. (Myron +Marston)

    +
  • +

    JSON Formatter (Alex Chaffee)

    +
  • +

    Refactor rake task internals (Sam Phippen)

    +
  • +

    Refactor HtmlFormatter (Pete Hodgson)

    +
  • +

    Autotest supports a path to Ruby that contains spaces (dsisnero)

    +
  • +

    Provide a helpful warning when a shared example group is redefined. (Mark +Burns).

    +
  • +

    --default_path can be specified as +--default-line. --line_number can be specified +as --line-number. Hyphens are more idiomatic command line +argument separators (Sam Phippen).

    +
  • +

    A more useful error message is shown when an invalid command line option is +used (Jordi Polo).

    +
  • +

    Add format_docstrings { |str| } config option. It can be used +to apply formatting rules to example group and example docstrings. (Alex +Tan)

    +
  • +

    Add support for an .rspec-local options file. This is intended +to allow individual developers to set options in a git-ignored file that +override the common project options in .rspec. (Sam Phippen)

    +
  • +

    Support for mocha 0.13.0. (Andy Lindeman)

    +
+ +

Bug fixes

+
  • +

    Remove override of ExampleGroup#ancestors. This is a core ruby +method that RSpec shouldn't override. Instead, define +ExampleGroup#parent_groups. (Myron Marston)

    +
  • +

    Limit monkey patching of shared example/context declaration methods +(shared_examples_for, etc.) to just the objects that need it +rather than every object in the system (Myron Marston).

    +
  • +

    Fix Metadata#fetch to support computed values (Sam Goldman).

    +
  • +

    Named subject can now be referred to from within subject block in a nested +group (tomykaira).

    +
  • +

    Fix fail_fast so that it properly exits when an error occurs +in a before(:all) hook (Bradley Schaefer).

    +
  • +

    Make the order spec files are loaded consistent, regardless of the order +of the files returned by the OS or the order passed at the command line +(Jo Liss and Sam Phippen).

    +
  • +

    Ensure instance variables from before(:all) are always exposed +from after(:all), even if an error occurs in +before(:all) (Sam Phippen).

    +
  • +

    rspec --init no longer generates an incorrect warning about +--configure being deprecated (Sam Phippen).

    +
  • +

    Fix pluralization of 1 seconds (Odin Dutton)

    +
  • +

    Fix ANSICON url (Jarmo Pertman)

    +
  • +

    Use dup of Time so reporting isn't clobbered by examples that modify +Time without properly restoring it. (David Chelimsky)

    +
+ +

Deprecations

+
  • +

    share_as is no longer needed. shared_context +and/or RSpec::SharedContext provide better mechanisms (Sam +Phippen).

    +
  • +

    Deprecate RSpec.configuration with a block (use +RSpec.configure).

    +
+ +

2.11.1 / 2012-07-18

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix the way we autoload RSpec::Matchers so that custom matchers can be +defined before rspec-core has been configured to definitely use +rspec-expectations. (Myron Marston)

    +
  • +

    Fix typo in –help message printed for -e option. (Jo Liss)

    +
  • +

    Fix ruby warnings. (Myron Marston)

    +
  • +

    Ignore mock expectation failures when the example has already failed. Mock +expectation failures have always been ignored in this situation, but due +to my changes in 27059bf1 it was printing a confusing message. (Myron +Marston).

    +
+ +

2.11.0 / 2012-07-07

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Support multiple --example options. (Daniel Doubrovkine +@dblock)

    +
  • +

    Named subject e.g. subject(:article) { Article.new }

    + +
  • +

    config.mock_with and config.expect_with yield +custom config object to a block if given

    +
    • +

      aids decoupling from rspec-core's configuation

      +
    +
  • +

    include_context and include_examples support a +block, which gets eval'd in the current context (vs the nested context +generated by it_behaves_like).

    +
  • +

    Add config.order = 'random' to the +spec_helper.rb generated by rspec --init.

    +
  • +

    Delay the loading of DRb (Myron Marston).

    +
  • +

    Limit monkey patching of describe onto just the objects that +need it rather than every object in the system (Myron Marston).

    +
+ +

Bug fixes

+
  • +

    Support alternative path separators. For example, on Windows, you can now +do this: rspec spec\subdir. (Jarmo Pertman @jarmo)

    +
  • +

    When an example raises an error and an after or around hook does as well, +print out the hook error. Previously, the error was silenced and the user +got no feedback about what happened. (Myron Marston)

    +
  • +

    --require and -I are merged among different +configuration sources (Andy Lindeman)

    +
  • +

    Delegate to mocha methods instead of aliasing them in mocha adapter.

    +
+ +

2.10.1 / 2012-05-19

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    RSpec.reset properly reinits configuration and world

    +
  • +

    Call to_s before split on exception messages that +might not always be Strings (slyphon)

    +
+ +

2.10.0 / 2012-05-03

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Add prepend_before and append_after hooks +(preethiramdev)

    +
    • +

      intended for extension libs

      +
    • +

      restores rspec-1 behavior

      +
    +
  • +

    Reporting of profiled examples (moro)

    +
    • +

      Report the total amount of time taken for the top slowest examples.

      +
    • +

      Report what percentage the slowest examples took from the total runtime.

      +
    +
+ +

Bug fixes

+
  • +

    Properly parse SPEC_OPTS options.

    +
  • +

    example.description returns the location of the example if +there is no explicit description or matcher-generated description.

    +
  • +

    RDoc fixes (Grzegorz Świrski)

    +
  • +

    Do not modify example ancestry when dumping errors (Michael Grosser)

    +
+ +

2.9.0 / 2012-03-17

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Support for “X minutes X seconds” spec run duration in formatter. (uzzz)

    +
  • +

    Strip whitespace from group and example names in doc formatter.

    +
  • +

    Removed spork-0.9 shim. If you're using spork-0.8.x, you'll need to +upgrade to 0.9.0.

    +
+ +

Bug fixes

+
  • +

    Restore --full_backtrace option

    +
  • +

    Ensure that values passed to config.filter_run are respected +when running over DRb (using spork).

    +
  • +

    Ensure shared example groups are reset after a run (as example groups are).

    +
  • +

    Remove rescue false from calls to filters represented as Procs

    +
  • +

    Ensure described_class gets the closest constant (pyromaniac)

    +
  • +

    In “autorun”, don't run the specs in the at_exit hook if +there was an exception (most likely due to a SyntaxError). (sunaku)

    +
  • +

    Don't extend groups with modules already used to extend ancestor +groups.

    +
  • +

    its correctly memoizes nil or false values (Yamada Masaki)

    +
+ +

2.8.0 / 2012-01-04

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    For metadata filtering, restore passing the entire array to the proc, +rather than each item in the array (weidenfreak)

    +
  • +

    Ensure each spec file is loaded only once

    +
    • +

      Fixes a bug that caused all the examples in a file to be run when +referenced twice with line numbers in a command, e.g.

      +
      • +

        rspec path/to/file:37 path/to/file:42

        +
      +
    +
+ +

2.8.0.rc2 / 2011-12-19

+ +

Full +Changelog

+ +

Enhancments

+
  • +

    new --init command (Peter Schröder)

    +
    • +

      generates spec/spec_helper.rb

      +
    • +

      deletes obsolete files (on confirmation)

      +
    • +

      merged with and deprecates --configure command, which +generated .rspec

      +
    +
  • +

    use require_relative when available (Ian Leitch)

    +
  • +

    include_context and include_examples accept +params (Calvin Bascom)

    +
  • +

    print the time for every example in the html formatter (Richie Vos)

    +
  • +

    several tasty refactoring niblets (Sasha)

    +
  • +

    `it “does something”, :x => [:foo,'bar',/baz/] (Ivan Neverov)

    +
    • +

      supports matching n command line tag values with an example or group

      +
    +
+ +

2.8.0.rc1 / 2011-11-06

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    --order (Justin Ko)

    +
    • +

      run examples in random order: --order rand

      +
    • +

      specify the seed: --order rand:123

      +
    +
  • +

    --seed SEED

    +
    • +

      equivalent of --order rand:SEED

      +
    +
  • +

    SharedContext supports let (David Chelimsky)

    +
  • +

    Filter improvements (David Chelimsky)

    +
    • +

      override opposing tags from the command line

      +
    • +

      override RSpec.configure tags from the command line

      +
    • +

      --line_number 37 overrides all other filters

      +
    • +

      path/to/file.rb:37 overrides all other filters

      +
    • +

      refactor: consolidate filter management in a FilterManger object

      +
    +
  • +

    Eliminate Ruby warnings (Matijs van Zuijlen)

    +
  • +

    Make reporter.report an API (David Chelimsky)

    +
    • +

      supports extension tools like interative_rspec

      +
    +
+ +

Changes

+
  • +

    change config.color_enabled (getter/setter/predicate) to +color to align with --[no]-color CLI option.

    +
    • +

      color_enabled is still supported for now, but will likley be +deprecated in a 2.x release so we can remove it in 3.0.

      +
    +
+ +

Bug fixes

+
  • +

    Make sure the bar in --tag foo:bar makes it to +DRb (Aaron Gibralter)

    +
  • +

    Fix bug where full descriptions of groups nested 3 deep were repeated.

    +
  • +

    Restore report of time to run to start after files are loaded.

    +
    • +

      fixes bug where run times were cumalitive in spork

      +
    • +

      fixes compatibility with time-series metrics

      +
    • +

      fixes bug where run times were cumalitive in spork

      +
    • +

      fixes compatibility with time-series metrics

      +
    +
  • +

    Don't error out when config.mock_with or +expect_with is re-specifying the current config (Myron +Marston)

    +
  • +

    Deprecations

    +
    • +

      :alias option on configuration.add_setting. Use +:alias_with on the original setting declaration instead.

      +
    +
+ +

2.7.1 / 2011-10-20

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    tell autotest the correct place to find the rspec executable

    +
+ +

2.7.0 / 2011-10-16

+ +

Full +Changelog

+ +

NOTE: RSpec's release policy dictates that there should not be any +backward incompatible changes in minor releases, but we're making an +exception to release a change to how RSpec interacts with other command +line tools.

+ +

As of 2.7.0, you must explicity require +"rspec/autorun" unless you use the rspec +command (which already does this for you).

+ +

Enhancements

+
  • +

    Add example.exception (David Chelimsky)

    +
  • +

    --default_path command line option (Justin Ko)

    +
  • +

    support multiple --line_number options (David J. Hamilton)

    +
    • +

      also supports path/to/file.rb:5:9 (runs examples on lines 5 +and 9)

      +
    +
  • +

    Allow classes/modules to be used as shared example group identifiers +(Arthur Gunn)

    +
  • +

    Friendly error message when shared context cannot be found (Sławosz +Sławiński)

    +
  • +

    Clear formatters when resetting config (John Bintz)

    +
  • +

    Add xspecify and xexample as temp-pending methods (David +Chelimsky)

    +
  • +

    Add --no-drb option (Iain Hecker)

    +
  • +

    Provide more accurate run time by registering start time before code is +loaded (David Chelimsky)

    +
    • +

      reverted in 2.8.0

      +
    +
  • +

    Rake task default pattern finds specs in symlinked dirs (Kelly Felkins)

    +
  • +

    Rake task no longer does anything to invoke bundler since Bundler already +handles it for us. Thanks to Andre Arko for the tip.

    +
  • +

    Add --failure-exit-code option (Chris Griego)

    +
+ +

Bug fixes

+
  • +

    Include Rake::DSL to remove deprecation warnings in Rake > +0.8.7 (Pivotal Casebook)

    +
  • +

    Only eval let block once even if it returns nil +(Adam Meehan)

    +
  • +

    Fix --pattern option (wasn't being recognized) (David +Chelimsky)

    +
  • +

    Only implicitly require "rspec/autorun" with the +rspec command (David Chelimsky)

    +
  • +

    Ensure that rspec's at_exit defines the exit code (Daniel +Doubrovkine)

    +
  • +

    Show the correct snippet in the HTML and TextMate formatters (Brian +Faherty)

    +
+ +

2.6.4 / 2011-06-06

+ +

Full +Changelog

+ +

NOTE: RSpec's release policy dictates that there should not be new +functionality in patch releases, but this minor enhancement slipped in by +accident. As it doesn't add a new API, we decided to leave it in rather +than roll back this release.

+ +

Enhancements

+
  • +

    Add summary of commands to run individual failed examples.

    +
+ +

Bug fixes

+
  • +

    Support exclusion filters in DRb. (Yann Lugrin)

    +
  • +

    Fix –example escaping when run over DRb. (Elliot Winkler)

    +
  • +

    Use standard ANSI codes for color formatting so colors work in a wider set +of color schemes.

    +
+ +

2.6.3 / 2011-05-24

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Explicitly convert exit code to integer, avoiding TypeError when return +value of run is IO object proxied by DRb::DRbObject (Julian +Scheid)

    +
  • +

    Clarify behavior of --example command line option

    +
  • +

    Build using a rubygems-1.6.2 to avoid downstream yaml parsing error

    +
+ +

2.6.2 / 2011-05-21

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Warn rather than raise when HOME env var is not defined

    +
  • +

    Properly merge command-line exclusions with default :if and :unless +(joshcooper)

    +
+ +

2.6.1 / 2011-05-19

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Don't extend nil when filters are nil

    +
  • +

    require 'rspec/autorun' when running rcov.

    +
+ +

2.6.0 / 2011-05-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    shared_context (Damian Nurzynski)

    +
    • +

      extend groups matching specific metadata with:

      +
      • +

        method definitions

        +
      • +

        subject declarations

        +
      • +

        let/let! declarations

        +
      • +

        etc (anything you can do in a group)

        +
      +
    +
  • +

    its([:key]) works for any subject with #[]. (Peter Jaros)

    +
  • +

    treat_symbols_as_metadata_keys_with_true_values (Myron +Marston)

    +
  • +

    Print a deprecation warning when you configure RSpec after defining an +example. All configuration should happen before any examples are defined. +(Myron Marston)

    +
  • +

    Pass the exit status of a DRb run to the invoking process. This causes +specs run via DRb to not just return true or false. (Ilkka Laukkanen)

    +
  • +

    Refactoring of ConfigurationOptions#parse_options (Rodrigo +Rosenfeld Rosas)

    +
  • +

    Report excluded filters in runner output (tip from andyl)

    +
  • +

    Clean up messages for filters/tags.

    +
  • +

    Restore –pattern/-P command line option from rspec-1

    +
  • +

    Support false as well as true in config.full_backtrace= (Andreas Tolf +Tolfsen)

    +
+ +

Bug fixes

+
  • +

    Don't stumble over an exception without a message (Hans Hasselberg)

    +
  • +

    Remove non-ascii characters from comments that were choking rcov (Geoffrey +Byers)

    +
  • +

    Fixed backtrace so it doesn't include lines from before the autorun +at_exit hook (Myron Marston)

    +
  • +

    Include RSpec::Matchers when first example group is defined, rather than +just before running the examples. This works around an obscure bug in ruby +1.9 that can cause infinite recursion. (Myron Marston)

    +
  • +

    Don't send example_group_[started|finished] to formatters +for empty groups.

    +
  • +

    Get specs passing on jruby (Sidu Ponnappa)

    +
  • +

    Fix bug where mixing nested groups and outer-level examples gave +unpredictable :line_number behavior (Artur Małecki)

    +
  • +

    Regexp.escape the argument to –example (tip from Elliot Winkler)

    +
  • +

    Correctly pass/fail pending block with message expectations

    +
  • +

    CommandLine returns exit status (0/1) instead of true/false

    +
  • +

    Create path to formatter output file if it doesn't exist (marekj).

    +
+ +

2.5.1 / 2011-02-06

+ +

Full +Changelog

+ +

NOTE: this release breaks compatibility with rspec/autotest/bundler +integration, but does so in order to greatly simplify it.

+ +

With this release, if you want the generated autotest command to include +'bundle exec', require Autotest's bundler plugin in a .autotest +file in the project's root directory or in your home directory:

+ +
require "autotest/bundler"
+
+ +

Now you can just type 'autotest' on the commmand line and it will +work as you expect.

+ +

If you don't want 'bundle exec', there is nothing you have to +do.

+ +

2.5.0 / 2011-02-05

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Autotest::Rspec2 parses command line args passed to autotest after +'–'

    +
  • +

    –skip-bundler option for autotest command

    +
  • +

    Autotest regexp fixes (Jon Rowe)

    +
  • +

    Add filters to html and textmate formatters (Daniel Quimper)

    +
  • +

    Explicit passing of block (need for JRuby 1.6) (John Firebaugh)

    +
+ +

Bug fixes

+
  • +

    fix dom IDs in HTML formatter (Brian Faherty)

    +
  • +

    fix bug with –drb + formatters when not running in drb

    +
  • +

    include –tag options in drb args (monocle)

    +
  • +

    fix regression so now SPEC_OPTS take precedence over CLI options again +(Roman Chernyatchik)

    +
  • +

    only call its(:attribute) once (failing example from Brian Dunn)

    +
  • +

    fix bizarre bug where rspec would hang after String.alias :to_int :to_i +(Damian Nurzynski)

    +
+ +

Deprecations

+
  • +

    implicit inclusion of 'bundle exec' when Gemfile present (use +autotest's bundler plugin instead)

    +
+ +

2.4.0 / 2011-01-02

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    start the debugger on -d so the stack trace is visible when it stops +(Clifford Heath)

    +
  • +

    apply hook filtering to examples as well as groups (Myron Marston)

    +
  • +

    support multiple formatters, each with their own output

    +
  • +

    show exception classes in failure messages unless they come from RSpec +matchers or message expectations

    +
  • +

    before(:all) { pending } sets all examples to pending

    +
+ +

Bug fixes

+
  • +

    fix bug due to change in behavior of reject in Ruby 1.9.3-dev (Shota +Fukumori)

    +
  • +

    fix bug when running in jruby: be explicit about passing block to super +(John Firebaugh)

    +
  • +

    rake task doesn't choke on paths with quotes (Janmejay Singh)

    +
  • +

    restore –options option from rspec-1

    +
  • +

    require 'ostruct' to fix bug with its() (Kim +Burgestrand)

    +
  • +

    –configure option generates .rspec file instead of autotest/discover.rb

    +
+ +

2.3.1 / 2010-12-16

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    send debugger warning message to $stdout if +RSpec.configuration.error_stream has not been defined yet.

    +
  • +

    HTML Formatter finally properly displays nested groups (Jarmo +Pertman)

    +
  • +

    eliminate some warnings when running RSpec's own suite (Jarmo Pertman)

    +
+ +

2.3.0 / 2010-12-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    tell autotest to use “rspec2” if it sees a .rspec file in the project's +root directory

    +
    • +

      replaces the need for ./autotest/discover.rb, which will not work with all +versions of ZenTest and/or autotest

      +
    +
  • +

    config.expect_with

    +
    • +

      :rspec # => rspec/expectations

      +
    • +

      :stdlib # => test/unit/assertions

      +
    • +

      :rspec, :stdlib # => both

      +
    +
+ +

Bug fixes

+
  • +

    fix dev Gemfile to work on non-mac-os machines (Lake Denman)

    +
  • +

    ensure explicit subject is only eval'd once (Laszlo Bacsi)

    +
+ +

2.2.1 / 2010-11-28

+ +

Full +Changelog

+ +

Bug fixes * alias_method instead of override Kernel#method_missing (John +Wilger) * changed –autotest to –tty in generated command (MIKAMI Yoshiyuki) +* revert change to debugger (had introduced conflict with Rails) * also +restored –debugger/-debug option

+ +

2.2.0 / 2010-11-28

+ +

Full +Changelog

+ +

Deprecations/changes

+
  • +

    –debug/-d on command line is deprecated and now has no effect

    +
  • +

    win32console is now ignored; Windows users must use ANSICON for color +support (Bosko Ivanisevic)

    +
+ +

Enhancements

+
  • +

    When developing locally rspec-core now works with the rspec-dev setup or +your local gems

    +
  • +

    Raise exception with helpful message when rspec-1 is loaded alongside +rspec-2 (Justin Ko)

    +
  • +

    debugger statements just work as long as ruby-debug is installed

    +
  • +

    otherwise you get warned, but not fired

    +
  • +

    Expose example.metadata in around hooks

    +
  • +

    Performance improvments (much faster now)

    +
+ +

Bug fixes

+
  • +

    Make sure –fail-fast makes it across drb

    +
  • +

    Pass -Ilib:spec to rcov

    +
+ +

2.1.0 / 2010-11-07

+ +

Full +Changelog

+ +

Enhancments

+
  • +

    Add skip_bundler option to rake task to tell rake task to ignore the +presence of a Gemfile (jfelchner)

    +
  • +

    Add gemfile option to rake task to tell rake task what Gemfile to look for +(defaults to 'Gemfile')

    +
  • +

    Allow passing caller trace into Metadata to support extensions (Glenn +Vanderburg)

    +
  • +

    Add deprecation warning for Spec::Runner.configure to aid upgrade from +RSpec-1

    +
  • +

    Add deprecated Spec::Rake::SpecTask to aid upgrade from RSpec-1

    +
  • +

    Add 'autospec' command with helpful message to aid upgrade from +RSpec-1

    +
  • +

    Add support for filtering with tags on CLI (Lailson Bandeira)

    +
  • +

    Add a helpful message about RUBYOPT when require fails in bin/rspec +(slyphon)

    +
  • +

    Add “-Ilib” to the default rcov options (Tianyi Cui)

    +
  • +

    Make the expectation framework configurable (default rspec, of course) +(Justin Ko)

    +
  • +

    Add 'pending' to be conditional (Myron Marston)

    +
  • +

    Add explicit support for :if and :unless as metadata keys for conditional +run of examples (Myron Marston)

    +
  • +

    Add –fail-fast command line option (Jeff Kreeftmeijer)

    +
+ +

Bug fixes

+
  • +

    Eliminate stack overflow with “subject { self }”

    +
  • +

    Require 'rspec/core' in the Raketask (ensures it required when +running rcov)

    +
+ +

2.0.1 / 2010-10-18

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Restore color when using spork + autotest

    +
  • +

    Pending examples without docstrings render the correct message (Josep M. +Bach)

    +
  • +

    Fixed bug where a failure in a spec file ending in anything but _spec.rb +would fail in a confusing way.

    +
  • +

    Support backtrace lines from erb templates in html formatter (Alex +Crichton)

    +
+ +

2.0.0 / 2010-10-10

+ +

Full +Changelog

+ +

RSpec-1 compatibility

+
  • +

    Rake task uses ENV as file list if present

    +
+ +

Bug fixes

+
  • +

    Bug Fix: optparse –out foo.txt (Leonardo Bessa)

    +
  • +

    Suppress color codes for non-tty output (except autotest)

    +
+ +

2.0.0.rc / 2010-10-05

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    implicitly require unknown formatters so you don't have to require the +file explicitly on the commmand line (Michael Grosser)

    +
  • +

    add –out/-o option to assign output target

    +
  • +

    added fail_fast configuration option to abort on first failure

    +
  • +

    support a Hash subject (its() { should == value }) +(Josep M. Bach)

    +
+ +

Bug fixes

+
  • +

    Explicitly require rspec version to fix broken rdoc task (Hans de Graaff)

    +
  • +

    Ignore backtrace lines that come from other languages, like Java or +Javascript (Charles Lowell)

    +
  • +

    Rake task now does what is expected when setting (or not setting) +fail_on_error and verbose

    +
  • +

    Fix bug in which before/after(:all) hooks were running on excluded nested +groups (Myron Marston)

    +
  • +

    Fix before(:all) error handling so that it fails examples in nested groups, +too (Myron Marston)

    +
+ +

2.0.0.beta.22 / 2010-09-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    removed at_exit hook

    +
  • +

    CTRL-C stops the run (almost) immediately

    +
    • +

      first it cleans things up by running the appropriate after(:all) and +after(:suite) hooks

      +
    • +

      then it reports on any examples that have already run

      +
    +
  • +

    cleaned up rake task

    +
    • +

      generate correct task under variety of conditions

      +
    • +

      options are more consistent

      +
    • +

      deprecated redundant options

      +
    +
  • +

    run 'bundle exec autotest' when Gemfile is present

    +
  • +

    support ERB in .rspec options files (Justin Ko)

    +
  • +

    depend on bundler for development tasks (Myron Marston)

    +
  • +

    add example_group_finished to formatters and reporter (Roman Chernyatchik)

    +
+ +

Bug fixes

+
  • +

    support paths with spaces when using autotest (Andreas Neuhaus)

    +
  • +

    fix module_exec with ruby 1.8.6 (Myron Marston)

    +
  • +

    remove context method from top-level

    +
    • +

      was conflicting with irb, for example

      +
    +
  • +

    errors in before(:all) are now reported correctly (Chad Humphries)

    +
+ +

Removals

+
  • +

    removed -o –options-file command line option

    +
    • +

      use ./.rspec and ~/.rspec

      +
    +
+
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/file.License.html b/source/documentation/3.1/rspec-core/file.License.html new file mode 100644 index 000000000..a34494e40 --- /dev/null +++ b/source/documentation/3.1/rspec-core/file.License.html @@ -0,0 +1,73 @@ + + + + + + File: License + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
(The MIT License)

Copyright (c) 2012 Chad Humphries, David Chelimsky, Myron Marston
Copyright (c) 2009 Chad Humphries, David Chelimsky
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
Copyright (c) 2005 Steven Baker

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/file.README.html b/source/documentation/3.1/rspec-core/file.README.html new file mode 100644 index 000000000..1357e5eca --- /dev/null +++ b/source/documentation/3.1/rspec-core/file.README.html @@ -0,0 +1,315 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

rspec-core

+ +

rspec-core provides the structure for writing executable examples of how +your code should behave, and an rspec command with tools to +constrain which examples get run and tailor the output.

+ +

install

+ +
gem install rspec      # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-core # for rspec-core only
+rspec --help
+ +

basic structure

+ +

RSpec uses the words “describe” and “it” so we can express concepts like a +conversation:

+ +
"Describe an order."
+"It sums the prices of its line items."
+ +
RSpec.describe Order do
+  it "sums the prices of its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe method creates an ExampleGroup. +Within the block passed to describe you can declare examples +using the it method.

+ +

Under the hood, an example group is a class in which the block passed to +describe is evaluated. The blocks passed to it +are evaluated in the context of an instance of that class.

+ +

nested groups

+ +

You can also declare nested nested groups using the describe +or context methods:

+ +
RSpec.describe Order do
+  context "with no items" do
+    it "behaves one way" do
+      # ...
+    end
+  end
+
+  context "with one item" do
+    it "behaves another way" do
+      # ...
+    end
+  end
+end
+
+ +

aliases

+ +

You can declare example groups using either describe or +context. For a top level example group, describe +and context are available off of RSpec. For +backwards compatibility, they are also available off of the +main object and Module unless you disable monkey +patching.

+ +

You can declare examples within a group using any of it, +specify, or example.

+ +

shared examples and contexts

+ +

Declare a shared example group using shared_examples, and then +include it in any group using include_examples.

+ +
RSpec.shared_examples "collections" do |collection_class|
+  it "is empty when first created" do
+    expect(collection_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections", Array
+end
+
+RSpec.describe Hash do
+  include_examples "collections", Hash
+end
+
+ +

Nearly anything that can be declared within an example group can be +declared within a shared example group. This includes before, +after, and around hooks, let +declarations, and nested groups/contexts.

+ +

You can also use the names shared_context and +include_context. These are pretty much the same as +shared_examples and include_examples, providing +more accurate naming when you share hooks, let declarations, +helper methods, etc, but no examples.

+ +

metadata

+ +

rspec-core stores a metadata hash with every example and group, which +contains their descriptions, the locations at which they were declared, +etc, etc. This hash powers many of rspec-core's features, including +output formatters (which access descriptions and locations), and filtering +before and after hooks.

+ +

Although you probably won't ever need this unless you are writing an +extension, you can access it from an example like this:

+ +
it "does something" do
+  expect(example.[:description]).to eq("does something")
+end
+
+ +

described_class

+ +

When a class is passed to describe, you can access it from an +example using the described_class method, which is a wrapper +for example.metadata[:described_class].

+ +
RSpec.describe Widget do
+  example do
+    expect(described_class).to equal(Widget)
+  end
+end
+
+ +

This is useful in extensions or shared example groups in which the specific +class is unknown. Taking the collections shared example group from above, +we can clean it up a bit using described_class:

+ +
RSpec.shared_examples "collections" do
+  it "is empty when first created" do
+    expect(described_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections"
+end
+
+RSpec.describe Hash do
+  include_examples "collections"
+end
+
+ +

the rspec command

+ +

When you install the rspec-core gem, it installs the rspec +executable, which you'll use to run rspec. The rspec +command comes with many useful options. Run rspec --help to +see the complete list.

+ +

store command line options .rspec

+ +

You can store command line options in a .rspec file in the +project's root directory, and the rspec command will read +them as though you typed them on the command line.

+ +

autotest integration

+ +

rspec-core no longer ships with an Autotest extension, if you require +Autotest integration, please use the rspec-autotest gem and +see rspec/rspec-autotest for +details

+ +

get started

+ +

Start with a simple example of behavior you expect from your system. Do +this before you write any implementation code:

+ +
# in spec/calculator_spec.rb
+RSpec.describe Calculator do
+  describe '#add' do
+    it 'returns the sum of its arguments' do
+      expect(Calculator.new.add(1, 2)).to eq(3)
+    end
+  end
+end
+
+ +

Run this with the rspec command, and watch it fail:

+ +
$ rspec spec/calculator_spec.rb
+./spec/calculator_spec.rb:1: uninitialized constant Calculator
+ +

Implement the simplest solution:

+ +
# in lib/calculator.rb
+class Calculator
+  def add(a,b)
+    a + b
+  end
+end
+
+ +

Be sure to require the implementation file in the spec:

+ +
# in spec/calculator_spec.rb
+# - RSpec adds ./lib to the $LOAD_PATH
+require "calculator"
+
+ +

Now run the spec again, and watch it pass:

+ +
$ rspec spec/calculator_spec.rb
+.
+
+Finished in 0.000315 seconds
+1 example, 0 failures
+ +

Use the documentation formatter to see the resulting spec:

+ +
$ rspec spec/calculator_spec.rb --format doc
+Calculator
+  #add
+    returns the sum of its arguments
+
+Finished in 0.000379 seconds
+1 example, 0 failures
+ +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/file_list.html b/source/documentation/3.1/rspec-core/file_list.html new file mode 100644 index 000000000..4fbe39987 --- /dev/null +++ b/source/documentation/3.1/rspec-core/file_list.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + File List + + + + +
+

File List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-core/frames.html b/source/documentation/3.1/rspec-core/frames.html new file mode 100644 index 000000000..87a4a6df1 --- /dev/null +++ b/source/documentation/3.1/rspec-core/frames.html @@ -0,0 +1,26 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + diff --git a/source/documentation/3.1/rspec-core/index.html b/source/documentation/3.1/rspec-core/index.html new file mode 100644 index 000000000..1357e5eca --- /dev/null +++ b/source/documentation/3.1/rspec-core/index.html @@ -0,0 +1,315 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

rspec-core

+ +

rspec-core provides the structure for writing executable examples of how +your code should behave, and an rspec command with tools to +constrain which examples get run and tailor the output.

+ +

install

+ +
gem install rspec      # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-core # for rspec-core only
+rspec --help
+ +

basic structure

+ +

RSpec uses the words “describe” and “it” so we can express concepts like a +conversation:

+ +
"Describe an order."
+"It sums the prices of its line items."
+ +
RSpec.describe Order do
+  it "sums the prices of its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe method creates an ExampleGroup. +Within the block passed to describe you can declare examples +using the it method.

+ +

Under the hood, an example group is a class in which the block passed to +describe is evaluated. The blocks passed to it +are evaluated in the context of an instance of that class.

+ +

nested groups

+ +

You can also declare nested nested groups using the describe +or context methods:

+ +
RSpec.describe Order do
+  context "with no items" do
+    it "behaves one way" do
+      # ...
+    end
+  end
+
+  context "with one item" do
+    it "behaves another way" do
+      # ...
+    end
+  end
+end
+
+ +

aliases

+ +

You can declare example groups using either describe or +context. For a top level example group, describe +and context are available off of RSpec. For +backwards compatibility, they are also available off of the +main object and Module unless you disable monkey +patching.

+ +

You can declare examples within a group using any of it, +specify, or example.

+ +

shared examples and contexts

+ +

Declare a shared example group using shared_examples, and then +include it in any group using include_examples.

+ +
RSpec.shared_examples "collections" do |collection_class|
+  it "is empty when first created" do
+    expect(collection_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections", Array
+end
+
+RSpec.describe Hash do
+  include_examples "collections", Hash
+end
+
+ +

Nearly anything that can be declared within an example group can be +declared within a shared example group. This includes before, +after, and around hooks, let +declarations, and nested groups/contexts.

+ +

You can also use the names shared_context and +include_context. These are pretty much the same as +shared_examples and include_examples, providing +more accurate naming when you share hooks, let declarations, +helper methods, etc, but no examples.

+ +

metadata

+ +

rspec-core stores a metadata hash with every example and group, which +contains their descriptions, the locations at which they were declared, +etc, etc. This hash powers many of rspec-core's features, including +output formatters (which access descriptions and locations), and filtering +before and after hooks.

+ +

Although you probably won't ever need this unless you are writing an +extension, you can access it from an example like this:

+ +
it "does something" do
+  expect(example.[:description]).to eq("does something")
+end
+
+ +

described_class

+ +

When a class is passed to describe, you can access it from an +example using the described_class method, which is a wrapper +for example.metadata[:described_class].

+ +
RSpec.describe Widget do
+  example do
+    expect(described_class).to equal(Widget)
+  end
+end
+
+ +

This is useful in extensions or shared example groups in which the specific +class is unknown. Taking the collections shared example group from above, +we can clean it up a bit using described_class:

+ +
RSpec.shared_examples "collections" do
+  it "is empty when first created" do
+    expect(described_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections"
+end
+
+RSpec.describe Hash do
+  include_examples "collections"
+end
+
+ +

the rspec command

+ +

When you install the rspec-core gem, it installs the rspec +executable, which you'll use to run rspec. The rspec +command comes with many useful options. Run rspec --help to +see the complete list.

+ +

store command line options .rspec

+ +

You can store command line options in a .rspec file in the +project's root directory, and the rspec command will read +them as though you typed them on the command line.

+ +

autotest integration

+ +

rspec-core no longer ships with an Autotest extension, if you require +Autotest integration, please use the rspec-autotest gem and +see rspec/rspec-autotest for +details

+ +

get started

+ +

Start with a simple example of behavior you expect from your system. Do +this before you write any implementation code:

+ +
# in spec/calculator_spec.rb
+RSpec.describe Calculator do
+  describe '#add' do
+    it 'returns the sum of its arguments' do
+      expect(Calculator.new.add(1, 2)).to eq(3)
+    end
+  end
+end
+
+ +

Run this with the rspec command, and watch it fail:

+ +
$ rspec spec/calculator_spec.rb
+./spec/calculator_spec.rb:1: uninitialized constant Calculator
+ +

Implement the simplest solution:

+ +
# in lib/calculator.rb
+class Calculator
+  def add(a,b)
+    a + b
+  end
+end
+
+ +

Be sure to require the implementation file in the spec:

+ +
# in spec/calculator_spec.rb
+# - RSpec adds ./lib to the $LOAD_PATH
+require "calculator"
+
+ +

Now run the spec again, and watch it pass:

+ +
$ rspec spec/calculator_spec.rb
+.
+
+Finished in 0.000315 seconds
+1 example, 0 failures
+ +

Use the documentation formatter to see the resulting spec:

+ +
$ rspec spec/calculator_spec.rb --format doc
+Calculator
+  #add
+    returns the sum of its arguments
+
+Finished in 0.000379 seconds
+1 example, 0 failures
+ +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-core/method_list.html b/source/documentation/3.1/rspec-core/method_list.html new file mode 100644 index 000000000..657ddcbe1 --- /dev/null +++ b/source/documentation/3.1/rspec-core/method_list.html @@ -0,0 +1,1683 @@ + + + + + + + + + + + + + + + + + Method List + + + + +
+

Method List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-core/top-level-namespace.html b/source/documentation/3.1/rspec-core/top-level-namespace.html new file mode 100644 index 000000000..c134dd46d --- /dev/null +++ b/source/documentation/3.1/rspec-core/top-level-namespace.html @@ -0,0 +1,112 @@ + + + + + + Top Level Namespace + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Top Level Namespace + + + +

+ +
+ + + + + + + + +
+
+ +

Defined Under Namespace

+

+ + + Modules: RSpec + + + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/BasicObject.html b/source/documentation/3.1/rspec-expectations/BasicObject.html new file mode 100644 index 000000000..471f8bc3c --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/BasicObject.html @@ -0,0 +1,392 @@ + + + + + + Class: BasicObject + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: BasicObject + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/expectations/syntax.rb
+ +
+
+ +

Overview

+
+

The legacy :should syntax adds the following methods directly to +BasicObject so that they are available off of any object. Note, however, +that this syntax does not always play nice with delegate/proxy objects. +We recommend you use the non-monkeypatching :expect syntax instead.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) should + + + + + +

+
+ +
+ Note: +

This is only available when you have enabled the :should syntax.

+
+
+ +

Passes if matcher returns true. Available on every Object.

+ + +
+
+
+ +
+

Examples:

+ + +
actual.should eq expected
+actual.should match /expression/
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + +
  • + +
  • + + message + + + (String) + + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/expectations/syntax.rb', line 109
+
+
+
+
+ +
+

+ + - (Boolean) should_not + + + + + +

+
+ +
+ Note: +

This is only available when you have enabled the :should syntax.

+
+
+ +

Passes if matcher returns false. Available on every Object.

+ + +
+
+
+ +
+

Examples:

+ + +
actual.should_not eq expected
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + +
  • + +
  • + + message + + + (String) + + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    false if the negative expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/expectations/syntax.rb', line 131
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec.html b/source/documentation/3.1/rspec-expectations/RSpec.html new file mode 100644 index 000000000..51e694460 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec.html @@ -0,0 +1,128 @@ + + + + + + Module: RSpec + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/matchers.rb,
+ lib/rspec/expectations.rb,
lib/rspec/matchers/dsl.rb,
lib/rspec/matchers/pretty.rb,
lib/rspec/matchers/built_in.rb,
lib/rspec/expectations/syntax.rb,
lib/rspec/matchers/composable.rb,
lib/rspec/matchers/built_in/be.rb,
lib/rspec/expectations/version.rb,
lib/rspec/expectations/handler.rb,
lib/rspec/matchers/built_in/eq.rb,
lib/rspec/matchers/built_in/all.rb,
lib/rspec/matchers/built_in/eql.rb,
lib/rspec/matchers/built_in/has.rb,
lib/rspec/expectations/fail_with.rb,
lib/rspec/matchers/built_in/match.rb,
lib/rspec/matchers/built_in/cover.rb,
lib/rspec/matchers/built_in/yield.rb,
lib/rspec/matchers/built_in/exist.rb,
lib/rspec/matchers/built_in/equal.rb,
lib/rspec/matchers/built_in/output.rb,
lib/rspec/matchers/aliased_matcher.rb,
lib/rspec/matchers/built_in/change.rb,
lib/rspec/matchers/matcher_protocol.rb,
lib/rspec/matchers/built_in/include.rb,
lib/rspec/matchers/built_in/satisfy.rb,
lib/rspec/matchers/built_in/compound.rb,
lib/rspec/matchers/matcher_delegator.rb,
lib/rspec/expectations/configuration.rb,
lib/rspec/matchers/built_in/operators.rb,
lib/rspec/matchers/built_in/be_within.rb,
lib/rspec/matchers/built_in/respond_to.rb,
lib/rspec/matchers/built_in/be_between.rb,
lib/rspec/matchers/built_in/be_kind_of.rb,
lib/rspec/matchers/built_in/raise_error.rb,
lib/rspec/matchers/built_in/throw_symbol.rb,
lib/rspec/matchers/built_in/base_matcher.rb,
lib/rspec/matchers/generated_descriptions.rb,
lib/rspec/expectations/expectation_target.rb,
lib/rspec/matchers/built_in/be_instance_of.rb,
lib/rspec/expectations/minitest_integration.rb,
lib/rspec/matchers/built_in/have_attributes.rb,
lib/rspec/matchers/built_in/contain_exactly.rb,
lib/rspec/matchers/built_in/start_and_end_with.rb
+
+ +
+
+ +

Overview

+
+

RSpec's top level namespace. All of rspec-expectations is contained +in the RSpec::Expectations and RSpec::Matchers namespaces.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Expectations, Matchers + + + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Expectations.html b/source/documentation/3.1/rspec-expectations/RSpec/Expectations.html new file mode 100644 index 000000000..4977437f3 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Expectations.html @@ -0,0 +1,407 @@ + + + + + + Module: RSpec::Expectations + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Expectations + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/expectations.rb,
+ lib/rspec/expectations/syntax.rb,
lib/rspec/expectations/version.rb,
lib/rspec/expectations/handler.rb,
lib/rspec/expectations/fail_with.rb,
lib/rspec/expectations/configuration.rb,
lib/rspec/expectations/expectation_target.rb,
lib/rspec/expectations/minitest_integration.rb
+
+ +
+
+ +

Overview

+
+

RSpec::Expectations provides a simple, readable API to express +the expected outcomes in a code example. To express an expected +outcome, wrap an object or block in expect, call to or to_not +(aliased as not_to) and pass it a matcher object:

+ +
expect(order.total).to eq(Money.new(5.55, :USD))
+expect(list).to include(user)
+expect(message).not_to match(/foo/)
+expect { do_something }.to raise_error
+
+ +

The last form (the block form) is needed to match against ruby constructs +that are not objects, but can only be observed when executing a block +of code. This includes raising errors, throwing symbols, yielding, +and changing values.

+ +

When expect(...).to is invoked with a matcher, it turns around +and calls matcher.matches?(<object wrapped by expect>). For example, +in the expression:

+ +
expect(order.total).to eq(Money.new(5.55, :USD))
+
+ +

...eq(Money.new(5.55, :USD)) returns a matcher object, and it results +in the equivalent of eq.matches?(order.total). If matches? returns +true, the expectation is met and execution continues. If false, then +the spec fails with the message returned by eq.failure_message.

+ +

Given the expression:

+ +
expect(order.entries).not_to include(entry)
+
+ +

...the not_to method (also available as to_not) invokes the equivalent of +include.matches?(order.entries), but it interprets false as success, and +true as a failure, using the message generated by +include.failure_message_when_negated.

+ +

rspec-expectations ships with a standard set of useful matchers, and writing +your own matchers is quite simple.

+ +

See RSpec::Matchers for more information about the +built-in matchers that ship with rspec-expectations, and how to write your +own custom matchers.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Syntax + + + + Classes: Configuration, ExpectationNotMetError, ExpectationTarget + + +

+ +

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (RSpec::Expectations::Configuration) configuration + + + + + +

+
+

The configuration object.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+140
+141
+142
+
+
# File 'lib/rspec/expectations/configuration.rb', line 140
+
+def self.configuration
+  @configuration ||= Configuration.new
+end
+
+
+ +
+

+ + + (Object) fail_with(message, expected = nil, actual = nil) + + + + + +

+
+

Raises an RSpec::Expectations::ExpectationNotMetError with message. +Adds a diff to the failure message when expected and actual are +both present.

+ + +
+
+
+

Parameters:

+
    + +
  • + + message + + + (String) + + + +
  • + +
  • + + expected + + + (Object) + + + (defaults to: nil) + + +
  • + +
  • + + actual + + + (Object) + + + (defaults to: nil) + + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/rspec/expectations/fail_with.rb', line 21
+
+def fail_with(message, expected=nil, actual=nil)
+  unless message
+    raise ArgumentError, "Failure message is nil. Does your matcher define the " \
+                         "appropriate failure_message[_when_negated] method to return a string?"
+  end
+
+  diff = differ.diff(actual, expected)
+  message = "#{message}\nDiff:#{diff}" unless diff.empty?
+
+  raise RSpec::Expectations::ExpectationNotMetError, message
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Expectations/Configuration.html b/source/documentation/3.1/rspec-expectations/RSpec/Expectations/Configuration.html new file mode 100644 index 000000000..a0dc0da9b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Expectations/Configuration.html @@ -0,0 +1,896 @@ + + + + + + Class: RSpec::Expectations::Configuration + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Expectations::Configuration + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/expectations/configuration.rb
+ +
+
+ +

Overview

+
+

Provides configuration options for rspec-expectations. +If you are using rspec-core, you can access this via a +block passed to RSpec::Core::Configuration#expect_with. +Otherwise, you can access it via RSpec::Expectations.configuration.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |rspec|
+  rspec.expect_with :rspec do |c|
+    # c is the config object
+  end
+end
+
+# or
+
+RSpec::Expectations.configuration
+ +
+ + +
+

Constant Summary

+ +
+ +
NullBacktraceFormatter = +
+
+

+ This constant is part of a private API. + You should avoid using this constant if possible, as it may be removed or be changed in the future. +

+

Null implementation of a backtrace formatter used by default +when rspec-core is not loaded. Does no filtering.

+ + +
+
+
+ + +
+
+
Module.new do
+  def self.format_backtrace(backtrace)
+    backtrace
+  end
+end
+ +
+ + + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) backtrace_formatter + + + + + +

+
+

Sets or gets the backtrace formatter. The backtrace formatter should +implement #format_backtrace(Array<String>). This is used +to format backtraces of errors handled by the raise_error +matcher.

+ +

If you are using rspec-core, rspec-core's backtrace formatting +will be used (including respecting the presence or absence of +the --backtrace option).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+101
+
+
# File 'lib/rspec/expectations/configuration.rb', line 101
+
+attr_writer :backtrace_formatter
+
+
+ + + +
+

+ + - (Object) color=(value) (writeonly) + + + + + +

+
+

Indicates whether or not diffs should be colored. +Delegates to rspec-core's color option if rspec-core +is loaded; otherwise you can set it here.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+68
+69
+70
+
+
# File 'lib/rspec/expectations/configuration.rb', line 68
+
+def color=(value)
+  @color = value
+end
+
+
+ + + +
+

+ + - (Object) include_chain_clauses_in_custom_matcher_descriptions=(value) (writeonly) + + + + + +

+
+

Sets if custom matcher descriptions and failure messages +should include clauses from methods defined using chain.

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + (Boolean) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+113
+114
+115
+
+
# File 'lib/rspec/expectations/configuration.rb', line 113
+
+def include_chain_clauses_in_custom_matcher_descriptions=(value)
+  @include_chain_clauses_in_custom_matcher_descriptions = value
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) add_should_and_should_not_to(*modules) + + + + + +

+
+

Adds should and should_not to the given classes +or modules. This can be used to ensure should works +properly on things like proxy objects (particular +Delegator-subclassed objects on 1.8).

+ + +
+
+
+

Parameters:

+
    + +
  • + + modules + + + (Array<Module>) + + + + — +

    the list of classes or modules +to add should and should_not to.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+85
+86
+87
+88
+89
+
+
# File 'lib/rspec/expectations/configuration.rb', line 85
+
+def add_should_and_should_not_to(*modules)
+  modules.each do |mod|
+    Expectations::Syntax.enable_should(mod)
+  end
+end
+
+
+ +
+

+ + - (Boolean) color? + + + + + +

+
+

Indicates whether or not diffs should be colored. +Delegates to rspec-core's color option if rspec-core +is loaded; otherwise you can set it here.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+73
+74
+75
+
+
# File 'lib/rspec/expectations/configuration.rb', line 73
+
+def color?
+  ::RSpec.configuration.color_enabled?
+end
+
+
+ +
+

+ + - (Boolean) include_chain_clauses_in_custom_matcher_descriptions? + + + + + +

+
+

Indicates whether or not custom matcher descriptions and failure messages +should include clauses from methods defined using chain. It is +false by default for backwards compatibility.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+118
+119
+120
+
+
# File 'lib/rspec/expectations/configuration.rb', line 118
+
+def include_chain_clauses_in_custom_matcher_descriptions?
+  @include_chain_clauses_in_custom_matcher_descriptions ||= false
+end
+
+
+ +
+

+ + - (Array<Symbol>) syntax + + + + + +

+
+

The list of configured syntaxes.

+ + +
+
+
+ +
+

Examples:

+ + +
unless RSpec::Matchers.configuration.syntax.include?(:expect)
+  raise "this RSpec extension gem requires the rspec-expectations `:expect` syntax"
+end
+ +
+ +

Returns:

+
    + +
  • + + + (Array<Symbol>) + + + + — +

    the list of configured syntaxes.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+53
+54
+55
+56
+57
+58
+
+
# File 'lib/rspec/expectations/configuration.rb', line 53
+
+def syntax
+  syntaxes = []
+  syntaxes << :should if Expectations::Syntax.should_enabled?
+  syntaxes << :expect if Expectations::Syntax.expect_enabled?
+  syntaxes
+end
+
+
+ +
+

+ + - (Object) syntax=(values) + + + + + +

+
+

Configures the supported syntax.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |rspec|
+  rspec.expect_with :rspec do |c|
+    c.syntax = :should
+    # or
+    c.syntax = :expect
+    # or
+    c.syntax = [:should, :expect]
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + values + + + (Array<Symbol>, Symbol) + + + + — +

    the syntaxes to enable

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lib/rspec/expectations/configuration.rb', line 33
+
+def syntax=(values)
+  if Array(values).include?(:expect)
+    Expectations::Syntax.enable_expect
+  else
+    Expectations::Syntax.disable_expect
+  end
+
+  if Array(values).include?(:should)
+    Expectations::Syntax.enable_should
+  else
+    Expectations::Syntax.disable_should
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Expectations/ExpectationTarget.html b/source/documentation/3.1/rspec-expectations/RSpec/Expectations/ExpectationTarget.html new file mode 100644 index 000000000..97d783534 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Expectations/ExpectationTarget.html @@ -0,0 +1,515 @@ + + + + + + Class: RSpec::Expectations::ExpectationTarget + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Expectations::ExpectationTarget + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/expectations/expectation_target.rb
+ +
+
+ +

Overview

+
+ +
+ Note: +

ExpectationTarget is not intended to be instantiated +directly by users. Use expect instead.

+
+
+ +

Wraps the target of an expectation.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(something)       # => ExpectationTarget wrapping something
+expect { do_something } # => ExpectationTarget wrapping the block
+
+# used with `to`
+expect(actual).to eq(3)
+
+# with `not_to`
+expect(actual).not_to eq(3)
+ +
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ExpectationTarget) initialize(value) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ExpectationTarget

+ + +
+
+
+ + +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lib/rspec/expectations/expectation_target.rb', line 25
+
+def initialize(value)
+  @target = value
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) not_to(matcher = nil, message = nil, &block) + + + + Also known as: + to_not + + + + +

+
+

Runs the given expectation, passing if matcher returns false.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(value).not_to eq(5)
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + (defaults to: nil) + + +
  • + +
  • + + message + + + (String or Proc) + + + (defaults to: nil) + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    false if the negative expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+65
+66
+67
+68
+
+
# File 'lib/rspec/expectations/expectation_target.rb', line 65
+
+def not_to(matcher=nil, message=nil, &block)
+  prevent_operator_matchers(:not_to) unless matcher
+  RSpec::Expectations::NegativeExpectationHandler.handle_matcher(@target, matcher, message, &block)
+end
+
+
+ +
+

+ + - (Boolean) to(matcher = nil, message = nil, &block) + + + + + +

+
+

Runs the given expectation, passing if matcher returns true.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(value).to eq(5)
+expect { perform }.to raise_error
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + (defaults to: nil) + + +
  • + +
  • + + message + + + (String or Proc) + + + (defaults to: nil) + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+52
+53
+54
+55
+
+
# File 'lib/rspec/expectations/expectation_target.rb', line 52
+
+def to(matcher=nil, message=nil, &block)
+  prevent_operator_matchers(:to) unless matcher
+  RSpec::Expectations::PositiveExpectationHandler.handle_matcher(@target, matcher, message, &block)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Expectations/Syntax.html b/source/documentation/3.1/rspec-expectations/RSpec/Expectations/Syntax.html new file mode 100644 index 000000000..969230397 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Expectations/Syntax.html @@ -0,0 +1,838 @@ + + + + + + Module: RSpec::Expectations::Syntax + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Expectations::Syntax + + + Private +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/expectations/syntax.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+

Provides methods for enabling and disabling the available +syntaxes provided by rspec-expectations.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) default_should_host + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Determines where we add should and should_not.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lib/rspec/expectations/syntax.rb', line 11
+
+def default_should_host
+  @default_should_host ||= ::Object.ancestors.last
+end
+
+
+ +
+

+ + + (Object) disable_expect(syntax_host = ::RSpec::Matchers) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Disables the expect syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+80
+81
+82
+83
+84
+85
+86
+
+
# File 'lib/rspec/expectations/syntax.rb', line 80
+
+def disable_expect(syntax_host=::RSpec::Matchers)
+  return unless expect_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    undef expect
+  end
+end
+
+
+ +
+

+ + + (Object) disable_should(syntax_host = default_should_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Disables the should syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+62
+63
+64
+
+
# File 'lib/rspec/expectations/syntax.rb', line 57
+
+def disable_should(syntax_host=default_should_host)
+  return unless should_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    undef should
+    undef should_not
+  end
+end
+
+
+ +
+

+ + + (Object) enable_expect(syntax_host = ::RSpec::Matchers) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Enables the expect syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+74
+75
+76
+
+
# File 'lib/rspec/expectations/syntax.rb', line 68
+
+def enable_expect(syntax_host=::RSpec::Matchers)
+  return if expect_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    def expect(value=::RSpec::Expectations::ExpectationTarget::UndefinedValue, &block)
+      ::RSpec::Expectations::ExpectationTarget.for(value, block)
+    end
+  end
+end
+
+
+ +
+

+ + + (Object) enable_should(syntax_host = default_should_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Enables the should syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/rspec/expectations/syntax.rb', line 38
+
+def enable_should(syntax_host=default_should_host)
+  @warn_about_should = false if syntax_host == default_should_host
+  return if should_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    def should(matcher=nil, message=nil, &block)
+      ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__)
+      ::RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
+    end
+
+    def should_not(matcher=nil, message=nil, &block)
+      ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__)
+      ::RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
+    end
+  end
+end
+
+
+ +
+

+ + + (Boolean) expect_enabled?(syntax_host = ::RSpec::Matchers) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates whether or not the expect syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+96
+97
+98
+
+
# File 'lib/rspec/expectations/syntax.rb', line 96
+
+def expect_enabled?(syntax_host=::RSpec::Matchers)
+  syntax_host.method_defined?(:expect)
+end
+
+
+ +
+

+ + + (Boolean) should_enabled?(syntax_host = default_should_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates whether or not the should syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+90
+91
+92
+
+
# File 'lib/rspec/expectations/syntax.rb', line 90
+
+def should_enabled?(syntax_host=default_should_host)
+  syntax_host.method_defined?(:should)
+end
+
+
+ +
+

+ + + (Object) warn_about_should! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Instructs rspec-expectations to warn on first usage of should or should_not. +Enabled by default. This is largely here to facilitate testing.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lib/rspec/expectations/syntax.rb', line 18
+
+def warn_about_should!
+  @warn_about_should = true
+end
+
+
+ +
+

+ + + (Object) warn_about_should_unless_configured(method_name) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Generates a deprecation warning for the given method if no warning +has already been issued.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+
+
# File 'lib/rspec/expectations/syntax.rb', line 25
+
+def warn_about_should_unless_configured(method_name)
+  return unless @warn_about_should
+
+  RSpec.deprecate(
+    "Using `#{method_name}` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax",
+    :replacement => "the new `:expect` syntax or explicitly enable `:should`"
+  )
+
+  @warn_about_should = false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers.html new file mode 100644 index 000000000..c2018d0af --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers.html @@ -0,0 +1,3910 @@ + + + + + + Module: RSpec::Matchers + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers + + + +

+ +
+ + + + + + + +
Included in:
+
DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers.rb,
+ lib/rspec/matchers/dsl.rb,
lib/rspec/matchers/pretty.rb,
lib/rspec/matchers/built_in.rb,
lib/rspec/matchers/composable.rb,
lib/rspec/matchers/built_in/be.rb,
lib/rspec/matchers/built_in/eq.rb,
lib/rspec/matchers/built_in/all.rb,
lib/rspec/matchers/built_in/eql.rb,
lib/rspec/matchers/built_in/has.rb,
lib/rspec/matchers/built_in/match.rb,
lib/rspec/matchers/built_in/cover.rb,
lib/rspec/matchers/built_in/yield.rb,
lib/rspec/matchers/built_in/exist.rb,
lib/rspec/matchers/built_in/equal.rb,
lib/rspec/matchers/built_in/output.rb,
lib/rspec/matchers/aliased_matcher.rb,
lib/rspec/matchers/built_in/change.rb,
lib/rspec/matchers/matcher_protocol.rb,
lib/rspec/matchers/built_in/include.rb,
lib/rspec/matchers/built_in/satisfy.rb,
lib/rspec/matchers/built_in/compound.rb,
lib/rspec/matchers/matcher_delegator.rb,
lib/rspec/matchers/built_in/operators.rb,
lib/rspec/matchers/built_in/be_within.rb,
lib/rspec/matchers/built_in/respond_to.rb,
lib/rspec/matchers/built_in/be_between.rb,
lib/rspec/matchers/built_in/be_kind_of.rb,
lib/rspec/matchers/built_in/raise_error.rb,
lib/rspec/matchers/built_in/throw_symbol.rb,
lib/rspec/matchers/built_in/base_matcher.rb,
lib/rspec/matchers/generated_descriptions.rb,
lib/rspec/matchers/built_in/be_instance_of.rb,
lib/rspec/matchers/built_in/have_attributes.rb,
lib/rspec/matchers/built_in/contain_exactly.rb,
lib/rspec/matchers/built_in/start_and_end_with.rb
+
+ +
+
+ +

Overview

+
+

RSpec::Matchers provides a number of useful matchers we use to define +expectations. Any object that implements the matcher protocol +can be used as a matcher.

+ +

Predicates

+ +

In addition to matchers that are defined explicitly, RSpec will create +custom matchers on the fly for any arbitrary predicate, giving your specs a +much more natural language feel.

+ +

A Ruby predicate is a method that ends with a "?" and returns true or false. +Common examples are empty?, nil?, and instance_of?.

+ +

All you need to do is write expect(..).to be_ followed by the predicate +without the question mark, and RSpec will figure it out from there. +For example:

+ +
expect([]).to be_empty     # => [].empty?() | passes
+expect([]).not_to be_empty # => [].empty?() | fails
+
+ +

In addtion to prefixing the predicate matchers with "be", you can also use "be_a" +and "bean", making your specs read much more naturally:

+ +
expect("a string").to be_an_instance_of(String) # =>"a string".instance_of?(String) # passes
+
+expect(3).to be_a_kind_of(Fixnum)        # => 3.kind_of?(Numeric)     | passes
+expect(3).to be_a_kind_of(Numeric)       # => 3.kind_of?(Numeric)     | passes
+expect(3).to be_an_instance_of(Fixnum)   # => 3.instance_of?(Fixnum)  | passes
+expect(3).not_to be_an_instance_of(Numeric) # => 3.instance_of?(Numeric) | fails
+
+ +

RSpec will also create custom matchers for predicates like has_key?. To +use this feature, just state that the object should have_key(:key) and RSpec will +call has_key?(:key) on the target. For example:

+ +
expect(:a => "A").to have_key(:a)
+expect(:a => "A").to have_key(:b) # fails
+
+ +

You can use this feature to invoke any predicate that begins with "has_", whether it is +part of the Ruby libraries (like Hash#has_key?) or a method you wrote on your own class.

+ +

Note that RSpec does not provide composable aliases for these dynamic predicate +matchers. You can easily define your own aliases, though:

+ +
RSpec::Matchers.alias_matcher :a_user_who_is_an_admin, :be_an_admin
+expect(user_list).to include(a_user_who_is_an_admin)
+
+ +

Custom Matchers

+ +

When you find that none of the stock matchers provide a natural feeling +expectation, you can very easily write your own using RSpec's matcher DSL +or writing one from scratch.

+ +

Matcher DSL

+ +

Imagine that you are writing a game in which players can be in various +zones on a virtual board. To specify that bob should be in zone 4, you +could say:

+ +
expect(bob.current_zone).to eql(Zone.new("4"))
+
+ +

But you might find it more expressive to say:

+ +
expect(bob).to be_in_zone("4")
+
+ +

and/or

+ +
expect(bob).not_to be_in_zone("3")
+
+ +

You can create such a matcher like so:

+ +
RSpec::Matchers.define :be_in_zone do |zone|
+  match do |player|
+    player.in_zone?(zone)
+  end
+end
+
+ +

This will generate a be_in_zone method that returns a matcher +with logical default messages for failures. You can override the failure +messages and the generated description as follows:

+ +
RSpec::Matchers.define :be_in_zone do |zone|
+  match do |player|
+    player.in_zone?(zone)
+  end
+
+  failure_message do |player|
+    # generate and return the appropriate string.
+  end
+
+  failure_message_when_negated do |player|
+    # generate and return the appropriate string.
+  end
+
+  description do
+    # generate and return the appropriate string.
+  end
+end
+
+ +

Each of the message-generation methods has access to the block arguments +passed to the create method (in this case, zone). The +failure message methods (failure_message and +failure_message_when_negated) are passed the actual value (the +receiver of expect(..) or expect(..).not_to).

+ +

Custom Matcher from scratch

+ +

You could also write a custom matcher from scratch, as follows:

+ +
class BeInZone
+  def initialize(expected)
+    @expected = expected
+  end
+
+  def matches?(target)
+    @target = target
+    @target.current_zone.eql?(Zone.new(@expected))
+  end
+
+  def failure_message
+    "expected #{@target.inspect} to be in Zone #{@expected}"
+  end
+
+  def failure_message_when_negated
+    "expected #{@target.inspect} not to be in Zone #{@expected}"
+  end
+end
+
+ +

... and a method like this:

+ +
def be_in_zone(expected)
+  BeInZone.new(expected)
+end
+
+ +

And then expose the method to your specs. This is normally done +by including the method and the class in a module, which is then +included in your spec:

+ +
module CustomGameMatchers
+  class BeInZone
+    # ...
+  end
+
+  def be_in_zone(expected)
+    # ...
+  end
+end
+
+describe "Player behaviour" do
+  include CustomGameMatchers
+  # ...
+end
+
+ +

or you can include in globally in a spec_helper.rb file required +from your spec file(s):

+ +
RSpec::configure do |config|
+  config.include(CustomGameMatchers)
+end
+
+ +

Making custom matchers composable

+ +

RSpec's built-in matchers are designed to be composed, in expressions like:

+ +
expect(["barn", 2.45]).to contain_exactly(
+  a_value_within(0.1).of(2.5),
+  a_string_starting_with("bar")
+)
+
+ +

Custom matchers can easily participate in composed matcher expressions like these. +Include Composable in your custom matcher to make it support +being composed (matchers defined using the DSL have this included automatically). +Within your matcher's matches? method (or the match block, if using the DSL), +use values_match?(expected, actual) rather than expected == actual. +Under the covers, values_match? is able to match arbitrary +nested data structures containing a mix of both matchers and non-matcher objects. +It uses === and == to perform the matching, considering the values to +match if either returns true. The Composable mixin also provides some helper +methods for surfacing the matcher descriptions within your matcher's description +or failure messages.

+ +

RSpec's built-in matchers each have a number of aliases that rephrase the matcher +from a verb phrase (such as be_within) to a noun phrase (such as a_value_within), +which reads better when the matcher is passed as an argument in a composed matcher +expressions, and also uses the noun-phrase wording in the matcher's description, +for readable failure messages. You can alias your custom matchers in similar fashion +using Matchers.alias_matcher.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: BuiltIn, Composable, DSL, Pretty + + + + Classes: AliasedMatcher, MatcherProtocol + + +

+ +

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing(method, *args, &block) (private) + + + + + +

+ + + + +
+
+
+
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+
+
# File 'lib/rspec/matchers.rb', line 931
+
+def method_missing(method, *args, &block)
+  case method.to_s
+  when BE_PREDICATE_REGEX
+    BuiltIn::BePredicate.new(method, *args, &block)
+  when HAS_REGEX
+    BuiltIn::Has.new(method, *args, &block)
+  else
+    super
+  end
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (Object) alias_matcher(new_name, old_name, options = {}) {|String| ... } + + + + + +

+
+

Defines a matcher alias. The returned matcher's description will be overriden +to reflect the phrasing of the new name, which will be used in failure messages +when passed as an argument to another matcher in a composed matcher expression.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.alias_matcher :a_list_that_sums_to, :sum_to
+sum_to(3).description # => "sum to 3"
+a_list_that_sums_to(3).description # => "a list that sums to 3"
+ + +

+RSpec::Matchers.alias_matcher :a_list_sorted_by, :be_sorted_by do |description|
+  description.sub("be sorted by", "a list sorted by")
+end
+
+be_sorted_by(:age).description # => "be sorted by age"
+a_list_sorted_by(:age).description # => "a list sorted by age"
+ +
+

Parameters:

+
    + +
  • + + new_name + + + (Symbol) + + + + — +

    the new name for the matcher

    +
    + +
  • + +
  • + + old_name + + + (Symbol) + + + + — +

    the original name for the matcher

    +
    + +
  • + +
  • + + options + + + (Hash) + + + (defaults to: {}) + + + — +

    options for the aliased matcher

    +
    + +
  • + +
+ + + + + + + + +

Options Hash (options):

+
    + +
  • + :klass + (Class) + + + + + —

    the ruby class to use as the decorator. (Not normally used).

    +
    + +
  • + +
+ + +

Yields:

+
    + +
  • + + + (String) + + + + — +

    optional block that, when given is used to define the overriden +description. The yielded arg is the original description. If no block is +provided, a default description override is used based on the old and +new names.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+
+
# File 'lib/rspec/matchers.rb', line 246
+
+def self.alias_matcher(new_name, old_name, options={}, &description_override)
+  description_override ||= lambda do |old_desc|
+    old_desc.gsub(Pretty.split_words(old_name), Pretty.split_words(new_name))
+  end
+  klass = options.fetch(:klass) { AliasedMatcher }
+
+  define_method(new_name) do |*args, &block|
+    matcher = __send__(old_name, *args, &block)
+    klass.new(matcher, description_override)
+  end
+end
+
+
+ +
+

+ + + (Object) clear_generated_description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Used by rspec-core to clear the state used to generate +descriptions after an example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/generated_descriptions.rb', line 11
+
+def self.clear_generated_description
+  self.last_matcher = nil
+  self.last_expectation_handler = nil
+end
+
+
+ +
+

+ + + (RSpec::Expectations::Configuration) configuration + + + + + +

+
+

Delegates to Expectations.configuration. +This is here because rspec-core's expect_with option +looks for a configuration method on the mixin +(RSpec::Matchers) to yield to a block.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+922
+923
+924
+
+
# File 'lib/rspec/matchers.rb', line 922
+
+def self.configuration
+  Expectations.configuration
+end
+
+
+ +
+

+ + + (Object) define_negated_matcher(negated_name, base_name) {|String| ... } + + + + + +

+
+

Defines a negated matcher. The returned matcher's description and failure_message +will be overriden to reflect the phrasing of the new name, and the match logic will +be based on the original matcher but negated.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define_negated_matcher :a_value_not_between, :a_value_between
+a_value_between(3, 5).description # => "a value between 3 and 5"
+a_value_not_between(3, 5).description # => "a value not between 3 and 5"
+ +
+

Parameters:

+
    + +
  • + + negated_name + + + (Symbol) + + + + — +

    the name for the negated matcher

    +
    + +
  • + +
  • + + base_name + + + (Symbol) + + + + — +

    the name of the original matcher that will be negated

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + (String) + + + + — +

    optional block that, when given is used to define the overriden +description. The yielded arg is the original description. If no block is +provided, a default description override is used based on the old and +new names.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+274
+275
+276
+
+
# File 'lib/rspec/matchers.rb', line 274
+
+def self.define_negated_matcher(negated_name, base_name, &description_override)
+  alias_matcher(negated_name, base_name, :klass => AliasedNegatedMatcher, &description_override)
+end
+
+
+ +
+

+ + + (Object) generated_description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Generates an an example description based on the last expectation. +Used by rspec-core's one-liner syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+22
+
+
# File 'lib/rspec/matchers/generated_descriptions.rb', line 19
+
+def self.generated_description
+  return nil if last_expectation_handler.nil?
+  "#{last_expectation_handler.verb} #{last_description}"
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Object) all(expected) + + + + + +

+
+ +
+ Note: +

The negative form not_to all is not supported. Instead +use not_to include or pass a negative form of a matcher +as the argument (e.g. all exclude(:foo)).

+
+
+ +
+ Note: +

You can also use this with compound matchers as well.

+
+
+ +

Passes if actual all expected objects pass. This works for +any enumerable object.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect([1, 3, 5]).to all be_odd
+expect([1, 3, 6]).to all be_odd # fails
+ + +
expect([1, 3, 5]).to all( be_odd.and be_an(Integer) )
+ +
+ + +
+ + + + +
+
+
+
+635
+636
+637
+
+
# File 'lib/rspec/matchers.rb', line 635
+
+def all(expected)
+  BuiltIn::All.new(expected)
+end
+
+
+ +
+

+ + - (Object) be(*args) + + + + Also known as: + a_value + + + + +

+
+

Given true, false, or nil, will pass if actual value is true, false or +nil (respectively). Given no args means the caller should satisfy an if +condition (to be or not to be).

+ +

Predicates are any Ruby method that ends in a "?" and returns true or +false. Given be_ followed by arbitrary_predicate (without the "?"), +RSpec will match convert that into a query against the target object.

+ +

The arbitrarypredicate feature will handle any predicate prefixed with +"be_an" (e.g. bean_instance_of), "be_a" (e.g. bea_kind_of) or "be" +(e.g. be_empty), letting you choose the prefix that best suits the +predicate.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(actual).to     be_truthy
+expect(actual).to     be_falsey
+expect(actual).to     be_nil
+expect(actual).to     be_[arbitrary_predicate](*args)
+expect(actual).not_to be_nil
+expect(actual).not_to be_[arbitrary_predicate](*args)
+ +
+ + +
+ + + + +
+
+
+
+318
+319
+320
+
+
# File 'lib/rspec/matchers.rb', line 318
+
+def be(*args)
+  args.empty? ? Matchers::BuiltIn::Be.new : equal(*args)
+end
+
+
+ +
+

+ + - (Object) be_a(klass) + + + + Also known as: + be_an + + + + +

+
+

passes if target.kind_of?(klass)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+324
+325
+326
+
+
# File 'lib/rspec/matchers.rb', line 324
+
+def be_a(klass)
+  be_a_kind_of(klass)
+end
+
+
+ +
+

+ + - (Object) be_a_kind_of(expected) + + + + Also known as: + be_kind_of, a_kind_of + + + + +

+
+

Passes if actual.kind_of?(expected)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     be_a_kind_of(Fixnum)
+expect(5).to     be_a_kind_of(Numeric)
+expect(5).not_to be_a_kind_of(Float)
+ +
+ + +
+ + + + +
+
+
+
+349
+350
+351
+
+
# File 'lib/rspec/matchers.rb', line 349
+
+def be_a_kind_of(expected)
+  BuiltIn::BeAKindOf.new(expected)
+end
+
+
+ +
+

+ + - (Object) be_an_instance_of(expected) + + + + Also known as: + be_instance_of, an_instance_of + + + + +

+
+

Passes if actual.instance_of?(expected)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     be_an_instance_of(Fixnum)
+expect(5).not_to be_an_instance_of(Numeric)
+expect(5).not_to be_an_instance_of(Float)
+ +
+ + +
+ + + + +
+
+
+
+336
+337
+338
+
+
# File 'lib/rspec/matchers.rb', line 336
+
+def be_an_instance_of(expected)
+  BuiltIn::BeAnInstanceOf.new(expected)
+end
+
+
+ +
+

+ + - (Object) be_between(min, max) + + + + Also known as: + a_value_between + + + + +

+
+

Passes if actual.between?(min, max). Works with any Comparable object, +including String, Symbol, Time, or Numeric (Fixnum, Bignum, Integer, +Float, Complex, and Rational).

+ +

By default, be_between is inclusive (i.e. passes when given either the max or min value), +but you can make it exclusive by chaining that off the matcher.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to      be_between(1, 10)
+expect(11).not_to be_between(1, 10)
+expect(10).not_to be_between(1, 10).exclusive
+ +
+ + +
+ + + + +
+
+
+
+367
+368
+369
+
+
# File 'lib/rspec/matchers.rb', line 367
+
+def be_between(min, max)
+  BuiltIn::BeBetween.new(min, max)
+end
+
+
+ +
+

+ + - (Object) be_falsey + + + + Also known as: + be_falsy, a_falsey_value, a_falsy_value + + + + +

+
+

Passes if actual is falsey (false or nil)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+285
+286
+287
+
+
# File 'lib/rspec/matchers.rb', line 285
+
+def be_falsey
+  BuiltIn::BeFalsey.new
+end
+
+
+ +
+

+ + - (Object) be_nil + + + + Also known as: + a_nil_value + + + + +

+
+

Passes if actual is nil

+ + +
+
+
+ + +
+ + + + +
+
+
+
+293
+294
+295
+
+
# File 'lib/rspec/matchers.rb', line 293
+
+def be_nil
+  BuiltIn::BeNil.new
+end
+
+
+ +
+

+ + - (Object) be_truthy + + + + Also known as: + a_truthy_value + + + + +

+
+

Passes if actual is truthy (anything but false or nil)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+279
+280
+281
+
+
# File 'lib/rspec/matchers.rb', line 279
+
+def be_truthy
+  BuiltIn::BeTruthy.new
+end
+
+
+ +
+

+ + - (Object) be_within(delta) + + + + Also known as: + a_value_within, within + + + + +

+
+

Passes if actual == expected +/- delta

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(result).to     be_within(0.5).of(3.0)
+expect(result).not_to be_within(0.5).of(3.0)
+ +
+ + +
+ + + + +
+
+
+
+378
+379
+380
+
+
# File 'lib/rspec/matchers.rb', line 378
+
+def be_within(delta)
+  BuiltIn::BeWithin.new(delta)
+end
+
+
+ +
+

+ + - (Object) change(receiver = nil, message = nil, &block) + + + + Also known as: + a_block_changing, changing + + + + +

+
+

Applied to a proc, specifies that its execution will cause some value to +change.

+ +

You can either pass receiver and message, or a block, +but not both.

+ +

When passing a block, it must use the { ... } format, not +do/end, as { ... } binds to the change method, whereas do/end +would errantly bind to the expect(..).to or expect(...).not_to method.

+ +

You can chain any of the following off of the end to specify details +about the change:

+ +
    +
  • from
  • +
  • to
  • +
+ +

or any one of:

+ +
    +
  • by
  • +
  • by_at_least
  • +
  • by_at_most
  • +
+ +

== Notes

+ +

Evaluates receiver.message or block before and after it +evaluates the block passed to expect.

+ +

expect( ... ).not_to change supports the form that specifies from +(which specifies what you expect the starting, unchanged value to be) +but does not support forms with subsequent calls to by, by_at_least, +by_at_most or to.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect {
+  team.add_player(player)
+}.to change(roster, :count)
+
+expect {
+  team.add_player(player)
+}.to change(roster, :count).by(1)
+
+expect {
+  team.add_player(player)
+}.to change(roster, :count).by_at_least(1)
+
+expect {
+  team.add_player(player)
+}.to change(roster, :count).by_at_most(1)
+
+string = "string"
+expect {
+  string.reverse!
+}.to change { string }.from("string").to("gnirts")
+
+string = "string"
+expect {
+  string
+}.not_to change { string }.from("string")
+
+expect {
+  person.happy_birthday
+}.to change(person, :birthday).from(32).to(33)
+
+expect {
+  employee.develop_great_new_social_networking_app
+}.to change(employee, :title).from("Mail Clerk").to("CEO")
+
+expect {
+  doctor.leave_office
+}.to change(doctor, :sign).from(/is in/).to(/is out/)
+
+user = User.new(:type => "admin")
+expect {
+  user.symbolize_type
+}.to change(user, :type).from(String).to(Symbol)
+ +
+

Parameters:

+
    + +
  • + + receiver + + + (Object) + + + (defaults to: nil) + + +
  • + +
  • + + message + + + (Symbol) + + + (defaults to: nil) + + + — +

    the message to send the receiver

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+463
+464
+465
+
+
# File 'lib/rspec/matchers.rb', line 463
+
+def change(receiver=nil, message=nil, &block)
+  BuiltIn::Change.new(receiver, message, &block)
+end
+
+
+ +
+

+ + - (Object) contain_exactly(*items) + + + + Also known as: + a_collection_containing_exactly, containing_exactly + + + + +

+
+ +
+ Note: +

This is also available using the =~ operator with should, +but =~ is not supported with expect.

+
+
+ +

Passes if actual contains all of the expected regardless of order. +This works for collections. Pass in multiple args and it will only +pass if all args are found in collection.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect([1, 2, 3]).to contain_exactly(1, 2, 3)
+expect([1, 2, 3]).to contain_exactly(1, 3, 2)
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+482
+483
+484
+
+
# File 'lib/rspec/matchers.rb', line 482
+
+def contain_exactly(*items)
+  BuiltIn::ContainExactly.new(items)
+end
+
+
+ +
+

+ + - (Object) cover(*values) + + + + Also known as: + a_range_covering, covering + + + + +

+
+

Passes if actual covers expected. This works for +Ranges. You can also pass in multiple args +and it will only pass if all args are found in Range.

+ +

Warning:: Ruby >= 1.9 only

+ + +
+
+
+ +
+

Examples:

+ + +
expect(1..10).to     cover(5)
+expect(1..10).to     cover(4, 6)
+expect(1..10).to     cover(4, 6, 11) # fails
+expect(1..10).not_to cover(11)
+expect(1..10).not_to cover(5)        # fails
+ +
+ + +
+ + + + +
+
+
+
+500
+501
+502
+
+
# File 'lib/rspec/matchers.rb', line 500
+
+def cover(*values)
+  BuiltIn::Cover.new(*values)
+end
+
+
+ +
+

+ + - (Object) end_with(*expected) + + + + Also known as: + a_collection_ending_with, a_string_ending_with, ending_with + + + + +

+
+

Matches if the actual value ends with the expected value(s). In the case +of a string, matches against the last expected.length characters of the +actual string. In the case of an array, matches against the last +expected.length elements of the actual array.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect("this string").to   end_with "string"
+expect([0, 1, 2, 3, 4]).to end_with 4
+expect([0, 2, 3, 4, 4]).to end_with 3, 4
+ +
+ + +
+ + + + +
+
+
+
+516
+517
+518
+
+
# File 'lib/rspec/matchers.rb', line 516
+
+def end_with(*expected)
+  BuiltIn::EndWith.new(*expected)
+end
+
+
+ +
+

+ + - (Object) eq(expected) + + + + Also known as: + an_object_eq_to, eq_to + + + + +

+
+

Passes if actual == expected.

+ +

See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more +information about equality in Ruby.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     eq(5)
+expect(5).not_to eq(3)
+ +
+ + +
+ + + + +
+
+
+
+532
+533
+534
+
+
# File 'lib/rspec/matchers.rb', line 532
+
+def eq(expected)
+  BuiltIn::Eq.new(expected)
+end
+
+
+ +
+

+ + - (Object) eql(expected) + + + + Also known as: + an_object_eql_to, eql_to + + + + +

+
+

Passes if actual.eql?(expected)

+ +

See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more +information about equality in Ruby.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     eql(5)
+expect(5).not_to eql(3)
+ +
+ + +
+ + + + +
+
+
+
+547
+548
+549
+
+
# File 'lib/rspec/matchers.rb', line 547
+
+def eql(expected)
+  BuiltIn::Eql.new(expected)
+end
+
+
+ +
+

+ + - (Object) equal(expected) + + + + Also known as: + an_object_equal_to, equal_to + + + + +

+
+

Passes if actual.equal?(expected) (object identity).

+ +

See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more +information about equality in Ruby.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to       equal(5)   # Fixnums are equal
+expect("5").not_to equal("5") # Strings that look the same are not the same object
+ +
+ + +
+ + + + +
+
+
+
+562
+563
+564
+
+
# File 'lib/rspec/matchers.rb', line 562
+
+def equal(expected)
+  BuiltIn::Equal.new(expected)
+end
+
+
+ +
+

+ + - (Object) exist(*args) + + + + Also known as: + an_object_existing, existing + + + + +

+
+

Passes if actual.exist? or actual.exists?

+ + +
+
+
+ +
+

Examples:

+ + +
expect(File).to exist("path/to/file")
+ +
+ + +
+ + + + +
+
+
+
+572
+573
+574
+
+
# File 'lib/rspec/matchers.rb', line 572
+
+def exist(*args)
+  BuiltIn::Exist.new(*args)
+end
+
+
+ +
+

+ + - (ExpectationTarget) expect + + + + + +

+
+

Supports expect(actual).to matcher syntax by wrapping actual in an +ExpectationTarget.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(actual).to eq(expected)
+expect(actual).not_to eq(expected)
+ +
+ +

Returns:

+
    + +
  • + + + (ExpectationTarget) + + + +
  • + +
+ +

See Also:

+
    + +
  • ExpectationTarget#to
  • + +
  • ExpectationTarget#not_to
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers.rb', line 205
+
+
+
+
+ +
+

+ + - (Object) have_attributes(expected) + + + + Also known as: + an_object_having_attributes + + + + +

+
+ +
+ Note: +

It will fail if actual doesn't respond to any of the expected attributes.

+
+
+ +

Passes if actual's attribute values match the expected attributes hash. +This works no matter how you define your attribute readers.

+ + +
+
+
+ +
+

Examples:

+ + +

+Person = Struct.new(:name, :age)
+person = Person.new("Bob", 32)
+
+expect(person).to have_attributes(:name => "Bob", :age => 32)
+expect(person).to have_attributes(:name => a_string_starting_with("B"), :age => (a_value > 30) )
+ + +

+expect(person).to have_attributes(:color => "red")
+ +
+ + +
+ + + + +
+
+
+
+594
+595
+596
+
+
# File 'lib/rspec/matchers.rb', line 594
+
+def have_attributes(expected)
+  BuiltIn::HaveAttributes.new(expected)
+end
+
+
+ +
+

+ + - (Object) include(*expected) + + + + Also known as: + a_collection_including, a_string_including, a_hash_including, including + + + + +

+
+

Passes if actual includes expected. This works for +collections and Strings. You can also pass in multiple args +and it will only pass if all args are found in collection.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect([1,2,3]).to      include(3)
+expect([1,2,3]).to      include(2,3)
+expect([1,2,3]).to      include(2,3,4) # fails
+expect([1,2,3]).not_to  include(4)
+expect("spread").to     include("read")
+expect("spread").not_to include("red")
+ +
+ + +
+ + + + +
+
+
+
+611
+612
+613
+
+
# File 'lib/rspec/matchers.rb', line 611
+
+def include(*expected)
+  BuiltIn::Include.new(*expected)
+end
+
+
+ +
+

+ + - (Object) match(expected) + + + + Also known as: + match_regex, an_object_matching, a_string_matching, matching + + + + +

+
+ +
+ Note: +

The match_regex alias is deprecated and is not recommended for use. +It was added in 2.12.1 to facilitate its use from within custom +matchers (due to how the custom matcher DSL was evaluated in 2.x, +match could not be used there), but is no longer needed in 3.x.

+
+
+ +

Given a Regexp or String, passes if actual.match(pattern) +Given an arbitrary nested data structure (e.g. arrays and hashes), +matches if expected === actual || actual == expected for each +pair of elements.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(email).to match(/^([^\s]+)((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
+expect(email).to match("@example.com")
+ + +

+hash = {
+  :a => {
+    :b => ["foo", 5],
+    :c => { :d => 2.05 }
+  }
+}
+
+expect(hash).to match(
+  :a => {
+    :b => a_collection_containing_exactly(
+      a_string_starting_with("f"),
+      an_instance_of(Fixnum)
+    ),
+    :c => { :d => (a_value < 3) }
+  }
+)
+ +
+ + +
+ + + + +
+
+
+
+672
+673
+674
+
+
# File 'lib/rspec/matchers.rb', line 672
+
+def match(expected)
+  BuiltIn::Match.new(expected)
+end
+
+
+ +
+

+ + - (Object) match_array(items) + + + + + +

+
+

An alternate form of contain_exactly that accepts +the expected contents as a single array arg rather +that splatted out as individual items.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(results).to contain_exactly(1, 2)
+# is identical to:
+expect(results).to match_array([1, 2])
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+691
+692
+693
+
+
# File 'lib/rspec/matchers.rb', line 691
+
+def match_array(items)
+  contain_exactly(*items)
+end
+
+
+ +
+

+ + - (Object) output(expected = nil) + + + + Also known as: + a_block_outputting + + + + +

+
+ +
+ Note: +

This matcher works by temporarily replacing $stdout or $stderr, +so it's not able to intercept stream output that explicitly uses STDOUT/STDERR +or that uses a reference to $stdout/$stderr that was stored before the +matcher is used.

+
+
+ +

With no arg, passes if the block outputs to_stdout or to_stderr. +With a string, passes if the blocks outputs that specific string to_stdout or to_stderr. +With a regexp or matcher, passes if the blocks outputs a string to_stdout or to_stderr that matches.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { print 'foo' }.to output.to_stdout
+expect { print 'foo' }.to output('foo').to_stdout
+expect { print 'foo' }.to output(/foo/).to_stdout
+
+expect { do_something }.to_not output.to_stdout
+
+expect { warn('foo') }.to output.to_stderr
+expect { warn('foo') }.to output('foo').to_stderr
+expect { warn('foo') }.to output(/foo/).to_stderr
+
+expect { do_something }.to_not output.to_stderr
+ +
+ + +
+ + + + +
+
+
+
+717
+718
+719
+
+
# File 'lib/rspec/matchers.rb', line 717
+
+def output(expected=nil)
+  BuiltIn::Output.new(expected)
+end
+
+
+ +
+

+ + - (Object) raise_error(error = Exception, message = nil, &block) + + + + Also known as: + raise_exception, a_block_raising, raising + + + + +

+
+

With no args, matches if any error is raised. +With a named error, matches only if that specific error is raised. +With a named error and messsage specified as a String, matches only if both match. +With a named error and messsage specified as a Regexp, matches only if both match. +Pass an optional block to perform extra verifications on the exception matched

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { do_something_risky }.to raise_error
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError)
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError) { |error| expect(error.data).to eq 42 }
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError, "that was too risky")
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError, /oo ri/)
+
+expect { do_something_risky }.not_to raise_error
+ +
+ + +
+ + + + +
+
+
+
+737
+738
+739
+
+
# File 'lib/rspec/matchers.rb', line 737
+
+def raise_error(error=Exception, message=nil, &block)
+  BuiltIn::RaiseError.new(error, message, &block)
+end
+
+
+ +
+

+ + - (Object) respond_to(*names) + + + + Also known as: + an_object_responding_to, responding_to + + + + +

+
+

Matches if the target object responds to all of the names +provided. Names can be Strings or Symbols.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect("string").to respond_to(:length)
+ +
+ + +
+ + + + +
+
+
+
+757
+758
+759
+
+
# File 'lib/rspec/matchers.rb', line 757
+
+def respond_to(*names)
+  BuiltIn::RespondTo.new(*names)
+end
+
+
+ +
+

+ + - (Object) satisfy(&block) + + + + Also known as: + an_object_satisfying, satisfying + + + + +

+
+

Passes if the submitted block returns true. Yields target to the +block.

+ +

Generally speaking, this should be thought of as a last resort when +you can't find any other way to specify the behaviour you wish to +specify.

+ +

If you do find yourself in such a situation, you could always write +a custom matcher, which would likely make your specs more expressive.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to satisfy { |n| n > 3 }
+ +
+ + +
+ + + + +
+
+
+
+776
+777
+778
+
+
# File 'lib/rspec/matchers.rb', line 776
+
+def satisfy(&block)
+  BuiltIn::Satisfy.new(&block)
+end
+
+
+ +
+

+ + - (Object) start_with(*expected) + + + + Also known as: + a_collection_starting_with, a_string_starting_with, starting_with + + + + +

+
+

Matches if the actual value starts with the expected value(s). In the +case of a string, matches against the first expected.length characters +of the actual string. In the case of an array, matches against the first +expected.length elements of the actual array.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect("this string").to   start_with "this s"
+expect([0, 1, 2, 3, 4]).to start_with 0
+expect([0, 2, 3, 4, 4]).to start_with 0, 1
+ +
+ + +
+ + + + +
+
+
+
+792
+793
+794
+
+
# File 'lib/rspec/matchers.rb', line 792
+
+def start_with(*expected)
+  BuiltIn::StartWith.new(*expected)
+end
+
+
+ +
+

+ + - (Object) throw_symbol(expected_symbol = nil, expected_arg = nil) + + + + Also known as: + a_block_throwing, throwing + + + + +

+
+

Given no argument, matches if a proc throws any Symbol.

+ +

Given a Symbol, matches if the given proc throws the specified Symbol.

+ +

Given a Symbol and an arg, matches if the given proc throws the +specified Symbol with the specified arg.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { do_something_risky }.to throw_symbol
+expect { do_something_risky }.to throw_symbol(:that_was_risky)
+expect { do_something_risky }.to throw_symbol(:that_was_risky, 'culprit')
+
+expect { do_something_risky }.not_to throw_symbol
+expect { do_something_risky }.not_to throw_symbol(:that_was_risky)
+expect { do_something_risky }.not_to throw_symbol(:that_was_risky, 'culprit')
+ +
+ + +
+ + + + +
+
+
+
+815
+816
+817
+
+
# File 'lib/rspec/matchers.rb', line 815
+
+def throw_symbol(expected_symbol=nil, expected_arg=nil)
+  BuiltIn::ThrowSymbol.new(expected_symbol, expected_arg)
+end
+
+
+ +
+

+ + - (Object) yield_control + + + + Also known as: + a_block_yielding_control, yielding_control + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +
+ Note: +

This matcher is not designed for use with methods that yield +multiple times.

+
+
+ +

Passes if the method called in the expect block yields, regardless +of whether or not arguments are yielded.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| 5.tap(&b) }.to yield_control
+expect { |b| "a".to_sym(&b) }.not_to yield_control
+ +
+ + +
+ + + + +
+
+
+
+839
+840
+841
+
+
# File 'lib/rspec/matchers.rb', line 839
+
+def yield_control
+  BuiltIn::YieldControl.new
+end
+
+
+ +
+

+ + - (Object) yield_successive_args(*args) + + + + Also known as: + a_block_yielding_successive_args, yielding_successive_args + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +

Designed for use with methods that repeatedly yield (such as +iterators). Passes if the method called in the expect block yields +multiple times with arguments matching those given.

+ +

Argument matching is done using === (the case match operator) +and ==. If the expected and actual arguments match with either +operator, the matcher will pass.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
+expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2])
+expect { |b| [1, 2, 3].each(&b) }.not_to yield_successive_args(1, 2)
+ +
+ + +
+ + + + +
+
+
+
+911
+912
+913
+
+
# File 'lib/rspec/matchers.rb', line 911
+
+def yield_successive_args(*args)
+  BuiltIn::YieldSuccessiveArgs.new(*args)
+end
+
+
+ +
+

+ + - (Object) yield_with_args(*args) + + + + Also known as: + a_block_yielding_with_args, yielding_with_args + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +
+ Note: +

This matcher is not designed for use with methods that yield +multiple times.

+
+
+ +

Given no arguments, matches if the method called in the expect +block yields with arguments (regardless of what they are or how +many there are).

+ +

Given arguments, matches if the method called in the expect block +yields with arguments that match the given arguments.

+ +

Argument matching is done using === (the case match operator) +and ==. If the expected and actual arguments match with either +operator, the matcher will pass.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| 5.tap(&b) }.to yield_with_args # because #tap yields an arg
+expect { |b| 5.tap(&b) }.to yield_with_args(5) # because 5 == 5
+expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum) # because Fixnum === 5
+expect { |b| File.open("f.txt", &b) }.to yield_with_args(/txt/) # because /txt/ === "f.txt"
+
+expect { |b| User.transaction(&b) }.not_to yield_with_args # because it yields no args
+expect { |b| 5.tap(&b) }.not_to yield_with_args(1, 2, 3)
+ +
+ + +
+ + + + +
+
+
+
+889
+890
+891
+
+
# File 'lib/rspec/matchers.rb', line 889
+
+def yield_with_args(*args)
+  BuiltIn::YieldWithArgs.new(*args)
+end
+
+
+ +
+

+ + - (Object) yield_with_no_args + + + + Also known as: + a_block_yielding_with_no_args, yielding_with_no_args + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +
+ Note: +

This matcher is not designed for use with methods that yield +multiple times.

+
+
+ +

Passes if the method called in the expect block yields with +no arguments. Fails if it does not yield, or yields with arguments.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| User.transaction(&b) }.to yield_with_no_args
+expect { |b| 5.tap(&b) }.not_to yield_with_no_args # because it yields with `5`
+expect { |b| "a".to_sym(&b) }.not_to yield_with_no_args # because it does not yield
+ +
+ + +
+ + + + +
+
+
+
+858
+859
+860
+
+
# File 'lib/rspec/matchers.rb', line 858
+
+def yield_with_no_args
+  BuiltIn::YieldWithNoArgs.new
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/AliasedMatcher.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/AliasedMatcher.html new file mode 100644 index 000000000..fbb1dd6d8 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/AliasedMatcher.html @@ -0,0 +1,545 @@ + + + + + + Class: RSpec::Matchers::AliasedMatcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::AliasedMatcher + + + Private +

+ +
+ +
Inherits:
+
+ MatcherDelegator + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/aliased_matcher.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Decorator that wraps a matcher and overrides description +using the provided block in order to support an alias +of a matcher. This is intended for use when composing +matchers, so that you can use an expression like +include( a_value_within(0.1).of(3) ) rather than +include( be_within(0.1).of(3) ), and have the corresponding +description read naturally.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (AliasedMatcher) initialize(base_matcher, description_block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of AliasedMatcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 13
+
+def initialize(base_matcher, description_block)
+  @description_block = description_block
+  super(base_matcher)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Forward messages on to the wrapped matcher. +Since many matchers provide a fluent interface +(e.g. a_value_within(0.1).of(3)), we need to wrap +the returned value if it responds to description, +so that our override can be applied when it is eventually +used.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 24
+
+def method_missing(*)
+  return_val = super
+  return return_val unless RSpec::Matchers.is_a_matcher?(return_val)
+  self.class.new(return_val, @description_block)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides the description of the aliased matcher. Aliased matchers +are designed to behave identically to the original matcher except +for the description and failure messages. The description is different +to reflect the aliased name.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 36
+
+def description
+  @description_block.call(super)
+end
+
+
+ +
+

+ + - (Object) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides the failure_message of the aliased matcher. Aliased matchers +are designed to behave identically to the original matcher except +for the description and failure messages. The failure_message is different +to reflect the aliased name.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 46
+
+def failure_message
+  @description_block.call(super)
+end
+
+
+ +
+

+ + - (Object) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides the failure_message_when_negated of the aliased matcher. Aliased matchers +are designed to behave identically to the original matcher except +for the description and failure messages. The failure_message_when_negated is different +to reflect the aliased name.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+56
+57
+58
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 56
+
+def failure_message_when_negated
+  @description_block.call(super)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn.html new file mode 100644 index 000000000..a9b77223c --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn.html @@ -0,0 +1,133 @@ + + + + + + Module: RSpec::Matchers::BuiltIn + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::BuiltIn + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in.rb,
+ lib/rspec/matchers/built_in/be.rb,
lib/rspec/matchers/built_in/eq.rb,
lib/rspec/matchers/built_in/all.rb,
lib/rspec/matchers/built_in/eql.rb,
lib/rspec/matchers/built_in/has.rb,
lib/rspec/matchers/built_in/match.rb,
lib/rspec/matchers/built_in/cover.rb,
lib/rspec/matchers/built_in/yield.rb,
lib/rspec/matchers/built_in/exist.rb,
lib/rspec/matchers/built_in/equal.rb,
lib/rspec/matchers/built_in/output.rb,
lib/rspec/matchers/built_in/change.rb,
lib/rspec/matchers/built_in/include.rb,
lib/rspec/matchers/built_in/satisfy.rb,
lib/rspec/matchers/built_in/compound.rb,
lib/rspec/matchers/built_in/operators.rb,
lib/rspec/matchers/built_in/be_within.rb,
lib/rspec/matchers/built_in/respond_to.rb,
lib/rspec/matchers/built_in/be_between.rb,
lib/rspec/matchers/built_in/be_kind_of.rb,
lib/rspec/matchers/built_in/raise_error.rb,
lib/rspec/matchers/built_in/throw_symbol.rb,
lib/rspec/matchers/built_in/base_matcher.rb,
lib/rspec/matchers/built_in/be_instance_of.rb,
lib/rspec/matchers/built_in/have_attributes.rb,
lib/rspec/matchers/built_in/contain_exactly.rb,
lib/rspec/matchers/built_in/start_and_end_with.rb
+
+ +
+
+ +

Overview

+
+

Container module for all built-in matchers. The matcher classes are here +(rather than directly under RSpec::Matchers) in order to prevent name +collisions, since RSpec::Matchers gets included into the user's namespace.

+ +

Autoloading is used to delay when the matcher classes get loaded, allowing +rspec-matchers to boot faster, and avoiding loading matchers the user is +not using.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: All, BaseMatcher, Be, BeAKindOf, BeAnInstanceOf, BeBetween, BeComparedTo, BeFalsey, BeNil, BePredicate, BeTruthy, BeWithin, Change, ChangeFromValue, ChangeRelatively, ChangeToValue, Compound, ContainExactly, Cover, EndWith, Eq, Eql, Equal, Exist, Has, HaveAttributes, Include, Match, OperatorMatcher, Output, RaiseError, RespondTo, Satisfy, SpecificValuesChange, StartAndEndWith, StartWith, ThrowSymbol, YieldControl, YieldSuccessiveArgs, YieldWithArgs, YieldWithNoArgs + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/All.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/All.html new file mode 100644 index 000000000..0f4d28607 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/All.html @@ -0,0 +1,454 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::All + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::All + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/all.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for all. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (All) initialize(matcher) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of All

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/built_in/all.rb', line 11
+
+def initialize(matcher)
+  @matcher = matcher
+  @failed_objects = {}
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+37
+38
+39
+
+
# File 'lib/rspec/matchers/built_in/all.rb', line 37
+
+def description
+  improve_hash_formatting "all #{description_of matcher}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+
+
# File 'lib/rspec/matchers/built_in/all.rb', line 23
+
+def failure_message
+  unless iterable?
+    return "#{improve_hash_formatting(super)}, but was not iterable"
+  end
+
+  all_messages = [improve_hash_formatting(super)]
+  failed_objects.each do |index, matcher_failure_message|
+    all_messages << failure_message_for_item(index, matcher_failure_message)
+  end
+  all_messages.join("\n\n")
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html new file mode 100644 index 000000000..84c872cd3 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html @@ -0,0 +1,799 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BaseMatcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BaseMatcher + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
DefaultFailureMessages, Composable, Pretty
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/base_matcher.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used internally as a base class for matchers that ship with +rspec-expectations and rspec-rails.

+ +

Warning:

+ +

This class is for internal use, and subject to change without notice. We +strongly recommend that you do not base your custom matchers on this +class. If/when this changes, we will announce it and remove this warning.

+ + +
+
+
+ + +
+

Defined Under Namespace

+

+ + + Modules: DefaultFailureMessages + + + + +

+ +

Constant Summary

+ +
+ +
UNDEFINED = +
+
+

+ This constant is part of a private API. + You should avoid using this constant if possible, as it may be removed or be changed in the future. +

+

Used to detect when no arg is passed to initialize. +nil cannot be used because it's a valid value to pass.

+ + +
+
+
+ + +
+
+
Object.new.freeze
+ +
+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BaseMatcher) initialize(expected = UNDEFINED) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BaseMatcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+26
+27
+28
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 26
+
+def initialize(expected=UNDEFINED)
+  @expected = expected unless UNDEFINED.equal?(expected)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Generates a "pretty" description using the logic in Pretty.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+58
+59
+60
+61
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 58
+
+def description
+  return name_to_sentence unless defined?(@expected)
+  "#{name_to_sentence}#{to_sentence @expected}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Matchers are not diffable by default. Override this to make your +subclass diffable.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 66
+
+def diffable?
+  false
+end
+
+
+ +
+

+ + - (Boolean) expects_call_stack_jump? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+79
+80
+81
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 79
+
+def expects_call_stack_jump?
+  false
+end
+
+
+ +
+

+ + - (Object) match_unless_raises(*exceptions) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Used to wrap a block of code that will indicate failure by +raising one of the named exceptions.

+ +

This is used by rspec-rails for some of its matchers that +wrap rails' assertions.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 45
+
+def match_unless_raises(*exceptions)
+  exceptions.unshift Exception if exceptions.empty?
+  begin
+    yield
+    true
+  rescue *exceptions => @rescued_exception
+    false
+  end
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates if the match is successful. Delegates to match, which +should be defined on a subclass. Takes care of consistently +initializing the actual attribute.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+34
+35
+36
+37
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 34
+
+def matches?(actual)
+  @actual = actual
+  match(expected, actual)
+end
+
+
+ +
+

+ + - (Boolean) supports_block_expectations? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Most matchers are value matchers (i.e. meant to work with expect(value)) +rather than block matchers (i.e. meant to work with expect { }), so +this defaults to false. Block matchers must override this to return true.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+74
+75
+76
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 74
+
+def supports_block_expectations?
+  false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher/DefaultFailureMessages.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher/DefaultFailureMessages.html new file mode 100644 index 000000000..5e30ed422 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher/DefaultFailureMessages.html @@ -0,0 +1,304 @@ + + + + + + Module: RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages + + + Private +

+ +
+ + + + + + + +
Included in:
+
RSpec::Matchers::BuiltIn::BaseMatcher, DSL::DefaultImplementations
+ + + +
Defined in:
+
lib/rspec/matchers/built_in/base_matcher.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+

Provides default implementations of failure messages, based on the description.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides a good generic failure message. Based on description. +When subclassing, if you are not satisfied with this failure message +you often only need to override description.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+106
+107
+108
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 106
+
+def failure_message
+  "expected #{actual.inspect} to #{description}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides a good generic negative failure message. Based on description. +When subclassing, if you are not satisfied with this failure message +you often only need to override description.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+115
+116
+117
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 115
+
+def failure_message_when_negated
+  "expected #{actual.inspect} not to #{description}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html new file mode 100644 index 000000000..d5586852c --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html @@ -0,0 +1,437 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Be + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Be + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Be) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Be

+ + +
+
+
+ + +
+ + + + +
+
+
+
+104
+105
+106
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 104
+
+def initialize(*args)
+  @args = args
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+110
+111
+112
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 110
+
+def failure_message
+  "expected #{@actual.inspect} to evaluate to true"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+116
+117
+118
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 116
+
+def failure_message_when_negated
+  "expected #{@actual.inspect} to evaluate to false"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html new file mode 100644 index 000000000..f4f0efc24 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html @@ -0,0 +1,196 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeAKindOf + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeAKindOf + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_kind_of.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_a_kind_of. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html new file mode 100644 index 000000000..5c9fe3f2f --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html @@ -0,0 +1,291 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeAnInstanceOf + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeAnInstanceOf + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_instance_of.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_an_instance_of. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/be_instance_of.rb', line 10
+
+def description
+  "be an instance of #{expected}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html new file mode 100644 index 000000000..78861200b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html @@ -0,0 +1,684 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeBetween + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeBetween + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_between.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_between. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages

+

#failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BeBetween) initialize(min, max) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BeBetween

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 8
+
+def initialize(min, max)
+  @min, @max = min, max
+  inclusive
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+57
+58
+59
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 57
+
+def description
+  "be between #{@min.inspect} and #{@max.inspect} (#{@mode})"
+end
+
+
+ +
+

+ + - (Object) exclusive + + + + + +

+
+

Makes the between comparison exclusive.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(3).to be_between(2, 4).exclusive
+ +
+ + +
+ + + + +
+
+
+
+33
+34
+35
+36
+37
+38
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 33
+
+def exclusive
+  @less_than_operator = :<
+  @greater_than_operator = :>
+  @mode = :exclusive
+  self
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+51
+52
+53
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 51
+
+def failure_message
+  "#{super}#{not_comparable_clause}"
+end
+
+
+ +
+

+ + - (Object) inclusive + + + + + +

+
+ +
+ Note: +

The matcher is inclusive by default; this simply provides +a way to be more explicit about it.

+
+
+ +

Makes the between comparison inclusive.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(3).to be_between(2, 3).inclusive
+ +
+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 21
+
+def inclusive
+  @less_than_operator = :<=
+  @greater_than_operator = :>=
+  @mode = :inclusive
+  self
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+42
+43
+44
+45
+46
+47
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 42
+
+def matches?(actual)
+  @actual = actual
+  comparable? && compare
+rescue ArgumentError
+  false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html new file mode 100644 index 000000000..6d6b7d613 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html @@ -0,0 +1,607 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeComparedTo + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeComparedTo + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation of be <operator> value. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BeComparedTo) initialize(operand, operator) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BeComparedTo

+ + +
+
+
+ + +
+ + + + +
+
+
+
+139
+140
+141
+142
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 139
+
+def initialize(operand, operator)
+  @expected, @operator = operand, operator
+  @args = []
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+168
+169
+170
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 168
+
+def description
+  "be #{@operator} #{expected_to_sentence}#{args_to_sentence}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+151
+152
+153
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 151
+
+def failure_message
+  "expected: #{@operator} #{@expected.inspect}\n     got: #{@operator.to_s.gsub(/./, ' ')} #{@actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+157
+158
+159
+160
+161
+162
+163
+164
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 157
+
+def failure_message_when_negated
+  message = "`expect(#{@actual.inspect}).not_to be #{@operator} #{@expected.inspect}`"
+  if [:<, :>, :<=, :>=].include?(@operator)
+    message + " not only FAILED, it is a bit confusing."
+  else
+    message
+  end
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+144
+145
+146
+147
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 144
+
+def matches?(actual)
+  @actual = actual
+  @actual.__send__ @operator, @expected
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html new file mode 100644 index 000000000..0d8a1602a --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html @@ -0,0 +1,364 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeFalsey + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeFalsey + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_falsey. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 33
+
+def failure_message
+  "expected: falsey value\n     got: #{actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+39
+40
+41
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 39
+
+def failure_message_when_negated
+  "expected: truthy value\n     got: #{actual.inspect}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html new file mode 100644 index 000000000..a2e69bc90 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html @@ -0,0 +1,364 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeNil + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeNil + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_nil. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 56
+
+def failure_message
+  "expected: nil\n     got: #{actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 62
+
+def failure_message_when_negated
+  "expected: not nil\n     got: nil"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html new file mode 100644 index 000000000..699fd78eb --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html @@ -0,0 +1,683 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BePredicate + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BePredicate + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation of be_<predicate>. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BePredicate) initialize(*args, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BePredicate

+ + +
+
+
+ + +
+ + + + +
+
+
+
+179
+180
+181
+182
+183
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 179
+
+def initialize(*args, &block)
+  @expected = parse_expected(args.shift)
+  @args = args
+  @block = block
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+211
+212
+213
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 211
+
+def description
+  "#{prefix_to_sentence}#{expected_to_sentence}#{args_to_sentence}"
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(actual, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+191
+192
+193
+194
+195
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 191
+
+def does_not_match?(actual, &block)
+  @actual  = actual
+  @block ||= block
+  predicate_accessible? && !predicate_matches?
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+199
+200
+201
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 199
+
+def failure_message
+  failure_message_expecting(true)
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+205
+206
+207
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 205
+
+def failure_message_when_negated
+  failure_message_expecting(false)
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+185
+186
+187
+188
+189
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 185
+
+def matches?(actual, &block)
+  @actual  = actual
+  @block ||= block
+  predicate_accessible? && predicate_matches?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html new file mode 100644 index 000000000..7e64455a3 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html @@ -0,0 +1,364 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeTruthy + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeTruthy + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_truthy. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 10
+
+def failure_message
+  "expected: truthy value\n     got: #{actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 16
+
+def failure_message_when_negated
+  "expected: falsey value\n     got: #{actual.inspect}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html new file mode 100644 index 000000000..a5bc3da8b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html @@ -0,0 +1,648 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeWithin + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeWithin + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_within.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_within. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BeWithin) initialize(delta) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BeWithin

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 8
+
+def initialize(delta)
+  @delta = delta
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 52
+
+def description
+  "be within #{@delta}#{@unit} of #{@expected}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+40
+41
+42
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 40
+
+def failure_message
+  "expected #{@actual.inspect} to #{description}#{not_numeric_clause}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 46
+
+def failure_message_when_negated
+  "expected #{@actual.inspect} not to #{description}"
+end
+
+
+ +
+

+ + - (Object) of(expected) + + + + + +

+
+

Sets the expected value.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+14
+15
+16
+17
+18
+19
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 14
+
+def of(expected)
+  @expected  = expected
+  @tolerance = @delta
+  @unit      = ''
+  self
+end
+
+
+ +
+

+ + - (Object) percent_of(expected) + + + + + +

+
+

Sets the expected value, and makes the matcher do +a percent comparison.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+29
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 24
+
+def percent_of(expected)
+  @expected  = expected
+  @tolerance = @delta * @expected.abs / 100.0
+  @unit      = '%'
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html new file mode 100644 index 000000000..dfdc62bcd --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html @@ -0,0 +1,843 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Change + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Change + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for change. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) by(expected_delta) + + + + + +

+
+

Specifies the delta of the expected change.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 10
+
+def by(expected_delta)
+  ChangeRelatively.new(@change_details, expected_delta, :by) do |actual_delta|
+    values_match?(expected_delta, actual_delta)
+  end
+end
+
+
+ +
+

+ + - (Object) by_at_least(minimum) + + + + + +

+
+

Specifies a minimum delta of the expected change.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+21
+22
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 18
+
+def by_at_least(minimum)
+  ChangeRelatively.new(@change_details, minimum, :by_at_least) do |actual_delta|
+    actual_delta >= minimum
+  end
+end
+
+
+ +
+

+ + - (Object) by_at_most(maximum) + + + + + +

+
+

Specifies a maximum delta of the expected change.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+26
+27
+28
+29
+30
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 26
+
+def by_at_most(maximum)
+  ChangeRelatively.new(@change_details, maximum, :by_at_most) do |actual_delta|
+    actual_delta <= maximum
+  end
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+72
+73
+74
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 72
+
+def description
+  "change #{@change_details.message}"
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(event_proc) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+53
+54
+55
+56
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 53
+
+def does_not_match?(event_proc)
+  raise_block_syntax_error if block_given?
+  !matches?(event_proc) && Proc === event_proc
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+60
+61
+62
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 60
+
+def failure_message
+  "expected #{@change_details.message} to have changed, but #{positive_failure_reason}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 66
+
+def failure_message_when_negated
+  "expected #{@change_details.message} not to have changed, but #{negative_failure_reason}"
+end
+
+
+ +
+

+ + - (Object) from(value) + + + + + +

+
+

Specifies the original value.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+40
+41
+42
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 40
+
+def from(value)
+  ChangeFromValue.new(@change_details, value)
+end
+
+
+ +
+

+ + - (Object) to(value) + + + + + +

+
+

Specifies the new value you expect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+34
+35
+36
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 34
+
+def to(value)
+  ChangeToValue.new(@change_details, value)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html new file mode 100644 index 000000000..a4c4b7577 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html @@ -0,0 +1,357 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ChangeFromValue + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ChangeFromValue + + + Private +

+ +
+ +
Inherits:
+
+ SpecificValuesChange + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used to specify a change from a specific value +(and, optionally, to a specific value).

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (ChangeFromValue) initialize(change_details, expected_before) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ChangeFromValue

+ + +
+
+
+ + +
+ + + + +
+
+
+
+222
+223
+224
+225
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 222
+
+def initialize(change_details, expected_before)
+  @description_suffix = nil
+  super(change_details, expected_before, MATCH_ANYTHING)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) to(value) + + + + + +

+
+

Specifies the new value you expect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+229
+230
+231
+232
+233
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 229
+
+def to(value)
+  @expected_after     = value
+  @description_suffix = " to #{description_of value}"
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html new file mode 100644 index 000000000..8955e778c --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html @@ -0,0 +1,279 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ChangeRelatively + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ChangeRelatively + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used to specify a relative change.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (ChangeRelatively) initialize(change_details, expected_delta, relativity, &comparer) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ChangeRelatively

+ + +
+
+
+ + +
+ + + + +
+
+
+
+106
+107
+108
+109
+110
+111
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 106
+
+def initialize(change_details, expected_delta, relativity, &comparer)
+  @change_details = change_details
+  @expected_delta = expected_delta
+  @relativity     = relativity
+  @comparer       = comparer
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html new file mode 100644 index 000000000..cbde3440a --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html @@ -0,0 +1,357 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ChangeToValue + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ChangeToValue + + + Private +

+ +
+ +
Inherits:
+
+ SpecificValuesChange + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used to specify a change to a specific value +(and, optionally, from a specific value).

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (ChangeToValue) initialize(change_details, expected_after) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ChangeToValue

+ + +
+
+
+ + +
+ + + + +
+
+
+
+265
+266
+267
+268
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 265
+
+def initialize(change_details, expected_after)
+  @description_suffix = nil
+  super(change_details, MATCH_ANYTHING, expected_after)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) from(value) + + + + + +

+
+

Specifies the original value.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+272
+273
+274
+275
+276
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 272
+
+def from(value)
+  @expected_before    = value
+  @description_suffix = " from #{description_of value}"
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html new file mode 100644 index 000000000..130eb325a --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html @@ -0,0 +1,533 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Base class for and and or compound matchers.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

And, Or

+
+

Defined Under Namespace

+

+ + + + + Classes: And, NestedEvaluator, Or, SequentialEvaluator + + +

+ +

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #match_unless_raises, #matches?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Compound) initialize(matcher_1, matcher_2) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Compound

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 10
+
+def initialize(matcher_1, matcher_2)
+  @matcher_1 = matcher_1
+  @matcher_2 = matcher_2
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 25
+
+def description
+  singleline_message(matcher_1.description, matcher_2.description)
+end
+
+
+ +
+

+ + - (Boolean) expects_call_stack_jump? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+34
+35
+36
+37
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 34
+
+def expects_call_stack_jump?
+  NestedEvaluator.matcher_expects_call_stack_jump?(matcher_1) ||
+  NestedEvaluator.matcher_expects_call_stack_jump?(matcher_2)
+end
+
+
+ +
+

+ + - (Boolean) supports_block_expectations? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+29
+30
+31
+32
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 29
+
+def supports_block_expectations?
+  matcher_supports_block_expectations?(matcher_1) &&
+  matcher_supports_block_expectations?(matcher_2)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html new file mode 100644 index 000000000..c7c54b6fb --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html @@ -0,0 +1,311 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound::And + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound::And + + + +

+ +
+ +
Inherits:
+
+ RSpec::Matchers::BuiltIn::Compound + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

Matcher used to represent a compound and expectation.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from RSpec::Matchers::BuiltIn::Compound

+

#description, #expects_call_stack_jump?, #initialize, #supports_block_expectations?

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::Compound

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+213
+214
+215
+216
+217
+218
+219
+220
+221
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 213
+
+def failure_message
+  if matcher_1_matches?
+    matcher_2.failure_message
+  elsif matcher_2_matches?
+    matcher_1.failure_message
+  else
+    compound_failure_message
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/NestedEvaluator.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/NestedEvaluator.html new file mode 100644 index 000000000..38857daad --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/NestedEvaluator.html @@ -0,0 +1,333 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound::NestedEvaluator + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound::NestedEvaluator + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Normally, we evaluate the matching sequentially. For an expression like +expect(x).to foo.and bar, this becomes:

+ +

expect(x).to foo + expect(x).to bar

+ +

For block expectations, we need to nest them instead, so that +expect { x }.to foo.and bar becomes:

+ +

expect { + expect { x }.to foo + }.to bar

+ +

This is necessary so that the expect block is only executed once.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (NestedEvaluator) initialize(actual, matcher_1, matcher_2) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of NestedEvaluator

+ + +
+
+
+ + +
+ + + + +
+
+
+
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 130
+
+def initialize(actual, matcher_1, matcher_2)
+  @actual        = actual
+  @matcher_1     = matcher_1
+  @matcher_2     = matcher_2
+  @match_results = {}
+
+  inner, outer = order_block_matchers
+
+  @match_results[outer] = outer.matches?(Proc.new do |*args|
+    @match_results[inner] = inner.matches?(inner_matcher_block(args))
+  end)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) matcher_matches?(matcher) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+143
+144
+145
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 143
+
+def matcher_matches?(matcher)
+  @match_results.fetch(matcher)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html new file mode 100644 index 000000000..8aad80111 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html @@ -0,0 +1,299 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound::Or + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound::Or + + + +

+ +
+ +
Inherits:
+
+ RSpec::Matchers::BuiltIn::Compound + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

Matcher used to represent a compound or expectation.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from RSpec::Matchers::BuiltIn::Compound

+

#description, #expects_call_stack_jump?, #initialize, #supports_block_expectations?

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::Compound

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+240
+241
+242
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 240
+
+def failure_message
+  compound_failure_message
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/SequentialEvaluator.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/SequentialEvaluator.html new file mode 100644 index 000000000..a2b3fabdc --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/SequentialEvaluator.html @@ -0,0 +1,302 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound::SequentialEvaluator + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound::SequentialEvaluator + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

For value expectations, we can evaluate the matchers sequentially.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (SequentialEvaluator) initialize(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of SequentialEvaluator

+ + +
+
+
+ + +
+ + + + +
+
+
+
+106
+107
+108
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 106
+
+def initialize(actual, *)
+  @actual = actual
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) matcher_matches?(matcher) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+110
+111
+112
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 110
+
+def matcher_matches?(matcher)
+  matcher.matches?(@actual)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html new file mode 100644 index 000000000..9b65eee80 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html @@ -0,0 +1,460 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ContainExactly + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ContainExactly + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/contain_exactly.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for contain_exactly and match_array. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+31
+32
+33
+
+
# File 'lib/rspec/matchers/built_in/contain_exactly.rb', line 31
+
+def description
+  "contain exactly#{to_sentence(surface_descriptions_in expected)}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/rspec/matchers/built_in/contain_exactly.rb', line 10
+
+def failure_message
+  if Array === actual
+    message  = "expected collection contained:  #{safe_sort(surface_descriptions_in expected).inspect}\n"
+    message += "actual collection contained:    #{safe_sort(actual).inspect}\n"
+    message += "the missing elements were:      #{safe_sort(surface_descriptions_in missing_items).inspect}\n" unless missing_items.empty?
+    message += "the extra elements were:        #{safe_sort(extra_items).inspect}\n" unless extra_items.empty?
+    message
+  else
+    "expected a collection that can be converted to an array with " \
+    "`#to_ary` or `#to_a`, but got #{actual.inspect}"
+  end
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lib/rspec/matchers/built_in/contain_exactly.rb', line 25
+
+def failure_message_when_negated
+  "expected #{actual.inspect} not to contain exactly#{to_sentence(surface_descriptions_in expected)}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html new file mode 100644 index 000000000..2f1134264 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html @@ -0,0 +1,440 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Cover + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Cover + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/cover.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for cover. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Cover) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Cover

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/cover.rb', line 8
+
+def initialize(*expected)
+  @expected = expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) does_not_match?(range) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+17
+18
+19
+20
+
+
# File 'lib/rspec/matchers/built_in/cover.rb', line 17
+
+def does_not_match?(range)
+  @actual = range
+  expected.none? { |e| range.cover?(e) }
+end
+
+
+ +
+

+ + - (Boolean) matches?(range) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+12
+13
+14
+15
+
+
# File 'lib/rspec/matchers/built_in/cover.rb', line 12
+
+def matches?(range)
+  @actual = range
+  @expected.all? { |e| range.cover?(e) }
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html new file mode 100644 index 000000000..3aa514e07 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html @@ -0,0 +1,209 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::EndWith + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::EndWith + + + Private +

+ +
+ +
Inherits:
+
+ StartAndEndWith + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/start_and_end_with.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for end_with. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from StartAndEndWith

+

#description, #failure_message, #initialize

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::StartAndEndWith

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html new file mode 100644 index 000000000..be908e51f --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html @@ -0,0 +1,520 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Eq + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Eq + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/eq.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for eq. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 22
+
+def description
+  "#{name_to_sentence} #{@expected.inspect}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 28
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 10
+
+def failure_message
+  "\nexpected: #{format_object(expected)}\n     got: #{format_object(actual)}\n\n(compared using ==)\n"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 16
+
+def failure_message_when_negated
+  "\nexpected: value != #{format_object(expected)}\n     got: #{format_object(actual)}\n\n(compared using ==)\n"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html new file mode 100644 index 000000000..44526b88e --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html @@ -0,0 +1,442 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Eql + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Eql + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/eql.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for eql. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/eql.rb', line 22
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/eql.rb', line 10
+
+def failure_message
+  "\nexpected: #{expected.inspect}\n     got: #{actual.inspect}\n\n(compared using eql?)\n"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/eql.rb', line 16
+
+def failure_message_when_negated
+  "\nexpected: value != #{expected.inspect}\n     got: #{actual.inspect}\n\n(compared using eql?)\n"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html new file mode 100644 index 000000000..21241e12b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html @@ -0,0 +1,464 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Equal + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Equal + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/equal.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for equal. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/built_in/equal.rb', line 33
+
+def diffable?
+  !expected_is_a_literal_singleton?
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'lib/rspec/matchers/built_in/equal.rb', line 10
+
+def failure_message
+  if expected_is_a_literal_singleton?
+    simple_failure_message
+  else
+    detailed_failure_message
+  end
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'lib/rspec/matchers/built_in/equal.rb', line 20
+
+def failure_message_when_negated
+  <<-MESSAGE
+
+expected not #{inspect_object(actual)}
+ got #{inspect_object(expected)}
+
+Compared using equal?, which compares object identity.
+
+MESSAGE
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html new file mode 100644 index 000000000..864a0afa7 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html @@ -0,0 +1,605 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Exist + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Exist + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/exist.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for exist. +Not intended to be instantiated directly.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: ExistenceTest + + +

+ +

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Exist) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Exist

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 8
+
+def initialize(*expected)
+  @expected = expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) does_not_match?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+25
+26
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 22
+
+def does_not_match?(actual)
+  @actual = actual
+  @test = ExistenceTest.new @actual, @expected
+  @test.valid_test? && !@test.actual_exists?
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 30
+
+def failure_message
+  "expected #{@actual.inspect} to exist#{@test.validity_message}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 36
+
+def failure_message_when_negated
+  "expected #{@actual.inspect} not to exist#{@test.validity_message}"
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+14
+15
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 14
+
+def matches?(actual)
+  @actual = actual
+  @test = ExistenceTest.new @actual, @expected
+  @test.valid_test? && @test.actual_exists?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html new file mode 100644 index 000000000..77247dafa --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html @@ -0,0 +1,583 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Exist::ExistenceTest + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Exist::ExistenceTest + + + Private +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/exist.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Simple class for memoizing actual/expected for this matcher +and examining the match

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) actual + + + + + +

+
+

Returns the value of attribute actual

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Object) + + + + — +

    the current value of actual

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+43
+44
+45
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
+
+def actual
+  @actual
+end
+
+
+ + + +
+

+ + - (Object) expected + + + + + +

+
+

Returns the value of attribute expected

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Object) + + + + — +

    the current value of expected

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+43
+44
+45
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
+
+def expected
+  @expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) actual_exists? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 52
+
+def actual_exists?
+  existence_values.first
+end
+
+
+ +
+

+ + - (Boolean) valid_test? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 46
+
+def valid_test?
+  uniq_truthy_values.size == 1
+end
+
+
+ +
+

+ + - (String) validity_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 58
+
+def validity_message
+  case uniq_truthy_values.size
+  when 0
+    " but it does not respond to either `exist?` or `exists?`"
+  when 2
+    " but `exist?` and `exists?` returned different values:\n\n"\
+    " exist?: #{existence_values.first}\n"\
+    "exists?: #{existence_values.last}"
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html new file mode 100644 index 000000000..cca74ae94 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html @@ -0,0 +1,509 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Has + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Has + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/has.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for has_<predicate>. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Has) initialize(method_name, *args, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Has

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 8
+
+def initialize(method_name, *args, &block)
+  @method_name, @args, @block = method_name, args, block
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+40
+41
+42
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 40
+
+def description
+  [method_description, args_description].compact.join(' ')
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 28
+
+def failure_message
+  validity_message || "expected ##{predicate}#{failure_message_args_description} to return true, got false"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+34
+35
+36
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 34
+
+def failure_message_when_negated
+  validity_message || "expected ##{predicate}#{failure_message_args_description} to return false, got true"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/HaveAttributes.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/HaveAttributes.html new file mode 100644 index 000000000..001263168 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/HaveAttributes.html @@ -0,0 +1,677 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::HaveAttributes + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::HaveAttributes + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/have_attributes.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for have_attributes. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (HaveAttributes) initialize(expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of HaveAttributes

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 11
+
+def initialize(expected)
+  @expected = expected
+  @respond_to_failed = false
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+34
+35
+36
+37
+
+
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 34
+
+def description
+  described_items = surface_descriptions_in(expected)
+  improve_hash_formatting "have attributes #{described_items.inspect}"
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+26
+27
+28
+29
+30
+
+
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 26
+
+def does_not_match?(actual)
+  @actual = actual
+  return false unless respond_to_attributes?
+  perform_match(:none?)
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+41
+42
+43
+
+
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 41
+
+def failure_message
+  respond_to_failure_message_or { super }
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 47
+
+def failure_message_when_negated
+  respond_to_failure_message_or { super }
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+18
+19
+20
+21
+22
+
+
# File 'lib/rspec/matchers/built_in/have_attributes.rb', line 18
+
+def matches?(actual)
+  @actual = actual
+  return false unless respond_to_attributes?
+  perform_match(:all?)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html new file mode 100644 index 000000000..25d2e4ee6 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html @@ -0,0 +1,749 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Include + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Include + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/include.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for include. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Include) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Include

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 8
+
+def initialize(*expected)
+  @expected = expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+31
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 28
+
+def description
+  described_items = surface_descriptions_in(expected)
+  improve_hash_formatting "include#{to_sentence(described_items)}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 47
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+21
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 21
+
+def does_not_match?(actual)
+  @actual = actual
+  perform_match(:none?, :any?)
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 35
+
+def failure_message
+  improve_hash_formatting(super) + invalid_type_message
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+41
+42
+43
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 41
+
+def failure_message_when_negated
+  improve_hash_formatting(super) + invalid_type_message
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+14
+15
+16
+17
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 14
+
+def matches?(actual)
+  @actual = actual
+  perform_match(:all?, :all?)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html new file mode 100644 index 000000000..eef6dafb4 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html @@ -0,0 +1,369 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Match + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Match + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/match.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for match. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/match.rb', line 10
+
+def description
+  "match #{surface_descriptions_in(expected).inspect}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/match.rb', line 16
+
+def diffable?
+  true
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html new file mode 100644 index 000000000..1d7589660 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html @@ -0,0 +1,304 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::OperatorMatcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::OperatorMatcher + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/operators.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for operator matchers. +Not intended to be instantiated directly. +Only available for use with should.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (OperatorMatcher) initialize(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of OperatorMatcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+41
+42
+43
+
+
# File 'lib/rspec/matchers/built_in/operators.rb', line 41
+
+def initialize(actual)
+  @actual = actual
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+76
+77
+78
+
+
# File 'lib/rspec/matchers/built_in/operators.rb', line 76
+
+def description
+  "#{@operator} #{@expected.inspect}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html new file mode 100644 index 000000000..af4fa62ce --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html @@ -0,0 +1,973 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Output + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Output + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/output.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for output. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#expects_call_stack_jump?, #match_unless_raises

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Output) initialize(expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Output

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 10
+
+def initialize(expected)
+  @expected        = expected
+  @actual          = ""
+  @block           = nil
+  @stream_capturer = NullCapture
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 56
+
+def description
+  if @expected
+    "output #{description_of @expected} to #{@stream_capturer.name}"
+  else
+    "output to #{@stream_capturer.name}"
+  end
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 66
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 24
+
+def does_not_match?(block)
+  !matches?(block) && Proc === block
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+44
+45
+46
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 44
+
+def failure_message
+  "expected block to #{description}, but #{positive_failure_reason}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+50
+51
+52
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 50
+
+def failure_message_when_negated
+  "expected block to not #{description}, but #{negative_failure_reason}"
+end
+
+
+ +
+

+ + - (Boolean) matches?(block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 17
+
+def matches?(block)
+  @block = block
+  return false unless Proc === block
+  @actual = @stream_capturer.capture(block)
+  @expected ? values_match?(@expected, @actual) : captured?
+end
+
+
+ +
+

+ + - (True) supports_block_expectations? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates this matcher matches against a block.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (True) + + + +
  • + +
+ +
+ + + + +
+
+
+
+73
+74
+75
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 73
+
+def supports_block_expectations?
+  true
+end
+
+
+ +
+

+ + - (Object) to_stderr + + + + + +

+
+

Tells the matcher to match against stderr.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+37
+38
+39
+40
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 37
+
+def to_stderr
+  @stream_capturer = CaptureStderr
+  self
+end
+
+
+ +
+

+ + - (Object) to_stdout + + + + + +

+
+

Tells the matcher to match against stdout.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+30
+31
+32
+33
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 30
+
+def to_stdout
+  @stream_capturer = CaptureStdout
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html new file mode 100644 index 000000000..253bed0ed --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html @@ -0,0 +1,634 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::RaiseError + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::RaiseError + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/raise_error.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for raise_error. +Not intended to be instantiated directly. +rubocop:disable ClassLength

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (RaiseError) initialize(expected_error_or_message = Exception, expected_message = nil, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of RaiseError

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 11
+
+def initialize(expected_error_or_message=Exception, expected_message=nil, &block)
+  @block = block
+  @actual_error = nil
+  case expected_error_or_message
+  when String, Regexp
+    @expected_error, @expected_message = Exception, expected_error_or_message
+  else
+    @expected_error, @expected_message = expected_error_or_message, expected_message
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+88
+89
+90
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 88
+
+def description
+  "raise #{expected_error}"
+end
+
+
+ +
+

+ + - (Boolean) expects_call_stack_jump? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+70
+71
+72
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 70
+
+def expects_call_stack_jump?
+  true
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+76
+77
+78
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 76
+
+def failure_message
+  @eval_block ? @actual_error.message : "expected #{expected_error}#{given_error}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+82
+83
+84
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 82
+
+def failure_message_when_negated
+  "expected no #{expected_error}#{given_error}"
+end
+
+
+ +
+

+ + - (Object) with_message(expected_message) + + + + + +

+
+

Specifies the expected error message.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 24
+
+def with_message(expected_message)
+  raise_message_already_set if @expected_message
+  @expected_message = expected_message
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html new file mode 100644 index 000000000..1d772309b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html @@ -0,0 +1,661 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::RespondTo + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::RespondTo + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/respond_to.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for respond_to. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (RespondTo) initialize(*names) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of RespondTo

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 10
+
+def initialize(*names)
+  @names = names
+  @expected_arity = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) argument + + + + Also known as: + arguments + + + + +

+
+

No-op. Intended to be used as syntactic sugar when using with.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(obj).to respond_to(:message).with(3).arguments
+ +
+ + +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 30
+
+def argument
+  self
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+59
+60
+61
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 59
+
+def description
+  "respond to #{pp_names}#{with_arity}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 47
+
+def failure_message
+  "expected #{@actual.inspect} to respond to #{@failing_method_names.map { |name| name.inspect }.join(', ')}#{with_arity}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+53
+54
+55
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 53
+
+def failure_message_when_negated
+  failure_message.sub(/to respond to/, 'not to respond to')
+end
+
+
+ +
+

+ + - (Object) with(n) + + + + + +

+
+

Specifies the number of expected arguments.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(obj).to respond_to(:message).with(3).arguments
+ +
+ + +
+ + + + +
+
+
+
+20
+21
+22
+23
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 20
+
+def with(n)
+  @expected_arity = n
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html new file mode 100644 index 000000000..4d477f450 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html @@ -0,0 +1,509 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Satisfy + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Satisfy + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/satisfy.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for satisfy. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Satisfy) initialize(&block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Satisfy

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 8
+
+def initialize(&block)
+  @block = block
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 33
+
+def description
+  "satisfy block"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 21
+
+def failure_message
+  "expected #{@actual} to satisfy block"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 27
+
+def failure_message_when_negated
+  "expected #{@actual} not to satisfy block"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html new file mode 100644 index 000000000..bcd2fe91a --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html @@ -0,0 +1,281 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::SpecificValuesChange + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::SpecificValuesChange + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Base class for specifying a change from and/or to specific values.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

ChangeFromValue, ChangeToValue

+
+ +

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (SpecificValuesChange) initialize(change_details, from, to) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of SpecificValuesChange

+ + +
+
+
+ + +
+ + + + +
+
+
+
+155
+156
+157
+158
+159
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 155
+
+def initialize(change_details, from, to)
+  @change_details  = change_details
+  @expected_before = from
+  @expected_after  = to
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html new file mode 100644 index 000000000..ce1bd2c03 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html @@ -0,0 +1,456 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::StartAndEndWith + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::StartAndEndWith + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/start_and_end_with.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Base class for the end_with and start_with matchers. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

EndWith, StartWith

+
+ +

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (StartAndEndWith) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of StartAndEndWith

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+
+
# File 'lib/rspec/matchers/built_in/start_and_end_with.rb', line 8
+
+def initialize(*expected)
+  @actual_does_not_have_ordered_elements = false
+  @expected = expected.length == 1 ? expected.first : expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+27
+28
+29
+30
+
+
# File 'lib/rspec/matchers/built_in/start_and_end_with.rb', line 27
+
+def description
+  return super unless Hash === expected
+  "#{name_to_sentence} #{surface_descriptions_in(expected).inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lib/rspec/matchers/built_in/start_and_end_with.rb', line 15
+
+def failure_message
+  super.tap do |msg|
+    if @actual_does_not_have_ordered_elements
+      msg << ", but it does not have ordered elements"
+    elsif !actual.respond_to?(:[])
+      msg << ", but it cannot be indexed using #[]"
+    end
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html new file mode 100644 index 000000000..b8c4cbcb1 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html @@ -0,0 +1,209 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::StartWith + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::StartWith + + + Private +

+ +
+ +
Inherits:
+
+ StartAndEndWith + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/start_and_end_with.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for start_with. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from StartAndEndWith

+

#description, #failure_message, #initialize

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::StartAndEndWith

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html new file mode 100644 index 000000000..295cc0e5b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html @@ -0,0 +1,716 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ThrowSymbol + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ThrowSymbol + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/throw_symbol.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for throw_symbol. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (ThrowSymbol) initialize(expected_symbol = nil, expected_arg = nil) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ThrowSymbol

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 10
+
+def initialize(expected_symbol=nil, expected_arg=nil)
+  @expected_symbol = expected_symbol
+  @expected_arg = expected_arg
+  @caught_symbol = @caught_arg = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+86
+87
+88
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 86
+
+def description
+  "throw #{expected}"
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(given_proc) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

rubocop:enable MethodLength

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+68
+69
+70
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 68
+
+def does_not_match?(given_proc)
+  !matches?(given_proc) && Proc === given_proc
+end
+
+
+ +
+

+ + - (Boolean) expects_call_stack_jump? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+97
+98
+99
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 97
+
+def expects_call_stack_jump?
+  true
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+74
+75
+76
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 74
+
+def failure_message
+  "expected #{expected} to be thrown, #{actual_result}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+80
+81
+82
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 80
+
+def failure_message_when_negated
+  "expected #{expected('no Symbol')}#{' not' if @expected_symbol} to be thrown, #{actual_result}"
+end
+
+
+ +
+

+ + - (True) supports_block_expectations? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates this matcher matches against a block.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (True) + + + +
  • + +
+ +
+ + + + +
+
+
+
+93
+94
+95
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 93
+
+def supports_block_expectations?
+  true
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html new file mode 100644 index 000000000..c8057fdde --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html @@ -0,0 +1,886 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldControl + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldControl + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_control. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #match_unless_raises

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (YieldControl) initialize + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of YieldControl

+ + +
+
+
+ + +
+ + + + +
+
+
+
+96
+97
+98
+99
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 96
+
+def initialize
+  @expectation_type = nil
+  @expected_yields_count = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) at_least(number) + + + + + +

+
+

Specifies the minimum number of times the method is expected to yield

+ + +
+
+
+ + +
+ + + + +
+
+
+
+138
+139
+140
+141
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 138
+
+def at_least(number)
+  set_expected_yields_count(:>=, number)
+  self
+end
+
+
+ +
+

+ + - (Object) at_most(number) + + + + + +

+
+

Specifies the maximum number of times the method is expected to yield

+ + +
+
+
+ + +
+ + + + +
+
+
+
+131
+132
+133
+134
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 131
+
+def at_most(number)
+  set_expected_yields_count(:<=, number)
+  self
+end
+
+
+ +
+

+ + - (Object) exactly(number) + + + + + +

+
+

Specifies that the method is expected to yield the given number of times.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+124
+125
+126
+127
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 124
+
+def exactly(number)
+  set_expected_yields_count(:==, number)
+  self
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+168
+169
+170
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 168
+
+def failure_message
+  'expected given block to yield control' + failure_reason
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+174
+175
+176
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 174
+
+def failure_message_when_negated
+  'expected given block not to yield control' + failure_reason
+end
+
+
+ +
+

+ + - (Object) once + + + + + +

+
+

Specifies that the method is expected to yield once.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+103
+104
+105
+106
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 103
+
+def once
+  exactly(1)
+  self
+end
+
+
+ +
+

+ + - (Object) thrice + + + + + +

+
+

Specifies that the method is expected to yield thrice.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+117
+118
+119
+120
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 117
+
+def thrice
+  exactly(3)
+  self
+end
+
+
+ +
+

+ + - (Object) times + + + + + +

+
+

No-op. Provides syntactic sugar.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+145
+146
+147
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 145
+
+def times
+  self
+end
+
+
+ +
+

+ + - (Object) twice + + + + + +

+
+

Specifies that the method is expected to yield twice.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+110
+111
+112
+113
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 110
+
+def twice
+  exactly(2)
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html new file mode 100644 index 000000000..31ba8c64b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html @@ -0,0 +1,353 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldSuccessiveArgs + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldSuccessiveArgs + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_successive_args. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (YieldSuccessiveArgs) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of YieldSuccessiveArgs

+ + +
+
+
+ + +
+ + + + +
+
+
+
+354
+355
+356
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 354
+
+def initialize(*args)
+  @expected = args
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) does_not_match?(block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+366
+367
+368
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 366
+
+def does_not_match?(block)
+  !matches?(block) && @probe.has_block?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html new file mode 100644 index 000000000..96a4d407e --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html @@ -0,0 +1,269 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldWithArgs + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldWithArgs + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_with_args. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #expects_call_stack_jump?, #match_unless_raises

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (YieldWithArgs) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of YieldWithArgs

+ + +
+
+
+ + +
+ + + + +
+
+
+
+267
+268
+269
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 267
+
+def initialize(*args)
+  @expected = args
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html new file mode 100644 index 000000000..d2e26df5b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html @@ -0,0 +1,191 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldWithNoArgs + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldWithNoArgs + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_with_no_args. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from BaseMatcher

+

#description, #diffable?, #expects_call_stack_jump?, #initialize, #match_unless_raises

+ + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable.html new file mode 100644 index 000000000..4d12d3406 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable.html @@ -0,0 +1,779 @@ + + + + + + Module: RSpec::Matchers::Composable + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::Composable + + + +

+ +
+ + + + + + + +
Included in:
+
BuiltIn::BaseMatcher, BuiltIn::RaiseError, BuiltIn::ThrowSymbol, DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/composable.rb
+ +
+
+ +

Overview

+
+

Mixin designed to support the composable matcher features +of RSpec 3+. Mix it into your custom matcher classes to +allow them to be used in a composable fashion.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: DescribableItem + + +

+ + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Boolean) enumerable?(item) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+164
+165
+166
+167
+
+
# File 'lib/rspec/matchers/composable.rb', line 164
+
+def enumerable?(item)
+  return false if String === item
+  Enumerable === item
+end
+
+
+ +
+

+ + + (Object) surface_descriptions_in(item) + + + + + +

+
+

Transforms the given data structue (typically a hash or array) +into a new data structure that, when #inspect is called on it, +will provide descriptions of any contained matchers rather than +the normal #inspect output.

+ +

You are encouraged to use this in your custom matcher's +description, failure_message or +failure_message_when_negated implementation if you are +supporting any arguments which may be a data structure +containing matchers.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+
+
# File 'lib/rspec/matchers/composable.rb', line 99
+
+def surface_descriptions_in(item)
+  if Matchers.is_a_describable_matcher?(item)
+    DescribableItem.new(item)
+  elsif Hash === item
+    Hash[surface_descriptions_in(item.to_a)]
+  elsif Struct === item
+    item.inspect
+  elsif enumerable?(item)
+    begin
+      item.map { |subitem| surface_descriptions_in(subitem) }
+    rescue IOError # STDOUT is enumerable but `map` raises an error
+      item.inspect
+    end
+  else
+    item
+  end
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Object) ===(value) + + + + + +

+
+

Delegates to #matches?. Allows matchers to be used in composable +fashion and also supports using matchers in case statements.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lib/rspec/matchers/composable.rb', line 45
+
+def ===(value)
+  matches?(value)
+end
+
+
+ +
+

+ + - (Object) and(matcher) + + + + Also known as: + & + + + + +

+
+ +
+ Note: +

The negative form (expect(...).not_to matcher.and other) +is not supported at this time.

+
+
+ +

Creates a compound and expectation. The matcher will +only pass if both sub-matchers pass. +This can be chained together to form an arbitrarily long +chain of matchers.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(alphabet).to start_with("a").and end_with("z")
+expect(alphabet).to start_with("a") & end_with("z")
+ +
+ + +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/matchers/composable.rb', line 22
+
+def and(matcher)
+  BuiltIn::Compound::And.new self, matcher
+end
+
+
+ +
+

+ + - (Object) description_of(object) + + + + + +

+
+

Returns the description of the given object in a way that is +aware of composed matchers. If the object is a matcher with +a description method, returns the description; otherwise +returns object.inspect.

+ +

You are encouraged to use this in your custom matcher's +description, failure_message or +failure_message_when_negated implementation if you are +supporting matcher arguments.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+82
+83
+84
+85
+
+
# File 'lib/rspec/matchers/composable.rb', line 82
+
+def description_of(object)
+  return object.description if Matchers.is_a_describable_matcher?(object)
+  object.inspect
+end
+
+
+ +
+

+ + - (Object) or(matcher) + + + + Also known as: + | + + + + +

+
+ +
+ Note: +

The negative form (expect(...).not_to matcher.or other) +is not supported at this time.

+
+
+ +

Creates a compound or expectation. The matcher will +pass if either sub-matcher passes. +This can be chained together to form an arbitrarily long +chain of matchers.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
+expect(stoplight.color).to eq("red") | eq("green") | eq("yellow")
+ +
+ + +
+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'lib/rspec/matchers/composable.rb', line 38
+
+def or(matcher)
+  BuiltIn::Compound::Or.new self, matcher
+end
+
+
+ +
+

+ + - (Boolean) values_match?(expected, actual) + + + + + +

+
+

This provides a generic way to fuzzy-match an expected value against +an actual value. It understands nested data structures (e.g. hashes +and arrays) and is able to match against a matcher being used as +the expected value or within the expected value at any level of +nesting.

+ +

Within a custom matcher you are encouraged to use this whenever your +matcher needs to match two values, unless it needs more precise semantics. +For example, the eq matcher does not use this as it is meant to +use == (and only ==) for matching.

+ + +
+
+
+

Parameters:

+
    + +
  • + + expected + + + (Object) + + + + — +

    what is expected

    +
    + +
  • + +
  • + + actual + + + (Object) + + + + — +

    the actual value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+69
+
+
# File 'lib/rspec/matchers/composable.rb', line 66
+
+def values_match?(expected, actual)
+  expected = with_matchers_cloned(expected)
+  Support::FuzzyMatcher.values_match?(expected, actual)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html new file mode 100644 index 000000000..80bac3b25 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html @@ -0,0 +1,137 @@ + + + + + + Class: RSpec::Matchers::Composable::DescribableItem + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::Composable::DescribableItem + + + Private +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/composable.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Wraps an item in order to surface its description via inspect.

+ + +
+
+
+ + +
+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL.html new file mode 100644 index 000000000..8ad9f4b01 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL.html @@ -0,0 +1,224 @@ + + + + + + Module: RSpec::Matchers::DSL + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

Defines the custom matcher DSL.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: DefaultImplementations, Macros + + + + Classes: Matcher + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) define(name, &declarations) + + + + Also known as: + matcher + + + + +

+
+

Defines a custom matcher.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+
+
# File 'lib/rspec/matchers/dsl.rb', line 7
+
+def define(name, &declarations)
+  define_method name do |*expected|
+    RSpec::Matchers::DSL::Matcher.new(name, declarations, self, *expected)
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html new file mode 100644 index 000000000..2aae52cbd --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html @@ -0,0 +1,450 @@ + + + + + + Module: RSpec::Matchers::DSL::DefaultImplementations + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL::DefaultImplementations + + + +

+ +
+ + + + + +
Includes:
+
BuiltIn::BaseMatcher::DefaultFailureMessages
+ + + + +
Included in:
+
Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

Defines default implementations of the matcher +protocol methods for custom matchers. You can +override any of these using the Macros methods +from within an RSpec::Matchers.define block.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from BuiltIn::BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) description + + + + + +

+
+

The default description.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+257
+258
+259
+
+
# File 'lib/rspec/matchers/dsl.rb', line 257
+
+def description
+  "#{name_to_sentence}#{to_sentence expected}#{chained_method_clause_sentences}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Used internally by objects returns by should and should_not.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+252
+253
+254
+
+
# File 'lib/rspec/matchers/dsl.rb', line 252
+
+def diffable?
+  false
+end
+
+
+ +
+

+ + - (Boolean) expects_call_stack_jump? + + + + + +

+
+

Most matchers do not expect call stack jumps.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+268
+269
+270
+
+
# File 'lib/rspec/matchers/dsl.rb', line 268
+
+def expects_call_stack_jump?
+  false
+end
+
+
+ +
+

+ + - (Boolean) supports_block_expectations? + + + + + +

+
+

Matchers do not support block expectations by default. You +must opt-in.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+263
+264
+265
+
+
# File 'lib/rspec/matchers/dsl.rb', line 263
+
+def supports_block_expectations?
+  false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros.html new file mode 100644 index 000000000..07531048c --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros.html @@ -0,0 +1,982 @@ + + + + + + Module: RSpec::Matchers::DSL::Macros + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL::Macros + + + +

+ +
+ + + + + + + +
Included in:
+
Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

Contains the methods that are available from within the +RSpec::Matchers.define DSL for creating custom matchers.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Deprecated + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) chain(name, &definition) + + + + + +

+
+

Convenience for defining methods on this matcher to create a fluent +interface. The trick about fluent interfaces is that each method must +return self in order to chain methods together. chain handles that +for you. If the method is invoked and the +include_chain_clauses_in_custom_matcher_descriptions config option +hash been enabled, the chained method name and args will be added to the +default description and failure message.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :have_errors_on do |key|
+  chain :with do |message|
+    @message = message
+  end
+
+  match do |actual|
+    actual.errors[key] == @message
+  end
+end
+
+expect(minor).to have_errors_on(:age).with("Not old enough to participate")
+ +
+ + +
+ + + + +
+
+
+
+181
+182
+183
+184
+185
+186
+187
+
+
# File 'lib/rspec/matchers/dsl.rb', line 181
+
+def chain(name, &definition)
+  define_user_override(name, definition) do |*args, &block|
+    super(*args, &block)
+    @chained_method_clauses.push([name, args])
+    self
+  end
+end
+
+
+ +
+

+ + - (Object) description {|Object| ... } + + + + + +

+
+

Customize the description to use for one-liners. Only use this when +the description generated by default doesn't suit your needs.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :qualify_for do |expected|
+  match { your_match_logic }
+
+  description do
+    "qualify for #{expected}"
+  end
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+142
+143
+144
+
+
# File 'lib/rspec/matchers/dsl.rb', line 142
+
+def description(&definition)
+  define_user_override(__method__, definition)
+end
+
+
+ +
+

+ + - (Object) diffable + + + + + +

+
+

Tells the matcher to diff the actual and expected values in the failure +message.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+148
+149
+150
+
+
# File 'lib/rspec/matchers/dsl.rb', line 148
+
+def diffable
+  define_method(:diffable?) { true }
+end
+
+
+ +
+

+ + - (Object) failure_message {|Object| ... } + + + + + +

+
+

Customizes the failure messsage to use when this matcher is +asked to positively match. Only use this when the message +generated by default doesn't suit your needs.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :have_strength do |expected|
+  match { your_match_logic }
+
+  failure_message do |actual|
+    "Expected strength of #{expected}, but had #{actual.strength}"
+  end
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+105
+106
+107
+
+
# File 'lib/rspec/matchers/dsl.rb', line 105
+
+def failure_message(&definition)
+  define_user_override(__method__, definition)
+end
+
+
+ +
+

+ + - (Object) failure_message_when_negated {|Object| ... } + + + + + +

+
+

Customize the failure messsage to use when this matcher is asked +to negatively match. Only use this when the message generated by +default doesn't suit your needs.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :have_strength do |expected|
+  match { your_match_logic }
+
+  failure_message_when_negated do |actual|
+    "Expected not to have strength of #{expected}, but did"
+  end
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+124
+125
+126
+
+
# File 'lib/rspec/matchers/dsl.rb', line 124
+
+def failure_message_when_negated(&definition)
+  define_user_override(__method__, definition)
+end
+
+
+ +
+

+ + - (Object) match {|Object| ... } + + + + + +

+
+

Stores the block that is used to determine whether this matcher passes +or fails. The block should return a boolean value. When the matcher is +passed to expect(...).to and the block returns true, then the expectation +passes. Similarly, when the matcher is passed to expect(...).not_to and the +block returns false, then the expectation passes.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :be_even do
+  match do |actual|
+    actual.even?
+  end
+end
+
+expect(4).to be_even     # passes
+expect(3).not_to be_even # passes
+expect(3).to be_even     # fails
+expect(4).not_to be_even # fails
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual value (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+
+
# File 'lib/rspec/matchers/dsl.rb', line 39
+
+def match(&match_block)
+  define_user_override(:matches?, match_block) do |actual|
+    begin
+      @actual = actual
+      super(*actual_arg_for(match_block))
+    rescue RSpec::Expectations::ExpectationNotMetError
+      false
+    end
+  end
+end
+
+
+ +
+

+ + - (Object) match_unless_raises(expected_exception = Exception) {|Object| ... } + + + + + +

+
+

Use this instead of match when the block will raise an exception +rather than returning false to indicate a failure.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :accept_as_valid do |candidate_address|
+  match_unless_raises ValidationException do |validator|
+    validator.validate(candidate_address)
+  end
+end
+
+expect(email_validator).to accept_as_valid("person@company.com")
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+
+
# File 'lib/rspec/matchers/dsl.rb', line 77
+
+def match_unless_raises(expected_exception=Exception, &match_block)
+  define_user_override(:matches?, match_block) do |actual|
+    @actual = actual
+    begin
+      super(*actual_arg_for(match_block))
+    rescue expected_exception => @rescued_exception
+      false
+    else
+      true
+    end
+  end
+end
+
+
+ +
+

+ + - (Object) match_when_negated {|Object| ... } + + + + + +

+
+

Use this to define the block for a negative expectation (expect(...).not_to) +when the positive and negative forms require different handling. This +is rarely necessary, but can be helpful, for example, when specifying +asynchronous processes that require different timeouts.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual value (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+
+
# File 'lib/rspec/matchers/dsl.rb', line 56
+
+def match_when_negated(&match_block)
+  define_user_override(:does_not_match?, match_block) do |actual|
+    @actual = actual
+    super(*actual_arg_for(match_block))
+  end
+end
+
+
+ +
+

+ + - (Object) supports_block_expectations + + + + + +

+
+

Declares that the matcher can be used in a block expectation. +Users will not be able to use your matcher in a block +expectation without declaring this. +(e.g. expect { do_something }.to matcher).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+156
+157
+158
+
+
# File 'lib/rspec/matchers/dsl.rb', line 156
+
+def supports_block_expectations
+  define_method(:supports_block_expectations?) { true }
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html new file mode 100644 index 000000000..c0fde7fa7 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html @@ -0,0 +1,402 @@ + + + + + + Module: RSpec::Matchers::DSL::Macros::Deprecated + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL::Macros::Deprecated + + Deprecated + +

+ +
+ + + + + + + +
Included in:
+
RSpec::Matchers::DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+
Deprecated.

Use the methods from RSpec::Matchers::DSL::Macros instead.

+
+

Defines deprecated macro methods from RSpec 2 for backwards compatibility.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) failure_message_for_should(&definition) + + + + + +

+
+ + + +
+
+
+ + +
+ + + + +
+
+
+
+230
+231
+232
+233
+
+
# File 'lib/rspec/matchers/dsl.rb', line 230
+
+def failure_message_for_should(&definition)
+  RSpec.deprecate("`failure_message_for_should`", :replacement => "`failure_message`")
+  failure_message(&definition)
+end
+
+
+ +
+

+ + - (Object) failure_message_for_should_not(&definition) + + + + + +

+ +
+
+ + +
+ + + + +
+
+
+
+236
+237
+238
+239
+
+
# File 'lib/rspec/matchers/dsl.rb', line 236
+
+def failure_message_for_should_not(&definition)
+  RSpec.deprecate("`failure_message_for_should_not`", :replacement => "`failure_message_when_negated`")
+  failure_message_when_negated(&definition)
+end
+
+
+ +
+

+ + - (Object) match_for_should(&definition) + + + + + +

+
+
Deprecated.
+ + +
+
+
+ + +
+ + + + +
+
+
+
+218
+219
+220
+221
+
+
# File 'lib/rspec/matchers/dsl.rb', line 218
+
+def match_for_should(&definition)
+  RSpec.deprecate("`match_for_should`", :replacement => "`match`")
+  match(&definition)
+end
+
+
+ +
+

+ + - (Object) match_for_should_not(&definition) + + + + + +

+
+ + + +
+
+
+ + +
+ + + + +
+
+
+
+224
+225
+226
+227
+
+
# File 'lib/rspec/matchers/dsl.rb', line 224
+
+def match_for_should_not(&definition)
+  RSpec.deprecate("`match_for_should_not`", :replacement => "`match_when_negated`")
+  match_when_negated(&definition)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Matcher.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Matcher.html new file mode 100644 index 000000000..dde6ac7da --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/DSL/Matcher.html @@ -0,0 +1,923 @@ + + + + + + Class: RSpec::Matchers::DSL::Matcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::DSL::Matcher + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + +
Extended by:
+
Macros, RSpec::Matchers::DSL::Macros::Deprecated
+ + + + +
Includes:
+
RSpec::Matchers, Composable, DefaultImplementations, Pretty
+ + + + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

The class used for custom matchers. The block passed to +RSpec::Matchers.define will be evaluated in the context +of the singleton class of an instance, and will have the +Macros methods available.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from RSpec::Matchers::DSL::Macros::Deprecated

+

failure_message_for_should, failure_message_for_should_not, match_for_should, match_for_should_not

+ + + + + + + + + +

Methods included from Macros

+

chain, description, diffable, failure_message, failure_message_when_negated, match, match_unless_raises, match_when_negated, supports_block_expectations

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+ + + + + + + + + +

Methods included from RSpec::Matchers

+

alias_matcher, #all, #be, #be_a, #be_a_kind_of, #be_an_instance_of, #be_between, #be_falsey, #be_nil, #be_truthy, #be_within, #change, clear_generated_description, configuration, #contain_exactly, #cover, define_negated_matcher, #end_with, #eq, #eql, #equal, #exist, #expect, generated_description, #have_attributes, #include, #match, #match_array, #output, #raise_error, #respond_to, #satisfy, #start_with, #throw_symbol, #yield_control, #yield_successive_args, #yield_with_args, #yield_with_no_args

+ + + + + + + + + +

Methods included from DefaultImplementations

+

#description, #diffable?, #expects_call_stack_jump?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from BuiltIn::BaseMatcher::DefaultFailureMessages

+

#failure_message, #failure_message_when_negated

+
+

Constructor Details

+ +
+

+ + - (Matcher) initialize(name, declarations, matcher_execution_context, *expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Matcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+
+
# File 'lib/rspec/matchers/dsl.rb', line 313
+
+def initialize(name, declarations, matcher_execution_context, *expected)
+  @name     = name
+  @actual   = nil
+  @expected_as_array = expected
+  @matcher_execution_context = matcher_execution_context
+  @chained_method_clauses = []
+
+  class << self
+    # See `Macros#define_user_override` above, for an explanation.
+    include(@user_method_defs = Module.new)
+    self
+  end.class_exec(*expected, &declarations)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing(method, *args, &block) (private) + + + + + +

+
+

Takes care of forwarding unhandled messages to the +@matcher_execution_context (typically the current +running RSpec::Core::Example). This is needed by +rspec-rails so that it can define matchers that wrap +Rails' test helper methods, but it's also a useful +feature in its own right.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+379
+380
+381
+382
+383
+384
+385
+
+
# File 'lib/rspec/matchers/dsl.rb', line 379
+
+def method_missing(method, *args, &block)
+  if @matcher_execution_context.respond_to?(method)
+    @matcher_execution_context.__send__ method, *args, &block
+  else
+    super(method, *args, &block)
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) actual (readonly) + + + + + +

+
+

Exposes the value being matched against -- generally the object +object wrapped by expect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+306
+307
+308
+
+
# File 'lib/rspec/matchers/dsl.rb', line 306
+
+def actual
+  @actual
+end
+
+
+ + + +
+

+ + - (Object) expected_as_array (readonly) + + + + + +

+
+

Returns the expected value as an an array. This exists primarily +to aid in upgrading from RSpec 2.x, since in RSpec 2, expected +always returned an array.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+343
+344
+345
+
+
# File 'lib/rspec/matchers/dsl.rb', line 343
+
+def expected_as_array
+  @expected_as_array
+end
+
+
+ + + +
+

+ + - (Object) rescued_exception (readonly) + + + + + +

+
+

Exposes the exception raised during the matching by match_unless_raises. +Could be useful to extract details for a failure message.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+310
+311
+312
+
+
# File 'lib/rspec/matchers/dsl.rb', line 310
+
+def rescued_exception
+  @rescued_exception
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) expected + + + + + +

+
+

Provides the expected value. This will return an array if +multiple arguments were passed to the matcher; otherwise it +will return a single value.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+331
+332
+333
+334
+335
+336
+337
+
+
# File 'lib/rspec/matchers/dsl.rb', line 331
+
+def expected
+  if expected_as_array.size == 1
+    expected_as_array[0]
+  else
+    expected_as_array
+  end
+end
+
+
+ +
+

+ + - (Object) inspect + + + + + +

+
+

Adds the name (rather than a cryptic hex number) +so we can identify an instance of +the matcher in error messages (e.g. for NoMethodError)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+348
+349
+350
+
+
# File 'lib/rspec/matchers/dsl.rb', line 348
+
+def inspect
+  "#<#{self.class.name} #{name}>"
+end
+
+
+ +
+

+ + - (Boolean) respond_to?(method, include_private = false) + + + + + +

+
+

Indicates that this matcher responds to messages +from the @matcher_execution_context as well.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+362
+363
+364
+
+
# File 'lib/rspec/matchers/dsl.rb', line 362
+
+def respond_to?(method, include_private=false)
+  super || @matcher_execution_context.respond_to?(method, include_private)
+end
+
+
+ +
+

+ + - (Boolean) respond_to_missing?(method, include_private = false) + + + + + +

+
+

Indicates that this matcher responds to messages +from the @matcher_execution_context as well. +Also, supports getting a method object for such methods.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+356
+357
+358
+
+
# File 'lib/rspec/matchers/dsl.rb', line 356
+
+def respond_to_missing?(method, include_private=false)
+  super || @matcher_execution_context.respond_to?(method, include_private)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/MatcherProtocol.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/MatcherProtocol.html new file mode 100644 index 000000000..0592db2c0 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/MatcherProtocol.html @@ -0,0 +1,1068 @@ + + + + + + Class: RSpec::Matchers::MatcherProtocol + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::MatcherProtocol + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/matcher_protocol.rb
+ +
+
+ +

Overview

+
+ +
+ Note: +

This class is not loaded at runtime by rspec-expectations. It exists +purely to provide documentation for the matcher protocol.

+
+
+ +

rspec-expectations can work with any matcher object that implements this protocol.

+ + +
+
+
+ + +
+ + + + + + + +

+ Required Methods + (collapse) +

+ + + +

+ Optional Methods + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (String, Object) actual + + + + + +

+
+ +
+ Note: +

This method is required if diffable? returns true.

+
+
+ +

The actual value for the purposes of a diff.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String, Object) + + + + — +

    If an object (rather than a string) is provided, +RSpec will use the pp library to convert it to multi-line output in +order to diff.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 82
+
+
+
+
+ +
+

+ + - (String) description + + + + + +

+
+

The description is used for two things:

+ +
    +
  • When using RSpec's one-liner syntax +(e.g. it { is_expected.to matcher }), the description +is used to generate the example's doc string since you +have not provided one.
  • +
  • In a composed matcher expression, the description is used +as part of the failure message (and description) of the outer +matcher.
  • +
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    Description of the matcher.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 42
+
+
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

Indicates that this matcher provides actual and expected attributes, +and that the values returned by these can be usefully diffed, which can +be included in the output.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if actual and expected can be diffed.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 76
+
+
+
+
+ +
+

+ + - (Boolean) does_not_match? { ... } + + + + + +

+
+

In a negative expectation such as expect(x).not_to foo, RSpec will +call foo.does_not_match?(x) if this method is defined. If it's not +defined it will fall back to using !foo.matches?(x). This allows you +to provide custom logic for the negative case.

+ + +
+
+
+

Parameters:

+
    + +
  • + + actual + + + (Object) + + + + — +

    The object being matched against.

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    For an expression like expect(x).not_to matcher do...end, the do/end +block binds to not_to. It passes that block, if there is one, on to this method.

    +
    + +
  • + +
+

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if this matcher does not match the provided object.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 24
+
+
+
+
+ +
+

+ + - (String, Object) expected + + + + + +

+
+ +
+ Note: +

This method is required if diffable? returns true.

+
+
+ +

The expected value for the purposes of a diff.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String, Object) + + + + — +

    If an object (rather than a string) is provided, +RSpec will use the pp library to convert it to multi-line output in +order to diff.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 89
+
+
+
+
+ +
+

+ + - (Boolean) expects_call_stack_jump? + + + + + +

+
+ +
+ Note: +

This method is very rarely used or needed.

+
+
+ +
+ Note: +

If not defined, RSpec assumes a value of false for this method.

+
+
+ +

Indicates that when this matcher is used in a block expectation +expression, it expects the block to use a ruby construct that causes +a call stack jump (such as raising an error or throwing a symbol).

+ +

This is used internally for compound block expressions, as matchers +which expect call stack jumps must be treated with care to work properly.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the matcher expects a call stack jump

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 63
+
+
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

This will only be called if #matches? returns false.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    Explanation for the failure.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 16
+
+
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+ +
+ Note: +

This method is listed as optional because matchers do not have to +support negation. But if your matcher does support negation, this is a +required method -- otherwise, you'll get a NoMethodError.

+
+
+ +

This will only be called when a negative match fails.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    Explanation for the failure.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 35
+
+
+
+
+ +
+

+ + - (Boolean) matches? { ... } + + + + + +

+
+

Returns true if this matcher matches the provided object.

+ + +
+
+
+

Parameters:

+
    + +
  • + + actual + + + (Object) + + + + — +

    The object being matched against.

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    For an expression like expect(x).to matcher do...end, the do/end +block binds to to. It passes that block, if there is one, on to this method.

    +
    + +
  • + +
+

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if this matcher matches the provided object.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 10
+
+
+
+
+ +
+

+ + - (Boolean) supports_block_expectations? + + + + + +

+
+ +
+ Note: +

If not defined, RSpec assumes a value of false for this method.

+
+
+ +

Indicates that this matcher can be used in a block expectation expression, +such as expect { foo }.to raise_error. Generally speaking, this is +only needed for matchers which operate on a side effect of a block, rather +than on a particular object.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if this matcher can be used in block expressions.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers/matcher_protocol.rb', line 55
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Pretty.html b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Pretty.html new file mode 100644 index 000000000..c8f770c46 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/RSpec/Matchers/Pretty.html @@ -0,0 +1,446 @@ + + + + + + Module: RSpec::Matchers::Pretty + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::Pretty + + + Private +

+ +
+ + + + + + + +
Included in:
+
BuiltIn::BaseMatcher, DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/pretty.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+

Contains logic to facilitate converting ruby symbols and +objects to english phrases.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) split_words(sym) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Converts a symbol into an english expression.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lib/rspec/matchers/pretty.rb', line 9
+
+def split_words(sym)
+  sym.to_s.gsub(/_/, ' ')
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Object) name + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides a name for the matcher.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lib/rspec/matchers/pretty.rb', line 45
+
+def name
+  defined?(@name) ? @name : underscore(self.class.name.split("::").last)
+end
+
+
+ +
+

+ + - (Object) to_sentence(words) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Converts a collection of objects into an english expression.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'lib/rspec/matchers/pretty.rb', line 16
+
+def to_sentence(words)
+  return " #{words.inspect}" if !words || Struct === words
+  words = Array(words).map { |w| to_word(w) }
+  case words.length
+  when 0
+    ""
+  when 1
+    " #{words[0]}"
+  when 2
+    " #{words[0]} and #{words[1]}"
+  else
+    " #{words[0...-1].join(', ')}, and #{words[-1]}"
+  end
+end
+
+
+ +
+

+ + - (Object) to_word(item) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Converts the given item to string suitable for use in a list expression.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/pretty.rb', line 33
+
+def to_word(item)
+  is_matcher_with_description?(item) ? item.description : item.inspect
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/_index.html b/source/documentation/3.1/rspec-expectations/_index.html new file mode 100644 index 000000000..7755bde18 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/_index.html @@ -0,0 +1,677 @@ + + + + + + Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Documentation by YARD 0.8.7.4

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + +
    +
  • A
  • +
      + +
    • + AliasedMatcher + + (RSpec::Matchers) + +
    • + +
    • + All + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + And + + (RSpec::Matchers::BuiltIn::Compound) + +
    • + +
    +
+ + +
    +
  • B
  • +
      + +
    • + BaseMatcher + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BasicObject + +
    • + +
    • + Be + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeAKindOf + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeAnInstanceOf + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeBetween + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeComparedTo + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeFalsey + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeNil + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BePredicate + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeTruthy + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeWithin + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BuiltIn + + (RSpec::Matchers) + +
    • + +
    +
+ + + + + + + + +
    +
  • E
  • +
      + +
    • + EndWith + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Eq + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Eql + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Equal + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Exist + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + ExistenceTest + + (RSpec::Matchers::BuiltIn::Exist) + +
    • + +
    • + ExpectationTarget + + (RSpec::Expectations) + +
    • + +
    • + Expectations + + (RSpec) + +
    • + +
    +
+ + +
    +
  • H
  • +
      + +
    • + Has + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + HaveAttributes + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + +
    +
  • I
  • +
      + +
    • + Include + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + +
+ + +
    +
  • M
  • +
      + +
    • + Macros + + (RSpec::Matchers::DSL) + +
    • + +
    • + Match + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Matcher + + (RSpec::Matchers::DSL) + +
    • + +
    • + MatcherProtocol + + (RSpec::Matchers) + +
    • + +
    • + Matchers + + (RSpec) + +
    • + +
    +
+ + +
    +
  • N
  • + +
+ + +
    +
  • O
  • +
      + +
    • + OperatorMatcher + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Or + + (RSpec::Matchers::BuiltIn::Compound) + +
    • + +
    • + Output + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + +
    +
  • P
  • +
      + +
    • + Pretty + + (RSpec::Matchers) + +
    • + +
    +
+ + +
    +
  • R
  • +
      + +
    • + RSpec + +
    • + +
    • + RaiseError + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + RespondTo + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + + + + +
    +
  • T
  • +
      + +
    • + ThrowSymbol + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + + + +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/class_list.html b/source/documentation/3.1/rspec-expectations/class_list.html new file mode 100644 index 000000000..523eaf381 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/class_list.html @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + Class List + + + + +
+

Class List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-expectations/file.Changelog.html b/source/documentation/3.1/rspec-expectations/file.Changelog.html new file mode 100644 index 000000000..edc70b759 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/file.Changelog.html @@ -0,0 +1,1092 @@ + + + + + + File: Changelog + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

3.1.2 / 2014-09-26

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix define_negated_matcher so that matchers that support fluent +interfaces continue to be negated after you use the chained method. +(Myron Marston, #656)
  • +
  • Fix define_negated_matcher so that the matchers fail with an +appropriate failure message. (Myron Marston, #659)
  • +
+ +

3.1.1 / 2014-09-15

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix regression in all matcher in 3.1.0 that prevented it from +working on objects that are not Enumerable but do implement +each_with_index (such as an ActiveRecord proxy). (Jori Hardman, #647)
  • +
+ +

3.1.0 / 2014-09-04

+ +

Full Changelog

+ +

Enhancements:

+ +
    +
  • Add have_attributes matcher, that passes if actual's attribute +values match the expected attributes hash: +Person = Struct.new(:name, :age) +person = Person.new("Bob", 32) +expect(person).to have_attributes(:name => "Bob", :age => 32). +(Adam Farhi, #571)
  • +
  • Extended compound matcher support to block matchers, for cases like: +expect { ... }.to change { x }.to(3).and change { y }.to(4). (Myron +Marston, #567)
  • +
  • Include chained methods in custom matcher description and failure message +when new include_chain_clauses_in_custom_matcher_descriptions config +option is enabled. (Dan Oved, #600)
  • +
  • Add thrice modifier to yield_control matcher as a synonym for +exactly(3).times. (Dennis Taylor, #615)
  • +
  • Add RSpec::Matchers.define_negated_matcher, which defines a negated +version of the named matcher. (Adam Farhi, Myron Marston, #618)
  • +
  • Document and support negation of contain_exactly/match_array. +(Jon Rowe, #626).
  • +
+ +

Bug Fixes:

+ +
    +
  • Rename private LegacyMacherAdapter constant to LegacyMatcherAdapter +to fix typo. (Abdelkader Boudih, #563)
  • +
  • Fix all matcher so that it fails properly (rather than raising a +NoMethodError) when matched against a non-enumerable. (Hao Su, #622)
  • +
+ +

3.0.4 / 2014-08-14

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix start_with and end_with so that they work properly with +structs. (Myron Marston, #620)
  • +
  • Fix failure message generation so that structs are printed properly +in failures. Previously failure messages would represent them as +an array. (Myron Marston, #620)
  • +
  • Fix composable matcher support so that it does not wrongly treat +structs as arrays. (Myron Marston, #620)
  • +
+ +

3.0.3 / 2014-07-21

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix issue with detection of generic operator matchers so they work +correctly when undefined. (Myron Marston, #597)
  • +
  • Don't inadvertently define BasicObject in 1.8.7. (Chris Griego, #603)
  • +
  • Fix include matcher so that it fails gracefully when matched against +an object that does not respond to include?. (Myron Marston, #607)
  • +
+ +

3.0.2 / 2014-06-19

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix regression in contain_exactly (AKA match_array) that caused it +to wrongly pass when the expected array was empty. (Myron Marston, #581)
  • +
  • Provide a better error message when you use the change(obj, :msg) +form of the change matcher but forget the message argument. (Alex +Sunderland, #585)
  • +
  • Make the contain_exactly matcher work with arrays that contain hashes in +arbitrary ordering. (Sam Phippen, #578)
  • +
+ +

3.0.1 / 2014-06-12

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Add a missing require that would cause the respond_to matcher to +fail when used in a project where the rest of RSpec (e.g. core and +expecatations) weren't being used. (Myron Marston, #566)
  • +
  • Structs are no longer treated as arrays when diffed. (Jon Rowe, #576)
  • +
+ +

3.0.0 / 2014-06-01

+ +

Full Changelog

+ +

No code changes. Just taking it out of pre-release.

+ +

3.0.0.rc1 / 2014-05-18

+ +

Full Changelog

+ +

Breaking Changes for 3.0.0:

+ +
    +
  • Remove matcher_execution_context attribute from DSL-defined +custom matchers. (Myron Marston)
  • +
  • Remove RSpec::Matchers::Pretty#_pretty_print. (Myron Marston)
  • +
  • Remove RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston)
  • +
  • Rename RSpec::Matchers::Configuration constant to +RSpec::Expectations::Configuration. (Myron Marston)
  • +
  • Prevent have_xyz predicate matchers using private methods. +(Adrian Gonzalez)
  • +
  • Block matchers must now implement supports_block_expectations?. +(Myron Marston)
  • +
  • Stop supporting require 'rspec-expectations'. +Use require 'rspec/expectations' instead. (Myron Marston)
  • +
+ +

Bug Fixes:

+ +
    +
  • Fix NoMethodError triggered by beta2 when YARD was loaded in +the test environment. (Myron Marston)
  • +
  • Fix be_xyz matcher to accept a do...end block. (Myron Marston)
  • +
  • Fix composable matcher failure message generation logic +so that it does not blow up when given $stdout or $stderr. +(Myron Marston)
  • +
  • Fix change matcher to work properly with IO objects. +(Myron Marston)
  • +
  • Fix exist matcher so that it can be used in composed matcher +expressions involving objects that do not implement exist? or +exists?. (Daniel Fone)
  • +
  • Fix composable matcher match logic so that it clones matchers +before using them in order to work properly with matchers +that use internal memoization based on a given actual value. +(Myron Marston)
  • +
  • Fix be_xyz and has_xyz predicate matchers so that they can +be used in composed matcher expressions involving objects that +do not implement the predicate method. (Daniel Fone)
  • +
+ +

Enhancements:

+ +
    +
  • Document the remaining public APIs. rspec-expectations now has 100% of +the public API documented and will remain that way (as new undocumented +methods will fail the build). (Myron Marston)
  • +
  • Improve the formatting of BigDecimal objects in eq matcher failure +messages. (Daniel Fone)
  • +
  • Improve the failure message for be_xyz predicate matchers so +that it includes the inspect output of the receiver. +(Erik Michaels-Ober, Sam Phippen)
  • +
  • Add all matcher, to allow you to specify that a given matcher +matches all elements in a collection: +expect([1, 3, 5]).to all( be_odd ). (Adam Farhi)
  • +
  • Add boolean aliases (&/|) for compound operators (and/or). (Adam Farhi)
  • +
  • Give users a clear error when they wrongly use a value matcher +in a block expectation expression (e.g. expect { 3 }.to eq(3)) +or vice versa. (Myron Marston)
  • +
+ +

3.0.0.beta2 / 2014-02-17

+ +

Full Changelog

+ +

Breaking Changes for 3.0.0:

+ +
    +
  • Remove deprecated support for accessing the RSpec constant using +Rspec or Spec. (Myron Marston)
  • +
  • Remove deprecated RSpec::Expectations.differ=. (Myron Marston)
  • +
  • Remove support for deprecated expect(...).should. (Myron Marston)
  • +
  • Explicitly disallow expect { }.not_to change { } with by, +by_at_least, by_at_most or to. These have never been supported +but did not raise explicit errors. (Myron Marston)
  • +
  • Provide === rather than == as an alias of matches? for +all matchers. The semantics of === are closer to an RSpec +matcher than ==. (Myron Marston)
  • +
  • Remove deprecated RSpec::Matchers::OperatorMatcher constant. +(Myron Marston)
  • +
  • Make RSpec::Expectations::ExpectationNotMetError subclass +Exception rather than StandardError so they can bypass +a bare rescue in end-user code (e.g. when an expectation is +set from within a rspec-mocks stub implementation). (Myron Marston)
  • +
  • Remove Test::Unit and Minitest 4.x integration. (Myron Marston)
  • +
+ +

Enhancements:

+ +
    +
  • Simplify the failure message of the be matcher when matching against: +true, false and nil. (Sam Phippen)
  • +
  • Update matcher protocol and custom matcher DSL to better align +with the newer expect syntax. If you want your matchers to +maintain compatibility with multiple versions of RSpec, you can +alias the new names to the old. (Myron Marston) + +
      +
    • failure_message_for_should => failure_message
    • +
    • failure_message_for_should_not => failure_message_when_negated
    • +
    • match_for_should => match
    • +
    • match_for_should_not => match_when_negated
    • +
  • +
  • Improve generated descriptions from change matcher. (Myron Marston)
  • +
  • Add support for compound matcher expressions using and and or. +Simply chain them off of any existing matcher to create an expression +like expect(alphabet).to start_with("a").and end_with("z"). +(Eloy Espinaco)
  • +
  • Add contain_exactly as a less ambiguous version of match_array. +Note that it expects the expected array to be splatted as +individual args: expect(array).to contain_exactly(1, 2) is +the same as expect(array).to match_array([1, 2]). (Myron Marston)
  • +
  • Update contain_exactly/match_array so that it can match against +other non-array collections (such as a Set). (Myron Marston)
  • +
  • Update built-in matchers so that they can accept matchers as arguments +to allow you to compose matchers in arbitrary ways. (Myron Marston)
  • +
  • Add RSpec::Matchers::Composable mixin that can be used to make +a custom matcher composable as well. Note that custom matchers +defined via RSpec::Matchers.define already have this. (Myron +Marston)
  • +
  • Define noun-phrase aliases for built-in matchers, which can be +used when creating composed matcher expressions that read better +and provide better failure messages. (Myron Marston)
  • +
  • Add RSpec::Matchers.alias_matcher so users can define their own +matcher aliases. The description of the matcher will reflect the +alternate matcher name. (Myron Marston)
  • +
  • Add explicit be_between matcher. be_between has worked for a +long time as a dynamic predicate matcher, but the failure message +was suboptimal. The new matcher provides a much better failure +message. (Erik Michaels-Ober)
  • +
  • Enhance the be_between matcher to allow for inclusive or exclusive +comparison (e.g. inclusive of min/max or exclusive of min/max). +(Pedro Gimenez)
  • +
  • Make failure message for not_to be #{operator} less confusing by +only saying it's confusing when comparison operators are used. +(Prathamesh Sonpatki)
  • +
  • Improve failure message of eq matcher when Time or DateTime +objects are used so that the full sub-second precision is included. +(Thomas Holmes, Jeff Wallace)
  • +
  • Add output matcher for expecting that a block outputs to_stdout +or to_stderr. (Luca Pette, Matthias Günther)
  • +
  • Forward a provided block on to the has_xyz? method call when +the have_xyz matcher is used. (Damian Galarza)
  • +
  • Provide integration with Minitest 5.x. Require +rspec/expectations/minitest_integration after loading minitest +to use rspec-expectations with minitest. (Myron Marston)
  • +
+ +

Bug Fixes:

+ +
    +
  • Fix wrong matcher descriptions with falsey expected value (yujinakayama)
  • +
  • Fix expect { }.not_to change { }.from(x) so that the matcher only +passes if the starting value is x. (Tyler Rick, Myron Marston)
  • +
  • Fix hash diffing, so that it colorizes properly and doesn't consider trailing +commas when performing the diff. (Jared Norman)
  • +
  • Fix built-in matchers to fail normally rather than raising +ArgumentError when given an object of the wrong type to match +against, so that they work well in composite matcher expressions like +expect([1.51, "foo"]).to include(a_string_matching(/foo/), a_value_within(0.1).of(1.5)). +(Myron Marston)
  • +
+ +

Deprecations:

+ +
    +
  • Retain support for RSpec 2 matcher protocol (e.g. for matchers +in 3rd party extension gems like shoulda), but it will print +a deprecation warning. (Myron Marston)
  • +
+ +

3.0.0.beta1 / 2013-11-07

+ +

Full Changelog

+ +

Breaking Changes for 3.0.0:

+ +
    +
  • Remove explicit support for 1.8.6. (Jon Rowe)
  • +
  • Remove the deprecated be_close matcher, preferring be_within instead. +(Sam Phippen)
  • +
  • Remove the deprecated have, have_at_least and have_at_most matchers. +You can continue using those matchers through https://github.com/rspec/rspec-collection_matchers, +or you can rewrite your expectations with something like +expect(your_object.size).to eq(num). (Hugo Baraúna)
  • +
  • Rename be_true and be_false to be_truthy and be_falsey. (Sam Phippen)
  • +
  • Make expect { }.to_not raise_error(SomeSpecificClass, message), + expect { }.to_not raise_error(SomeSpecificClass) and + expect { }.to_not raise_error(message) invalid, since they are prone +to hiding failures. Instead, use expect { }.to_not raise_error (with no +args). (Sam Phippen)
  • +
  • Within RSpec::Matchers.define blocks, helper methods made available +either via def self.helper or extend HelperModule are no longer +available to the match block (or any of the others). Instead +include your helper module and define the helper method as an +instance method. (Myron Marston)
  • +
  • Force upgrading Diff::LCS for encoding compatability with diffs. (Jon Rowe)
  • +
+ +

Enhancements:

+ +
    +
  • Support do..end style block with raise_error matcher. (Yuji Nakayama)
  • +
  • Rewrote custom matcher DSL to simplify its implementation and solve a +few issues. (Myron Marston)
  • +
  • Allow early return from within custom matcher DSL blocks. (Myron +Marston)
  • +
  • The custom matcher DSL's chain can now accept a block. (Myron +Marston)
  • +
  • Support setting an expectation on a raise_error matcher via a chained +with_message method call. (Sam Phippen)
  • +
+ +

Bug Fixes:

+ +
    +
  • Allow include and match matchers to be used from within a +DSL-defined custom matcher's match block. (Myron Marston)
  • +
  • Correct encoding error message on diff failure (Jon Rowe)
  • +
+ +

Deprecations:

+ +
    +
  • Using the old :should syntax without explicitly configuring it is deprecated. +It will continue to work but will emit a deprecation warning in RSpec 3 if +you do not explicitly enable it. (Sam Phippen)
  • +
+ +

2.99.2 / 2014-07-21

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix regression in Expectations#method_handle_for where proxy objects +with method delegated would wrongly not return a method handle. +(Jon Rowe, #594)
  • +
  • Fix issue with detection of generic operator matchers so they work +correctly when undefined. (Myron Marston, #597)
  • +
+ +

2.99.1 / 2014-06-19

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix typo in custom matcher expected deprecation warning -- it's +expected_as_array, not expected_array. (Frederick Cheung, #562)
  • +
+ +

2.99.0 / 2014-06-01

+ +

Full Changelog

+ +

Enhancements:

+ +
    +
  • Special case deprecation message for errors_on with rspec-rails to be more useful. +(Aaron Kromer)
  • +
+ +

2.99.0.rc1 / 2014-05-18

+ +

Full Changelog

+ +

Deprecations:

+ +
    +
  • Deprecate matcher_execution_context attribute on DSL-defined +custom matchers. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::Pretty#_pretty_print. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::Configuration in favor of +RSpec::Expectations::Configuration. (Myron Marston)
  • +
  • Deprecate be_xyz predicate matcher on an object that doesn't respond to +xyz? or xyzs?. (Daniel Fone)
  • +
  • Deprecate have_xyz matcher on an object that doesn't respond to has_xyz?. +(Daniel Fone)
  • +
  • Deprecate have_xyz matcher on an object that has a private method has_xyz?. +(Jon Rowe)
  • +
  • Issue a deprecation warning when a block expectation expression is +used with a matcher that doesn't explicitly support block expectations +via supports_block_expectations?. (Myron Marston)
  • +
  • Deprecate require 'rspec-expectations'. Use +require 'rspec/expectations' instead. (Myron Marston)
  • +
+ +

2.99.0.beta2 / 2014-02-17

+ +

Full Changelog

+ +

Deprecations:

+ +
    +
  • Deprecate chaining by, by_at_least, by_at_most or to off of +expect { }.not_to change { }. The docs have always said these are +not supported for the negative form but now they explicitly raise +errors in RSpec 3. (Myron Marston)
  • +
  • Change the semantics of expect { }.not_to change { x }.from(y). +In RSpec 2.x, this expectation would only fail if x started with +the value of y and changed. If it started with a different value +and changed, it would pass. In RSpec 3, it will pass only if the +value starts at y and it does not change. (Myron Marston)
  • +
  • Deprecate matcher == value as an alias for matcher.matches?(value), +in favor of matcher === value. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::OperatorMatcher in favor of +RSpec::Matchers::BuiltIn::OperatorMatcher. (Myron Marston)
  • +
  • Deprecate auto-integration with Test::Unit and minitest. +Instead, include RSpec::Matchers in the appropriate test case +base class yourself. (Myron Marston)
  • +
  • Deprecate treating #expected on a DSL-generated custom matcher +as an array when only 1 argument is passed to the matcher method. +In RSpec 3 it will be the single value in order to make diffs +work properly. (Jon Rowe)
  • +
+ +

2.99.0.beta1 / 2013-11-07

+ +

Full Changelog

+ +

Deprecations

+ +
    +
  • Deprecate have, have_at_least and have_at_most. You can continue using those +matchers through https://github.com/rspec/rspec-collection_matchers, or +you can rewrite your expectations with something like +expect(your_object.size).to eq(num). (Hugo Baraúna)
  • +
  • Deprecate be_xyz predicate matcher when xyz? is a private method. +(Jon Rowe)
  • +
  • Deprecate be_true/be_false in favour of be_truthy/be_falsey +(for Ruby's conditional semantics) or be true/be false +(for exact equality). (Sam Phippen)
  • +
  • Deprecate calling helper methods from a custom matcher with the wrong +scope. (Myron Marston) + +
      +
    • def self.foo / extend Helper can be used to add macro methods +(e.g. methods that call the custom matcher DSL methods), but should +not be used to define helper methods called from within the DSL +blocks.
    • +
    • def foo / include Helper is the opposite: it's for helper methods +callable from within a DSL block, but not for defining macros.
    • +
    • RSpec 2.x allowed helper methods defined either way to be used for +either purpose, but RSpec 3.0 will not.
    • +
  • +
+ +

2.14.5 / 2014-02-01

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix wrong matcher descriptions with falsey expected value +(yujinakayama)
  • +
+ +

2.14.4 / 2013-11-06

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Make the match matcher produce a diff output. (Jon Rowe, Ben Moss)
  • +
  • Choose encoding for diff's more intelligently, and when all else fails fall +back to default internal encoding with replacing characters. (Jon Rowe)
  • +
+ +

2.14.3 / 2013-09-22

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix operator matchers (should syntax) when method is redefined on target. +(Brandon Turner)
  • +
  • Fix diffing of hashes with object based keys. (Jon Rowe)
  • +
  • Fix operator matchers (should syntax) when operator is defined via +method_missing (Jon Rowe)
  • +
+ +

2.14.2 / 2013-08-14

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix be_<predicate> matcher to not support operator chaining like the +be matcher does (e.g. be == 5). This led to some odd behaviors +since be_<predicate> == anything returned a BeComparedTo matcher +and was thus always truthy. This was a consequence of the implementation +(e.g. subclassing the basic Be matcher) and was not intended behavior. +(Myron Marston).
  • +
  • Fix change matcher to compare using == in addition to ===. This +is important for an expression like: +expect {}.to change { a.class }.from(ClassA).to(ClassB) because +SomeClass === SomeClass returns false. (Myron Marston)
  • +
+ +

2.14.1 / 2013-08-08

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Ensure diff output uses the same encoding as the encoding of +the string being diff'd to prevent Encoding::UndefinedConversionError +errors (Jon Rowe).
  • +
+ +

2.14.0 / 2013-07-06

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Values that are not matchers use #inspect, rather than #description for +documentation output (Andy Lindeman, Sam Phippen).
  • +
  • Make expect(a).to be_within(x).percent_of(y) work with negative y +(Katsuhiko Nishimra).
  • +
  • Make the be_predicate matcher work as expected used with expect{...}.to +change... (Sam Phippen).
  • +
+ +

2.14.0.rc1 / 2013-05-27

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Enhance yield_control so that you can specify an exact or relative +number of times: expect { }.to yield_control.exactly(3).times, +expect { }.to yield_control.at_least(2).times, etc (Bartek +Borkowski).
  • +
  • Make the differ that is used when an expectation fails better handle arrays +by splitting each element of the array onto its own line. (Sam Phippen)
  • +
  • Accept duck-typed strings that respond to :to_str as expectation messages. +(Toby Ovod-Everett)
  • +
+ +

Bug fixes

+ +
    +
  • Fix differ to not raise errors when dealing with differently-encoded +strings (Jon Rowe).
  • +
  • Fix expect(something).to be_within(x).percent_of(y) where x and y are both +integers (Sam Phippen).
  • +
  • Fix have matcher to handle the fact that on ruby 2.0, +Enumerator#size may return nil (Kenta Murata).
  • +
  • Fix expect { raise s }.to raise_error(s) where s is an error instance +on ruby 2.0 (Sam Phippen).
  • +
  • Fix expect(object).to raise_error passing. This now warns the user and +fails the spec (tomykaira).
  • +
+ +

Deprecations

+ +
    +
  • Deprecate expect { }.not_to raise_error(SpecificErrorClass) or +expect { }.not_to raise_error("some specific message"). Using +these was prone to hiding failures as they would allow any other +error to pass. (Sam Phippen and David Chelimsky)
  • +
+ +

2.13.0 / 2013-02-23

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Add support for percent deltas to be_within matcher: +expect(value).to be_within(10).percent_of(expected) +(Myron Marston).
  • +
  • Add support to include matcher to allow it to be given a list +of matchers as the expecteds to match against (Luke Redpath).
  • +
+ +

Bug fixes

+ +
    +
  • Fix change matcher so that it dups strings in order to handle +mutated strings (Myron Marston).
  • +
  • Fix should be =~ /some regex/ / expect(...).to be =~ /some regex/. +Previously, these either failed with a confusing undefined method +matches?' for false:FalseClass error or were no-ops that didn't +actually verify anything (Myron Marston).
  • +
  • Add compatibility for diff-lcs 1.2 and relax the version +constraint (Peter Goldstein).
  • +
  • Fix DSL-generated matchers to allow multiple instances of the +same matcher in the same example to have different description +and failure messages based on the expected value (Myron Marston).
  • +
  • Prevent undefined method #split for Array error when dumping +the diff of an array of multiline strings (Myron Marston).
  • +
  • Don't blow up when comparing strings that are in an encoding +that is not ASCII compatible (Myron Marston).
  • +
  • Remove confusing "Check the implementation of #==" message +printed for empty diffs (Myron Marston).
  • +
+ +

2.12.1 / 2012-12-15

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Improve the failure message for an expression like +{}.should =~ {}. (Myron Marston and Andy Lindeman)
  • +
  • Provide a match_regex alias so that custom matchers +built using the matcher DSL can use it (since match +is a different method in that context). +(Steven Harman)
  • +
+ +

2.12.0 / 2012-11-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Colorize diffs if the --color option is configured. (Alex Coplan)
  • +
  • Include backtraces in unexpected errors handled by raise_error +matcher (Myron Marston)
  • +
  • Print a warning when users accidentally pass a non-string argument +as an expectation message (Sam Phippen)
  • +
  • =~ and match_array matchers output a more useful error message when +the actual value is not an array (or an object that responds to #to_ary) +(Sam Phippen)
  • +
+ +

Bug fixes

+ +
    +
  • Fix include matcher so that expect({}).to include(:a => nil) +fails as it should (Sam Phippen).
  • +
  • Fix be_an_instance_of matcher so that Class#to_s is used in the +description rather than Class#inspect, since some classes (like +ActiveRecord::Base) define a long, verbose #inspect. +(Tom Stuart)
  • +
+ +

2.11.3 / 2012-09-04

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix (and deprecate) expect { }.should syntax so that it works even +though it was never a documented or intended syntax. It worked as a +consequence of the implementation of expect in RSpec 2.10 and +earlier. (Myron Marston)
  • +
  • Ensure #== is defined on built in matchers so that they can be composed. +For example:

    + +

    expect { + user.emailed! +}.to change { user.last_emailed_at }.to be_within(1.second).of(Time.zone.now)

  • +
+ +

2.11.2 / 2012-07-25

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Define should and should_not on Object rather than BasicObject +on MacRuby. On MacRuby, BasicObject is defined but is not the root +of the object hierarchy. (Gabriel Gilder)
  • +
+ +

2.11.1 / 2012-07-08

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Constrain actual in be_within matcher to values that respond to - instead +of requiring a specific type. + +
      +
    • Time, for example, is a legit alternative.
    • +
  • +
+ +

2.11.0 / 2012-07-07

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Expand expect syntax so that it supports expections on bare values +in addition to blocks (Myron Marston).
  • +
  • Add configuration options to control available expectation syntaxes +(Myron Marston): + +
      +
    • RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :expect }
    • +
    • RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :should }
    • +
    • RSpec.configuration.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
    • +
    • RSpec.configuration.add_should_and_should_not_to Delegator
    • +
  • +
+ +

Bug fixes

+ +
    +
  • Allow only Numeric values to be the "actual" in the be_within matcher. +This prevents confusing error messages. (Su Zhang @zhangsu)
  • +
  • Define should and should_not on BasicObject rather than Kernel +on 1.9. This makes should and should_not work properly with +BasicObject-subclassed proxy objects like Delegator. (Myron +Marston)
  • +
+ +

2.10.0 / 2012-05-03

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Add new start_with and end_with matchers (Jeremy Wadsack)
  • +
  • Add new matchers for specifying yields (Myron Marston): + +
      +
    • expect {...}.to yield_control
    • +
    • expect {...}.to yield_with_args(1, 2, 3)
    • +
    • expect {...}.to yield_with_no_args
    • +
    • expect {...}.to yield_successive_args(1, 2, 3)
    • +
  • +
  • match_unless_raises takes multiple exception args
  • +
+ +

Bug fixes

+ +
    +
  • Fix be_within matcher to be inclusive of delta.
  • +
  • Fix message-specific specs to pass on Rubinius (John Firebaugh)
  • +
+ +

2.9.1 / 2012-04-03

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Provide a helpful message if the diff between two objects is empty.
  • +
  • Fix bug diffing single strings with multiline strings.
  • +
  • Fix for error with using custom matchers inside other custom matchers +(mirasrael)
  • +
  • Fix using execution context methods in nested DSL matchers (mirasrael)
  • +
+ +

2.9.0 / 2012-03-17

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Move built-in matcher classes to RSpec::Matchers::BuiltIn to reduce pollution +of RSpec::Matchers (which is included in every example).
  • +
  • Autoload files with matcher classes to improve load time.
  • +
+ +

Bug fixes

+ +
    +
  • Align respond_to? and method_missing in DSL-defined matchers.
  • +
  • Clear out user-defined instance variables between invocations of DSL-defined +matchers.
  • +
  • Dup the instance of a DSL generated matcher so its state is not changed by +subsequent invocations.
  • +
  • Treat expected args consistently across positive and negative expectations +(thanks to Ralf Kistner for the heads up)
  • +
+ +

2.8.0 / 2012-01-04

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Better diff output for Hash (Philippe Creux)
  • +
  • Eliminate Ruby warnings (Olek Janiszewski)
  • +
+ +

2.8.0.rc2 / 2011-12-19

+ +

Full Changelog

+ +

No changes for this release. Just releasing with the other rspec gems.

+ +

2.8.0.rc1 / 2011-11-06

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Use classes for the built-in matchers (they're faster).
  • +
  • Eliminate Ruby warnings (Matijs van Zuijlen)
  • +
+ +

2.7.0 / 2011-10-16

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • HaveMatcher converts argument using to_i (Alex Bepple & Pat Maddox)
  • +
  • Improved failure message for the have_xxx matcher (Myron Marston)
  • +
  • HaveMatcher supports count (Matthew Bellantoni)
  • +
  • Change matcher dups Enumerable before the action, supporting custom +Enumerable types like CollectionProxy in Rails (David Chelimsky)
  • +
+ +

Bug fixes

+ +
    +
  • Fix typo in have(n).xyz documentation (Jean Boussier)
  • +
  • fix safe_sort for ruby 1.9.2 (Kernel now defines <=> for Object) (Peter +van Hardenberg)
  • +
+ +

2.6.0 / 2011-05-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • change matcher accepts regexps (Robert Davis)
  • +
  • better descriptions for have_xxx matchers (Magnus Bergmark)
  • +
  • range.should cover(*values) (Anders Furseth)
  • +
+ +

Bug fixes

+ +
    +
  • Removed non-ascii characters that were choking rcov (Geoffrey Byers)
  • +
  • change matcher dups arrays and hashes so their before/after states can be +compared correctly.
  • +
  • Fix the order of inclusion of RSpec::Matchers in Test::Unit::TestCase and +MiniTest::Unit::TestCase to prevent a SystemStackError (Myron Marston)
  • +
+ +

2.5.0 / 2011-02-05

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • should exist works with exist? or exists? (Myron Marston)
  • +
  • expect { ... }.not_to do_something (in addition to to_not)
  • +
+ +

Documentation

+ +
    +
  • improved docs for raise_error matcher (James Almond)
  • +
+ +

2.4.0 / 2011-01-02

+ +

Full Changelog

+ +

No functional changes in this release, which was made to align with the +rspec-core-2.4.0 release.

+ +

Enhancements

+ +
    +
  • improved RDoc for change matcher (Jo Liss)
  • +
+ +

2.3.0 / 2010-12-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • diff strings when include matcher fails (Mike Sassak)
  • +
+ +

2.2.0 / 2010-11-28

+ +

Full Changelog

+ +

2.1.0 / 2010-11-07

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • be_within(delta).of(expected) matcher (Myron Marston)
  • +
  • Lots of new Cucumber features (Myron Marston)
  • +
  • Raise error if you try should != expected on Ruby-1.9 (Myron Marston)
  • +
  • Improved failure messages from throw_symbol (Myron Marston)
  • +
+ +

Bug fixes

+ +
    +
  • Eliminate hard dependency on RSpec::Core (Myron Marston)
  • +
  • have_matcher - use pluralize only when ActiveSupport inflections are indeed +defined (Josep M Bach)
  • +
  • throw_symbol matcher no longer swallows exceptions (Myron Marston)
  • +
  • fix matcher chaining to avoid name collisions (Myron Marston)
  • +
+ +

2.0.0 / 2010-10-10

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Add match_for_should_not method to matcher DSL (Myron Marston)
  • +
+ +

Bug fixes

+ +
    +
  • respond_to matcher works correctly with should_not with multiple methods +(Myron Marston)
  • +
  • include matcher works correctly with should_not with multiple values +(Myron Marston)
  • +
+ +

2.0.0.rc / 2010-10-05

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • require 'rspec/expectations' in a T::U or MiniUnit suite (Josep M. Bach)
  • +
+ +

Bug fixes

+ +
    +
  • change by 0 passes/fails correctly (Len Smith)
  • +
  • Add description to satisfy matcher
  • +
+ +

2.0.0.beta.22 / 2010-09-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • diffing improvements + +
      +
    • diff multiline strings
    • +
    • don't diff single line strings
    • +
    • don't diff numbers (silly)
    • +
    • diff regexp + multiline string
    • +
  • +
+ +

Bug fixes + * should[_not] change now handles boolean values correctly

+
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/file.License.html b/source/documentation/3.1/rspec-expectations/file.License.html new file mode 100644 index 000000000..3ebd24d22 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/file.License.html @@ -0,0 +1,73 @@ + + + + + + File: License + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +
(The MIT License)

Copyright (c) 2012 David Chelimsky, Myron Marston
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
Copyright (c) 2005 Steven Baker

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/file.README.html b/source/documentation/3.1/rspec-expectations/file.README.html new file mode 100644 index 000000000..662d94038 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/file.README.html @@ -0,0 +1,338 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

RSpec Expectations Build Status Code Climate

+ +

RSpec::Expectations lets you express expected outcomes on an object in an +example.

+ +
expect(.balance).to eq(Money.new(37.42, :USD))
+
+ +

Install

+ +

If you want to use rspec-expectations with rspec, just install the rspec gem +and RubyGems will also install rspec-expectations for you (along with +rspec-core and rspec-mocks):

+ +
gem install rspec
+
+ +

If you want to use rspec-expectations with another tool, like Test::Unit, +Minitest, or Cucumber, you can install it directly:

+ +
gem install rspec-expectations
+
+ +

Basic usage

+ +

Here's an example using rspec-core:

+ +
RSpec.describe Order do
+  it "sums the prices of the items in its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe and it methods come from rspec-core. The Order, LineItem, Item and Money classes would be from your code. The last line of the example +expresses an expected outcome. If order.total == Money.new(5.55, :USD), then +the example passes. If not, it fails with a message like:

+ +
expected: #<Money @value=5.55 @currency=:USD>
+     got: #<Money @value=1.11 @currency=:USD>
+
+ +

Built-in matchers

+ +

Equivalence

+ +
expect(actual).to eq(expected)  # passes if actual == expected
+expect(actual).to eql(expected) # passes if actual.eql?(expected)
+
+ +

Note: The new expect syntax no longer supports the == matcher.

+ +

Identity

+ +
expect(actual).to be(expected)    # passes if actual.equal?(expected)
+expect(actual).to equal(expected) # passes if actual.equal?(expected)
+
+ +

Comparisons

+ +
expect(actual).to be >  expected
+expect(actual).to be >= expected
+expect(actual).to be <= expected
+expect(actual).to be <  expected
+expect(actual).to be_within(delta).of(expected)
+
+ +

Regular expressions

+ +
expect(actual).to match(/expression/)
+
+ +

Note: The new expect syntax no longer supports the =~ matcher.

+ +

Types/classes

+ +
expect(actual).to be_an_instance_of(expected) # passes if actual.class == expected
+expect(actual).to be_a(expected)              # passes if actual.is_a?(expected)
+expect(actual).to be_an(expected)             # an alias for be_a
+expect(actual).to be_a_kind_of(expected)      # another alias
+
+ +

Truthiness

+ +
expect(actual).to be_truthy # passes if actual is truthy (not nil or false)
+expect(actual).to be true   # passes if actual == true
+expect(actual).to be_falsy  # passes if actual is falsy (nil or false)
+expect(actual).to be false  # passes if actual == false
+expect(actual).to be_nil    # passes if actual is nil
+
+ +

Expecting errors

+ +
expect { ... }.to raise_error
+expect { ... }.to raise_error(ErrorClass)
+expect { ... }.to raise_error("message")
+expect { ... }.to raise_error(ErrorClass, "message")
+
+ +

Expecting throws

+ +
expect { ... }.to throw_symbol
+expect { ... }.to throw_symbol(:symbol)
+expect { ... }.to throw_symbol(:symbol, 'value')
+
+ +

Yielding

+ +
expect { |b| 5.tap(&b) }.to yield_control # passes regardless of yielded args
+
+expect { |b| yield_if_true(true, &b) }.to yield_with_no_args # passes only if no args are yielded
+
+expect { |b| 5.tap(&b) }.to yield_with_args(5)
+expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum)
+expect { |b| "a string".tap(&b) }.to yield_with_args(/str/)
+
+expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
+expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2])
+
+ +

Predicate matchers

+ +
expect(actual).to be_xxx         # passes if actual.xxx?
+expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
+
+ +

Ranges (Ruby >= 1.9 only)

+ +
expect(1..10).to cover(3)
+
+ +

Collection membership

+ +
expect(actual).to include(expected)
+expect(actual).to start_with(expected)
+expect(actual).to end_with(expected)
+
+expect(actual).to contain_exactly(individual, items)
+# ...which is the same as:
+expect(actual).to match_array(expected_array)
+
+ +

Examples

+ +
expect([1, 2, 3]).to include(1)
+expect([1, 2, 3]).to include(1, 2)
+expect([1, 2, 3]).to start_with(1)
+expect([1, 2, 3]).to start_with(1, 2)
+expect([1, 2, 3]).to end_with(3)
+expect([1, 2, 3]).to end_with(2, 3)
+expect({:a => 'b'}).to include(:a => 'b')
+expect("this string").to include("is str")
+expect("this string").to start_with("this")
+expect("this string").to end_with("ring")
+expect([1, 2, 3]).to contain_exactly(2, 3, 1)
+expect([1, 2, 3]).to match_array([3, 2, 1])
+
+ +

should syntax

+ +

In addition to the expect syntax, rspec-expectations continues to support the +should syntax:

+ +
actual.should eq expected
+actual.should be > 3
+[1, 2, 3].should_not include 4
+
+ +

See detailed information on the should syntax and its usage.

+ +

Compound Matcher Expressions

+ +

You can also create compound matcher expressions using and or or:

+ +
expect(alphabet).to start_with("a").and end_with("z")
+expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
+
+ +

Composing Matchers

+ +

Many of the built-in matchers are designed to take matchers as +arguments, to allow you to flexibly specify only the essential +aspects of an object or data structure. In addition, all of the +built-in matchers have one or more aliases that provide better +phrasing for when they are used as arguments to another matcher.

+ +

Examples

+ +
expect { k += 1.05 }.to change { k }.by( a_value_within(0.1).of(1.0) )
+
+expect { s = "barn" }.to change { s }
+  .from( a_string_matching(/foo/) )
+  .to( a_string_matching(/bar/) )
+
+expect(["barn", 2.45]).to contain_exactly(
+  a_value_within(0.1).of(2.5),
+  a_string_starting_with("bar")
+)
+
+expect(["barn", "food", 2.45]).to end_with(
+  a_string_matching("foo"),
+  a_value > 2
+)
+
+expect(["barn", 2.45]).to include( a_string_starting_with("bar") )
+
+expect(:a => "food", :b => "good").to include(:a => a_string_matching(/foo/))
+
+hash = {
+  :a => {
+    :b => ["foo", 5],
+    :c => { :d => 2.05 }
+  }
+}
+
+expect(hash).to match(
+  :a => {
+    :b => a_collection_containing_exactly(
+      a_string_starting_with("f"),
+      an_instance_of(Fixnum)
+    ),
+    :c => { :d => (a_value < 3) }
+  }
+)
+
+expect { |probe|
+  [1, 2, 3].each(&probe)
+}.to yield_successive_args( a_value < 2, 2, a_value > 2 )
+
+ +

Usage outside rspec-core

+ +

You always need to load rspec/expectations even if you only want to use one part of the library:

+ +
require 'rspec/expectations'
+
+ +

Then simply include RSpec::Matchers in any class:

+ +
class MyClass
+  include RSpec::Matchers
+
+  def do_something(arg)
+    expect(arg).to be > 0
+    # do other stuff
+  end
+end
+
+ +

Also see

+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/file_list.html b/source/documentation/3.1/rspec-expectations/file_list.html new file mode 100644 index 000000000..ac9df6c7e --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/file_list.html @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + File List + + + + +
+

File List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-expectations/frames.html b/source/documentation/3.1/rspec-expectations/frames.html new file mode 100644 index 000000000..43d89f7b9 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/frames.html @@ -0,0 +1,26 @@ + + + + + + Documentation by YARD 0.8.7.4 + + + + diff --git a/source/documentation/3.1/rspec-expectations/index.html b/source/documentation/3.1/rspec-expectations/index.html new file mode 100644 index 000000000..662d94038 --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/index.html @@ -0,0 +1,338 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

RSpec Expectations Build Status Code Climate

+ +

RSpec::Expectations lets you express expected outcomes on an object in an +example.

+ +
expect(.balance).to eq(Money.new(37.42, :USD))
+
+ +

Install

+ +

If you want to use rspec-expectations with rspec, just install the rspec gem +and RubyGems will also install rspec-expectations for you (along with +rspec-core and rspec-mocks):

+ +
gem install rspec
+
+ +

If you want to use rspec-expectations with another tool, like Test::Unit, +Minitest, or Cucumber, you can install it directly:

+ +
gem install rspec-expectations
+
+ +

Basic usage

+ +

Here's an example using rspec-core:

+ +
RSpec.describe Order do
+  it "sums the prices of the items in its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe and it methods come from rspec-core. The Order, LineItem, Item and Money classes would be from your code. The last line of the example +expresses an expected outcome. If order.total == Money.new(5.55, :USD), then +the example passes. If not, it fails with a message like:

+ +
expected: #<Money @value=5.55 @currency=:USD>
+     got: #<Money @value=1.11 @currency=:USD>
+
+ +

Built-in matchers

+ +

Equivalence

+ +
expect(actual).to eq(expected)  # passes if actual == expected
+expect(actual).to eql(expected) # passes if actual.eql?(expected)
+
+ +

Note: The new expect syntax no longer supports the == matcher.

+ +

Identity

+ +
expect(actual).to be(expected)    # passes if actual.equal?(expected)
+expect(actual).to equal(expected) # passes if actual.equal?(expected)
+
+ +

Comparisons

+ +
expect(actual).to be >  expected
+expect(actual).to be >= expected
+expect(actual).to be <= expected
+expect(actual).to be <  expected
+expect(actual).to be_within(delta).of(expected)
+
+ +

Regular expressions

+ +
expect(actual).to match(/expression/)
+
+ +

Note: The new expect syntax no longer supports the =~ matcher.

+ +

Types/classes

+ +
expect(actual).to be_an_instance_of(expected) # passes if actual.class == expected
+expect(actual).to be_a(expected)              # passes if actual.is_a?(expected)
+expect(actual).to be_an(expected)             # an alias for be_a
+expect(actual).to be_a_kind_of(expected)      # another alias
+
+ +

Truthiness

+ +
expect(actual).to be_truthy # passes if actual is truthy (not nil or false)
+expect(actual).to be true   # passes if actual == true
+expect(actual).to be_falsy  # passes if actual is falsy (nil or false)
+expect(actual).to be false  # passes if actual == false
+expect(actual).to be_nil    # passes if actual is nil
+
+ +

Expecting errors

+ +
expect { ... }.to raise_error
+expect { ... }.to raise_error(ErrorClass)
+expect { ... }.to raise_error("message")
+expect { ... }.to raise_error(ErrorClass, "message")
+
+ +

Expecting throws

+ +
expect { ... }.to throw_symbol
+expect { ... }.to throw_symbol(:symbol)
+expect { ... }.to throw_symbol(:symbol, 'value')
+
+ +

Yielding

+ +
expect { |b| 5.tap(&b) }.to yield_control # passes regardless of yielded args
+
+expect { |b| yield_if_true(true, &b) }.to yield_with_no_args # passes only if no args are yielded
+
+expect { |b| 5.tap(&b) }.to yield_with_args(5)
+expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum)
+expect { |b| "a string".tap(&b) }.to yield_with_args(/str/)
+
+expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
+expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2])
+
+ +

Predicate matchers

+ +
expect(actual).to be_xxx         # passes if actual.xxx?
+expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
+
+ +

Ranges (Ruby >= 1.9 only)

+ +
expect(1..10).to cover(3)
+
+ +

Collection membership

+ +
expect(actual).to include(expected)
+expect(actual).to start_with(expected)
+expect(actual).to end_with(expected)
+
+expect(actual).to contain_exactly(individual, items)
+# ...which is the same as:
+expect(actual).to match_array(expected_array)
+
+ +

Examples

+ +
expect([1, 2, 3]).to include(1)
+expect([1, 2, 3]).to include(1, 2)
+expect([1, 2, 3]).to start_with(1)
+expect([1, 2, 3]).to start_with(1, 2)
+expect([1, 2, 3]).to end_with(3)
+expect([1, 2, 3]).to end_with(2, 3)
+expect({:a => 'b'}).to include(:a => 'b')
+expect("this string").to include("is str")
+expect("this string").to start_with("this")
+expect("this string").to end_with("ring")
+expect([1, 2, 3]).to contain_exactly(2, 3, 1)
+expect([1, 2, 3]).to match_array([3, 2, 1])
+
+ +

should syntax

+ +

In addition to the expect syntax, rspec-expectations continues to support the +should syntax:

+ +
actual.should eq expected
+actual.should be > 3
+[1, 2, 3].should_not include 4
+
+ +

See detailed information on the should syntax and its usage.

+ +

Compound Matcher Expressions

+ +

You can also create compound matcher expressions using and or or:

+ +
expect(alphabet).to start_with("a").and end_with("z")
+expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
+
+ +

Composing Matchers

+ +

Many of the built-in matchers are designed to take matchers as +arguments, to allow you to flexibly specify only the essential +aspects of an object or data structure. In addition, all of the +built-in matchers have one or more aliases that provide better +phrasing for when they are used as arguments to another matcher.

+ +

Examples

+ +
expect { k += 1.05 }.to change { k }.by( a_value_within(0.1).of(1.0) )
+
+expect { s = "barn" }.to change { s }
+  .from( a_string_matching(/foo/) )
+  .to( a_string_matching(/bar/) )
+
+expect(["barn", 2.45]).to contain_exactly(
+  a_value_within(0.1).of(2.5),
+  a_string_starting_with("bar")
+)
+
+expect(["barn", "food", 2.45]).to end_with(
+  a_string_matching("foo"),
+  a_value > 2
+)
+
+expect(["barn", 2.45]).to include( a_string_starting_with("bar") )
+
+expect(:a => "food", :b => "good").to include(:a => a_string_matching(/foo/))
+
+hash = {
+  :a => {
+    :b => ["foo", 5],
+    :c => { :d => 2.05 }
+  }
+}
+
+expect(hash).to match(
+  :a => {
+    :b => a_collection_containing_exactly(
+      a_string_starting_with("f"),
+      an_instance_of(Fixnum)
+    ),
+    :c => { :d => (a_value < 3) }
+  }
+)
+
+expect { |probe|
+  [1, 2, 3].each(&probe)
+}.to yield_successive_args( a_value < 2, 2, a_value > 2 )
+
+ +

Usage outside rspec-core

+ +

You always need to load rspec/expectations even if you only want to use one part of the library:

+ +
require 'rspec/expectations'
+
+ +

Then simply include RSpec::Matchers in any class:

+ +
class MyClass
+  include RSpec::Matchers
+
+  def do_something(arg)
+    expect(arg).to be > 0
+    # do other stuff
+  end
+end
+
+ +

Also see

+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-expectations/method_list.html b/source/documentation/3.1/rspec-expectations/method_list.html new file mode 100644 index 000000000..c2f2378df --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/method_list.html @@ -0,0 +1,1745 @@ + + + + + + + + + + + + + + + + + Method List + + + + +
+

Method List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-expectations/top-level-namespace.html b/source/documentation/3.1/rspec-expectations/top-level-namespace.html new file mode 100644 index 000000000..3aab3aa7b --- /dev/null +++ b/source/documentation/3.1/rspec-expectations/top-level-namespace.html @@ -0,0 +1,129 @@ + + + + + + Top Level Namespace + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Top Level Namespace + + + +

+ +
+ + + +
Extended by:
+
RSpec::Matchers::DSL
+ + + + + + + +
+
+ +

Defined Under Namespace

+

+ + + Modules: RSpec + + + + Classes: BasicObject + + +

+ + + + + + + + + + + + + + +

Method Summary

+ +

Methods included from RSpec::Matchers::DSL

+

define

+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/BasicObject.html b/source/documentation/3.1/rspec-mocks/BasicObject.html new file mode 100644 index 000000000..d1010f6dc --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/BasicObject.html @@ -0,0 +1,720 @@ + + + + + + Class: BasicObject + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: BasicObject + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/syntax.rb
+ +
+
+ +

Overview

+
+ +

The legacy :should syntax adds the following methods directly +to BasicObject so that they are available off of any object. +Note, however, that this syntax does not always play nice with +delegate/proxy objects. We recommend you use the non-monkeypatching +:expect syntax instead.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) as_null_object + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Tells the object to respond to all messages. If specific stub values are +declared, they'll work as expected. If not, the receiver is returned.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 286
+
+
+
+
+ +
+

+ + - (Object) null_object? + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Returns true if this object has received as_null_object

+ + +
+
+
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 297
+
+
+
+
+ +
+

+ + - (Object) should_not_receive + + + + + +

+
+ +

Sets and expectation that this object should not receive a message +during this example.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 226
+
+
+
+
+ +
+

+ + - (Object) should_receive + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Sets an expectation that this object should receive a message before the +end of the example.

+ + +
+
+
+ +
+

Examples:

+ + +

+logger = double('logger')
+thing_that_logs = ThingThatLogs.new(logger)
+logger.should_receive(:log)
+thing_that_logs.do_something_that_logs_a_message
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 212
+
+
+
+
+ +
+

+ + - (Object) stub + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Tells the object to respond to the message with the specified value.

+ + +
+
+
+ +
+

Examples:

+ + +

+counter.stub(:count).and_return(37)
+counter.stub(:count => 37)
+counter.stub(:count) { 37 }
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 231
+
+
+
+
+ +
+

+ + + - (Object) stub_chain(method1, method2) + + - (Object) stub_chain("method1.method2") + + - (Object) stub_chain(method1, method_to_value_hash) + + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Stubs a chain of methods.

+ +

Warning:

+ +

Chains can be arbitrarily long, which makes it quite painless to violate +the Law of Demeter in violent ways, so you should consider any use of +stub_chain a code smell. Even though not all code smells +indicate real problems (think fluent interfaces), stub_chain +still results in brittle examples. For example, if you write +foo.stub_chain(:bar, :baz => 37) in a spec and then the +implementation calls foo.baz.bar, the stub will not work.

+ + +
+
+
+ +
+

Examples:

+ + +

+double.stub_chain("foo.bar") { :baz }
+double.stub_chain(:foo, :bar => :baz)
+double.stub_chain(:foo, :bar) { :baz }
+
+# Given any of ^^ these three forms ^^:
+double.foo.bar # => :baz
+
+# Common use in Rails/ActiveRecord:
+Article.stub_chain("recent.published") { [Article.new] }
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 254
+
+
+
+
+ +
+

+ + - (Object) unstub + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Removes a stub. On a double, the object will no longer respond to +message. On a real object, the original method (if it exists) +is restored.

+ +

This is rarely used, but can be useful when a stub is set up during a +shared before hook for the common case, but you want to +replace it for a special case.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 243
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/Class.html b/source/documentation/3.1/rspec-mocks/Class.html new file mode 100644 index 000000000..3e0063a64 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/Class.html @@ -0,0 +1,271 @@ + + + + + + Class: Class + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: Class + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/syntax.rb
+ +
+
+ +

Overview

+
+ +

The legacy :should syntax adds the any_instance +to Class. We generally recommend you use the newer +:expect syntax instead, which allows you to stub any instance +of a class using allow_any_instance_of(klass) or mock any +instance using expect_any_instance_of(klass).

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Recorder) any_instance + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Used to set stubs and message expectations on any instance of a given +class. Returns a Recorder, which records messages +like stub and should_receive for later playback +on instances of the class.

+ + +
+
+
+ +
+

Examples:

+ + +

+Car.any_instance.should_receive(:go)
+race = Race.new
+race.cars << Car.new
+race.go # assuming this delegates to all of its cars
+        # this example would pass
+
+Account.any_instance.stub(:balance) { Money.new(:USD, 25) }
+Account.new.balance # => Money.new(:USD, 25))
+ +
+ +

Returns:

+
    + +
  • + + + (Recorder) + + + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 329
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec.html b/source/documentation/3.1/rspec-mocks/RSpec.html new file mode 100644 index 000000000..f834ac048 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec.html @@ -0,0 +1,129 @@ + + + + + + Module: RSpec + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks.rb,
+ lib/rspec/mocks/proxy.rb,
lib/rspec/mocks/space.rb,
lib/rspec/mocks/syntax.rb,
lib/rspec/mocks/version.rb,
lib/rspec/mocks/targets.rb,
lib/rspec/mocks/test_double.rb,
lib/rspec/mocks/order_group.rb,
lib/rspec/mocks/mutate_const.rb,
lib/rspec/mocks/configuration.rb,
lib/rspec/mocks/message_chain.rb,
lib/rspec/mocks/method_double.rb,
lib/rspec/mocks/example_methods.rb,
lib/rspec/mocks/verifying_proxy.rb,
lib/rspec/mocks/error_generator.rb,
lib/rspec/mocks/method_reference.rb,
lib/rspec/mocks/matchers/receive.rb,
lib/rspec/mocks/verifying_double.rb,
lib/rspec/mocks/object_reference.rb,
lib/rspec/mocks/argument_matchers.rb,
lib/rspec/mocks/marshal_extension.rb,
lib/rspec/mocks/any_instance/proxy.rb,
lib/rspec/mocks/any_instance/chain.rb,
lib/rspec/mocks/message_expectation.rb,
lib/rspec/mocks/any_instance/recorder.rb,
lib/rspec/mocks/argument_list_matcher.rb,
lib/rspec/mocks/matchers/have_received.rb,
lib/rspec/mocks/instance_method_stasher.rb,
lib/rspec/mocks/any_instance/stub_chain.rb,
lib/rspec/mocks/matchers/receive_messages.rb,
lib/rspec/mocks/any_instance/message_chains.rb,
lib/rspec/mocks/verifying_message_expecation.rb,
lib/rspec/mocks/any_instance/stub_chain_chain.rb,
lib/rspec/mocks/matchers/receive_message_chain.rb,
lib/rspec/mocks/any_instance/expectation_chain.rb,
lib/rspec/mocks/any_instance/expect_chain_chain.rb,
lib/rspec/mocks/matchers/expectation_customization.rb
+
+ +
+
+ +

Overview

+
+ +

Share the top-level RSpec namespace, because we are a core supported +extension.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Mocks + + + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks.html new file mode 100644 index 000000000..d29f2c286 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks.html @@ -0,0 +1,860 @@ + + + + + + Module: RSpec::Mocks + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks.rb,
+ lib/rspec/mocks/proxy.rb,
lib/rspec/mocks/space.rb,
lib/rspec/mocks/syntax.rb,
lib/rspec/mocks/version.rb,
lib/rspec/mocks/targets.rb,
lib/rspec/mocks/test_double.rb,
lib/rspec/mocks/order_group.rb,
lib/rspec/mocks/mutate_const.rb,
lib/rspec/mocks/configuration.rb,
lib/rspec/mocks/message_chain.rb,
lib/rspec/mocks/method_double.rb,
lib/rspec/mocks/example_methods.rb,
lib/rspec/mocks/verifying_proxy.rb,
lib/rspec/mocks/error_generator.rb,
lib/rspec/mocks/method_reference.rb,
lib/rspec/mocks/matchers/receive.rb,
lib/rspec/mocks/verifying_double.rb,
lib/rspec/mocks/object_reference.rb,
lib/rspec/mocks/argument_matchers.rb,
lib/rspec/mocks/marshal_extension.rb,
lib/rspec/mocks/any_instance/proxy.rb,
lib/rspec/mocks/any_instance/chain.rb,
lib/rspec/mocks/message_expectation.rb,
lib/rspec/mocks/any_instance/recorder.rb,
lib/rspec/mocks/argument_list_matcher.rb,
lib/rspec/mocks/matchers/have_received.rb,
lib/rspec/mocks/instance_method_stasher.rb,
lib/rspec/mocks/any_instance/stub_chain.rb,
lib/rspec/mocks/matchers/receive_messages.rb,
lib/rspec/mocks/any_instance/message_chains.rb,
lib/rspec/mocks/verifying_message_expecation.rb,
lib/rspec/mocks/any_instance/stub_chain_chain.rb,
lib/rspec/mocks/matchers/receive_message_chain.rb,
lib/rspec/mocks/any_instance/expectation_chain.rb,
lib/rspec/mocks/any_instance/expect_chain_chain.rb,
lib/rspec/mocks/matchers/expectation_customization.rb
+
+ +
+
+ +

Overview

+
+ +

Contains top-level utility methods. While this contains a few public +methods, these are not generally meant to be called from a test or example. +They exist primarily for integration with test frameworks (such as +rspec-core).

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: ArgumentMatchers, ExampleMethods, Matchers, Syntax, TestDouble, Version + + + + Classes: ArgumentListMatcher, Configuration, Constant, ConstantMutator, Double, VerifyingMessageExpectation + + +

+ +

Constant Summary

+ +
+ +
MockExpectationError = +
+
+ +

Raised when a message expectation is not satisfied.

+ + +
+
+
+ + +
+
+
Class.new(Exception)
+ +
ExpiredTestDoubleError = +
+
+ +

Raised when a test double is used after it has been torn down (typically at +the end of an rspec-core example).

+ + +
+
+
+ + +
+
+
Class.new(MockExpectationError)
+ +
OutsideOfExampleError = +
+
+ +

Raised when doubles or partial doubles are used outside of the per-test +lifecycle.

+ + +
+
+
+ + +
+
+
Class.new(StandardError)
+ +
+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) allow_message(subject, message, opts = {}) { ... } + + + + + +

+
+ +

Adds an allowance (stub) on subject

+ + +
+
+
+ +
+

Examples:

+ + +

+

Defines the implementation of foo on bar, using +the passed block

+

+ +
x = 0
+RSpec::Mocks.allow_message(bar, :foo) { x += 1 }
+ +
+

Parameters:

+
    + +
  • + + subject + + + + + + + — +
    +

    the subject to which the message will be added

    +
    + +
  • + +
  • + + message + + + + + + + — +
    +

    a symbol, representing the message that will be added.

    +
    + +
  • + +
  • + + opts + + + + + + (defaults to: {}) + + + — +
    +

    a hash of options, :expected_from is used to set the original call site

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    an optional implementation for the allowance

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+69
+70
+71
+
+
# File 'lib/rspec/mocks.rb', line 69
+
+def self.allow_message(subject, message, opts={}, &block)
+  space.proxy_for(subject).add_stub(message, opts, &block)
+end
+
+
+ +
+

+ + + (Object) configuration + + + + + +

+
+ +

Mocks specific configuration, as distinct from +RSpec.configuration which is core RSpec configuration.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+151
+152
+153
+
+
# File 'lib/rspec/mocks/configuration.rb', line 151
+
+def self.configuration
+  @configuration ||= Configuration.new
+end
+
+
+ +
+

+ + + (Object) expect_message(subject, message, opts = {}) { ... } + + + + + +

+
+ +

Sets a message expectation on subject.

+ + +
+
+
+ +
+

Examples:

+ + +

+

Expect the message foo to receive bar, then call +it

+

+ +
RSpec::Mocks.expect_message(bar, :foo)
+bar.foo
+ +
+

Parameters:

+
    + +
  • + + subject + + + + + + + — +
    +

    the subject on which the message will be expected

    +
    + +
  • + +
  • + + message + + + + + + + — +
    +

    a symbol, representing the message that will be expected.

    +
    + +
  • + +
  • + + opts + + + + + + (defaults to: {}) + + + — +
    +

    a hash of options, :expected_from is used to set the original call site

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    an optional implementation for the expectation

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+84
+85
+86
+
+
# File 'lib/rspec/mocks.rb', line 84
+
+def self.expect_message(subject, message, opts={}, &block)
+  space.proxy_for(subject).add_message_expectation(message, opts, &block)
+end
+
+
+ +
+

+ + + (Object) setup + + + + + +

+
+ +

Performs per-test/example setup. This should be called before an test or +example begins.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'lib/rspec/mocks.rb', line 38
+
+def self.setup
+  @space_stack << (@space = space.new_scope)
+end
+
+
+ +
+

+ + + (Object) teardown + + + + + +

+
+ +

Cleans up all test double state (including any methods that were redefined +on partial doubles). This must be called after each example, even +if an error was raised during the example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+51
+52
+53
+54
+55
+
+
# File 'lib/rspec/mocks.rb', line 51
+
+def self.teardown
+  space.reset_all
+  @space_stack.pop
+  @space = @space_stack.last || @root_space
+end
+
+
+ +
+

+ + + (Object) verify + + + + + +

+
+ +

Verifies any message expectations that were set during the test or example. +This should be called at the end of an example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+44
+45
+46
+
+
# File 'lib/rspec/mocks.rb', line 44
+
+def self.verify
+  space.verify_all
+end
+
+
+ +
+

+ + + (Object) with_temporary_scope + + + + + +

+
+ +

Call the passed block and verify mocks after it has executed. This allows +mock usage in arbitrary places, such as a before(:all) hook.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+
+
# File 'lib/rspec/mocks.rb', line 90
+
+def self.with_temporary_scope
+  setup
+
+  begin
+    yield
+    verify
+  ensure
+    teardown
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html new file mode 100644 index 000000000..bee9e9e9e --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html @@ -0,0 +1,397 @@ + + + + + + Class: RSpec::Mocks::ArgumentListMatcher + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::ArgumentListMatcher + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/argument_list_matcher.rb
+ +
+
+ +

Overview

+
+ +

Wrapper for matching arguments against a list of expected values. Used by +the with method on a MessageExpectation:

+ +
expect(object).to receive(:message).with(:a, 'b', 3)
+object.message(:a, 'b', 3)
+ +

Values passed to with can be literal values or argument +matchers that match against the real objects .e.g.

+ +
expect(object).to receive(:message).with(hash_including(:a => 'b'))
+
+ +

Can also be used directly to match the contents of any Array. +This enables 3rd party mocking libs to take advantage of rspec's +argument matching without using the rest of rspec-mocks.

+ +
require 'rspec/mocks/argument_list_matcher'
+include RSpec::Mocks::ArgumentMatchers
+
+arg_list_matcher = RSpec::Mocks::ArgumentListMatcher.new(123, hash_including(:a => 'b'))
+arg_list_matcher.args_match?(123, :a => 'b')
+
+ +

This class is immutable.

+ + +
+
+
+ + +

See Also:

+ + +
+

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ArgumentListMatcher) initialize(*expected_args) + + + + + +

+
+ +

Initializes an ArgumentListMatcher with a collection of +literal values and/or argument matchers.

+ + +
+
+
+

Parameters:

+
    + +
  • + + expected_args + + + (Array) + + + + — +
    +

    a list of expected literals and/or argument matchers

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/rspec/mocks/argument_list_matcher.rb', line 45
+
+def initialize(*expected_args)
+  @expected_args = expected_args
+
+  @matchers = case expected_args.first
+              when ArgumentMatchers::AnyArgsMatcher then Array
+              when ArgumentMatchers::NoArgsMatcher  then []
+              else expected_args
+              end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) args_match?(*args) + + + + + +

+
+ +

Matches each element in the expected_args against the element +in the same position of the arguments passed to new.

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array) + + + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lib/rspec/mocks/argument_list_matcher.rb', line 62
+
+def args_match?(*args)
+  Support::FuzzyMatcher.values_match?(@matchers, args)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html new file mode 100644 index 000000000..f0ff79a19 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html @@ -0,0 +1,918 @@ + + + + + + Module: RSpec::Mocks::ArgumentMatchers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::ArgumentMatchers + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleMethods
+ + + +
Defined in:
+
lib/rspec/mocks/argument_matchers.rb
+ +
+
+ +

Overview

+
+ +

ArgumentMatchers are placeholders that you can include in message +expectations to match arguments against a broader check than simple +equality.

+ +

With the exception of any_args and no_args, they +all match against the arg in same position in the argument list.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) any_args + + + + + +

+
+ +

Matches any args at all. Supports a more explicit variation of +expect(object).to receive(:message)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(any_args)
+ +
+ + +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 23
+
+def any_args
+  AnyArgsMatcher.new
+end
+
+
+ +
+

+ + - (Object) anything + + + + + +

+
+ +

Matches any argument at all.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(anything)
+ +
+ + +
+ + + + +
+
+
+
+32
+33
+34
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 32
+
+def anything
+  AnyArgMatcher.new
+end
+
+
+ +
+

+ + - (Object) array_including(*args) + + + + + +

+
+ +

Matches an array that includes the specified items at least once. Ignores +duplicates and additional values

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(array_including(1,2,3))
+expect(object).to receive(:message).with(array_including([1,2,3]))
+ +
+ + +
+ + + + +
+
+
+
+83
+84
+85
+86
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 83
+
+def array_including(*args)
+  actually_an_array = Array === args.first && args.count == 1 ? args.first : args
+  ArrayIncludingMatcher.new(actually_an_array)
+end
+
+
+ +
+

+ + - (Object) boolean + + + + + +

+
+ +

Matches a boolean value.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(boolean())
+ +
+ + +
+ + + + +
+
+
+
+60
+61
+62
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 60
+
+def boolean
+  BooleanMatcher.new
+end
+
+
+ +
+

+ + - (Object) duck_type(*args) + + + + + +

+
+ +

Matches if the actual argument responds to the specified messages.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(duck_type(:hello))
+expect(object).to receive(:message).with(duck_type(:hello, :goodbye))
+ +
+ + +
+ + + + +
+
+
+
+51
+52
+53
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 51
+
+def duck_type(*args)
+  DuckTypeMatcher.new(*args)
+end
+
+
+ +
+

+ + - (Object) hash_excluding(*args) + + + + Also known as: + hash_not_including + + + + +

+
+ +

Matches a hash that doesn't include the specified key(s) or key/value.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(hash_excluding(:key => val))
+expect(object).to receive(:message).with(hash_excluding(:key))
+expect(object).to receive(:message).with(hash_excluding(:key, :key2 => :val2))
+ +
+ + +
+ + + + +
+
+
+
+95
+96
+97
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 95
+
+def hash_excluding(*args)
+  HashExcludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
+end
+
+
+ +
+

+ + - (Object) hash_including(*args) + + + + + +

+
+ +

Matches a hash that includes the specified key(s) or key/value pairs. +Ignores any additional keys.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(hash_including(:key => val))
+expect(object).to receive(:message).with(hash_including(:key))
+expect(object).to receive(:message).with(hash_including(:key, :key2 => val2))
+ +
+ + +
+ + + + +
+
+
+
+72
+73
+74
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 72
+
+def hash_including(*args)
+  HashIncludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
+end
+
+
+ +
+

+ + - (Object) instance_of(klass) + + + + Also known as: + an_instance_of + + + + +

+
+ +

Matches if arg.instance_of?(klass)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(instance_of(Thing))
+ +
+ + +
+ + + + +
+
+
+
+106
+107
+108
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 106
+
+def instance_of(klass)
+  InstanceOf.new(klass)
+end
+
+
+ +
+

+ + - (Object) kind_of(klass) + + + + Also known as: + a_kind_of + + + + +

+
+ +

Matches if arg.kind_of?(klass)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(kind_of(Thing))
+ +
+ + +
+ + + + +
+
+
+
+116
+117
+118
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 116
+
+def kind_of(klass)
+  KindOf.new(klass)
+end
+
+
+ +
+

+ + - (Object) no_args + + + + + +

+
+ +

Matches no arguments.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(no_args)
+ +
+ + +
+ + + + +
+
+
+
+41
+42
+43
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 41
+
+def no_args
+  NoArgsMatcher.new
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Configuration.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Configuration.html new file mode 100644 index 000000000..988b99442 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Configuration.html @@ -0,0 +1,1265 @@ + + + + + + Class: RSpec::Mocks::Configuration + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::Configuration + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/configuration.rb
+ +
+
+ +

Overview

+
+ +

Provides configuration options for rspec-mocks.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Configuration) initialize + + + + + +

+
+ +

Returns a new instance of Configuration

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+
+
# File 'lib/rspec/mocks/configuration.rb', line 5
+
+def initialize
+  @yield_receiver_to_any_instance_implementation_blocks = true
+  @verify_doubled_constant_names = false
+  @transfer_nested_constants = false
+  @verify_partial_doubles = false
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) transfer_nested_constants=(value) (writeonly) + + + + + +

+
+ +

Sets the default for the transfer_nested_constants option when +stubbing constants.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+113
+114
+115
+
+
# File 'lib/rspec/mocks/configuration.rb', line 113
+
+def transfer_nested_constants=(value)
+  @transfer_nested_constants = value
+end
+
+
+ + + +
+

+ + - (Object) verify_doubled_constant_names=(value) (writeonly) + + + + + +

+
+ +

When this is set to true, an error will be raised when +instance_double or class_double is given the name +of an undefined constant. You probably only want to set this when running +your entire test suite, with all production code loaded. Setting this for +an isolated unit test will prevent you from being able to isolate it!

+ + +
+
+
+ + +
+ + + + +
+
+
+
+105
+106
+107
+
+
# File 'lib/rspec/mocks/configuration.rb', line 105
+
+def verify_doubled_constant_names=(value)
+  @verify_doubled_constant_names = value
+end
+
+
+ + + +
+

+ + - (Object) yield_receiver_to_any_instance_implementation_blocks=(value) (writeonly) + + + + + +

+
+ +

Sets whether or not RSpec will yield the receiving instance of a message to +blocks that are used for any_instance stub implementations. When set, the +first yielded argument will be the receiving instance. Defaults to +true.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.mock_with :rspec do |mocks|
+    mocks.yield_receiver_to_any_instance_implementation_blocks = false
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/rspec/mocks/configuration.rb', line 28
+
+def yield_receiver_to_any_instance_implementation_blocks=(value)
+  @yield_receiver_to_any_instance_implementation_blocks = value
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) add_stub_and_should_receive_to(*modules) + + + + + +

+
+ +

Adds stub and should_receive to the given modules +or classes. This is usually only necessary if you application uses some +proxy classes that “strip themselves down” to a bare minimum set of methods +and remove stub and should_receive in the +process.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.mock_with :rspec do |mocks|
+    mocks.add_stub_and_should_receive_to Delegator
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+45
+46
+47
+48
+49
+
+
# File 'lib/rspec/mocks/configuration.rb', line 45
+
+def add_stub_and_should_receive_to(*modules)
+  modules.each do |mod|
+    Syntax.enable_should(mod)
+  end
+end
+
+
+ +
+

+ + - (Object) patch_marshal_to_support_partial_doubles=(val) + + + + + +

+
+ +

Monkey-patch Marshal.dump to enable dumping of mocked or +stubbed objects. By default this will not work since RSpec mocks works by +adding singleton methods that cannot be serialized. This patch removes +these singleton methods before serialization. Setting to falsey removes the +patch.

+ +

This method is idempotent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+133
+134
+135
+136
+137
+138
+139
+
+
# File 'lib/rspec/mocks/configuration.rb', line 133
+
+def patch_marshal_to_support_partial_doubles=(val)
+  if val
+    RSpec::Mocks::MarshalExtension.patch!
+  else
+    RSpec::Mocks::MarshalExtension.unpatch!
+  end
+end
+
+
+ +
+

+ + - (Object) reset_syntaxes_to_default + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Resets the configured syntax to the default.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+143
+144
+145
+146
+
+
# File 'lib/rspec/mocks/configuration.rb', line 143
+
+def reset_syntaxes_to_default
+  self.syntax = [:should, :expect]
+  RSpec::Mocks::Syntax.warn_about_should!
+end
+
+
+ +
+

+ + - (Object) syntax + + + + + +

+
+ +

Returns an array with a list of syntaxes that are enabled.

+ + +
+
+
+ +
+

Examples:

+ + +

+unless RSpec::Mocks.configuration.syntax.include?(:expect)
+  raise "this RSpec extension gem requires the rspec-mocks `:expect` syntax"
+end
+ +
+ + +
+ + + + +
+
+
+
+89
+90
+91
+92
+93
+94
+
+
# File 'lib/rspec/mocks/configuration.rb', line 89
+
+def syntax
+  syntaxes = []
+  syntaxes << :should  if Syntax.should_enabled?
+  syntaxes << :expect if Syntax.expect_enabled?
+  syntaxes
+end
+
+
+ +
+

+ + - (Object) syntax=(*values) + + + + + +

+
+ +

Provides the ability to set either expect, should +or both syntaxes. RSpec uses expect syntax by default. This is +needed if you want to explicitly enable should syntax and/or +explicitly disable expect syntax.

+ +

end

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.mock_with :rspec do |mocks|
+    mocks.syntax = [:expect, :should]
+  end
+ +
+ + +
+ + + + +
+
+
+
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+
+
# File 'lib/rspec/mocks/configuration.rb', line 65
+
+def syntax=(*values)
+  syntaxes = values.flatten
+  if syntaxes.include?(:expect)
+    Syntax.enable_expect
+  else
+    Syntax.disable_expect
+  end
+
+  if syntaxes.include?(:should)
+    Syntax.enable_should
+  else
+    Syntax.disable_should
+  end
+end
+
+
+ +
+

+ + - (Boolean) transfer_nested_constants? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+107
+108
+109
+
+
# File 'lib/rspec/mocks/configuration.rb', line 107
+
+def transfer_nested_constants?
+  !!@transfer_nested_constants
+end
+
+
+ +
+

+ + - (Boolean) verify_doubled_constant_names? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+96
+97
+98
+
+
# File 'lib/rspec/mocks/configuration.rb', line 96
+
+def verify_doubled_constant_names?
+  !!@verify_doubled_constant_names
+end
+
+
+ +
+

+ + - (Object) verify_partial_doubles=(val) + + + + + +

+
+ +

When set to true, partial mocks will be verified the same as object +doubles. Any stubs will have their arguments checked against the original +method, and methods that do not exist cannot be stubbed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+118
+119
+120
+
+
# File 'lib/rspec/mocks/configuration.rb', line 118
+
+def verify_partial_doubles=(val)
+  @verify_partial_doubles = !!val
+end
+
+
+ +
+

+ + - (Boolean) verify_partial_doubles? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+122
+123
+124
+
+
# File 'lib/rspec/mocks/configuration.rb', line 122
+
+def verify_partial_doubles?
+  @verify_partial_doubles
+end
+
+
+ +
+

+ + - (Boolean) yield_receiver_to_any_instance_implementation_blocks? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'lib/rspec/mocks/configuration.rb', line 12
+
+def yield_receiver_to_any_instance_implementation_blocks?
+  @yield_receiver_to_any_instance_implementation_blocks
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Constant.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Constant.html new file mode 100644 index 000000000..c378ae24b --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Constant.html @@ -0,0 +1,952 @@ + + + + + + Class: RSpec::Mocks::Constant + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::Constant + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + +
Extended by:
+
Support::RecursiveConstMethods
+ + + + + + + +
Defined in:
+
lib/rspec/mocks/mutate_const.rb
+ +
+
+ +

Overview

+
+ +

Provides information about constants that may (or may not) have been +mutated by rspec-mocks.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + + +
+

Constructor Details

+ +
+

+ + - (Constant) initialize(name) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of Constant

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 11
+
+def initialize(name)
+  @name = name
+  @previously_defined = false
+  @stubbed = false
+  @hidden = false
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (String) name (readonly) + + + + + +

+
+ +

Returns The fully qualified name of the constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The fully qualified name of the constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+19
+20
+21
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 19
+
+def name
+  @name
+end
+
+
+ + + +
+

+ + - (Object?) original_value + + + + + +

+
+ +

Returns The original value (e.g. before it was mutated by rspec-mocks) of +the constant, or nil if the constant was not previously defined.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Object, nil) + + + + — +
    +

    The original value (e.g. before it was mutated by rspec-mocks) of the +constant, or nil if the constant was not previously defined.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 24
+
+def original_value
+  @original_value
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (Constant) original(name) + + + + + +

+
+ +

Queries rspec-mocks to find out information about the named constant.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    the name of the constant

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Constant) + + + + — +
    +

    an object contaning information about the named constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+75
+76
+77
+78
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 75
+
+def self.original(name)
+  mutator = ::RSpec::Mocks.space.constant_mutator_for(name)
+  mutator ? mutator.to_constant : unmutated(name)
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Boolean) hidden? + + + + + +

+
+ +

Returns Whether or not rspec-mocks has hidden this constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not rspec-mocks has hidden this constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+49
+50
+51
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 49
+
+def hidden?
+  @hidden
+end
+
+
+ +
+

+ + - (Boolean) mutated? + + + + + +

+
+ +

Returns Whether or not rspec-mocks has mutated (stubbed or hidden) this +constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not rspec-mocks has mutated (stubbed or hidden) this constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+37
+38
+39
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 37
+
+def mutated?
+  @stubbed || @hidden
+end
+
+
+ +
+

+ + - (Boolean) previously_defined? + + + + + +

+
+ +

Returns Whether or not the constant was defined before the current example.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not the constant was defined before the current example.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+31
+32
+33
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 31
+
+def previously_defined?
+  @previously_defined
+end
+
+
+ +
+

+ + - (Boolean) stubbed? + + + + + +

+
+ +

Returns Whether or not rspec-mocks has stubbed this constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not rspec-mocks has stubbed this constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+43
+44
+45
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 43
+
+def stubbed?
+  @stubbed
+end
+
+
+ +
+

+ + - (Object) to_s + + + + Also known as: + inspect + + + + +

+
+ +

The default to_s isn't very useful, so a custom version is +provided.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+54
+55
+56
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 54
+
+def to_s
+  "#<#{self.class.name} #{name}>"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ConstantMutator.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ConstantMutator.html new file mode 100644 index 000000000..a0ce563b6 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ConstantMutator.html @@ -0,0 +1,537 @@ + + + + + + Class: RSpec::Mocks::ConstantMutator + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::ConstantMutator + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + +
Extended by:
+
Support::RecursiveConstMethods
+ + + + + + + +
Defined in:
+
lib/rspec/mocks/mutate_const.rb
+ +
+
+ +

Overview

+
+ +

Provides a means to stub constants.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) hide(constant_name) + + + + + +

+
+ +
+ Note: +
+

It's recommended that you use hide_const in your examples. +This is an alternate public API that is provided so you can hide constants +in other contexts (e.g. helper classes).

+
+
+ + +

Hides a constant.

+ + +
+
+
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+116
+117
+118
+119
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 116
+
+def self.hide(constant_name)
+  mutate(ConstantHider.new(constant_name, nil, {}))
+  nil
+end
+
+
+ +
+

+ + + (Object) raise_on_invalid_const + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Used internally by the constant stubbing to raise a helpful error when a +constant like “A::B::C” is stubbed and A::B is not a module (and thus, +it's impossible to define “A::B::C” since only modules can have nested +constants).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+316
+317
+318
+319
+320
+321
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 316
+
+def self.raise_on_invalid_const
+  lambda do |const_name, failed_name|
+    raise "Cannot stub constant #{failed_name} on #{const_name} " \
+          "since #{const_name} is not a module."
+  end
+end
+
+
+ +
+

+ + + (Object) stub(constant_name, value, options = {}) + + + + + +

+
+ +
+ Note: +
+

It's recommended that you use stub_const in your examples. +This is an alternate public API that is provided so you can stub constants +in other contexts (e.g. helper classes).

+
+
+ + +

Stubs a constant.

+ + +
+
+
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
  • + + value + + + (Object) + + + + — +
    +

    The value to make the constant refer to. When the example completes, the +constant will be restored to its prior state.

    +
    + +
  • + +
  • + + options + + + (Hash) + + + (defaults to: {}) + + + — +
    +

    Stubbing options.

    +
    + +
  • + +
+ + + + + + + + +

Options Hash (options):

+
    + +
  • + :transfer_nested_constants + (Boolean, Array<Symbol>) + + + + + —
    +

    Determines what nested constants, if any, will be transferred from the +original value of the constant to the new value of the constant. This only +works if both the original and new values are modules (or classes).

    +
    + +
  • + +
+ + +

Returns:

+
    + +
  • + + + (Object) + + + + — +
    +

    the stubbed value of the constant

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 96
+
+def self.stub(constant_name, value, options={})
+  mutator = if recursive_const_defined?(constant_name, &raise_on_invalid_const)
+              DefinedConstantReplacer
+            else
+              UndefinedConstantSetter
+            end
+
+  mutate(mutator.new(constant_name, value, options[:transfer_nested_constants]))
+  value
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Double.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Double.html new file mode 100644 index 000000000..24e479f09 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Double.html @@ -0,0 +1,157 @@ + + + + + + Class: RSpec::Mocks::Double + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::Double + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
TestDouble
+ + + + + +
Defined in:
+
lib/rspec/mocks/test_double.rb
+ +
+
+ +

Overview

+
+ +

A generic test double object. double, +instance_double and friends return an instance of this.

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods included from TestDouble

+

#==, #as_null_object, #freeze, #initialize, #null_object?

+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class RSpec::Mocks::TestDouble + +

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods.html new file mode 100644 index 000000000..9cb8d1547 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods.html @@ -0,0 +1,2711 @@ + + + + + + Module: RSpec::Mocks::ExampleMethods + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::ExampleMethods + + + +

+ +
+ + + + + +
Includes:
+
ArgumentMatchers
+ + + + + +
Defined in:
+
lib/rspec/mocks/example_methods.rb
+ +
+
+ +

Overview

+
+ +

Contains methods intended to be used from within code examples. Mix this in +to your test context (such as a test framework base class) to use +rspec-mocks with your test framework. If you're using rspec-core, +it'll take care of doing this for you.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: ExpectHost + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from ArgumentMatchers

+

#any_args, #anything, #array_including, #boolean, #duck_type, #hash_excluding, #hash_including, #instance_of, #kind_of, #no_args

+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) allow + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Used to wrap an object in preparation for stubbing a method on it.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow(dbl).to receive(:foo).with(5).and_return(:return_value)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 256
+
+
+
+
+ +
+

+ + - (Object) allow_any_instance_of + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the expect +syntax.

+
+
+ + +

Used to wrap a class in preparation for stubbing a method on instances of +it.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow_any_instance_of(MyClass).to receive(:foo)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 276
+
+
+
+
+ +
+

+ + - (Object) allow_message_expectations_on_nil + + + + + +

+
+ +

Disables warning messages about expectations being set on nil.

+ +

By default warning messages are issued when expectations are set on nil. +This is to prevent false-positives and to catch potential bugs early on.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+159
+160
+161
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 159
+
+def allow_message_expectations_on_nil
+  RSpec::Mocks.space.proxy_for(nil).warn_about_expectations = false
+end
+
+
+ +
+

+ + + - (Object) class_double(doubled_class) + + - (Object) class_double(doubled_class, stubs) + + + + + + +

+
+ +

Constructs a test double against a specific class. If the given class name +has been loaded, only class methods defined on the class are allowed to be +stubbed. In all other ways it behaves like a double.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) class_double(doubled_class) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Module) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) class_double(doubled_class, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Module) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    ClassVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+69
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 66
+
+def class_double(doubled_class, *args)
+  ref = ObjectReference.for(doubled_class)
+  ExampleMethods.declare_verifying_double(ClassVerifyingDouble, ref, *args)
+end
+
+
+ +
+

+ + + - (Object) class_spy(doubled_class) + + - (Object) class_spy(doubled_class, stubs) + + + + + + +

+
+ +

Constructs a test double that is optimized for use with +have_received against a specific class. If the given class +name has been loaded, only class methods defined on the class are allowed +to be stubbed. With a normal double one has to stub methods in order to be +able to spy them. An class_spy automatically spies on all class methods to +which the class responds.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) class_spy(doubled_class) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Module) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) class_spy(doubled_class, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Module) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    ClassVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+150
+151
+152
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 150
+
+def class_spy(*args)
+  class_double(*args).as_null_object
+end
+
+
+ +
+

+ + + - (Double) double + + - (Double) double(name) + + - (Double) double(stubs) + + - (Double) double(name, stubs) + + + + + + +

+
+ +

Constructs an instance of :Mocks::Double +configured with an optional name, used for reporting in failure messages, +and an optional hash of message/return-value pairs.

+ + +
+
+
+ +
+

Examples:

+ + +

+book = double("book", :title => "The RSpec Book")
+book.title #=> "The RSpec Book"
+
+card = double("card", :suit => "Spades", :rank => "A")
+card.suit  #=> "Spades"
+card.rank  #=> "A"
+ +
+ +

Overloads:

+
    + + + +
  • + - (Double) double(name) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String/Symbol) + + + + — +
      +

      used to clarify intent

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (Double) double(stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (Double) double(name, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String/Symbol) + + + + — +
      +

      used to clarify intent

      +
      + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + (Double) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 35
+
+def double(*args)
+  ExampleMethods.declare_double(Double, *args)
+end
+
+
+ +
+

+ + - (Object) expect + + + + + +

+
+ +
+ Note: +
+

This method is usually provided by rspec-expectations. However, if you use +rspec-mocks without rspec-expectations, there's a definition of it that +is made available here. If you disable the :expect syntax this +method will be undefined.

+
+
+ + +

Used to wrap an object in preparation for setting a mock expectation on it.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(obj).to receive(:foo).with(5).and_return(:return_value)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 243
+
+
+
+
+ +
+

+ + - (Object) expect_any_instance_of + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Used to wrap a class in preparation for setting a mock expectation on +instances of it.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect_any_instance_of(MyClass).to receive(:foo)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 266
+
+
+
+
+ +
+

+ + - (Object) have_received(method_name, &block) + + + + + +

+
+ +

Verifies that the given object received the expected message during the +course of the test. On a spy objects or as null object doubles this works +for any method, on other objects the method must have been stubbed +beforehand in order for messages to be verified.

+ +

Stubbing and verifying messages received in this way implements the Test +Spy pattern.

+ + +
+
+
+ +
+

Examples:

+ + +

+invitation = double('invitation', accept: true)
+user.accept_invitation(invitation)
+expect(invitation).to have_received(:accept)
+
+# You can also use most message expectations:
+expect(invitation).to have_received(:accept).with(mailer).once
+ +
+

Parameters:

+
    + +
  • + + method_name + + + (Symbol) + + + + — +
    +

    name of the method expected to have been called.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+239
+240
+241
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 239
+
+def have_received(method_name, &block)
+  Matchers::HaveReceived.new(method_name, &block)
+end
+
+
+ +
+

+ + - (Object) hide_const(constant_name) + + + + + +

+
+ +

Hides the named constant with the given value. The constant will be +undefined for the duration of the test.

+ +

Like method stubs, the constant will be restored to its original value when +the example completes.

+ + +
+
+
+ +
+

Examples:

+ + +

+hide_const("MyClass") # => MyClass is now an undefined constant
+ +
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+216
+217
+218
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 216
+
+def hide_const(constant_name)
+  ConstantMutator.hide(constant_name)
+end
+
+
+ +
+

+ + + - (Object) instance_double(doubled_class) + + - (Object) instance_double(doubled_class, stubs) + + + + + + +

+
+ +

Constructs a test double against a specific class. If the given class name +has been loaded, only instance methods defined on the class are allowed to +be stubbed. In all other ways it behaves like a double.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) instance_double(doubled_class) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Class) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) instance_double(doubled_class, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Class) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    InstanceVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+50
+51
+52
+53
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 50
+
+def instance_double(doubled_class, *args)
+  ref = ObjectReference.for(doubled_class)
+  ExampleMethods.declare_verifying_double(InstanceVerifyingDouble, ref, *args)
+end
+
+
+ +
+

+ + + - (Object) instance_spy(doubled_class) + + - (Object) instance_spy(doubled_class, stubs) + + + + + + +

+
+ +

Constructs a test double that is optimized for use with +have_received against a specific class. If the given class +name has been loaded, only instance methods defined on the class are +allowed to be stubbed. With a normal double one has to stub methods in +order to be able to spy them. An instance_spy automatically spies on all +instance methods to which the class responds.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) instance_spy(doubled_class) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Class) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) instance_spy(doubled_class, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Class) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    InstanceVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+117
+118
+119
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 117
+
+def instance_spy(*args)
+  instance_double(*args).as_null_object
+end
+
+
+ +
+

+ + + - (Object) object_double(object_or_name) + + - (Object) object_double(object_or_name, stubs) + + + + + + +

+
+ +

Constructs a test double against a specific object. Only the methods the +object responds to are allowed to be stubbed. If a String argument is +provided, it is assumed to reference a constant object which is used for +verification. In all other ways it behaves like a double.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) object_double(object_or_name) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + object_or_name + + + (String, Object) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) object_double(object_or_name, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + object_or_name + + + (String, Object) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    ObjectVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+82
+83
+84
+85
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 82
+
+def object_double(object_or_name, *args)
+  ref = ObjectReference.for(object_or_name, :allow_direct_object_refs)
+  ExampleMethods.declare_verifying_double(ObjectVerifyingDouble, ref, *args)
+end
+
+
+ +
+

+ + + - (Object) object_spy(object_or_name) + + - (Object) object_spy(object_or_name, stubs) + + + + + + +

+
+ +

Constructs a test double that is optimized for use with +have_received against a specific object. Only instance methods +defined on the object are allowed to be stubbed. With a normal double one +has to stub methods in order to be able to spy them. An object_spy +automatically spies on all methods to which the object responds.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) object_spy(object_or_name) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + object_or_name + + + (String, Object) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) object_spy(object_or_name, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + object_or_name + + + (String, Object) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    ObjectVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+133
+134
+135
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 133
+
+def object_spy(*args)
+  object_double(*args).as_null_object
+end
+
+
+ +
+

+ + - (Object) receive + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Used to specify a message that you expect or allow an object to receive. +The object returned by receive supports the same fluent +interface that should_receive and stub have +always supported, allowing you to constrain the arguments or number of +times, and configure how the object should respond to the message.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(obj).to receive(:hello).with("world").exactly(3).times
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 286
+
+
+
+
+ +
+

+ + + - (Object) receive_message_chain(method1, method2) + + - (Object) receive_message_chain("method1.method2") + + - (Object) receive_message_chain(method1, method_to_value_hash) + + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

stubs/mocks a chain of messages on an object or test double.

+ +

Warning:

+ +

Chains can be arbitrarily long, which makes it quite painless to violate +the Law of Demeter in violent ways, so you should consider any use of +receive_message_chain a code smell. Even though not all code +smells indicate real problems (think fluent interfaces), +receive_message_chain still results in brittle examples. For +example, if you write allow(foo).to receive_message_chain(:bar, :baz +=> 37) in a spec and then the implementation calls +foo.baz.bar, the stub will not work.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow(double).to receive_message_chain("foo.bar") { :baz }
+allow(double).to receive_message_chain(:foo, :bar => :baz)
+allow(double).to receive_message_chain(:foo, :bar) { :baz }
+
+# Given any of ^^ these three forms ^^:
+double.foo.bar # => :baz
+
+# Common use in Rails/ActiveRecord:
+allow(Article).to receive_message_chain("recent.published") { [Article.new] }
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 313
+
+
+
+
+ +
+

+ + - (Object) receive_messages + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Shorthand syntax used to setup message(s), and their return value(s), that +you expect or allow an object to receive. The method takes a hash of +messages and their respective return values. Unlike with +receive, you cannot apply further customizations using a block +or the fluent interface.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow(obj).to receive_messages(:speak => "Hello World")
+allow(obj).to receive_messages(:speak => "Hello", :meow => "Meow")
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 299
+
+
+
+
+ +
+

+ + + - (Double) spy + + - (Double) spy(name) + + - (Double) spy(stubs) + + - (Double) spy(name, stubs) + + + + + + +

+
+ +

Constructs a test double that is optimized for use with +have_received. With a normal double one has to stub methods in +order to be able to spy them. A spy automatically spies on all methods.

+ + +
+
+
+ +

Overloads:

+
    + + + +
  • + - (Double) spy(name) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String/Symbol) + + + + — +
      +

      used to clarify intent

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (Double) spy(stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (Double) spy(name, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String/Symbol) + + + + — +
      +

      used to clarify intent

      +
      + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + (Double) + + + +
  • + +
+ +
+ + + + +
+
+
+
+100
+101
+102
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 100
+
+def spy(*args)
+  double(*args).as_null_object
+end
+
+
+ +
+

+ + - (Object) stub_const(constant_name, value, options = {}) + + + + + +

+
+ +

Stubs the named constant with the given value. Like method stubs, the +constant will be restored to its original value (or lack of one, if it was +undefined) when the example completes.

+ + +
+
+
+ +
+

Examples:

+ + +

+stub_const("MyClass", Class.new) # => Replaces (or defines) MyClass with a new class object.
+stub_const("SomeModel::PER_PAGE", 5) # => Sets SomeModel::PER_PAGE to 5.
+
+class CardDeck
+  SUITS = [:Spades, :Diamonds, :Clubs, :Hearts]
+  NUM_CARDS = 52
+end
+
+stub_const("CardDeck", Class.new)
+CardDeck::SUITS # => uninitialized constant error
+CardDeck::NUM_CARDS # => uninitialized constant error
+
+stub_const("CardDeck", Class.new, :transfer_nested_constants => true)
+CardDeck::SUITS # => our suits array
+CardDeck::NUM_CARDS # => 52
+
+stub_const("CardDeck", Class.new, :transfer_nested_constants => [:SUITS])
+CardDeck::SUITS # => our suits array
+CardDeck::NUM_CARDS # => uninitialized constant error
+ +
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
  • + + value + + + (Object) + + + + — +
    +

    The value to make the constant refer to. When the example completes, the +constant will be restored to its prior state.

    +
    + +
  • + +
  • + + options + + + (Hash) + + + (defaults to: {}) + + + — +
    +

    Stubbing options.

    +
    + +
  • + +
+ + + + + + + + +

Options Hash (options):

+
    + +
  • + :transfer_nested_constants + (Boolean, Array<Symbol>) + + + + + —
    +

    Determines what nested constants, if any, will be transferred from the +original value of the constant to the new value of the constant. This only +works if both the original and new values are modules (or classes).

    +
    + +
  • + +
+ + +

Returns:

+
    + +
  • + + + (Object) + + + + — +
    +

    the stubbed value of the constant

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+200
+201
+202
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 200
+
+def stub_const(constant_name, value, options={})
+  ConstantMutator.stub(constant_name, value, options)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html new file mode 100644 index 000000000..fa1da83b7 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html @@ -0,0 +1,117 @@ + + + + + + Module: RSpec::Mocks::ExampleMethods::ExpectHost + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::ExampleMethods::ExpectHost + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/example_methods.rb
+ +
+
+ +

Overview

+
+ +

This module exists to host the expect method for cases where +rspec-mocks is used w/o rspec-expectations.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Matchers.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Matchers.html new file mode 100644 index 000000000..ae7772377 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Matchers.html @@ -0,0 +1,118 @@ + + + + + + Module: RSpec::Mocks::Matchers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::Matchers + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks.rb,
+ lib/rspec/mocks/matchers/receive.rb,
lib/rspec/mocks/matchers/have_received.rb,
lib/rspec/mocks/matchers/receive_messages.rb,
lib/rspec/mocks/matchers/receive_message_chain.rb,
lib/rspec/mocks/matchers/expectation_customization.rb
+
+ +
+
+ +

Overview

+
+ +

Namespace for mock-related matchers.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Syntax.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Syntax.html new file mode 100644 index 000000000..0b2fea65d --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Syntax.html @@ -0,0 +1,929 @@ + + + + + + Module: RSpec::Mocks::Syntax + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::Syntax + + + Private +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/syntax.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+ +

Provides methods for enabling and disabling the available syntaxes provided +by rspec-mocks.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) default_should_syntax_host + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Determines where the methods like should_receive, and +stub are added.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+
+
# File 'lib/rspec/mocks/syntax.rb', line 181
+
+def self.default_should_syntax_host
+  # JRuby 1.7.4 introduces a regression whereby `defined?(::BasicObject) => nil`
+  # yet `BasicObject` still exists and patching onto ::Object breaks things
+  # e.g. SimpleDelegator expectations won't work
+  #
+  # See: https://github.com/jruby/jruby/issues/814
+  if defined?(JRUBY_VERSION) && JRUBY_VERSION == '1.7.4' && RUBY_VERSION.to_f > 1.8
+    return ::BasicObject
+  end
+
+  # On 1.8.7, Object.ancestors.last == Kernel but
+  # things blow up if we include `RSpec::Mocks::Methods`
+  # into Kernel...not sure why.
+  return Object unless defined?(::BasicObject)
+
+  # MacRuby has BasicObject but it's not the root class.
+  return Object unless Object.ancestors.last == ::BasicObject
+
+  ::BasicObject
+end
+
+
+ +
+

+ + + (Object) disable_expect(syntax_host = ::RSpec::Mocks::ExampleMethods) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Disables the expect syntax (expect(dbl).to receive, +allow(dbl).to receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+
+
# File 'lib/rspec/mocks/syntax.rb', line 150
+
+def self.disable_expect(syntax_host=::RSpec::Mocks::ExampleMethods)
+  return unless expect_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    undef receive
+    undef receive_messages
+    undef receive_message_chain
+    undef allow
+    undef expect_any_instance_of
+    undef allow_any_instance_of
+  end
+
+  RSpec::Mocks::ExampleMethods::ExpectHost.class_exec do
+    undef expect
+  end
+end
+
+
+ +
+

+ + + (Object) disable_should(syntax_host = default_should_syntax_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Disables the should syntax (dbl.stub, +dbl.should_receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+
+
# File 'lib/rspec/mocks/syntax.rb', line 89
+
+def self.disable_should(syntax_host=default_should_syntax_host)
+  return unless should_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    undef should_receive
+    undef should_not_receive
+    undef stub
+    undef unstub
+    undef stub_chain
+    undef as_null_object
+    undef null_object?
+    undef received_message?
+  end
+
+  Class.class_exec do
+    undef any_instance
+  end
+end
+
+
+ +
+

+ + + (Object) enable_expect(syntax_host = ::RSpec::Mocks::ExampleMethods) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Enables the expect syntax (expect(dbl).to receive, +allow(dbl).to receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+
+
# File 'lib/rspec/mocks/syntax.rb', line 110
+
+def self.enable_expect(syntax_host=::RSpec::Mocks::ExampleMethods)
+  return if expect_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    def receive(method_name, &block)
+      Matchers::Receive.new(method_name, block)
+    end
+
+    def receive_messages(message_return_value_hash)
+      matcher = Matchers::ReceiveMessages.new(message_return_value_hash)
+      matcher.warn_about_block if block_given?
+      matcher
+    end
+
+    def receive_message_chain(*messages, &block)
+      Matchers::ReceiveMessageChain.new(messages, &block)
+    end
+
+    def allow(target)
+      AllowanceTarget.new(target)
+    end
+
+    def expect_any_instance_of(klass)
+      AnyInstanceExpectationTarget.new(klass)
+    end
+
+    def allow_any_instance_of(klass)
+      AnyInstanceAllowanceTarget.new(klass)
+    end
+  end
+
+  RSpec::Mocks::ExampleMethods::ExpectHost.class_exec do
+    def expect(target)
+      ExpectationTarget.new(target)
+    end
+  end
+end
+
+
+ +
+

+ + + (Object) enable_should(syntax_host = default_should_syntax_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Enables the should syntax (dbl.stub, +dbl.should_receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+
+
# File 'lib/rspec/mocks/syntax.rb', line 26
+
+def self.enable_should(syntax_host=default_should_syntax_host)
+  @warn_about_should = false if syntax_host == default_should_syntax_host
+  return if should_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    def should_receive(message, opts={}, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks.expect_message(self, message, opts, &block)
+    end
+
+    def should_not_receive(message, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks.expect_message(self, message, {}, &block).never
+    end
+
+    def stub(message_or_hash, opts={}, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      if ::Hash === message_or_hash
+        message_or_hash.each { |message, value| stub(message).and_return value }
+      else
+        ::RSpec::Mocks.allow_message(self, message_or_hash, opts, &block)
+      end
+    end
+
+    def unstub(message)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__, "`allow(...).to_receive(...).and_call_original` or explicitly enable `:should`")
+      ::RSpec::Mocks.space.proxy_for(self).remove_stub(message)
+    end
+
+    def stub_chain(*chain, &blk)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks::StubChain.stub_chain_on(self, *chain, &blk)
+    end
+
+    def as_null_object
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      @_null_object = true
+      ::RSpec::Mocks.space.proxy_for(self).as_null_object
+    end
+
+    def null_object?
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      defined?(@_null_object)
+    end
+
+    def received_message?(message, *args, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks.space.proxy_for(self).received_message?(message, *args, &block)
+    end
+
+    unless Class.respond_to? :any_instance
+      Class.class_exec do
+        def any_instance
+          ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+          ::RSpec::Mocks.space.any_instance_proxy_for(self)
+        end
+      end
+    end
+  end
+end
+
+
+ +
+

+ + + (Boolean) expect_enabled?(syntax_host = ::RSpec::Mocks::ExampleMethods) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Indicates whether or not the expect syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+175
+176
+177
+
+
# File 'lib/rspec/mocks/syntax.rb', line 175
+
+def self.expect_enabled?(syntax_host=::RSpec::Mocks::ExampleMethods)
+  syntax_host.method_defined?(:allow)
+end
+
+
+ +
+

+ + + (Boolean) should_enabled?(syntax_host = default_should_syntax_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Indicates whether or not the should syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+169
+170
+171
+
+
# File 'lib/rspec/mocks/syntax.rb', line 169
+
+def self.should_enabled?(syntax_host=default_should_syntax_host)
+  syntax_host.method_defined?(:should_receive)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/TestDouble.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/TestDouble.html new file mode 100644 index 000000000..dc86c2cff --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/TestDouble.html @@ -0,0 +1,613 @@ + + + + + + Module: RSpec::Mocks::TestDouble + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::TestDouble + + + +

+ +
+ + + + + + + +
Included in:
+
Double
+ + + +
Defined in:
+
lib/rspec/mocks/test_double.rb
+ +
+
+ +

Overview

+
+ +

Implements the methods needed for a pure test double. RSpec::Mocks::Double +includes this module, and it is provided for cases where you want a pure +test double without subclassing RSpec::Mocks::Double.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing(message, *args, &block) (private) + + + + + +

+
+ + +
+
+
+ +

Raises:

+
    + +
  • + + + (NoMethodError) + + + +
  • + +
+ +
+ + + + +
+
+
+
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+
+
# File 'lib/rspec/mocks/test_double.rb', line 73
+
+def method_missing(message, *args, &block)
+  proxy = __mock_proxy
+  proxy.record_message_received(message, *args, &block)
+
+  if proxy.null_object?
+    case message
+    when :to_int        then return 0
+    when :to_a, :to_ary then return nil
+    when :to_str        then return to_s
+    else return self
+    end
+  end
+
+  # Defined private and protected methods will still trigger `method_missing`
+  # when called publicly. We want ruby's method visibility error to get raised,
+  # so we simply delegate to `super` in that case.
+  # ...well, we would delegate to `super`, but there's a JRuby
+  # bug, so we raise our own visibility error instead:
+  # https://github.com/jruby/jruby/issues/1398
+  visibility = proxy.visibility_for(message)
+  if visibility == :private || visibility == :protected
+    ErrorGenerator.new(self, @name).raise_non_public_error(
+      message, visibility
+    )
+  end
+
+  # Required wrapping doubles in an Array on Ruby 1.9.2
+  raise NoMethodError if [:to_a, :to_ary].include? message
+  proxy.raise_unexpected_message_error(message, *args)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) ==(other) + + + + + +

+
+ +

This allows for comparing the mock to other objects that proxy such as +ActiveRecords belongs_to proxy objects. By making the other object run the +comparison, we're sure the call gets delegated to the proxy target.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/mocks/test_double.rb', line 36
+
+def ==(other)
+  other == __mock_proxy
+end
+
+
+ +
+

+ + - (Object) as_null_object + + + + + +

+
+ +

Tells the object to respond to all messages. If specific stub values are +declared, they'll work as expected. If not, the receiver is returned.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/mocks/test_double.rb', line 23
+
+def as_null_object
+  __mock_proxy.as_null_object
+end
+
+
+ +
+

+ + - (Object) freeze + + + + + +

+
+ +

Override for default freeze implementation to prevent freezing of test +doubles.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+67
+68
+69
+
+
# File 'lib/rspec/mocks/test_double.rb', line 67
+
+def freeze
+  RSpec.warn_with("WARNING: you attempted to freeze a test double. This is explicitly a no-op as freezing doubles can lead to undesired behaviour when resetting tests.")
+end
+
+
+ +
+

+ + - (Object) initialize(name = nil, stubs = {}) + + + + + +

+
+ +

Creates a new test double with a name (that will be used in +error messages only)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'lib/rspec/mocks/test_double.rb', line 9
+
+def initialize(name=nil, stubs={})
+  @__expired = false
+  if Hash === name && stubs.empty?
+    stubs = name
+    @name = nil
+  else
+    @name = name
+  end
+  assign_stubs(stubs)
+end
+
+
+ +
+

+ + - (Boolean) null_object? + + + + + +

+
+ +

Returns true if this object has received as_null_object

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/rspec/mocks/test_double.rb', line 28
+
+def null_object?
+  __mock_proxy.null_object?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html new file mode 100644 index 000000000..58783a300 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html @@ -0,0 +1,324 @@ + + + + + + Class: RSpec::Mocks::VerifyingMessageExpectation + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::VerifyingMessageExpectation + + + Private +

+ +
+ +
Inherits:
+
+ MessageExpectation + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/verifying_message_expecation.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

A message expectation that knows about the real implementation of the +message being expected, so that it can verify that any expectations have +the valid arguments.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + +
+

Constructor Details

+ +
+

+ + - (VerifyingMessageExpectation) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of VerifyingMessageExpectation

+ + +
+
+
+ + +
+ + + + +
+
+
+
+20
+21
+22
+
+
# File 'lib/rspec/mocks/verifying_message_expecation.rb', line 20
+
+def initialize(*args)
+  super
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) method_reference + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

A level of indirection is used here rather than just passing in the method +itself, since method look up is expensive and we only want to do it if +actually needed.

+ +

Conceptually the method reference makes more sense as a constructor +argument since it should be immutable, but it is significantly more +straight forward to build the object in pieces so for now it stays as an +accessor.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lib/rspec/mocks/verifying_message_expecation.rb', line 18
+
+def method_reference
+  @method_reference
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Version.html b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Version.html new file mode 100644 index 000000000..8d508a8c3 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/RSpec/Mocks/Version.html @@ -0,0 +1,139 @@ + + + + + + Module: RSpec::Mocks::Version + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::Version + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/version.rb
+ +
+
+ +

Overview

+
+ +

Version information for RSpec mocks.

+ + +
+
+
+ + +
+

Constant Summary

+ +
+ +
STRING = +
+
+ +

Version of RSpec mocks currently in use in SemVer format.

+ + +
+
+
+ + +
+
+
'3.1.3'
+ +
+ + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/_index.html b/source/documentation/3.1/rspec-mocks/_index.html new file mode 100644 index 000000000..cf378ef58 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/_index.html @@ -0,0 +1,299 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Documentation by YARD 0.8.7.6

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + + + + + + + + + + +
    +
  • D
  • +
      + +
    • + Double + + (RSpec::Mocks) + +
    • + +
    +
+ + + + + +
    +
  • M
  • +
      + +
    • + Matchers + + (RSpec::Mocks) + +
    • + +
    • + Mocks + + (RSpec) + +
    • + +
    +
+ + +
    +
  • R
  • + +
+ + +
+ + +
    +
  • S
  • +
      + +
    • + Syntax + + (RSpec::Mocks) + +
    • + +
    +
+ + +
    +
  • T
  • + +
+ + + + +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/class_list.html b/source/documentation/3.1/rspec-mocks/class_list.html new file mode 100644 index 000000000..0dcaf4e45 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/class_list.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + Class List + + + + +
+

Class List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-mocks/file.Changelog.html b/source/documentation/3.1/rspec-mocks/file.Changelog.html new file mode 100644 index 000000000..f1c761ffb --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/file.Changelog.html @@ -0,0 +1,1292 @@ + + + + + + File: Changelog + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

3.1.4 Development

+ +

Full +Changelog

+ +

3.1.3 / 2014-10-08

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Correct received messages count when used with have_received +matcher. (Jon Rowe, #793)

    +
  • +

    Provide a clear error message when you use +allow_any_instance_of(...) or +expect_any_instance_of(...) with the +have_received matcher (they are not intended to be used +together and previously caused an odd internal failure in rspec-mocks). +(Jon Rowe, #799).

    +
  • +

    Fix verified double with verification so that it applies to +method stubs. (Myron Marston, #790)

    +
+ +

3.1.2 / 2014-09-26

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Provide a clear error message when you use allow(...) with the +have_received matcher (they are not intended to be used +together and previously caused an odd internal failure in rspec-mocks). +(Jon Rowe, #788).

    +
+ +

3.1.1 / 2014-09-18

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Prevent included modules being detected as prepended modules on Ruby 2.0 +when using any_instance_of(...). (Tony Novak, #781)

    +
+ +

3.1.0 / 2014-09-04

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Add spying methods (spy, ìnstance_spy, +class_spy and object_spy) which create doubles +as null objects for use with spying in testing. (Sam Phippen, #671)

    +
  • +

    have_received matcher will raise “does not implement” errors +correctly when used with verifying doubles and partial doubles. (Xavier +Shay, #722)

    +
  • +

    Allow matchers to be used in place of keyword arguments in +with expectations. (Xavier Shay, #726)

    +
  • +

    Add thrice modifier to message expectation interface as a +synonym for exactly(3).times. (Dennis Taylor, #753)

    +
  • +

    Add more thrice synonyms e.g. .at_least(:thrice), +.at_most(:thrice), receive(...).thrice and +have_received(...).thrice. (Jon Rowe, #754)

    +
  • +

    Add and_wrap_original modifier for partial doubles to mutate +the response from a method. (Jon Rowe, #762)

    +
+ +

Bugfixes:

+
  • +

    Remove any_number_of_times from any_instance +recorders that were erroneously causing mention of the method in +documentation. (Jon Rowe, #760)

    +
  • +

    Prevent included modules being detected as prepended modules on Ruby 2.0. +(Eugene Kenny, #771)

    +
+ +

3.0.4 / 2014-08-14

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Restore kind_of(x) to match using arg.kind_of?(x) +(like RSpec 2) rather than x === arg. (Jon Rowe, #750)

    +
+ +

3.0.3 / 2014-07-21

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    have_received matcher will raise “does not implement” errors +correctly when used with verifying doubles and partial doubles. (Xavier +Shay, #722)

    +
  • +

    Make double.as_null_object.dup and +double.as_null_object.clone make the copies be null objects. +(Myron Marston, #732)

    +
  • +

    Don't inadvertently define BasicObject in 1.8.7. (Chris +Griego, #739)

    +
+ +

3.0.2 / 2014-06-19

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix edge case that triggered “can't add a new key into hash during +iteration” during mock verification. (Sam Phippen, Myron Marston, #711)

    +
  • +

    Fix verifying doubles so that when they accidentally leak into another +example, they provide the same clear error message that normal doubles do. +(Myron Marston, #718)

    +
  • +

    Make ordered work with exact receive counts. (Sam Phippen, +#713)

    +
+ +

3.0.1 / 2014-06-07

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix receive_message_chain(...) so that it supports +with just like stub_chain did. (Jon Rowe, #697)

    +
  • +

    Fix regression in expect_any_instance_of so that it expects +the message on any instance rather than on every +instance. (Myron Marston, #699)

    +
+ +

3.0.0 / 2014-06-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix module prepend detection to work properly on ruby 2.0 for a case where +a module is extended onto itself. (Myron Marston)

    +
  • +

    Fix transfer_nested_constants option so that transferred +constants get properly reset at the end of the example. (Myron Marston)

    +
  • +

    Fix config.transfer_nested_constants = true so that you +don't erroneously get errors when stubbing a constant that is not a +module or a class. (Myron Marston)

    +
  • +

    Fix regression that caused double(:class => SomeClass) to +later trigger infinite recursion. (Myron Marston)

    +
  • +

    Fix bug in have_received(...).with(...).ordered where it was +not taking the args into account when checking the order. (Myron Marston)

    +
  • +

    Fix bug in have_received(...).ordered where it was wrongly +considering stubs when checking the order. (Myron Marston)

    +
  • +

    Message expectation matchers now show descriptions from argument matchers +when their expectations aren't met. (Jon Rowe)

    +
  • +

    Display warning when encountering TypeError during instance +method staging on 2.0.0-p195, suffers from bugs.ruby-lang.org/issues/8686 +too. (Cezar Halmagean).

    +
+ +

3.0.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Remove RSpec::Mocks::TestDouble.extend_onto. (Myron Marston)

    +
  • +

    Remove RSpec::Mocks::ConstantStubber. (Jon Rowe)

    +
  • +

    Make monkey-patch of Marshal to support dumping of stubbed objects opt-in. +(Xavier Shay)

    +
+ +

Enhancements:

+
  • +

    Instead of crashing when cleaning up stub methods on a frozen object, it +now issues a warning explaining that it's impossible to clean up the +stubs. (Justin Coyne and Sam Phippen)

    +
  • +

    Add meaningful descriptions to anything, +duck_type and instance_of argument matchers. +(Jon Rowe)

    +
+ +

Bug Fixes:

+
  • +

    Fix regression introduced in 3.0.0.beta2 that caused +double.as_null_object.to_str to return the double rather than +a string. (Myron Marston)

    +
  • +

    Fix bug in expect(dbl).to receive_message_chain(:foo, :bar) +where it was not setting an expectation for the last message in the chain. +(Jonathan del Strother)

    +
  • +

    Allow verifying partial doubles to have private methods stubbed. (Xavier +Shay)

    +
  • +

    Fix bug with allowing/expecting messages on Class objects which have had +their singleton class prepended to. (Jon Rowe)

    +
  • +

    Fix an issue with 1.8.7 not running implementation blocks on partial +doubles. (Maurício Linhares)

    +
  • +

    Prevent StackLevelTooDeep errors when stubbing an +any_instance method that's accessed in +inspect by providing our own inspect output. (Jon Rowe)

    +
  • +

    Fix bug in any_instance logic that did not allow you to mock +or stub private methods if verify_partial_doubles was +configured. (Oren Dobzinski)

    +
  • +

    Include useful error message when trying to observe an unimplemented method +on an any instance. (Xavier Shay)

    +
  • +

    Fix and_call_original to work properly when multiple classes +in an inheritance hierarchy have been stubbed with the same method. (Myron +Marston)

    +
  • +

    Fix any_instance so that it updates existing instances that +have already been stubbed. (Myron Marston)

    +
  • +

    Fix verified doubles so that their class name is included in failure +messages. (Myron Marston)

    +
  • +

    Fix expect_any_instance_of so that when the message is +received on an individual instance that has been directly stubbed, it +still satisfies the expectation. (Sam Phippen, Myron Marston)

    +
  • +

    Explicitly disallow using any_instance to mock or stub a +method that is defined on a module prepended onto the class. This +triggered SystemStackError before and is very hard to support +so we are not supporting it at this time. (Myron Marston)

    +
+ +

3.0.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Rename RSpec::Mocks::Mock to +RSpec::Mocks::Double. (Myron Marston)

    +
  • +

    Change how to integrate rspec-mocks in other test frameworks. You now need +to include RSpec::Mocks::ExampleMethods in your test context. +(Myron Marston)

    +
  • +

    Prevent RSpec mocks' doubles and partial doubles from being used +outside of the per-test lifecycle (e.g. from a before(:all) +hook). (Sam Phippen)

    +
  • +

    Remove the host argument of RSpec::Mocks.setup. +Instead RSpec::Mocks::ExampleMethods should be included +directly in the scope where RSpec's mocking capabilities are used. +(Sam Phippen)

    +
  • +

    Make test doubles raise errors if you attempt to use them after they get +reset, to help surface issues when you accidentally retain references to +test doubles and attempt to reuse them in another example. (Myron Marston)

    +
  • +

    Remove support for and_return { value } and +and_return without arguments. (Yuji Nakayama)

    +
+ +

Enhancements:

+
  • +

    Add receive_message_chain which provides the functionality of +the old stub_chain for the new allow/expect syntax. Use it +like so: allow(...).to receive_message_chain(:foo, :bar, +:bazz). (Sam Phippen).

    +
  • +

    Change argument matchers to use === as their primary matching +protocol, since their semantics mirror that of a case or rescue statement +(which uses === for matching). (Myron Marston)

    +
  • +

    Add RSpec::Mocks.with_temporary_scope, which allows you to +create temporary rspec-mocks scopes in arbitrary places (such as a +before(:all) hook). (Myron Marston)

    +
  • +

    Support keyword arguments when checking arity with verifying doubles. +(Xavier Shay)

    +
+ +

Bug Fixes:

+
  • +

    Fix regression in 3.0.0.beta1 that caused +double("string_name" => :value) to stop working. +(Xavier Shay)

    +
  • +

    Fix the way rspec-mocks and rspec-core interact so that if users define a +let with the same name as one of the methods from +RSpec::Mocks::ArgumentMatchers, the user's +let takes precedence. (Michi Huber, Myron Marston)

    +
  • +

    Fix verified doubles so that their methods match the visibility (public, +protected or private) of the interface they verify against. (Myron +Marston)

    +
  • +

    Fix verified null object doubles so that they do not wrongly report that +they respond to anything. They only respond to methods available on the +interface they verify against. (Myron Marston)

    +
  • +

    Fix deprecation warning for use of old :should syntax w/o +explicit config so that it no longer is silenced by an extension gem such +as rspec-rails when it calls +config.add_stub_and_should_receive_to. (Sam Phippen)

    +
  • +

    Fix expect syntax so that it does not wrongly emit a +“You're overriding a previous implementation for this stub” warning +when you are not actually doing that. (Myron Marston)

    +
  • +

    Fix any_instance.unstub when used on sub classes for whom the +super class has had any_instance.stub invoked on. (Jon Rowe)

    +
  • +

    Fix regression in +stub_chain/receive_message_chain that caused it +to raise an ArgumentError when passing args to the stubbed +methods. (Sam Phippen)

    +
  • +

    Correct stub of undefined parent modules all the way down when stubbing a +nested constant. (Xavier Shay)

    +
  • +

    Raise VerifyingDoubleNotDefinedError when a constant is not +defined for a verifying class double. (Maurício Linhares)

    +
  • +

    Remove Double#to_str, which caused confusing raise +some_double behavior. (Maurício Linhares)

    +
+ +

3.0.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Raise an explicit error if should_not_receive(...).and_return +is used. (Sam Phippen)

    +
  • +

    Remove 1.8.6 workarounds. (Jon Rowe)

    +
  • +

    Remove stub! and unstub!. (Sam Phippen)

    +
  • +

    Remove mock(name, methods) and stub(name, +methods), leaving double(name, methods) for creating +test doubles. (Sam Phippen, Michi Huber)

    +
  • +

    Remove any_number_of_times since +should_receive(:msg).any_number_of_times is really a stub in +a mock's clothing. (Sam Phippen)

    +
  • +

    Remove support for re-using the same null-object test double in multiple +examples. Test doubles are designed to only live for one example. (Myron +Marston)

    +
  • +

    Make at_least(0) raise an error. (Sam Phippen)

    +
  • +

    Remove support for require 'spec/mocks' which had been +kept in place for backwards compatibility with RSpec 1. (Myron Marston)

    +
  • +

    Blocks provided to with are always used as implementation. +(Xavier Shay)

    +
  • +

    The config option (added in 2.99) to yield the receiver to +any_instance implementation blocks now defaults to “on”. (Sam +Phippen)

    +
+ +

Enhancements:

+
  • +

    Allow the have_received matcher to use a block to set further +expectations on arguments. (Tim Cowlishaw)

    +
  • +

    Provide instance_double and class_double to +create verifying doubles, ported from rspec-fire. (Xavier +Shay)

    +
  • +

    as_null_object on a verifying double only responds to defined +methods. (Xavier Shay)

    +
  • +

    Provide object_double to create verified doubles of specific +object instances. (Xavier Shay)

    +
  • +

    Provide verify_partial_doubles configuration that provides +object_double like verification behaviour on partial doubles. +(Xavier Shay)

    +
  • +

    Improved performance of double creation, particularly those with many +attributes. (Xavier Shay)

    +
  • +

    Default value of transfer_nested_constants option for constant +stubbing can be configured. (Xavier Shay)

    +
  • +

    Messages can be allowed or expected on in bulk via +receive_messages(:message => :value). (Jon Rowe)

    +
  • +

    allow(Klass.any_instance) and +expect(Klass.any_instance) now print a warning. This is +usually a mistake, and users usually want +allow_any_instance_of or expect_any_instance_of +instead. (Sam Phippen)

    +
  • +

    instance_double and class_double raise +ArgumentError if the underlying module is loaded and the +arity of the method being invoked does not match the arity of the method +as it is actually implemented. (Andy Lindeman)

    +
  • +

    Spies can now check their invocation ordering is correct. (Jon Rowe)

    +
+ +

Deprecations:

+
  • +

    Using the old :should syntax without explicitly configuring it +is deprecated. It will continue to work but will emit a deprecation +warning in RSpec 3 if you do not explicitly enable it. (Sam Phippen)

    +
+ +

Bug Fixes:

+
  • +

    Fix and_call_original to handle a complex edge case involving +singleton class ancestors. (Marc-André Lafortune, Myron Marston)

    +
  • +

    When generating an error message for unexpected arguments, use +#inspect rather than #description if +#description returns nil or +'' so that you still get a useful message. (Nick +DeLuca)

    +
+ +

2.99.2 / 2014-07-21

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Warn about upcoming change to #=== matching and +DateTime#=== behaviour. (Jon Rowe, #735)

    +
+ +

2.99.1 / 2014-06-12

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix bug that caused errors at the end of each example when a +double.as_null_object had been frozen. (Yuji Nakayama, #698)

    +
+ +

Deprecations:

+
  • +

    Deprecate freezing a test double. (Yuji Nakayama, #698)

    +
+ +

2.99.0 / 2014-06-01

+ +

Full +Changelog

+ +

No changes. Just taking it out of pre-release.

+ +

2.99.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Deprecations:

+
  • +

    Deprecate RSpec::Mocks::TestDouble.extend_onto. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Mocks::ConstantStubber. (Jon Rowe)

    +
  • +

    Deprecate Marshal.dump monkey-patch without opt-in. (Xavier +Shay)

    +
+ +

2.99.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Deprecations:

+
  • +

    Deprecate RSpec::Mocks::Mock in favor of +RSpec::Mocks::Double. (Myron Marston)

    +
  • +

    Deprecate the host argument of +RSpec::Mocks.setup. Instead +RSpec::Mocks::ExampleMethods should be included directly in +the scope where RSpec's mocking capabilities are used. (Sam Phippen)

    +
  • +

    Deprecate using any of rspec-mocks' features outside the per-test +lifecycle (e.g. from a before(:all) hook). (Myron Marston)

    +
  • +

    Deprecate re-using a test double in another example. (Myron Marston)

    +
  • +

    Deprecate and_return { value } and and_return +without arguments. (Yuji Nakayama)

    +
+ +

2.99.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Deprecations

+
  • +

    Expecting to use lambdas or other strong arity implementations for stub +methods with mis-matched arity is deprecated and support for them will be +removed in 3.0. Either provide the right amount of arguments or use a weak +arity implementation (methods with splats or procs). (Jon Rowe)

    +
  • +

    Using the same test double instance in multiple examples is deprecated. +Test doubles are only meant to live for one example. The mocks and stubs +have always been reset between examples; however, in 2.x the +as_null_object state was not reset and some users relied on +this to have a null object double that is used for many examples. This +behavior will be removed in 3.0. (Myron Marston)

    +
  • +

    Print a detailed warning when an any_instance implementation +block is used when the new +yield_receiver_to_any_instance_implementation_blocks config +option is not explicitly set, as RSpec 3.0 will default to enabling this +new feature. (Sam Phippen)

    +
+ +

Enhancements:

+
  • +

    Add a config option to yield the receiver to any_instance +implementation blocks. (Sam Phippen)

    +
+ +

2.14.6 / 2014-02-20

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Ensure any_instance method stubs and expectations are torn +down regardless of expectation failures. (Sam Phippen)

    +
+ +

2.14.5 / 2014-02-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix regression that caused block implementations to not receive all args +on 1.8.7 if the block also receives a block, due to Proc#arity reporting +1 no matter how many args the block receives if it receives a +block, too. (Myron Marston)

    +
+ +

2.14.4 / 2013-10-15

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix issue where unstubing methods on “any instances” would not remove +stubs on existing instances (Jon Rowe)

    +
  • +

    Fix issue with receive(:message) do … end precedence preventing the usage +of modifications (and_return etc) (Jon Rowe)

    +
+ +

2.14.3 / 2013-08-08

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix stubbing some instance methods for classes whose hierarchy includes a +prepended Module (Bradley Schaefer)

    +
+ +

2.14.2 / 2013-07-30

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix as_null_object doubles so that they return +nil from to_ary (Jon Rowe).

    +
  • +

    Fix regression in 2.14 that made stub! (with an implicit +receiver) return a test double rather than stub a method (Myron Marston).

    +
+ +

2.14.1 / 2013-07-07

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Restore double.as_null_object behavior from 2.13 and earlier: +a double's nullness persisted between examples in earlier examples. +While this is not an intended use case (test doubles are meant to live for +only one example), we don't want to break behavior users rely on in a +minor relase. This will be deprecated in 2.99 and removed in 3.0. (Myron +Marston)

    +
+ +

2.14.0 / 2013-07-06

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Document test spies in the readme. (Adarsh Pandit)

    +
  • +

    Add an array_including matcher. (Sam Phippen)

    +
  • +

    Add a syntax-agnostic API for mocking or stubbing a method. This is +intended for use by libraries such as rspec-rails that need to mock or +stub a method, and work regardless of the syntax the user has configured +(Paul Annesley, Myron Marston and Sam Phippen).

    +
+ +

Bug Fixes:

+
  • +

    Fix double so that it sets up passed stubs correctly +regardless of the configured syntax (Paul Annesley).

    +
  • +

    Allow a block implementation to be used in combination with +and_yield, and_raise, and_return or +and_throw. This got fixed in 2.13.1 but failed to get merged +into master for the 2.14.0.rc1 release (Myron Marston).

    +
  • +

    Marshal.dump does not unnecessarily duplicate objects when +rspec-mocks has not been fully initialized. This could cause errors when +using spork or similar preloading gems (Andy Lindeman).

    +
+ +

2.14.0.rc1 / 2013-05-27

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Refactor internals so that the mock proxy methods and state are held +outside of the mocked object rather than inside it. This paves the way for +future syntax enhancements and removes the need for some hacky work +arounds for any_instance dup'ing and YAML +serialization, among other things. Note that the code now relies upon +__id__ returning a unique, consistent value for any object +you want to mock or stub (Myron Marston).

    +
  • +

    Add support for test spies. This allows you to verify a message was +received afterwards using the have_received matcher. Note +that you must first stub the method or use a null double. (Joe Ferris and +Joël Quenneville)

    +
  • +

    Make at_least and at_most style receive +expectations print that they were expecting at least or at most some +number of calls, rather than just the number of calls given in the +expectation (Sam Phippen)

    +
  • +

    Make with style receive expectations print the args they were +expecting, and the args that they got (Sam Phippen)

    +
  • +

    Fix some warnings seen under ruby 2.0.0p0 (Sam Phippen).

    +
  • +

    Add a new :expect syntax for message expectations (Myron +Marston and Sam Phippen).

    +
+ +

Bug fixes

+
  • +

    Fix any_instance so that a frozen object can be +dup'd when methods have been stubbed on that type using +any_instance (Jon Rowe).

    +
  • +

    Fix and_call_original so that it properly raises an +ArgumentError when the wrong number of args are passed (Jon +Rowe).

    +
  • +

    Fix double on 1.9.2 so you can wrap them in an Array using +Array(my_double) (Jon Rowe).

    +
  • +

    Fix stub_const and hide_const to handle constants +that redefine send (Sam Phippen).

    +
  • +

    Fix Marshal.dump extension so that it correctly handles nil. +(Luke Imhoff, Jon Rowe)

    +
  • +

    Fix isolation of allow_message_expectations_on_nil (Jon Rowe)

    +
  • +

    Use inspect to format actual arguments on expectations in failure messages +(#280, Ben Langfeld)

    +
  • +

    Protect against improperly initialised test doubles (#293) (Joseph +Shraibman and Jon Rowe)

    +
+ +

Deprecations

+
  • +

    Deprecate stub and mock as aliases for +double. double is the best term for creating a +test double, and it reduces confusion to have only one term (Michi Huber).

    +
  • +

    Deprecate stub! and unstub! in favor of +stub and unstub (Jon Rowe).

    +
  • +

    Deprecate at_least(0).times and +any_number_of_times (Michi Huber).

    +
+ +

2.13.1 / 2013-04-06

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Allow a block implementation to be used in combination with +and_yield, and_raise, and_return or +and_throw (Myron Marston).

    +
+ +

2.13.0 / 2013-02-23

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix bug that caused weird behavior when a method that had previously been +stubbed with multiple return values (e.g. +obj.stub(:foo).and_return(1, 2)) was later mocked with a +single return value (e.g. +obj.should_receive(:foo).once.and_return(1)). (Myron Marston)

    +
  • +

    Fix bug related to a mock expectation for a method that already had +multiple stubs with different with constraints. Previously, +the first stub was used, even though it may not have matched the passed +args. The fix defers this decision until the message is received so that +the proper stub response can be chosen based on the passed arguments +(Myron Marston).

    +
  • +

    Do not call nil? extra times on a mocked object, in case +nil? itself is expected a set number of times (Myron +Marston).

    +
  • +

    Fix missing_default_stub_error message so array args are +handled properly (Myron Marston).

    +
  • +

    Explicitly disallow any_instance.unstub! (Ryan Jones).

    +
  • +

    Fix any_instance stubbing so that it works with +Delegator subclasses (Myron Marston).

    +
  • +

    Fix and_call_original so that it works with +Delegator subclasses (Myron Marston).

    +
  • +

    Fix any_instance.should_not_receive when +any_instance.should_receive is used on the same class in the +same example. Previously it would wrongly report a failure even when the +message was not received (Myron Marston).

    +
+ +

2.12.2 / 2013-01-27

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix and_call_original to work properly for methods defined on +a module extended onto an object instance (Myron Marston).

    +
  • +

    Fix stub_const with an undefined constnat name to work +properly with constant strings that are prefixed with :: – +and edge case I missed in the bug fix in the 2.12.1 release (Myron +Marston).

    +
  • +

    Ensure method visibility on a partial mock is restored after reseting +method stubs, even on a singleton module (created via extend +self) when the method visibility differs between the instance and +singleton versions (Andy Lindeman).

    +
+ +

2.12.1 / 2012-12-21

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix any_instance to support and_call_original. +(Myron Marston)

    +
  • +

    Properly restore stubbed aliased methods on rubies that report the +incorrect owner (Myron Marston and Andy Lindeman).

    +
  • +

    Fix hide_const and stub_const with a defined +constnat name to work properly with constant strings that are prefixed +with :: (Myron Marston).

    +
+ +

2.12.0 / 2012-11-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    and_raise can accept an exception class and message, more +closely matching Kernel#raise (e.g., +foo.stub(:bar).and_raise(RuntimeError, "message")) +(Bas Vodde)

    +
  • +

    Add and_call_original, which will delegate the message to the +original method (Myron Marston).

    +
+ +

Deprecations:

+
  • +

    Add deprecation warning when using and_return with +should_not_receive (Neha Kumari)

    +
+ +

2.11.3 / 2012-09-19

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix :transfer_nested_constants option of +stub_const so that it doesn't blow up when there are +inherited constants. (Myron Marston)

    +
  • +

    any_instance stubs can be used on classes that override +Object#method. (Andy Lindeman)

    +
  • +

    Methods stubbed with any_instance are unstubbed after the test +finishes. (Andy Lindeman)

    +
  • +

    Fix confusing error message when calling a mocked class method an extra +time with the wrong arguments (Myron Marston).

    +
+ +

2.11.2 / 2012-08-11

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Don't modify dup on classes that don't support +dup (David Chelimsky)

    +
  • +

    Fix any_instance so that it works properly with methods +defined on a superclass. (Daniel Eguzkiza)

    +
  • +

    Fix stub_const so that it works properly for nested constants +that share a name with a top-level constant (e.g. “MyGem::Hash”). (Myron +Marston)

    +
+ +

2.11.1 / 2012-07-09

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix should_receive so that when it is called on an +as_null_object double with no implementation, and there is a +previous explicit stub for the same method, the explicit stub remains +(rather than being overriden with the null object +implementation–return self). (Myron Marston)

    +
+ +

2.11.0 / 2012-07-07

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Expose ArgumentListMatcher as a formal API

    +
    • +

      supports use by 3rd party mock frameworks like Surrogate

      +
    +
  • +

    Add stub_const API to stub constants for the duration of an +example (Myron Marston).

    +
+ +

Bug fixes

+
  • +

    Fix regression of edge case behavior. double.should_receive(:foo) { a +} was causing a NoMethodError when +double.stub(:foo).and_return(a, b) had been setup before +(Myron Marston).

    +
  • +

    Infinite loop generated by using any_instance and +dup. (Sidu Ponnappa @kaiwren)

    +
  • +

    double.should_receive(:foo).at_least(:once).and_return(a) +always returns a even if :foo is already stubbed.

    +
  • +

    Prevent infinite loop when interpolating a null double into a string as an +integer ("%i" % double.as_null_object). (Myron +Marston)

    +
  • +

    Fix should_receive so that null object behavior (e.g. +returning self) is preserved if no implementation is given (Myron +Marston).

    +
  • +

    Fix and_raise so that it raises RuntimeError +rather than Exception by default, just like ruby does. +(Andrew Marshall)

    +
+ +

2.10.1 / 2012-05-05

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    fix regression of edge case behavior (github.com/rspec/rspec-mocks/issues/132)

    +
    • +

      fixed failure of +object.should_receive(:message).at_least(0).times.and_return +value

      +
    • +

      fixed failure of object.should_not_receive(:message).and_return +value

      +
    +
+ +

2.10.0 / 2012-05-03

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    fail fast when an exactly or at_most expectation +is exceeded

    +
+ +

2.9.0 / 2012-03-17

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Support order constraints across objects (preethiramdev)

    +
+ +

Bug fixes

+
  • +

    Allow a as_null_object to be passed to with

    +
  • +

    Pass proc to block passed to stub (Aubrey Rhodes)

    +
  • +

    Initialize child message expectation args to match any args (#109 - +preethiramdev)

    +
+ +

2.8.0 / 2012-01-04

+ +

Full +Changelog

+ +

No changes for this release. Just releasing with the other rspec gems.

+ +

2.8.0.rc2 / 2011-12-19

+ +

Full +Changelog

+ +

No changes for this release. Just releasing with the other rspec gems.

+ +

2.8.0.rc1 / 2011-11-06

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Eliminate Ruby warnings (Matijs van Zuijlen)

    +
+ +

2.7.0 / 2011-10-16

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Use __send__ rather than send (alextk)

    +
  • +

    Add support for any_instance.stub_chain (Sidu Ponnappa)

    +
  • +

    Add support for any_instance argument matching based on +with (Sidu Ponnappa and Andy Lindeman)

    +
+ +

Changes

+
  • +

    Check for failure_message_for_should or +failure_message instead of description to detect +a matcher (Tibor Claassen)

    +
+ +

Bug fixes

+
  • +

    pass a hash to any_instance.stub. (Justin Ko)

    +
  • +

    allow to_ary to be called without raising +NoMethodError (Mikhail Dieterle)

    +
  • +

    any_instance properly restores private methods (Sidu Ponnappa)

    +
+ +

2.6.0 / 2011-05-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Add support for any_instance.stub and +any_instance.should_receive (Sidu Ponnappa and Andy Lindeman)

    +
+ +

Bug fixes

+
  • +

    fix bug in which multiple chains with shared messages ending in hashes +failed to return the correct value

    +
+ +

2.5.0 / 2011-02-05

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    message expectation counts now work in combination with a stub (Damian +Nurzynski)

    +
  • +

    fix failure message when message received with incorrect args (Josep M. +Bach)

    +
+ +

2.4.0 / 2011-01-02

+ +

Full +Changelog

+ +

No functional changes in this release, which was made to align with the +rspec-core-2.4.0 release.

+ +

2.3.0 / 2010-12-12

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix our Marshal extension so that it does not interfere with objects that +have their own @mock_proxy instance variable. (Myron Marston)

    +
+ +

2.2.0 / 2010-11-28

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Added “rspec/mocks/standalone” for exploring the rspec-mocks in irb.

    +
+ +

Bug fix

+
  • +

    Eliminate warning on splat args without parens (Gioele Barabucci)

    +
  • +

    Fix bug where +obj.should_receive(:foo).with(stub.as_null_object) would pass +with a false positive.

    +
+ +

2.1.0 / 2010-11-07

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix serialization of stubbed object (Josep M Bach)

    +
+ +

2.0.0 / 2010-10-10

+ +

Full +Changelog

+ +

2.0.0.rc / 2010-10-05

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    support passing a block to an expectation block (Nicolas Braem)

    +
    • +

      obj.should_receive(:msg) {|&block| ... }

      +
    +
+ +

Bug fixes

+
  • +

    Fix YAML serialization of stub (Myron Marston)

    +
  • +

    Fix rdoc rake task (Hans de Graaff)

    +
+ +

2.0.0.beta.22 / 2010-09-12

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    fixed regression that broke obj.stub_chain(:a, :b => :c)

    +
  • +

    fixed regression that broke obj.stub_chain(:a, :b) { :c }

    +
  • +

    respond_to? always returns true when using +as_null_object

    +
+
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/file.License.html b/source/documentation/3.1/rspec-mocks/file.License.html new file mode 100644 index 000000000..c3835525a --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/file.License.html @@ -0,0 +1,73 @@ + + + + + + File: License + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
(The MIT License)

Copyright (c) 2012 David Chelimsky, Myron Marston
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
Copyright (c) 2005 Steven Baker

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/file.README.html b/source/documentation/3.1/rspec-mocks/file.README.html new file mode 100644 index 000000000..3ec295cf9 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/file.README.html @@ -0,0 +1,471 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

RSpec Mocks

+ +

rspec-mocks is a test-double framework for rspec with support for method +stubs, fakes, and message expectations on generated test-doubles and real +objects alike.

+ +

Install

+ +
gem install rspec       # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-mocks # for rspec-mocks only
+ +

Test Doubles

+ +

A test double is an object that stands in for another object in your system +during a code example. Use the double method, passing in an +optional identifier, to create one:

+ +
book = double("book")
+
+ +

Most of the time you will want some confidence that your doubles resemble +an existing object in your system. Verifying doubles are provided for this +purpose. If the existing object is available, they will prevent you from +adding stubs and expectations for methods that do not exist or that have an +invalid number of parameters.

+ +
book = instance_double("Book", :pages => 250)
+
+ +

Verifying doubles have some clever tricks to enable you to both test in +isolation without your dependencies loaded while still being able to +validate them against real objects. More detail is available in their +documentation.

+ +

Method Stubs

+ +

A method stub is an implementation that returns a pre-determined value. +Method stubs can be declared on test doubles or real objects using the same +syntax. rspec-mocks supports 3 forms for declaring method stubs:

+ +
allow(book).to receive(:title) { "The RSpec Book" }
+allow(book).to receive(:title).and_return("The RSpec Book")
+allow(book).to receive_messages(
+    :title => "The RSpec Book", 
+    :subtitle => "Behaviour-Driven Development with RSpec, Cucumber, and Friends")
+
+ +

You can also use this shortcut, which creates a test double and declares a +method stub in one statement:

+ +
book = double("book", :title => "The RSpec Book")
+
+ +

The first argument is a name, which is used for documentation and appears +in failure messages. If you don't care about the name, you can leave it +out, making the combined instantiation/stub declaration very terse:

+ +
double(:foo => 'bar')
+
+ +

This is particularly nice when providing a list of test doubles to a method +that iterates through them:

+ +
order.calculate_total_price(double(:price => 1.99), double(:price => 2.99))
+
+ +

Consecutive return values

+ +

When a stub might be invoked more than once, you can provide additional +arguments to and_return. The invocations cycle through the +list. The last value is returned for any subsequent invocations:

+ +
allow(die).to receive(:roll).and_return(1, 2, 3)
+die.roll # => 1
+die.roll # => 2
+die.roll # => 3
+die.roll # => 3
+die.roll # => 3
+
+ +

To return an array in a single invocation, declare an array:

+ +
allow(team).to receive(:players).and_return([double(:name => "David")])
+
+ +

Message Expectations

+ +

A message expectation is an expectation that the test double will receive a +message some time before the example ends. If the message is received, the +expectation is satisfied. If not, the example fails.

+ +
validator = double("validator")
+expect(validator).to receive(:validate) { "02134" }
+zipcode = Zipcode.new("02134", validator)
+zipcode.valid?
+
+ +

Test Spies

+ +

Verifies the given object received the expected message during the course +of the test. For a message to be verified, the given object must be setup +to spy on it, either by having it explicitly stubbed or by being a null +object double (e.g. double(...).as_null_object). Convenience +methods are provided to easily create null object doubles for this purpose:

+ +
spy("invitation") # => same as `double("invitation").as_null_object`
+instance_spy("Invitation") # => same as `instance_double("Invitation").as_null_object`
+class_spy("Invitation") # => same as `class_double("Invitation").as_null_object`
+object_spy("Invitation") # => same as `object_double("Invitation").as_null_object`
+
+ +

Stubbing and verifying messages received in this way implements the Test +Spy pattern.

+ +
invitation = spy('invitation')
+
+user.accept_invitation(invitation)
+
+expect(invitation).to have_received(:accept)
+
+# You can also use other common message expectations. For example:
+expect(invitation).to have_received(:accept).with(mailer)
+expect(invitation).to have_received(:accept).twice
+expect(invitation).to_not have_received(:accept).with(mailer)
+
+# One can specify a return value on the spy the same way one would a double.
+invitation = spy('invitation', :accept => true)
+expect(invitation).to have_received(:accept).with(mailer)
+expect(invitation.accept).to eq(true)
+
+ +

Nomenclature

+ +

Mock Objects and Test Stubs

+ +

The names Mock Object and Test Stub suggest specialized Test Doubles. i.e. +a Test Stub is a Test Double that only supports method stubs, and a Mock +Object is a Test Double that supports message expectations and method +stubs.

+ +

There is a lot of overlapping nomenclature here, and there are many +variations of these patterns (fakes, spies, etc). Keep in mind that most of +the time we're talking about method-level concepts that are variations +of method stubs and message expectations, and we're applying to them to +one generic kind of object: a Test Double.

+ +

Test-Specific Extension

+ +

a.k.a. Partial Double, a Test-Specific Extension is an extension of a real +object in a system that is instrumented with test-double like behaviour in +the context of a test. This technique is very common in Ruby because we +often see class objects acting as global namespaces for methods. For +example, in Rails:

+ +
person = double("person")
+allow(Person).to receive(:find) { person }
+
+ +

In this case we're instrumenting Person to return the person object +we've defined whenever it receives the find message. We +can also set a message expectation so that the example fails if +find is not called:

+ +
person = double("person")
+expect(Person).to receive(:find) { person }
+
+ +

RSpec replaces the method we're stubbing or mocking with its own +test-double-like method. At the end of the example, RSpec verifies any +message expectations, and then restores the original methods.

+ +

Expecting Arguments

+ +
expect(double).to receive(:msg).with(*args)
+expect(double).to_not receive(:msg).with(*args)
+
+ +

You can set multiple expectations for the same message if you need to:

+ +
expect(double).to receive(:msg).with("A", 1, 3)
+expect(double).to receive(:msg).with("B", 2, 4)
+
+ +

Argument Matchers

+ +

Arguments that are passed to with are compared with actual +arguments received using ==. In cases in which you want to specify things +about the arguments rather than the arguments themselves, you can use any +of the matchers that ship with rspec-expectations. They don't all make +syntactic sense (they were primarily designed for use with +RSpec::Expectations), but you are free to create your own custom +RSpec::Matchers.

+ +

rspec-mocks also adds some keyword Symbols that you can use to specify +certain kinds of arguments:

+ +
expect(double).to receive(:msg).with(no_args())
+expect(double).to receive(:msg).with(any_args())
+expect(double).to receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can be any kind of Numeric
+expect(double).to receive(:msg).with(1, boolean(), "b") #2nd argument can be true or false
+expect(double).to receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp
+expect(double).to receive(:msg).with(1, anything(), "b") #2nd argument can be anything at all
+expect(double).to receive(:msg).with(1, duck_type(:abs, :div), "b") #2nd argument can be object that responds to #abs and #div
+expect(double).to receive(:msg).with(hash_including(:a => 5)) # first arg is a hash with a: 5 as one of the key-values
+expect(double).to receive(:msg).with(array_including(5)) # first arg is an array with 5 as one of the key-values
+expect(double).to receive(:msg).with(hash_excluding(:a => 5)) # first arg is a hash without a: 5 as one of the key-values
+
+ +

Receive Counts

+ +
expect(double).to receive(:msg).once
+expect(double).to receive(:msg).twice
+expect(double).to receive(:msg).exactly(n).times
+expect(double).to receive(:msg).at_least(:once)
+expect(double).to receive(:msg).at_least(:twice)
+expect(double).to receive(:msg).at_least(n).times
+expect(double).to receive(:msg).at_most(:once)
+expect(double).to receive(:msg).at_most(:twice)
+expect(double).to receive(:msg).at_most(n).times
+
+ +

Ordering

+ +
expect(double).to receive(:msg).ordered
+expect(double).to receive(:other_msg).ordered
+  # This will fail if the messages are received out of order
+
+ +

This can include the same message with different arguments:

+ +
expect(double).to receive(:msg).with("A", 1, 3).ordered
+expect(double).to receive(:msg).with("B", 2, 4).ordered
+
+ +

Setting Responses

+ +

Whether you are setting a message expectation or a method stub, you can +tell the object precisely how to respond. The most generic way is to pass a +block to receive:

+ +
expect(double).to receive(:msg) { value }
+
+ +

When the double receives the msg message, it evaluates the +block and returns the result.

+ +
expect(double).to receive(:msg).and_return(value)
+expect(double).to receive(:msg).exactly(3).times.and_return(value1, value2, value3)
+  # returns value1 the first time, value2 the second, etc
+expect(double).to receive(:msg).and_raise(error)
+  # error can be an instantiated object or a class
+  # if it is a class, it must be instantiable with no args
+expect(double).to receive(:msg).and_throw(:msg)
+expect(double).to receive(:msg).and_yield(values, to, yield)
+expect(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+  # for methods that yield to a block multiple times
+
+ +

Any of these responses can be applied to a stub as well

+ +
allow(double).to receive(:msg).and_return(value)
+allow(double).to receive(:msg).and_return(value1, value2, value3)
+allow(double).to receive(:msg).and_raise(error)
+allow(double).to receive(:msg).and_throw(:msg)
+allow(double).to receive(:msg).and_yield(values, to, yield)
+allow(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+
+ +

Arbitrary Handling

+ +

Once in a while you'll find that the available expectations don't +solve the particular problem you are trying to solve. Imagine that you +expect the message to come with an Array argument that has a specific +length, but you don't care what is in it. You could do this:

+ +
expect(double).to receive(:msg) do |arg|
+  expect(arg.size).to eq 7
+end
+
+ +

If the method being stubbed itself takes a block, and you need to yield to +it in some special way, you can use this:

+ +
expect(double).to receive(:msg) do |&arg|
+  begin
+    arg.call
+  ensure
+    # cleanup
+  end
+end
+
+ +

Delegating to the Original Implementation

+ +

When working with a partial mock object, you may occasionally want to set a +message expecation without interfering with how the object responds to the +message. You can use and_call_original to achieve this:

+ +
expect(Person).to receive(:find).and_call_original
+Person.find # => executes the original find method and returns the result
+
+ +

Combining Expectation Details

+ +

Combining the message name with specific arguments, receive counts and +responses you can get quite a bit of detail in your expectations:

+ +
expect(double).to receive(:<<).with("illegal value").once.and_raise(ArgumentError)
+
+ +

While this is a good thing when you really need it, you probably don't +really need it! Take care to specify only the things that matter to the +behavior of your code.

+ +

Stubbing and Hiding Constants

+ +

See the mutating +constants README for info on this feature.

+ +

Use before(:example), not before(:context)

+ +

Stubs in before(:context) are not supported. The reason is +that all stubs and mocks get cleared out after each example, so any stub +that is set in before(:context) would work in the first +example that happens to run in that group, but not for any others.

+ +

Instead of before(:context), use +before(:example).

+ +

Settings mocks or stubs on any instance of a class

+ +

rspec-mocks provides two methods, allow_any_instance_of and +expect_any_instance_of, that will allow you to stub or mock +any instance of a class. They are used in place of allow or +expect:

+ +
allow_any_instance_of(Widget).to receive(:name).and_return("Wibble")
+expect_any_instance_of(Widget).to receive(:name).and_return("Wobble")
+
+ +

These methods add the appropriate stub or expectation to all instances of +Widget.

+ +

This feature is sometimes useful when working with legacy code, though in +general we discourage its use for a number of reasons:

+
  • +

    The rspec-mocks API is designed for individual object +instances, but this feature operates on entire classes of objects. As a +result there are some sematically confusing edge cases. For example in +expect_any_instance_of(Widget).to receive(:name).twice it +isn't clear whether each specific instance is expected to receive +name twice, or if two receives total are expected. (It's +the former.)

    +
  • +

    Using this feature is often a design smell. It may be that your test is +trying to do too much or that the object under test is too complex.

    +
  • +

    It is the most complicated feature of rspec-mocks, and has +historically received the most bug reports. (None of the core team +actively use it, which doesn't help.)

    +
+ +

Further Reading

+ +

There are many different viewpoints about the meaning of mocks and stubs. +If you are interested in learning more, here is some recommended reading:

+ + +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/file_list.html b/source/documentation/3.1/rspec-mocks/file_list.html new file mode 100644 index 000000000..4fbe39987 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/file_list.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + File List + + + + +
+

File List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-mocks/frames.html b/source/documentation/3.1/rspec-mocks/frames.html new file mode 100644 index 000000000..87a4a6df1 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/frames.html @@ -0,0 +1,26 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + diff --git a/source/documentation/3.1/rspec-mocks/index.html b/source/documentation/3.1/rspec-mocks/index.html new file mode 100644 index 000000000..3ec295cf9 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/index.html @@ -0,0 +1,471 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

RSpec Mocks

+ +

rspec-mocks is a test-double framework for rspec with support for method +stubs, fakes, and message expectations on generated test-doubles and real +objects alike.

+ +

Install

+ +
gem install rspec       # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-mocks # for rspec-mocks only
+ +

Test Doubles

+ +

A test double is an object that stands in for another object in your system +during a code example. Use the double method, passing in an +optional identifier, to create one:

+ +
book = double("book")
+
+ +

Most of the time you will want some confidence that your doubles resemble +an existing object in your system. Verifying doubles are provided for this +purpose. If the existing object is available, they will prevent you from +adding stubs and expectations for methods that do not exist or that have an +invalid number of parameters.

+ +
book = instance_double("Book", :pages => 250)
+
+ +

Verifying doubles have some clever tricks to enable you to both test in +isolation without your dependencies loaded while still being able to +validate them against real objects. More detail is available in their +documentation.

+ +

Method Stubs

+ +

A method stub is an implementation that returns a pre-determined value. +Method stubs can be declared on test doubles or real objects using the same +syntax. rspec-mocks supports 3 forms for declaring method stubs:

+ +
allow(book).to receive(:title) { "The RSpec Book" }
+allow(book).to receive(:title).and_return("The RSpec Book")
+allow(book).to receive_messages(
+    :title => "The RSpec Book", 
+    :subtitle => "Behaviour-Driven Development with RSpec, Cucumber, and Friends")
+
+ +

You can also use this shortcut, which creates a test double and declares a +method stub in one statement:

+ +
book = double("book", :title => "The RSpec Book")
+
+ +

The first argument is a name, which is used for documentation and appears +in failure messages. If you don't care about the name, you can leave it +out, making the combined instantiation/stub declaration very terse:

+ +
double(:foo => 'bar')
+
+ +

This is particularly nice when providing a list of test doubles to a method +that iterates through them:

+ +
order.calculate_total_price(double(:price => 1.99), double(:price => 2.99))
+
+ +

Consecutive return values

+ +

When a stub might be invoked more than once, you can provide additional +arguments to and_return. The invocations cycle through the +list. The last value is returned for any subsequent invocations:

+ +
allow(die).to receive(:roll).and_return(1, 2, 3)
+die.roll # => 1
+die.roll # => 2
+die.roll # => 3
+die.roll # => 3
+die.roll # => 3
+
+ +

To return an array in a single invocation, declare an array:

+ +
allow(team).to receive(:players).and_return([double(:name => "David")])
+
+ +

Message Expectations

+ +

A message expectation is an expectation that the test double will receive a +message some time before the example ends. If the message is received, the +expectation is satisfied. If not, the example fails.

+ +
validator = double("validator")
+expect(validator).to receive(:validate) { "02134" }
+zipcode = Zipcode.new("02134", validator)
+zipcode.valid?
+
+ +

Test Spies

+ +

Verifies the given object received the expected message during the course +of the test. For a message to be verified, the given object must be setup +to spy on it, either by having it explicitly stubbed or by being a null +object double (e.g. double(...).as_null_object). Convenience +methods are provided to easily create null object doubles for this purpose:

+ +
spy("invitation") # => same as `double("invitation").as_null_object`
+instance_spy("Invitation") # => same as `instance_double("Invitation").as_null_object`
+class_spy("Invitation") # => same as `class_double("Invitation").as_null_object`
+object_spy("Invitation") # => same as `object_double("Invitation").as_null_object`
+
+ +

Stubbing and verifying messages received in this way implements the Test +Spy pattern.

+ +
invitation = spy('invitation')
+
+user.accept_invitation(invitation)
+
+expect(invitation).to have_received(:accept)
+
+# You can also use other common message expectations. For example:
+expect(invitation).to have_received(:accept).with(mailer)
+expect(invitation).to have_received(:accept).twice
+expect(invitation).to_not have_received(:accept).with(mailer)
+
+# One can specify a return value on the spy the same way one would a double.
+invitation = spy('invitation', :accept => true)
+expect(invitation).to have_received(:accept).with(mailer)
+expect(invitation.accept).to eq(true)
+
+ +

Nomenclature

+ +

Mock Objects and Test Stubs

+ +

The names Mock Object and Test Stub suggest specialized Test Doubles. i.e. +a Test Stub is a Test Double that only supports method stubs, and a Mock +Object is a Test Double that supports message expectations and method +stubs.

+ +

There is a lot of overlapping nomenclature here, and there are many +variations of these patterns (fakes, spies, etc). Keep in mind that most of +the time we're talking about method-level concepts that are variations +of method stubs and message expectations, and we're applying to them to +one generic kind of object: a Test Double.

+ +

Test-Specific Extension

+ +

a.k.a. Partial Double, a Test-Specific Extension is an extension of a real +object in a system that is instrumented with test-double like behaviour in +the context of a test. This technique is very common in Ruby because we +often see class objects acting as global namespaces for methods. For +example, in Rails:

+ +
person = double("person")
+allow(Person).to receive(:find) { person }
+
+ +

In this case we're instrumenting Person to return the person object +we've defined whenever it receives the find message. We +can also set a message expectation so that the example fails if +find is not called:

+ +
person = double("person")
+expect(Person).to receive(:find) { person }
+
+ +

RSpec replaces the method we're stubbing or mocking with its own +test-double-like method. At the end of the example, RSpec verifies any +message expectations, and then restores the original methods.

+ +

Expecting Arguments

+ +
expect(double).to receive(:msg).with(*args)
+expect(double).to_not receive(:msg).with(*args)
+
+ +

You can set multiple expectations for the same message if you need to:

+ +
expect(double).to receive(:msg).with("A", 1, 3)
+expect(double).to receive(:msg).with("B", 2, 4)
+
+ +

Argument Matchers

+ +

Arguments that are passed to with are compared with actual +arguments received using ==. In cases in which you want to specify things +about the arguments rather than the arguments themselves, you can use any +of the matchers that ship with rspec-expectations. They don't all make +syntactic sense (they were primarily designed for use with +RSpec::Expectations), but you are free to create your own custom +RSpec::Matchers.

+ +

rspec-mocks also adds some keyword Symbols that you can use to specify +certain kinds of arguments:

+ +
expect(double).to receive(:msg).with(no_args())
+expect(double).to receive(:msg).with(any_args())
+expect(double).to receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can be any kind of Numeric
+expect(double).to receive(:msg).with(1, boolean(), "b") #2nd argument can be true or false
+expect(double).to receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp
+expect(double).to receive(:msg).with(1, anything(), "b") #2nd argument can be anything at all
+expect(double).to receive(:msg).with(1, duck_type(:abs, :div), "b") #2nd argument can be object that responds to #abs and #div
+expect(double).to receive(:msg).with(hash_including(:a => 5)) # first arg is a hash with a: 5 as one of the key-values
+expect(double).to receive(:msg).with(array_including(5)) # first arg is an array with 5 as one of the key-values
+expect(double).to receive(:msg).with(hash_excluding(:a => 5)) # first arg is a hash without a: 5 as one of the key-values
+
+ +

Receive Counts

+ +
expect(double).to receive(:msg).once
+expect(double).to receive(:msg).twice
+expect(double).to receive(:msg).exactly(n).times
+expect(double).to receive(:msg).at_least(:once)
+expect(double).to receive(:msg).at_least(:twice)
+expect(double).to receive(:msg).at_least(n).times
+expect(double).to receive(:msg).at_most(:once)
+expect(double).to receive(:msg).at_most(:twice)
+expect(double).to receive(:msg).at_most(n).times
+
+ +

Ordering

+ +
expect(double).to receive(:msg).ordered
+expect(double).to receive(:other_msg).ordered
+  # This will fail if the messages are received out of order
+
+ +

This can include the same message with different arguments:

+ +
expect(double).to receive(:msg).with("A", 1, 3).ordered
+expect(double).to receive(:msg).with("B", 2, 4).ordered
+
+ +

Setting Responses

+ +

Whether you are setting a message expectation or a method stub, you can +tell the object precisely how to respond. The most generic way is to pass a +block to receive:

+ +
expect(double).to receive(:msg) { value }
+
+ +

When the double receives the msg message, it evaluates the +block and returns the result.

+ +
expect(double).to receive(:msg).and_return(value)
+expect(double).to receive(:msg).exactly(3).times.and_return(value1, value2, value3)
+  # returns value1 the first time, value2 the second, etc
+expect(double).to receive(:msg).and_raise(error)
+  # error can be an instantiated object or a class
+  # if it is a class, it must be instantiable with no args
+expect(double).to receive(:msg).and_throw(:msg)
+expect(double).to receive(:msg).and_yield(values, to, yield)
+expect(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+  # for methods that yield to a block multiple times
+
+ +

Any of these responses can be applied to a stub as well

+ +
allow(double).to receive(:msg).and_return(value)
+allow(double).to receive(:msg).and_return(value1, value2, value3)
+allow(double).to receive(:msg).and_raise(error)
+allow(double).to receive(:msg).and_throw(:msg)
+allow(double).to receive(:msg).and_yield(values, to, yield)
+allow(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+
+ +

Arbitrary Handling

+ +

Once in a while you'll find that the available expectations don't +solve the particular problem you are trying to solve. Imagine that you +expect the message to come with an Array argument that has a specific +length, but you don't care what is in it. You could do this:

+ +
expect(double).to receive(:msg) do |arg|
+  expect(arg.size).to eq 7
+end
+
+ +

If the method being stubbed itself takes a block, and you need to yield to +it in some special way, you can use this:

+ +
expect(double).to receive(:msg) do |&arg|
+  begin
+    arg.call
+  ensure
+    # cleanup
+  end
+end
+
+ +

Delegating to the Original Implementation

+ +

When working with a partial mock object, you may occasionally want to set a +message expecation without interfering with how the object responds to the +message. You can use and_call_original to achieve this:

+ +
expect(Person).to receive(:find).and_call_original
+Person.find # => executes the original find method and returns the result
+
+ +

Combining Expectation Details

+ +

Combining the message name with specific arguments, receive counts and +responses you can get quite a bit of detail in your expectations:

+ +
expect(double).to receive(:<<).with("illegal value").once.and_raise(ArgumentError)
+
+ +

While this is a good thing when you really need it, you probably don't +really need it! Take care to specify only the things that matter to the +behavior of your code.

+ +

Stubbing and Hiding Constants

+ +

See the mutating +constants README for info on this feature.

+ +

Use before(:example), not before(:context)

+ +

Stubs in before(:context) are not supported. The reason is +that all stubs and mocks get cleared out after each example, so any stub +that is set in before(:context) would work in the first +example that happens to run in that group, but not for any others.

+ +

Instead of before(:context), use +before(:example).

+ +

Settings mocks or stubs on any instance of a class

+ +

rspec-mocks provides two methods, allow_any_instance_of and +expect_any_instance_of, that will allow you to stub or mock +any instance of a class. They are used in place of allow or +expect:

+ +
allow_any_instance_of(Widget).to receive(:name).and_return("Wibble")
+expect_any_instance_of(Widget).to receive(:name).and_return("Wobble")
+
+ +

These methods add the appropriate stub or expectation to all instances of +Widget.

+ +

This feature is sometimes useful when working with legacy code, though in +general we discourage its use for a number of reasons:

+
  • +

    The rspec-mocks API is designed for individual object +instances, but this feature operates on entire classes of objects. As a +result there are some sematically confusing edge cases. For example in +expect_any_instance_of(Widget).to receive(:name).twice it +isn't clear whether each specific instance is expected to receive +name twice, or if two receives total are expected. (It's +the former.)

    +
  • +

    Using this feature is often a design smell. It may be that your test is +trying to do too much or that the object under test is too complex.

    +
  • +

    It is the most complicated feature of rspec-mocks, and has +historically received the most bug reports. (None of the core team +actively use it, which doesn't help.)

    +
+ +

Further Reading

+ +

There are many different viewpoints about the meaning of mocks and stubs. +If you are interested in learning more, here is some recommended reading:

+ + +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.1/rspec-mocks/method_list.html b/source/documentation/3.1/rspec-mocks/method_list.html new file mode 100644 index 000000000..65c334029 --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/method_list.html @@ -0,0 +1,615 @@ + + + + + + + + + + + + + + + + + Method List + + + + +
+

Method List

+ + + + +
+ + diff --git a/source/documentation/3.1/rspec-mocks/top-level-namespace.html b/source/documentation/3.1/rspec-mocks/top-level-namespace.html new file mode 100644 index 000000000..44209da6d --- /dev/null +++ b/source/documentation/3.1/rspec-mocks/top-level-namespace.html @@ -0,0 +1,140 @@ + + + + + + Top Level Namespace + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Top Level Namespace + + + +

+ +
+ + + + + +
Includes:
+
RSpec::Mocks::ExampleMethods
+ + + + + +
+
+ +

Defined Under Namespace

+

+ + + Modules: RSpec + + + + Classes: BasicObject, Class + + +

+ + + + + + + + + + + + + + +

Method Summary

+ +

Methods included from RSpec::Mocks::ExampleMethods

+

#allow, #allow_any_instance_of, #allow_message_expectations_on_nil, #class_double, #class_spy, #double, #expect, #expect_any_instance_of, #have_received, #hide_const, #instance_double, #instance_spy, #object_double, #object_spy, #receive, #receive_message_chain, #receive_messages, #spy, #stub_const

+ + + + + + + + + +

Methods included from RSpec::Mocks::ArgumentMatchers

+

#any_args, #anything, #array_including, #boolean, #duck_type, #hash_excluding, #hash_including, #instance_of, #kind_of, #no_args

+ + +
+ + + + + \ No newline at end of file From 5e8129d06d0fba95ab247decf6b30970bf4c1c2e Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 18 Dec 2014 09:42:38 +1100 Subject: [PATCH 2/2] 3.0 documentation --- .../documentation/3.0/rspec-core/RSpec.html | 580 ++ .../3.0/rspec-core/RSpec/Core.html | 153 + .../rspec-core/RSpec/Core/Configuration.html | 6281 +++++++++++++++++ .../RSpec/Core/ConfigurationOptions.html | 530 ++ .../3.0/rspec-core/RSpec/Core/DSL.html | 322 + .../3.0/rspec-core/RSpec/Core/Example.html | 1349 ++++ .../RSpec/Core/Example/ExecutionResult.html | 957 +++ .../rspec-core/RSpec/Core/Example/Procsy.html | 324 + .../rspec-core/RSpec/Core/ExampleGroup.html | 3627 ++++++++++ .../3.0/rspec-core/RSpec/Core/Formatters.html | 354 + .../RSpec/Core/Formatters/BaseFormatter.html | 1629 +++++ .../Core/Formatters/BaseTextFormatter.html | 524 ++ .../RSpec/Core/Formatters/ConsoleCodes.html | 387 + .../RSpec/Core/Formatters/Helpers.html | 533 ++ .../RSpec/Core/Formatters/Loader.html | 601 ++ .../Core/Formatters/ProfileFormatter.html | 316 + .../Core/Formatters/SnippetExtractor.html | 681 ++ .../3.0/rspec-core/RSpec/Core/Hooks.html | 1233 ++++ .../RSpec/Core/MemoizedHelpers.html | 603 ++ .../Core/MemoizedHelpers/ClassMethods.html | 690 ++ .../3.0/rspec-core/RSpec/Core/Metadata.html | 287 + .../rspec-core/RSpec/Core/MetadataFilter.html | 128 + .../rspec-core/RSpec/Core/Notifications.html | 127 + .../DeprecationNotification.html | 498 ++ .../Notifications/ExampleNotification.html | 248 + .../Notifications/ExamplesNotification.html | 861 +++ .../FailedExampleNotification.html | 937 +++ .../Core/Notifications/GroupNotification.html | 245 + .../Notifications/MessageNotification.html | 233 + .../Core/Notifications/NullNotification.html | 133 + .../PendingExampleFixedNotification.html | 550 ++ .../Notifications/ProfileNotification.html | 410 ++ .../Core/Notifications/SeedNotification.html | 321 + .../Core/Notifications/StartNotification.html | 322 + .../Notifications/SummaryNotification.html | 586 ++ .../3.0/rspec-core/RSpec/Core/Pending.html | 473 ++ .../Core/Pending/SkipDeclaredInExample.html | 299 + .../3.0/rspec-core/RSpec/Core/RakeTask.html | 870 +++ .../3.0/rspec-core/RSpec/Core/Reporter.html | 468 ++ .../3.0/rspec-core/RSpec/Core/Runner.html | 929 +++ .../rspec-core/RSpec/Core/SharedContext.html | 136 + .../RSpec/Core/SharedExampleGroup.html | 457 ++ .../Core/SharedExampleGroup/TopLevelDSL.html | 295 + .../3.0/rspec-core/RSpec/Core/Version.html | 139 + .../3.0/rspec-core/RSpec/Core/World.html | 983 +++ .../documentation/3.0/rspec-core/_index.html | 550 ++ .../3.0/rspec-core/class_list.html | 58 + .../3.0/rspec-core/file.Changelog.html | 2368 +++++++ .../3.0/rspec-core/file.License.html | 73 + .../3.0/rspec-core/file.README.html | 315 + .../3.0/rspec-core/file_list.html | 66 + .../documentation/3.0/rspec-core/frames.html | 26 + .../documentation/3.0/rspec-core/index.html | 315 + .../3.0/rspec-core/method_list.html | 1623 +++++ .../3.0/rspec-core/top-level-namespace.html | 112 + .../3.0/rspec-expectations/BasicObject.html | 392 + .../3.0/rspec-expectations/RSpec.html | 128 + .../RSpec/Expectations.html | 436 ++ .../RSpec/Expectations/Configuration.html | 732 ++ .../RSpec/Expectations/ExpectationTarget.html | 515 ++ .../RSpec/Expectations/Syntax.html | 838 +++ .../rspec-expectations/RSpec/Matchers.html | 3655 ++++++++++ .../RSpec/Matchers/AliasedMatcher.html | 394 ++ .../RSpec/Matchers/BuiltIn.html | 133 + .../RSpec/Matchers/BuiltIn/All.html | 435 ++ .../RSpec/Matchers/BuiltIn/BaseMatcher.html | 868 +++ .../RSpec/Matchers/BuiltIn/Be.html | 431 ++ .../RSpec/Matchers/BuiltIn/BeAKindOf.html | 185 + .../Matchers/BuiltIn/BeAnInstanceOf.html | 280 + .../RSpec/Matchers/BuiltIn/BeBetween.html | 673 ++ .../RSpec/Matchers/BuiltIn/BeComparedTo.html | 601 ++ .../RSpec/Matchers/BuiltIn/BeFalsey.html | 358 + .../RSpec/Matchers/BuiltIn/BeNil.html | 358 + .../RSpec/Matchers/BuiltIn/BePredicate.html | 677 ++ .../RSpec/Matchers/BuiltIn/BeTruthy.html | 358 + .../RSpec/Matchers/BuiltIn/BeWithin.html | 613 ++ .../RSpec/Matchers/BuiltIn/Change.html | 808 +++ .../Matchers/BuiltIn/ChangeFromValue.html | 316 + .../Matchers/BuiltIn/ChangeRelatively.html | 239 + .../RSpec/Matchers/BuiltIn/ChangeToValue.html | 316 + .../RSpec/Matchers/BuiltIn/Compound.html | 362 + .../RSpec/Matchers/BuiltIn/Compound/And.html | 300 + .../RSpec/Matchers/BuiltIn/Compound/Or.html | 288 + .../Matchers/BuiltIn/ContainExactly.html | 454 ++ .../RSpec/Matchers/BuiltIn/Cover.html | 429 ++ .../RSpec/Matchers/BuiltIn/EndWith.html | 198 + .../RSpec/Matchers/BuiltIn/Eq.html | 514 ++ .../RSpec/Matchers/BuiltIn/Eql.html | 436 ++ .../RSpec/Matchers/BuiltIn/Equal.html | 458 ++ .../RSpec/Matchers/BuiltIn/Exist.html | 599 ++ .../Matchers/BuiltIn/Exist/ExistenceTest.html | 583 ++ .../RSpec/Matchers/BuiltIn/Has.html | 474 ++ .../RSpec/Matchers/BuiltIn/Include.html | 743 ++ .../RSpec/Matchers/BuiltIn/Match.html | 358 + .../Matchers/BuiltIn/OperatorMatcher.html | 304 + .../RSpec/Matchers/BuiltIn/Output.html | 963 +++ .../RSpec/Matchers/BuiltIn/RaiseError.html | 555 ++ .../RSpec/Matchers/BuiltIn/RespondTo.html | 626 ++ .../RSpec/Matchers/BuiltIn/Satisfy.html | 474 ++ .../BuiltIn/SpecificValuesChange.html | 244 + .../Matchers/BuiltIn/StartAndEndWith.html | 445 ++ .../RSpec/Matchers/BuiltIn/StartWith.html | 198 + .../RSpec/Matchers/BuiltIn/ThrowSymbol.html | 638 ++ .../RSpec/Matchers/BuiltIn/YieldControl.html | 815 +++ .../Matchers/BuiltIn/YieldSuccessiveArgs.html | 318 + .../RSpec/Matchers/BuiltIn/YieldWithArgs.html | 234 + .../Matchers/BuiltIn/YieldWithNoArgs.html | 185 + .../RSpec/Matchers/Composable.html | 779 ++ .../Matchers/Composable/DescribableItem.html | 137 + .../RSpec/Matchers/DSL.html | 224 + .../Matchers/DSL/DefaultImplementations.html | 485 ++ .../RSpec/Matchers/DSL/Macros.html | 977 +++ .../RSpec/Matchers/DSL/Macros/Deprecated.html | 402 ++ .../RSpec/Matchers/DSL/Matcher.html | 910 +++ .../RSpec/Matchers/Pretty.html | 446 ++ .../3.0/rspec-expectations/_index.html | 634 ++ .../3.0/rspec-expectations/class_list.html | 54 + .../rspec-expectations/file.Changelog.html | 1030 +++ .../3.0/rspec-expectations/file.License.html | 73 + .../3.0/rspec-expectations/file.README.html | 338 + .../3.0/rspec-expectations/file_list.html | 62 + .../3.0/rspec-expectations/frames.html | 26 + .../3.0/rspec-expectations/index.html | 338 + .../3.0/rspec-expectations/method_list.html | 1565 ++++ .../top-level-namespace.html | 129 + .../3.0/rspec-mocks/BasicObject.html | 720 ++ .../documentation/3.0/rspec-mocks/Class.html | 271 + .../documentation/3.0/rspec-mocks/RSpec.html | 129 + .../3.0/rspec-mocks/RSpec/Mocks.html | 860 +++ .../RSpec/Mocks/ArgumentListMatcher.html | 397 ++ .../RSpec/Mocks/ArgumentMatchers.html | 918 +++ .../RSpec/Mocks/Configuration.html | 1234 ++++ .../3.0/rspec-mocks/RSpec/Mocks/Constant.html | 953 +++ .../RSpec/Mocks/ConstantMutator.html | 538 ++ .../3.0/rspec-mocks/RSpec/Mocks/Double.html | 157 + .../RSpec/Mocks/ExampleMethods.html | 1973 ++++++ .../Mocks/ExampleMethods/ExpectHost.html | 117 + .../3.0/rspec-mocks/RSpec/Mocks/Matchers.html | 118 + .../3.0/rspec-mocks/RSpec/Mocks/Syntax.html | 929 +++ .../rspec-mocks/RSpec/Mocks/TestDouble.html | 613 ++ .../Mocks/VerifyingMessageExpectation.html | 324 + .../3.0/rspec-mocks/RSpec/Mocks/Version.html | 139 + .../documentation/3.0/rspec-mocks/_index.html | 299 + .../3.0/rspec-mocks/class_list.html | 58 + .../3.0/rspec-mocks/file.Changelog.html | 1217 ++++ .../3.0/rspec-mocks/file.License.html | 73 + .../3.0/rspec-mocks/file.README.html | 453 ++ .../3.0/rspec-mocks/file_list.html | 66 + .../documentation/3.0/rspec-mocks/frames.html | 26 + .../documentation/3.0/rspec-mocks/index.html | 453 ++ .../3.0/rspec-mocks/method_list.html | 609 ++ .../3.0/rspec-mocks/top-level-namespace.html | 140 + 152 files changed, 87442 insertions(+) create mode 100644 source/documentation/3.0/rspec-core/RSpec.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Configuration.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/ConfigurationOptions.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/DSL.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Example.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Example/ExecutionResult.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Example/Procsy.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/ExampleGroup.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseFormatter.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Helpers.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Loader.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Hooks.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Metadata.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/MetadataFilter.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExampleNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/GroupNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/MessageNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/NullNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ProfileNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SeedNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/StartNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SummaryNotification.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Pending.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/RakeTask.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Reporter.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Runner.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/SharedContext.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/Version.html create mode 100644 source/documentation/3.0/rspec-core/RSpec/Core/World.html create mode 100644 source/documentation/3.0/rspec-core/_index.html create mode 100644 source/documentation/3.0/rspec-core/class_list.html create mode 100644 source/documentation/3.0/rspec-core/file.Changelog.html create mode 100644 source/documentation/3.0/rspec-core/file.License.html create mode 100644 source/documentation/3.0/rspec-core/file.README.html create mode 100644 source/documentation/3.0/rspec-core/file_list.html create mode 100644 source/documentation/3.0/rspec-core/frames.html create mode 100644 source/documentation/3.0/rspec-core/index.html create mode 100644 source/documentation/3.0/rspec-core/method_list.html create mode 100644 source/documentation/3.0/rspec-core/top-level-namespace.html create mode 100644 source/documentation/3.0/rspec-expectations/BasicObject.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Expectations.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Expectations/Configuration.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Expectations/ExpectationTarget.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Expectations/Syntax.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/AliasedMatcher.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/All.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Matcher.html create mode 100644 source/documentation/3.0/rspec-expectations/RSpec/Matchers/Pretty.html create mode 100644 source/documentation/3.0/rspec-expectations/_index.html create mode 100644 source/documentation/3.0/rspec-expectations/class_list.html create mode 100644 source/documentation/3.0/rspec-expectations/file.Changelog.html create mode 100644 source/documentation/3.0/rspec-expectations/file.License.html create mode 100644 source/documentation/3.0/rspec-expectations/file.README.html create mode 100644 source/documentation/3.0/rspec-expectations/file_list.html create mode 100644 source/documentation/3.0/rspec-expectations/frames.html create mode 100644 source/documentation/3.0/rspec-expectations/index.html create mode 100644 source/documentation/3.0/rspec-expectations/method_list.html create mode 100644 source/documentation/3.0/rspec-expectations/top-level-namespace.html create mode 100644 source/documentation/3.0/rspec-mocks/BasicObject.html create mode 100644 source/documentation/3.0/rspec-mocks/Class.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/Configuration.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/Constant.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/ConstantMutator.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/Double.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/Matchers.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/Syntax.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/TestDouble.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html create mode 100644 source/documentation/3.0/rspec-mocks/RSpec/Mocks/Version.html create mode 100644 source/documentation/3.0/rspec-mocks/_index.html create mode 100644 source/documentation/3.0/rspec-mocks/class_list.html create mode 100644 source/documentation/3.0/rspec-mocks/file.Changelog.html create mode 100644 source/documentation/3.0/rspec-mocks/file.License.html create mode 100644 source/documentation/3.0/rspec-mocks/file.README.html create mode 100644 source/documentation/3.0/rspec-mocks/file_list.html create mode 100644 source/documentation/3.0/rspec-mocks/frames.html create mode 100644 source/documentation/3.0/rspec-mocks/index.html create mode 100644 source/documentation/3.0/rspec-mocks/method_list.html create mode 100644 source/documentation/3.0/rspec-mocks/top-level-namespace.html diff --git a/source/documentation/3.0/rspec-core/RSpec.html b/source/documentation/3.0/rspec-core/RSpec.html new file mode 100644 index 000000000..c76615287 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec.html @@ -0,0 +1,580 @@ + + + + + + Module: RSpec + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core.rb,
+ lib/rspec/core/dsl.rb,
lib/rspec/core/drb.rb,
lib/rspec/core/hooks.rb,
lib/rspec/core/world.rb,
lib/rspec/core/runner.rb,
lib/rspec/core/example.rb,
lib/rspec/core/pending.rb,
lib/rspec/core/version.rb,
lib/rspec/core/metadata.rb,
lib/rspec/core/warnings.rb,
lib/rspec/core/ordering.rb,
lib/rspec/core/flat_map.rb,
lib/rspec/core/rake_task.rb,
lib/rspec/core/ruby_project.rb,
lib/rspec/core/configuration.rb,
lib/rspec/core/example_group.rb,
lib/rspec/core/filter_manager.rb,
lib/rspec/core/shared_context.rb,
lib/rspec/core/metadata_filter.rb,
lib/rspec/core/backport_random.rb,
lib/rspec/core/memoized_helpers.rb,
lib/rspec/core/formatters/helpers.rb,
lib/rspec/core/backtrace_formatter.rb,
lib/rspec/core/mocking_adapters/rr.rb,
lib/rspec/core/project_initializer.rb,
lib/rspec/core/shared_example_group.rb,
lib/rspec/core/mocking_adapters/null.rb,
lib/rspec/core/configuration_options.rb,
lib/rspec/core/mocking_adapters/rspec.rb,
lib/rspec/core/mocking_adapters/mocha.rb,
lib/rspec/core/formatters/html_printer.rb,
lib/rspec/core/formatters/console_codes.rb,
lib/rspec/core/formatters/base_formatter.rb,
lib/rspec/core/mocking_adapters/flexmock.rb,
lib/rspec/core/formatters/html_formatter.rb,
lib/rspec/core/formatters/json_formatter.rb,
lib/rspec/core/minitest_assertions_adapter.rb,
lib/rspec/core/formatters/snippet_extractor.rb,
lib/rspec/core/test_unit_assertions_adapter.rb,
lib/rspec/core/formatters/profile_formatter.rb,
lib/rspec/core/formatters/progress_formatter.rb,
lib/rspec/core/formatters/base_text_formatter.rb,
lib/rspec/core/formatters/deprecation_formatter.rb,
lib/rspec/core/formatters/documentation_formatter.rb
+
+ +
+
+ +

Overview

+
+ +

Namespace for all core RSpec code.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Core + + + + +

+ +

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + + + + + + + +
+

Class Method Details

+ + +
+

+ + + (void) configuration + + + + + +

+
+ +

Returns the global Configuration +object. While you can use this method to access the configuration, +the more common convention is to use RSpec.configure.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configuration.drb_port = 1234
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+61
+62
+63
+64
+65
+66
+67
+68
+
+
# File 'lib/rspec/core.rb', line 61
+
+def self.configuration
+  @configuration ||= begin
+                       config = RSpec::Core::Configuration.new
+                       config.expose_dsl_globally = true
+                       config
+                     end
+
+end
+
+
+ +
+

+ + + (void) configure {|Configuration| ... } + + + + + +

+
+ +

Yields the global configuration to a block.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.add_formatter 'documentation'
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Configuration) + + + + — +
    +

    global configuration

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+78
+79
+80
+
+
# File 'lib/rspec/core.rb', line 78
+
+def self.configure
+  yield configuration if block_given?
+end
+
+
+ +
+

+ + + (void) current_example + + + + + +

+
+ +

The example being executed.

+ +

The primary audience for this method is library authors who need access to +the example currently being executed and also want to support all versions +of RSpec 2 and 3.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |c|
+  # context.example is deprecated, but RSpec.current_example is not
+  # available until RSpec 3.0.
+  fetch_current_example = RSpec.respond_to?(:current_example) ?
+    proc { RSpec.current_example } : proc { |context| context.example }
+
+  c.before(:example) do
+    example = fetch_current_example.call(self)
+
+    # ...
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+103
+104
+105
+
+
# File 'lib/rspec/core.rb', line 103
+
+def self.current_example
+  [:current_example]
+end
+
+
+ +
+

+ + + (void) current_example=(example) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Set the current example being executed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+109
+110
+111
+
+
# File 'lib/rspec/core.rb', line 109
+
+def self.current_example=(example)
+  [:current_example] = example
+end
+
+
+ +
+

+ + + (void) reset + + + + + +

+
+ +

Used to ensure examples get reloaded between multiple runs in the same +process.

+ +

Users must invoke this if they want to have the configuration reset when +they use runner multiple times within the same process.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+48
+49
+50
+51
+
+
# File 'lib/rspec/core.rb', line 48
+
+def self.reset
+  @world = nil
+  @configuration = nil
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core.html b/source/documentation/3.0/rspec-core/RSpec/Core.html new file mode 100644 index 000000000..ce532d9dc --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core.html @@ -0,0 +1,153 @@ + + + + + + Module: RSpec::Core + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core.rb,
+ lib/rspec/core/dsl.rb,
lib/rspec/core/drb.rb,
lib/rspec/core/hooks.rb,
lib/rspec/core/world.rb,
lib/rspec/core/runner.rb,
lib/rspec/core/example.rb,
lib/rspec/core/pending.rb,
lib/rspec/core/version.rb,
lib/rspec/core/metadata.rb,
lib/rspec/core/warnings.rb,
lib/rspec/core/ordering.rb,
lib/rspec/core/flat_map.rb,
lib/rspec/core/reporter.rb,
lib/rspec/core/rake_task.rb,
lib/rspec/core/ruby_project.rb,
lib/rspec/core/notifications.rb,
lib/rspec/core/configuration.rb,
lib/rspec/core/option_parser.rb,
lib/rspec/core/example_group.rb,
lib/rspec/core/filter_manager.rb,
lib/rspec/core/shared_context.rb,
lib/rspec/core/metadata_filter.rb,
lib/rspec/core/backport_random.rb,
lib/rspec/core/memoized_helpers.rb,
lib/rspec/core/formatters/helpers.rb,
lib/rspec/core/backtrace_formatter.rb,
lib/rspec/core/mocking_adapters/rr.rb,
lib/rspec/core/project_initializer.rb,
lib/rspec/core/shared_example_group.rb,
lib/rspec/core/mocking_adapters/null.rb,
lib/rspec/core/configuration_options.rb,
lib/rspec/core/mocking_adapters/rspec.rb,
lib/rspec/core/mocking_adapters/mocha.rb,
lib/rspec/core/formatters/html_printer.rb,
lib/rspec/core/formatters/console_codes.rb,
lib/rspec/core/formatters/base_formatter.rb,
lib/rspec/core/mocking_adapters/flexmock.rb,
lib/rspec/core/formatters/html_formatter.rb,
lib/rspec/core/formatters/json_formatter.rb,
lib/rspec/core/minitest_assertions_adapter.rb,
lib/rspec/core/formatters/snippet_extractor.rb,
lib/rspec/core/test_unit_assertions_adapter.rb,
lib/rspec/core/formatters/profile_formatter.rb,
lib/rspec/core/formatters/progress_formatter.rb,
lib/rspec/core/formatters/base_text_formatter.rb,
lib/rspec/core/formatters/deprecation_formatter.rb,
lib/rspec/core/formatters/documentation_formatter.rb
+
+ +
+
+ +

Overview

+
+ +

Namespace for the rspec-core code.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: DSL, Formatters, Hooks, MemoizedHelpers, Metadata, MetadataFilter, Notifications, Pending, SharedContext, SharedExampleGroup, Version + + + + Classes: Configuration, ConfigurationOptions, Example, ExampleGroup, RakeTask, Reporter, Runner, World + + +

+ +

Constant Summary

+ +
+ +
DeprecationError = +
+
+ +

Deprecation Error

+ + +
+
+
+ + +
+
+
Class.new(StandardError)
+ +
+ + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Configuration.html b/source/documentation/3.0/rspec-core/RSpec/Core/Configuration.html new file mode 100644 index 000000000..7feeb1e02 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Configuration.html @@ -0,0 +1,6281 @@ + + + + + + Class: RSpec::Core::Configuration + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Configuration + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Hooks
+ + + + + +
Defined in:
+
lib/rspec/core/configuration.rb
+ +
+
+ +

Overview

+
+ +

Stores runtime configuration information.

+ +

Configuration options are loaded from ~/.rspec, +.rspec, .rspec-local, command line switches, and +the SPEC_OPTS environment variable (listed in lowest to +highest precedence; for example, an option in ~/.rspec can be +overridden by an option in .rspec-local).

+ + +
+
+
+ +
+

Examples:

+ + +

+

Standard settings

+

+ +
RSpec.configure do |c|
+  c.drb          = true
+  c.drb_port     = 1234
+  c.default_path = 'behavior'
+end
+ + +

+

Hooks

+

+ +
RSpec.configure do |c|
+  c.before(:suite)   { establish_connection }
+  c.before(:example) {  :authorized }
+  c.around(:example) { |ex| Database.transaction(&ex) }
+end
+ +
+ + +

See Also:

+ + +
+

Constant Summary

+ + + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (void) default_color + + + + + + + + + + + + + + + + +
    +

    The default output color.

    +
    + +
  • + + +
  • + + + - (void) default_path + + + + + + + + + + + + + + + + +
    +

    Path to use if no path is provided to the rspec command +(default: "spec").

    +
    + +
  • + + +
  • + + + - (void) detail_color + + + + + + + + + + + + + + + + +
    +

    Color used to print details.

    +
    + +
  • + + +
  • + + + - (void) drb + + + + + + + + + + + + + + + + +
    +

    Run examples over DRb (default: false).

    +
    + +
  • + + +
  • + + + - (void) drb_port + + + + + + + + + + + + + + + + +
    +

    The drb_port (default: nil).

    +
    + +
  • + + +
  • + + + - (void) dry_run + + + + + + + + + + + + + + + + +
    +

    Prints the formatter output of your suite without running any examples or +hooks.

    +
    + +
  • + + +
  • + + + - (void) error_stream + + + + + + + + + + + + + + + + +
    +

    Default: $stderr.

    +
    + +
  • + + +
  • + + + - (void) fail_fast + + + + + + + + + + + + + + + + +
    +

    Clean up and exit after the first failure (default: false).

    +
    + +
  • + + +
  • + + + - (void) failure_color + + + + + + + + + + + + + + + + +
    +

    Color to use to indicate failure.

    +
    + +
  • + + +
  • + + + - (void) failure_exit_code + + + + + + + + + + + + + + + + +
    +

    The exit code to return if there are any failures (default: 1).

    +
    + +
  • + + +
  • + + + - (Array) files_to_run + + + + + + + + + readonly + + + + + + + + + +
    +

    The spec files RSpec will run.

    +
    + +
  • + + +
  • + + + - (void) fixed_color + + + + + + + + + + + + + + + + +
    +

    Color used when a pending example is fixed.

    +
    + +
  • + + +
  • + + + - (void) libs + + + + + + + + + readonly + + + + + + + + + +
    +

    Returns dirs that have been prepended to the load path by the +-I command line option.

    +
    + +
  • + + +
  • + + + - (void) output_stream + + + + + + + + + + + + + + + + +
    +

    Determines where RSpec will send its output.

    +
    + +
  • + + +
  • + + + - (void) pattern + + + + + + + + + + + + + + + + +
    +

    Load files matching this pattern (default: +'**/*_spec.rb').

    +
    + +
  • + + +
  • + + + - (void) pending_color + + + + + + + + + + + + + + + + +
    +

    Color to use to print pending examples.

    +
    + +
  • + + +
  • + + + - (void) profile_examples + + + + + + + + + + + + + + private + + +
    +

    Defaults profile_examples to 10 examples when +@profile_examples is true.

    +
    + +
  • + + +
  • + + + - (void) requires + + + + + + + + + readonly + + + + + + + + + +
    +

    Indicates files configured to be required.

    +
    + +
  • + + +
  • + + + - (void) run_all_when_everything_filtered + + + + + + + + + + + + + + + + +
    +

    Run all examples if none match the configured filters (default: +false).

    +
    + +
  • + + +
  • + + + - (void) success_color + + + + + + + + + + + + + + + + +
    +

    Color to use to indicate success.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Hooks

+

#after, #append_after, #around, #before, #prepend_before

+
+

Constructor Details

+ +
+

+ + - (Configuration) initialize + + + + + +

+
+ +

Returns a new instance of Configuration

+ + +
+
+
+ + +
+ + + + +
+
+
+
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+
+
# File 'lib/rspec/core/configuration.rb', line 275
+
+def initialize
+  @start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
+  @expectation_frameworks = []
+  @include_or_extend_modules = []
+  @mock_framework = nil
+  @files_or_directories_to_run = []
+  @color = false
+  @pattern = '**/*_spec.rb'
+  @failure_exit_code = 1
+  @spec_files_loaded = false
+
+  @backtrace_formatter = BacktraceFormatter.new
+
+  @default_path = 'spec'
+  @deprecation_stream = $stderr
+  @output_stream = $stdout
+  @reporter = nil
+  @reporter_buffer = nil
+  @filter_manager = FilterManager.new
+  @ordering_manager = Ordering::ConfigurationManager.new
+  @preferred_options = {}
+  @failure_color = :red
+  @success_color = :green
+  @pending_color = :yellow
+  @default_color = :white
+  @fixed_color = :blue
+  @detail_color = :cyan
+  @profile_examples = false
+  @requires = []
+  @libs = []
+  @derived_metadata_blocks = []
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) default_color + + + + + +

+
+ +

The default output color.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :white but can be set to one of the +following:[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+234
+
+
# File 'lib/rspec/core/configuration.rb', line 234
+
+add_setting :default_color
+
+
+ + + +
+

+ + - (void) default_path + + + + + +

+
+ +

Path to use if no path is provided to the rspec command +(default: "spec"). Allows you to just type +rspec instead of rspec spec to run all the +examples in the spec directory.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+92
+
+
# File 'lib/rspec/core/configuration.rb', line 92
+
+add_setting :default_path
+
+
+ + + +
+

+ + - (void) detail_color + + + + + +

+
+ +

Color used to print details.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :cyan but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+248
+
+
# File 'lib/rspec/core/configuration.rb', line 248
+
+add_setting :detail_color
+
+
+ + + +
+

+ + - (void) drb + + + + + +

+
+ +

Run examples over DRb (default: false). RSpec doesn't +supply the DRb server, but you can use tools like spork.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+97
+
+
# File 'lib/rspec/core/configuration.rb', line 97
+
+add_setting :drb
+
+
+ + + +
+

+ + - (void) drb_port + + + + + +

+
+ +

The drb_port (default: nil).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+101
+
+
# File 'lib/rspec/core/configuration.rb', line 101
+
+add_setting :drb_port
+
+
+ + + +
+

+ + - (void) dry_run + + + + + +

+
+ +

Prints the formatter output of your suite without running any examples or +hooks.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+153
+
+
# File 'lib/rspec/core/configuration.rb', line 153
+
+add_setting :dry_run
+
+
+ + + +
+

+ + - (void) error_stream + + + + + +

+
+ +

Default: $stderr.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+105
+
+
# File 'lib/rspec/core/configuration.rb', line 105
+
+add_setting :error_stream
+
+
+ + + +
+

+ + - (void) fail_fast + + + + + +

+
+ +

Clean up and exit after the first failure (default: false).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+148
+
+
# File 'lib/rspec/core/configuration.rb', line 148
+
+add_setting :fail_fast
+
+
+ + + +
+

+ + - (void) failure_color + + + + + +

+
+ +

Color to use to indicate failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :red but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+227
+
+
# File 'lib/rspec/core/configuration.rb', line 227
+
+add_setting :failure_color
+
+
+ + + +
+

+ + - (void) failure_exit_code + + + + + +

+
+ +

The exit code to return if there are any failures (default: 1).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+157
+
+
# File 'lib/rspec/core/configuration.rb', line 157
+
+add_setting :failure_exit_code
+
+
+ + + +
+

+ + - (Array) files_to_run + + + + + +

+
+ +

The spec files RSpec will run

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    specified files about to run

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+720
+721
+722
+
+
# File 'lib/rspec/core/configuration.rb', line 720
+
+def files_to_run
+  @files_to_run ||= get_files_to_run(@files_or_directories_to_run)
+end
+
+
+ + + +
+

+ + - (void) fixed_color + + + + + +

+
+ +

Color used when a pending example is fixed.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :blue but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+241
+
+
# File 'lib/rspec/core/configuration.rb', line 241
+
+add_setting :fixed_color
+
+
+ + + +
+

+ + - (void) libs + + + + + +

+
+ +

Returns dirs that have been prepended to the load path by the +-I command line option

+ + +
+
+
+ + +
+ + + + +
+
+
+
+165
+
+
# File 'lib/rspec/core/configuration.rb', line 165
+
+define_reader :libs
+
+
+ + + +
+

+ + - (void) output_stream + + + + + +

+
+ +

Determines where RSpec will send its output. Default: $stdout.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+170
+
+
# File 'lib/rspec/core/configuration.rb', line 170
+
+define_reader :output_stream
+
+
+ + + +
+

+ + - (void) pattern + + + + + +

+
+ +

Load files matching this pattern (default: +'**/*_spec.rb')

+ + +
+
+
+ + +
+ + + + +
+
+
+
+187
+
+
# File 'lib/rspec/core/configuration.rb', line 187
+
+define_reader :pattern
+
+
+ + + +
+

+ + - (void) pending_color + + + + + +

+
+ +

Color to use to print pending examples.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :yellow but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+220
+
+
# File 'lib/rspec/core/configuration.rb', line 220
+
+add_setting :pending_color
+
+
+ + + +
+

+ + - (void) profile_examples + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Defaults profile_examples to 10 examples when +@profile_examples is true.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+202
+
+
# File 'lib/rspec/core/configuration.rb', line 202
+
+add_setting :profile_examples
+
+
+ + + +
+

+ + - (void) requires + + + + + +

+
+ +

Indicates files configured to be required

+ + +
+
+
+ + +
+ + + + +
+
+
+
+161
+
+
# File 'lib/rspec/core/configuration.rb', line 161
+
+define_reader :requires
+
+
+ + + +
+

+ + - (void) run_all_when_everything_filtered + + + + + +

+
+ +

Run all examples if none match the configured filters (default: +false).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+206
+
+
# File 'lib/rspec/core/configuration.rb', line 206
+
+add_setting :run_all_when_everything_filtered
+
+
+ + + +
+

+ + - (void) success_color + + + + + +

+
+ +

Color to use to indicate success.

+ + +
+
+
+

Parameters:

+
    + +
  • + + color + + + (Symbol) + + + + — +
    +

    defaults to :green but can be set to one of the following: +[:black, :white, :red, :green, :yellow, :blue, :magenta, +:cyan]

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+213
+
+
# File 'lib/rspec/core/configuration.rb', line 213
+
+add_setting :success_color
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) add_formatter(formatter) + + + + Also known as: + formatter= + + + + +

+
+ +

Adds a formatter to the formatters collection. formatter can +be a string representing any of the built-in formatters (see +built_in_formatter), or a custom formatter class.

+ +

Note

+ +

For internal purposes, add_formatter also accepts the name of +a class and paths to use for output streams, but you should consider that a +private api that may change at any time without notice.

+ + +
+
+
+ + + + +
+ + + + +
+
+
+
+623
+624
+625
+626
+
+
# File 'lib/rspec/core/configuration.rb', line 623
+
+def add_formatter(formatter_to_use, *paths)
+  paths << output_stream if paths.empty?
+  formatter_loader.add formatter_to_use, *paths
+end
+
+
+ +
+

+ + + - (void) add_setting(name) + + - (void) add_setting(name, opts) + + + + + + +

+
+ +

Adds a custom setting to the RSpec.configuration object.

+ +
RSpec.configuration.add_setting :foo
+ +

Used internally and by extension frameworks like rspec-rails, so they can +add config settings that are domain specific. For example:

+ +
RSpec.configure do |c|
+  c.add_setting :use_transactional_fixtures,
+    :default => true,
+    :alias_with => :use_transactional_examples
+end
+
+ +

add_setting creates three methods on the configuration object, +a setter, a getter, and a predicate:

+ +
RSpec.configuration.foo=(value)
+RSpec.configuration.foo
+RSpec.configuration.foo? # returns true if foo returns anything but nil or false
+ + +
+
+
+

Parameters:

+
    + +
  • + + opts + + + (Hash) + + + (defaults to: {}) + + + — +
    +

    a customizable set of options

    +
    + +
  • + +
+ + + + + + +

Options Hash (opts):

+
    + +
  • + :default + (Symbol) + + + + + —
    +

    set a default value for the generated getter and predicate methods:

    + +
    add_setting(:foo, :default => "default value")
    +
    +
    + +
  • + +
  • + :alias_with + (Symbol) + + + + + —
    +

    Use :alias_with to alias the setter, getter, and predicate to +another name, or names:

    + +
    add_setting(:foo, :alias_with => :bar)
    +add_setting(:foo, :alias_with => [:bar, :baz])
    +
    +
    + +
  • + +
+ + + +
+ + + + +
+
+
+
+358
+359
+360
+361
+362
+363
+364
+
+
# File 'lib/rspec/core/configuration.rb', line 358
+
+def add_setting(name, opts={})
+  default = opts.delete(:default)
+  (class << self; self; end).class_exec do
+    add_setting(name, opts)
+  end
+  __send__("#{name}=", default) if default
+end
+
+
+ +
+

+ + - (void) alias_example_group_to(new_name, *args) + + + + + +

+
+ +
+ Note: +
+

The defined aliased will also be added to the top level (e.g. +main and from within modules) if +expose_dsl_globally is set to true.

+
+
+ + +

Creates a method that defines an example group with the provided metadata. +Can be used to define example group/metadata shortcuts.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.alias_example_group_to :describe_model, :type => :model
+end
+
+shared_context_for "model tests", :type => :model do
+  # define common model test helper methods, `let` declarations, etc
+end
+
+# This lets you do this:
+
+RSpec.describe_model User do
+end
+
+# ... which is the equivalent of
+
+RSpec.describe User, :type => :model do
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+788
+789
+790
+791
+
+
# File 'lib/rspec/core/configuration.rb', line 788
+
+def alias_example_group_to(new_name, *args)
+  extra_options = Metadata.build_hash_from(args)
+  RSpec::Core::ExampleGroup.define_example_group_method(new_name, extra_options)
+end
+
+
+ +
+

+ + - (void) alias_example_to(name, *args) + + + + + +

+
+ +
+ Note: +
+

The specific example alias below (pending) is already defined +for you.

+
+
+ +
+ Note: +
+

Use with caution. This extends the language used in your specs, but does +not add any additional documentation. We use this in rspec to define +methods like focus and xit, but we also add docs +for those methods.

+
+
+ + +

Creates a method that delegates to example including the +submitted args. Used internally to add variants of +example like pending:

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.alias_example_to :pending, :pending => true
+end
+
+# This lets you do this:
+
+describe Thing do
+  pending "does something" do
+    thing = Thing.new
+  end
+end
+
+# ... which is the equivalent of
+
+describe Thing do
+  it "does something", :pending => true do
+    thing = Thing.new
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    example name alias

    +
    + +
  • + +
  • + + args + + + (Array<Symbol>, Hash) + + + + — +
    +

    metadata for the generated example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+756
+757
+758
+759
+
+
# File 'lib/rspec/core/configuration.rb', line 756
+
+def alias_example_to(name, *args)
+  extra_options = Metadata.build_hash_from(args)
+  RSpec::Core::ExampleGroup.define_example_method(name, extra_options)
+end
+
+
+ +
+

+ + - (void) alias_it_behaves_like_to(new_name, report_label = '') + + + + Also known as: + alias_it_should_behave_like_to + + + + +

+
+ +
+ Note: +
+

Use with caution. This extends the language used in your specs, but does +not add any additional documentation. We use this in rspec to define +it_should_behave_like (for backward compatibility), but we +also add docs for that method.

+
+
+ + +

Define an alias for it_should_behave_like that allows different language +(like “it_has_behavior” or “it_behaves_like”) to be employed when including +shared examples.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  config.alias_it_behaves_like_to(:it_has_behavior, 'has behavior:')
+end
+
+# allows the user to include a shared example group like:
+
+describe Entity do
+  it_has_behavior 'sortability' do
+    let(:sortable) { Entity.new }
+  end
+end
+
+# which is reported in the output as:
+# Entity
+#   has behavior: sortability
+#     ...sortability examples here
+ +
+ + +
+ + + + +
+
+
+
+819
+820
+821
+
+
# File 'lib/rspec/core/configuration.rb', line 819
+
+def alias_it_behaves_like_to(new_name, report_label = '')
+  RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label)
+end
+
+
+ +
+

+ + - (void) backtrace_exclusion_patterns + + + + + +

+
+ +

Regexps used to exclude lines from backtraces.

+ +

Excludes lines from ruby (and jruby) source, installed gems, anything in +any “bin” directory, and any of the rspec libs (outside gem installs) by +default.

+ +

You can modify the list via the getter, or replace it with the setter.

+ +

To override this behaviour and display a full backtrace, use +--backtraceon the command line, in a .rspec file, +or in the rspec_options attribute of RSpec's rake task.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+388
+389
+390
+
+
# File 'lib/rspec/core/configuration.rb', line 388
+
+def backtrace_exclusion_patterns
+  @backtrace_formatter.exclusion_patterns
+end
+
+
+ +
+

+ + - (void) backtrace_exclusion_patterns=(patterns) + + + + + +

+
+ +

Set regular expressions used to exclude lines in backtrace

+ + +
+
+
+

Parameters:

+
    + +
  • + + patterns + + + (Regexp) + + + + — +
    +

    set the backtrace exlusion pattern

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+394
+395
+396
+
+
# File 'lib/rspec/core/configuration.rb', line 394
+
+def backtrace_exclusion_patterns=(patterns)
+  @backtrace_formatter.exclusion_patterns = patterns
+end
+
+
+ +
+

+ + - (void) backtrace_inclusion_patterns + + + + + +

+
+ +

Regexps used to include lines in backtraces.

+ +

Defaults to [Regexp.new Dir.getwd].

+ +

Lines that match an exclusion and an inclusion pattern will be +included.

+ +

You can modify the list via the getter, or replace it with the setter.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+406
+407
+408
+
+
# File 'lib/rspec/core/configuration.rb', line 406
+
+def backtrace_inclusion_patterns
+  @backtrace_formatter.inclusion_patterns
+end
+
+
+ +
+

+ + - (void) backtrace_inclusion_patterns=(patterns) + + + + + +

+
+ +

Set regular expressions used to include lines in backtrace

+ + +
+
+
+ + +
+ + + + +
+
+
+
+412
+413
+414
+
+
# File 'lib/rspec/core/configuration.rb', line 412
+
+def backtrace_inclusion_patterns=(patterns)
+  @backtrace_formatter.inclusion_patterns = patterns
+end
+
+
+ +
+

+ + - (Boolean) color + + + + + +

+
+ +

Returns the configuration option for color, but should not be used to check +if color is supported.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +

See Also:

+
    + +
  • color_enabled?
  • + +
+ +
+ + + + +
+
+
+
+568
+569
+570
+
+
# File 'lib/rspec/core/configuration.rb', line 568
+
+def color
+  value_for(:color, @color)
+end
+
+
+ +
+

+ + - (void) color=(true_or_false) + + + + + +

+
+ +

Toggle output color

+ + +
+
+
+ + +
+ + + + +
+
+
+
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+
+
# File 'lib/rspec/core/configuration.rb', line 582
+
+def color=(true_or_false)
+  if true_or_false
+    if RSpec.world.windows_os? and not ENV['ANSICON']
+      RSpec.warning "You must use ANSICON 1.31 or later (http://adoxa.3eeweb.com/ansicon/) to use colour on Windows"
+      @color = false
+    else
+      @color = true
+    end
+  end
+end
+
+
+ +
+

+ + - (Boolean) color_enabled?(output = output_stream) + + + + + +

+
+ +

Check if color is enabled for a particular output

+ + +
+
+
+

Parameters:

+
    + +
  • + + output + + + (IO) + + + (defaults to: output_stream) + + + — +
    +

    an output stream to use, defaults to the current output_stream

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+576
+577
+578
+
+
# File 'lib/rspec/core/configuration.rb', line 576
+
+def color_enabled?(output = output_stream)
+  output_to_tty?(output) && color
+end
+
+
+ +
+

+ + - (void) default_formatter + + + + + +

+
+ +

The formatter that will be used if no formatter has been set. Defaults to +'progress'.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+631
+632
+633
+
+
# File 'lib/rspec/core/configuration.rb', line 631
+
+def default_formatter
+  formatter_loader.default_formatter
+end
+
+
+ +
+

+ + - (void) default_formatter=(value) + + + + + +

+
+ +

Sets a fallback formatter to use if none other has been set.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.default_formatter = 'doc'
+end
+ +
+ + +
+ + + + +
+
+
+
+642
+643
+644
+
+
# File 'lib/rspec/core/configuration.rb', line 642
+
+def default_formatter=(value)
+  formatter_loader.default_formatter = value
+end
+
+
+ +
+

+ + - (void) define_derived_metadata(*filters) {|metadata| ... } + + + + + +

+
+ +

Defines a callback that can assign derived metadata values.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |config|
+  # Tag all groups and examples in the spec/unit directory with :type => :unit
+  config.(:file_path => %r{/spec/unit/}) do ||
+    [:type] = :unit
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + filters + + + (Array<Symbol>, Hash) + + + + — +
    +

    metadata filters that determine which example or group metadata hashes the +callback will be triggered for. If none are given, the callback will be run +against the metadata hashes of all groups and examples.

    +
    + +
  • + +
+ +

Yield Parameters:

+
    + +
  • + + metadata + + + (Hash) + + + + — +
    +

    original metadata hash from an example or group. Mutate this in your block +as needed.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+1264
+1265
+1266
+1267
+
+
# File 'lib/rspec/core/configuration.rb', line 1264
+
+def (*filters, &block)
+  meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
+  @derived_metadata_blocks << [meta, block]
+end
+
+
+ +
+

+ + - (IO, String) deprecation_stream + + + + + +

+
+ +

Determines where deprecation warnings are printed. Defaults to +$stderr.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (IO, String) + + + + — +
    +

    IO to write to or filename to write to

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+130
+
+
# File 'lib/rspec/core/configuration.rb', line 130
+
+define_reader :deprecation_stream
+
+
+ +
+

+ + - (void) deprecation_stream=(value) + + + + + +

+
+ +

Determines where deprecation warnings are printed.

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + (IO, String) + + + + — +
    +

    IO to write to or filename to write to

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+
+
# File 'lib/rspec/core/configuration.rb', line 134
+
+def deprecation_stream=(value)
+  if @reporter && !value.equal?(@deprecation_stream)
+    warn "RSpec's reporter has already been initialized with " +
+      "#{deprecation_stream.inspect} as the deprecation stream, so your change to "+
+      "`deprecation_stream` will be ignored. You should configure it earlier for " +
+      "it to take effect, or use the `--deprecation-out` CLI option. " +
+      "(Called from #{CallerFilter.first_non_rspec_line})"
+  else
+    @deprecation_stream = value
+  end
+end
+
+
+ +
+

+ + - (void) disable_monkey_patching! + + + + + +

+
+ +
+ Note: +
+

It configures rspec-mocks and rspec-expectations only if the user is using +those (either explicitly or implicitly by not setting +mock_with or expect_with to anything else).

+
+
+ +
+ Note: +
+

If the user uses this options with mock_with :mocha (or +similiar) they will still have monkey patching active in their test +environment from mocha.

+
+
+ + +

Enables zero monkey patching mode for RSpec. It removes monkey patching of +the top-level DSL methods (describe, +shared_examples_for, etc) onto main and +Module, instead requiring you to prefix these methods with +RSpec.. It enables expect-only syntax for rspec-mocks and +rspec-expectations. It simply disables monkey patching on whatever pieces +of rspec the user is using.

+ + +
+
+
+ +
+

Examples:

+ + +

+# It disables all monkey patching
+RSpec.configure do |config|
+  config.disable_monkey_patching!
+end
+
+# Is an equivalent to
+RSpec.configure do |config|
+  config.expose_dsl_globally = false
+
+  config.mock_with :rspec do |mocks|
+    mocks.syntax = :expect
+    mocks.patch_marshal_to_support_partial_doubles = false
+  end
+
+  config.mock_with :rspec do |expectations|
+    expectations.syntax = :expect
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+1239
+1240
+1241
+1242
+1243
+1244
+
+
# File 'lib/rspec/core/configuration.rb', line 1239
+
+def disable_monkey_patching!
+  self.expose_dsl_globally = false
+  self.disable_monkey_patching = true
+  conditionally_disable_mocks_monkey_patching
+  conditionally_disable_expectations_monkey_patching
+end
+
+
+ +
+

+ + - (void) exclusion_filter + + + + + +

+
+ +

Returns the exclusion_filter. If none has been set, returns an +empty hash.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+930
+931
+932
+
+
# File 'lib/rspec/core/configuration.rb', line 930
+
+def exclusion_filter
+  filter_manager.exclusions
+end
+
+
+ +
+

+ + - (void) exclusion_filter=(filter) + + + + + +

+
+ +

Clears and reassigns the exclusion_filter. Set to +nil if you don't want any exclusion filter at all.

+ +

Warning

+ +

This overrides any exclusion filters/tags set on the command line or in +configuration files.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+923
+924
+925
+926
+
+
# File 'lib/rspec/core/configuration.rb', line 923
+
+def exclusion_filter=(filter)
+  meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
+  filter_manager.exclude_only meta
+end
+
+
+ +
+

+ + - (void) expect_with(*frameworks) + + + + + +

+
+ +

Sets the expectation framework module(s) to be included in each example +group.

+ +

frameworks can be :rspec, +:test_unit, :minitest, a custom module, or any +combination thereof:

+ +
config.expect_with :rspec
+config.expect_with :test_unit
+config.expect_with :minitest
+config.expect_with :rspec, :minitest
+config.expect_with OtherExpectationFramework
+ +

RSpec will translate :rspec, :minitest, and +:test_unit into the appropriate modules.

+ +

Configuration

+ +

If the module responds to configuration, +expect_with will yield the configuration object +if given a block:

+ +
config.expect_with OtherExpectationFramework do |custom_config|
+  custom_config.custom_setting = true
+end
+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+
+
# File 'lib/rspec/core/configuration.rb', line 518
+
+def expect_with(*frameworks)
+  modules = frameworks.map do |framework|
+    case framework
+    when Module
+      framework
+    when :rspec
+      require 'rspec/expectations'
+      self.expecting_with_rspec = true
+      ::RSpec::Matchers
+    when :test_unit
+      require 'rspec/core/test_unit_assertions_adapter'
+      ::RSpec::Core::TestUnitAssertionsAdapter
+    when :minitest
+      require 'rspec/core/minitest_assertions_adapter'
+      ::RSpec::Core::MinitestAssertionsAdapter
+    else
+      raise ArgumentError, "#{framework.inspect} is not supported"
+    end
+  end
+
+  if (modules - @expectation_frameworks).any?
+    assert_no_example_groups_defined(:expect_with)
+  end
+
+  if block_given?
+    raise "expect_with only accepts a block with a single argument. Call expect_with #{modules.length} times, once with each argument, instead." if modules.length > 1
+    raise "#{modules.first} must respond to `configuration` so that expect_with can yield it." unless modules.first.respond_to?(:configuration)
+    yield modules.first.configuration
+  end
+
+  @expectation_frameworks.push(*modules)
+end
+
+
+ +
+

+ + - (void) expectation_framework=(framework) + + + + + +

+
+ +

Delegates to expect_with(framework)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+491
+492
+493
+
+
# File 'lib/rspec/core/configuration.rb', line 491
+
+def expectation_framework=(framework)
+  expect_with(framework)
+end
+
+
+ +
+

+ + - (void) expectation_frameworks + + + + + +

+
+ +

Returns the configured expectation framework adapter module(s)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+485
+486
+487
+488
+
+
# File 'lib/rspec/core/configuration.rb', line 485
+
+def expectation_frameworks
+  expect_with :rspec if @expectation_frameworks.empty?
+  @expectation_frameworks
+end
+
+
+ +
+

+ + - (void) expose_current_running_example_as(method_name) + + + + + +

+
+ +

Exposes the current running example via the named helper method. RSpec 2.x +exposed this via example, but in RSpec 3.0, the example is +instead exposed via an arg yielded to it, before, +let, etc. However, some extension gems (such as Capybara) +depend on the RSpec 2.x's example method, so this config +option can be used to maintain compatibility.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.expose_current_running_example_as :example
+end
+
+describe MyClass do
+  before do
+    # `example` can be used here because of the above config.
+    do_something if example.[:type] == "foo"
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + method_name + + + (Symbol) + + + + — +
    +

    the name of the helper method

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+
+
# File 'lib/rspec/core/configuration.rb', line 1177
+
+def expose_current_running_example_as(method_name)
+  ExposeCurrentExample.module_exec do
+    extend RSpec::SharedContext
+    let(method_name) { |ex| ex }
+  end
+
+  include ExposeCurrentExample
+end
+
+
+ +
+

+ + - (void) expose_dsl_globally=(value) + + + + + +

+
+ +

Use this to expose the core RSpec DSL via Module and the +main object. It will be set automatically but you can override +it to remove the DSL. Default: true

+ + +
+
+
+ + +
+ + + + +
+
+
+
+117
+118
+119
+120
+121
+122
+123
+124
+125
+
+
# File 'lib/rspec/core/configuration.rb', line 117
+
+def expose_dsl_globally=(value)
+  if value
+    Core::DSL.expose_globally!
+    Core::SharedExampleGroup::TopLevelDSL.expose_globally!
+  else
+    Core::DSL.remove_globally!
+    Core::SharedExampleGroup::TopLevelDSL.remove_globally!
+  end
+end
+
+
+ +
+

+ + - (Boolean) expose_dsl_globally? + + + + + +

+
+ +

Indicates if the DSL has been exposed off of modules and main. +Default: true

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+109
+110
+111
+
+
# File 'lib/rspec/core/configuration.rb', line 109
+
+def expose_dsl_globally?
+  Core::DSL.exposed_globally?
+end
+
+
+ +
+

+ + - (void) extend(mod, *filters) + + + + + +

+
+ +

Tells RSpec to extend example groups with mod. Methods defined +in mod are exposed to example groups (not examples). Use +filters to constrain the groups to extend.

+ +

Similar to include, but behavior is added to example groups, +which are classes, rather than the examples, which are instances of those +classes.

+ + +
+
+
+ +
+

Examples:

+ + +

+module UiHelpers
+  def run_in_browser
+    # ...
+  end
+end
+
+RSpec.configure do |config|
+  config.extend(UiHelpers, :type => :request)
+end
+
+describe "edit profile", :type => :request do
+  run_in_browser
+
+  it "does stuff in the client" do
+    # ...
+  end
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+1000
+1001
+1002
+1003
+
+
# File 'lib/rspec/core/configuration.rb', line 1000
+
+def extend(mod, *filters)
+  meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
+  include_or_extend_modules << [:extend, mod, meta]
+end
+
+
+ +
+

+ + - (void) filter_run_excluding(*args) + + + + + +

+
+ +

Adds key/value pairs to the exclusion_filter. If +args includes any symbols that are not part of the hash, each +symbol is treated as a key in the hash with the value true.

+ +

Note

+ +

Filters set using this method can be overridden from the command line or +config files (e.g. .rspec).

+ + +
+
+
+ +
+

Examples:

+ + +
# given this declaration
+describe "something", :foo => 'bar' do
+  # ...
+end
+
+# any of the following will exclude that group
+config.filter_run_excluding :foo => 'bar'
+config.filter_run_excluding :foo => /^ba/
+config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
+config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+# given a proc with an arity of 1, the lambda is passed the value related to the key, e.g.
+config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
+
+# given a proc with an arity of 2, the lambda is passed the value related to the key,
+# and the metadata itself e.g.
+config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+filter_run_excluding :foo # same as filter_run_excluding :foo => true
+ +
+ + +
+ + + + +
+
+
+
+911
+912
+913
+914
+
+
# File 'lib/rspec/core/configuration.rb', line 911
+
+def filter_run_excluding(*args)
+  meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
+  filter_manager.exclude_with_low_priority meta
+end
+
+
+ +
+

+ + - (void) filter_run_including(*args) + + + + Also known as: + filter_run + + + + +

+
+ +

Adds key/value pairs to the inclusion_filter. If +args includes any symbols that are not part of the hash, each +symbol is treated as a key in the hash with the value true.

+ +

Note

+ +

Filters set using this method can be overridden from the command line or +config files (e.g. .rspec).

+ + +
+
+
+ +
+

Examples:

+ + +
# given this declaration
+describe "something", :foo => 'bar' do
+  # ...
+end
+
+# any of the following will include that group
+config.filter_run_including :foo => 'bar'
+config.filter_run_including :foo => /^ba/
+config.filter_run_including :foo => lambda {|v| v == 'bar'}
+config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+# given a proc with an arity of 1, the lambda is passed the value related to the key, e.g.
+config.filter_run_including :foo => lambda {|v| v == 'bar'}
+
+# given a proc with an arity of 2, the lambda is passed the value related to the key,
+# and the metadata itself e.g.
+config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}
+
+filter_run_including :foo # same as filter_run_including :foo => true
+ +
+ + +
+ + + + +
+
+
+
+853
+854
+855
+856
+
+
# File 'lib/rspec/core/configuration.rb', line 853
+
+def filter_run_including(*args)
+  meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
+  filter_manager.include_with_low_priority meta
+end
+
+
+ +
+

+ + - (void) format_docstrings(&block) + + + + + +

+
+ +

Formats the docstring output using the block provided.

+ + +
+
+
+ +
+

Examples:

+ + +
# This will strip the descriptions of both examples and example groups.
+RSpec.configure do |config|
+  config.format_docstrings { |s| s.strip }
+end
+ +
+ + +
+ + + + +
+
+
+
+1072
+1073
+1074
+
+
# File 'lib/rspec/core/configuration.rb', line 1072
+
+def format_docstrings(&block)
+  @format_docstrings_block = block_given? ? block : DEFAULT_FORMATTER
+end
+
+
+ +
+

+ + - (Array) formatters + + + + + +

+
+ +

Returns a duplicate of the formatters currently loaded in the +FormatterLoader for introspection.

+ +

Note as this is a duplicate, any mutations will be disregarded.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    the formatters currently loaded

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+652
+653
+654
+
+
# File 'lib/rspec/core/configuration.rb', line 652
+
+def formatters
+  formatter_loader.formatters.dup
+end
+
+
+ +
+

+ + - (void) full_backtrace=(true_or_false) + + + + + +

+
+ +

Toggle full backtrace

+ + +
+
+
+ + +
+ + + + +
+
+
+
+559
+560
+561
+
+
# File 'lib/rspec/core/configuration.rb', line 559
+
+def full_backtrace=(true_or_false)
+  @backtrace_formatter.full_backtrace = true_or_false
+end
+
+
+ +
+

+ + - (Boolean) full_backtrace? + + + + + +

+
+ +

Check if full backtrace is enabled

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    is full backtrace enabled

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+553
+554
+555
+
+
# File 'lib/rspec/core/configuration.rb', line 553
+
+def full_backtrace?
+  @backtrace_formatter.full_backtrace?
+end
+
+
+ +
+

+ + - (Array) full_description + + + + + +

+
+ +

Returns full description filter

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    full description filter

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+608
+609
+610
+
+
# File 'lib/rspec/core/configuration.rb', line 608
+
+def full_description
+  filter.fetch :full_description, nil
+end
+
+
+ +
+

+ + - (void) full_description=(description) + + + + + +

+
+ +

Run examples matching on description in all files to run.

+ + +
+
+
+

Parameters:

+
    + +
  • + + description + + + (String, Regexp) + + + + — +
    +

    the pattern to filter on

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+603
+604
+605
+
+
# File 'lib/rspec/core/configuration.rb', line 603
+
+def full_description=(description)
+  filter_run :full_description => Regexp.union(*Array(description).map {|d| Regexp.new(d) })
+end
+
+
+ +
+

+ + - (void) include(mod, *filters) + + + + + +

+
+ +

Tells RSpec to include mod in example groups. Methods defined +in mod are exposed to examples (not example groups). Use +filters to constrain the groups in which to include the +module.

+ + +
+
+
+ +
+

Examples:

+ + +

+module AuthenticationHelpers
+  def (user)
+    # ...
+  end
+end
+
+module UserHelpers
+  def users(username)
+    # ...
+  end
+end
+
+RSpec.configure do |config|
+  config.include(UserHelpers) # included in all modules
+  config.include(AuthenticationHelpers, :type => :request)
+end
+
+describe "edit profile", :type => :request do
+  it "can be viewed by owning user" do
+     users(:jdoe)
+    get "/profiles/jdoe"
+    assert_select ".username", :text => 'jdoe'
+  end
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+966
+967
+968
+969
+
+
# File 'lib/rspec/core/configuration.rb', line 966
+
+def include(mod, *filters)
+  meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
+  include_or_extend_modules << [:include, mod, meta]
+end
+
+
+ +
+

+ + - (void) inclusion_filter + + + + Also known as: + filter + + + + +

+
+ +

Returns the inclusion_filter. If none has been set, returns an +empty hash.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+876
+877
+878
+
+
# File 'lib/rspec/core/configuration.rb', line 876
+
+def inclusion_filter
+  filter_manager.inclusions
+end
+
+
+ +
+

+ + - (void) inclusion_filter=(filter) + + + + Also known as: + filter= + + + + +

+
+ +

Clears and reassigns the inclusion_filter. Set to +nil if you don't want any inclusion filter at all.

+ +

Warning

+ +

This overrides any inclusion filters/tags set on the command line or in +configuration files.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+867
+868
+869
+870
+
+
# File 'lib/rspec/core/configuration.rb', line 867
+
+def inclusion_filter=(filter)
+  meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
+  filter_manager.include_only meta
+end
+
+
+ +
+

+ + - (void) mock_framework + + + + + +

+
+ +

Returns the configured mock framework adapter module

+ + +
+
+
+ + +
+ + + + +
+
+
+
+367
+368
+369
+370
+
+
# File 'lib/rspec/core/configuration.rb', line 367
+
+def mock_framework
+  mock_with :rspec unless @mock_framework
+  @mock_framework
+end
+
+
+ +
+

+ + - (void) mock_framework=(framework) + + + + + +

+
+ +

Delegates to mock_framework=(framework)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+373
+374
+375
+
+
# File 'lib/rspec/core/configuration.rb', line 373
+
+def mock_framework=(framework)
+  mock_with framework
+end
+
+
+ +
+

+ + - (void) mock_with(framework) + + + + + +

+
+ +

Sets the mock framework adapter module.

+ +

framework can be a Symbol or a Module.

+ +

Given any of :rspec, :mocha, +:flexmock, or :rr, configures the named +framework.

+ +

Given :nothing, configures no framework. Use this if you +don't use any mocking framework to save a little bit of overhead.

+ +

Given a Module, includes that module in every example group. The module +should adhere to RSpec's mock framework adapter API:

+ +
setup_mocks_for_rspec
+  - called before each example
+
+verify_mocks_for_rspec
+  - called after each example if the example hasn't yet failed.
+    Framework should raise an exception when expectations fail
+
+teardown_mocks_for_rspec
+  - called after verify_mocks_for_rspec (even if there are errors)
+ +

If the module responds to configuration and +mock_with receives a block, it will yield the configuration +object to the block e.g.

+ +
config.mock_with OtherMockFrameworkAdapter do |mod_config|
+  mod_config.custom_setting = true
+end
+
+ + +
+
+
+ + +
+ + + + +
+
+
+
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+
+
# File 'lib/rspec/core/configuration.rb', line 454
+
+def mock_with(framework)
+  framework_module = if framework.is_a?(Module)
+     framework
+  else
+    const_name = MOCKING_ADAPTERS.fetch(framework) do
+      raise ArgumentError,
+        "Unknown mocking framework: #{framework.inspect}. " +
+        "Pass a module or one of #{MOCKING_ADAPTERS.keys.inspect}"
+    end
+
+    RSpec::Support.require_rspec_core "mocking_adapters/#{const_name.to_s.downcase}"
+    RSpec::Core::MockingAdapters.const_get(const_name)
+  end
+
+  new_name, old_name = [framework_module, @mock_framework].map do |mod|
+    mod.respond_to?(:framework_name) ?  mod.framework_name : :unnamed
+  end
+
+  unless new_name == old_name
+    assert_no_example_groups_defined(:mock_framework)
+  end
+
+  if block_given?
+    raise "#{framework_module} must respond to `configuration` so that mock_with can yield it." unless framework_module.respond_to?(:configuration)
+    yield framework_module.configuration
+  end
+
+  @mock_framework = framework_module
+end
+
+
+ +
+

+ + - (void) order= + + + + + +

+
+ +

Sets the default global order and, if order is +'rand:<seed>', also sets the seed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1114
+
+
# File 'lib/rspec/core/configuration.rb', line 1114
+
+delegate_to_ordering_manager :order=
+
+
+ +
+

+ + - (void) raise_errors_for_deprecations! + + + + + +

+
+ +

Turns deprecation warnings into errors, in order to surface the full +backtrace of the call site. This can be useful when you need more context +to address a deprecation than the single-line call site normally provided.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.raise_errors_for_deprecations!
+end
+ +
+ + +
+ + + + +
+
+
+
+1199
+1200
+1201
+
+
# File 'lib/rspec/core/configuration.rb', line 1199
+
+def raise_errors_for_deprecations!
+  self.deprecation_stream = Formatters::DeprecationFormatter::RaiseErrorStream.new
+end
+
+
+ +
+

+ + - (void) register_ordering {|list| ... } + + + + + +

+
+ +
+ Note: +
+

Pass the symbol :global to set the ordering strategy that will +be used to order the top-level example groups and any example groups that +do not have declared :order metadata.

+
+
+ + +

Registers a named ordering strategy that can later be used to order an +example group's subgroups by adding :order => +<name> metadata to the example group.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |rspec|
+  rspec.register_ordering :reverse do |list|
+    list.reverse
+  end
+end
+
+describe MyClass, :order => :reverse do
+  # ...
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (Symbol) + + + + — +
    +

    The name of the ordering.

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    Block that will order the given examples or example groups

    +
    + +
  • + +
+

Yield Parameters:

+ +

Yield Returns:

+ + +
+ + + + +
+
+
+
+1140
+
+
# File 'lib/rspec/core/configuration.rb', line 1140
+
+delegate_to_ordering_manager :register_ordering
+
+
+ +
+

+ + - (void) seed + + + + + +

+
+ +

Seed for random ordering (default: generated randomly each run).

+ +

When you run specs with --order random, RSpec generates a +random seed for the randomization and prints it to the +output_stream (assuming you're using RSpec's built-in +formatters). If you discover an ordering dependency (i.e. examples fail +intermittently depending on order), set this (on Configuration or on the +command line with --seed) to run using the same seed while you +debug the issue.

+ +

We recommend, actually, that you use the command line approach so you +don't accidentally leave the seed encoded.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1109
+
+
# File 'lib/rspec/core/configuration.rb', line 1109
+
+delegate_to_ordering_manager :seed
+
+
+ +
+

+ + - (void) seed= + + + + + +

+
+ +

Sets the seed value and sets the default global ordering to random.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1095
+
+
# File 'lib/rspec/core/configuration.rb', line 1095
+
+delegate_to_ordering_manager :seed=
+
+
+ +
+

+ + - (void) treat_symbols_as_metadata_keys_with_true_values=(value) + + + + + +

+
+ +

Deprecated. This config option was added in RSpec 2 to pave the way for +this being the default behavior in RSpec 3. Now this option is a no-op.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+253
+254
+255
+256
+257
+
+
# File 'lib/rspec/core/configuration.rb', line 253
+
+def (value)
+  RSpec.deprecate("RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=",
+                  :message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= " +
+                              "is deprecated, it is now set to true as default and setting it to false has no effect.")
+end
+
+
+ +
+

+ + - (void) warnings=(value) + + + + + +

+
+ +

Set Ruby warnings on or off

+ + +
+
+
+ + +
+ + + + +
+
+
+
+1146
+1147
+1148
+
+
# File 'lib/rspec/core/configuration.rb', line 1146
+
+def warnings=(value)
+  $VERBOSE = !!value
+end
+
+
+ +
+

+ + - (Boolean) warnings? + + + + + +

+
+ +

Returns Whether or not ruby warnings are enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not ruby warnings are enabled.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+1151
+1152
+1153
+
+
# File 'lib/rspec/core/configuration.rb', line 1151
+
+def warnings?
+  $VERBOSE
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/ConfigurationOptions.html b/source/documentation/3.0/rspec-core/RSpec/Core/ConfigurationOptions.html new file mode 100644 index 000000000..512463314 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/ConfigurationOptions.html @@ -0,0 +1,530 @@ + + + + + + Class: RSpec::Core::ConfigurationOptions + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::ConfigurationOptions + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/configuration_options.rb
+ +
+
+ +

Overview

+
+ +

Responsible for utilizing externally provided configuration options, +whether via the command line, .rspec, ~/.rspec, +.rspec-local or a custom options file.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Hash) options + + + + + + + + + readonly + + + + + + + + + +
    +

    The final merged options, drawn from all external sources.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ConfigurationOptions) initialize(args) + + + + + +

+
+ +

Returns a new instance of ConfigurationOptions

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array<String>) + + + + — +
    +

    command line arguments

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+
+
# File 'lib/rspec/core/configuration_options.rb', line 12
+
+def initialize(args)
+  @args = args.dup
+  organize_options
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (Hash) options (readonly) + + + + + +

+
+ +

Returns the final merged options, drawn from all external sources

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Hash) + + + + — +
    +

    the final merged options, drawn from all external sources

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+37
+38
+39
+
+
# File 'lib/rspec/core/configuration_options.rb', line 37
+
+def options
+  @options
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) configure(config) + + + + + +

+
+ +

Updates the provided RSpec::Core::Configuration instance based on the provided +external configuration options.

+ + +
+
+
+

Parameters:

+
    + +
  • + + config + + + (Configuration) + + + + — +
    +

    the configuration instance to update

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+25
+
+
# File 'lib/rspec/core/configuration_options.rb', line 21
+
+def configure(config)
+  process_options_into config
+  configure_filter_manager config.filter_manager
+  load_formatters_into config
+end
+
+
+ +
+

+ + - (void) configure_filter_manager(filter_manager) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Updates the provided FilterManager based on the filter options.

+ + +
+
+
+

Parameters:

+
    + +
  • + + filter_manager + + + (FilterManager) + + + + — +
    +

    instance to update

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+30
+31
+32
+33
+34
+
+
# File 'lib/rspec/core/configuration_options.rb', line 30
+
+def configure_filter_manager(filter_manager)
+  @filter_manager_options.each do |command, value|
+    filter_manager.__send__ command, value
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/DSL.html b/source/documentation/3.0/rspec-core/RSpec/Core/DSL.html new file mode 100644 index 000000000..7a79ef83b --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/DSL.html @@ -0,0 +1,322 @@ + + + + + + Module: RSpec::Core::DSL + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::DSL + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/dsl.rb
+ +
+
+ +

Overview

+
+ +

DSL defines methods to group examples, most notably describe, +and exposes them as class methods of RSpec. They can also be exposed +globally (on main and instances of Module) +through the Configuration option expose_dsl_globally.

+ +

By default the methods describe, context and +example_group are exposed. These methods define a named +context for one or more examples. The given block is evaluated in the +context of a generated subclass of ExampleGroup

+ +

Examples:

+ +
RSpec.describe "something" do
+  context "when something is a certain way" do
+    it "does something" do
+      # example code goes here
+    end
+  end
+end
+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ +
    + +
  • + + + + (void) expose_globally! + + + + + + + + + + + private + + +
    +

    Adds the describe method to Module and the top level binding.

    +
    + +
  • + + +
  • + + + + (void) remove_globally! + + + + + + + + + + + private + + +
    +

    Removes the describe method from Module and the top level binding.

    +
    + +
  • + + +
+ + + + +
+

Class Method Details

+ + +
+

+ + + (void) expose_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Adds the describe method to Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+54
+55
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib/rspec/core/dsl.rb', line 54
+
+def self.expose_globally!
+  return if exposed_globally?
+
+  example_group_aliases.each do |method_name|
+    expose_example_group_alias_globally(method_name)
+  end
+
+  @exposed_globally = true
+end
+
+
+ +
+

+ + + (void) remove_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Removes the describe method from Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+66
+67
+68
+69
+70
+71
+72
+73
+74
+
+
# File 'lib/rspec/core/dsl.rb', line 66
+
+def self.remove_globally!
+  return unless exposed_globally?
+
+  example_group_aliases.each do |method_name|
+    change_global_dsl { undef_method method_name }
+  end
+
+  @exposed_globally = false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Example.html b/source/documentation/3.0/rspec-core/RSpec/Core/Example.html new file mode 100644 index 000000000..1809bf410 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Example.html @@ -0,0 +1,1349 @@ + + + + + + Class: RSpec::Core::Example + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Example + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/example.rb
+ +
+
+ +

Overview

+
+ +
+ Note: +
+

Example blocks are evaluated in the context of an instance of an +ExampleGroup, not in the context of an instance of +Example.

+
+
+ + +

Wrapper for an instance of a subclass of ExampleGroup. An instance of +RSpec::Core::Example is returned by example definition methods +such as it and is yielded to the it, +before, after, around, +let and +subject blocks.

+ +

This allows us to provide rich metadata about each individual example +without adding tons of methods directly to the ExampleGroup that users may +inadvertantly redefine.

+ +

Useful for configuring logging and/or taking some action based on the state +of an example's metadata.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |config|
+  config.before do |example|
+    log example.description
+  end
+
+  config.after do |example|
+    log example.description
+  end
+
+  config.around do |example|
+    log example.description
+    example.run
+  end
+end
+
+shared_examples "auditable" do
+  it "does something" do
+    log "#{example.full_description}: #{auditable.inspect}"
+    auditable.should do_something
+  end
+end
+ +
+ + +

See Also:

+ + +

Defined Under Namespace

+

+ + + + + Classes: ExecutionResult, Procsy + + +

+ + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (void) exception + + + + + + + + + readonly + + + + + + + + + +
    +

    Returns the first exception raised in the context of running this example +(nil if no exception is raised).

    +
    + +
  • + + +
  • + + + - (void) metadata + + + + + + + + + readonly + + + + + + + + + +
    +

    Returns the metadata object associated with this example.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Example) initialize(example_group_class, description, user_metadata, example_block = nil) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Creates a new instance of Example.

+ + +
+
+
+

Parameters:

+
    + +
  • + + example_group_class + + + (Class) + + + + — +
    +

    the subclass of ExampleGroup in which this Example is declared

    +
    + +
  • + +
  • + + description + + + (String) + + + + — +
    +

    the String passed to the it method (or alias)

    +
    + +
  • + +
  • + + user_metadata + + + (Hash) + + + + — +
    +

    additional args passed to it to be used as metadata

    +
    + +
  • + +
  • + + example_block + + + (Proc) + + + (defaults to: nil) + + + — +
    +

    the block of code that represents the example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+
+
# File 'lib/rspec/core/example.rb', line 110
+
+def initialize(example_group_class, description, , example_block=nil)
+  @example_group_class = example_group_class
+  @example_block       = example_block
+
+  @metadata = Metadata::ExampleHash.create(
+    @example_group_class., , description, example_block
+  )
+
+  @example_group_instance = @exception = nil
+  @clock = RSpec::Core::Time
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) exception (readonly) + + + + + +

+
+ +

Returns the first exception raised in the context of running this example +(nil if no exception is raised)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+86
+87
+88
+
+
# File 'lib/rspec/core/example.rb', line 86
+
+def exception
+  @exception
+end
+
+
+ + + +
+

+ + - (void) metadata (readonly) + + + + + +

+
+ +

Returns the metadata object associated with this example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+91
+92
+93
+
+
# File 'lib/rspec/core/example.rb', line 91
+
+def 
+  @metadata
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) description + + + + + +

+
+ +

Returns the string submitted to example or its aliases (e.g. +specify, it, etc). If no string is submitted +(e.g. it { is_expected.to do_something }) it returns the +message generated by the matcher if there is one, otherwise returns a +message including the location of the example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+75
+76
+77
+78
+79
+80
+
+
# File 'lib/rspec/core/example.rb', line 75
+
+def description
+  description = [:description].to_s.empty? ?
+    "example at #{location}" :
+    [:description]
+  RSpec.configuration.format_docstrings_block.call(description)
+end
+
+
+ +
+

+ + - (void) example_group + + + + + +

+
+ +

Returns the example group class that provides the context for running this +example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+124
+125
+126
+
+
# File 'lib/rspec/core/example.rb', line 124
+
+def example_group
+  @example_group_class
+end
+
+
+ +
+

+ + - (ExecutionResult) execution_result + + + + + +

+
+ +

Returns represents the result of running this example.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (ExecutionResult) + + + + — +
    +

    represents the result of running this example.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+53
+
+
# File 'lib/rspec/core/example.rb', line 53
+
+ :execution_result
+
+
+ +
+

+ + - (String) file_path + + + + + +

+
+ +

Returns the relative path to the file where this example was defined.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the relative path to the file where this example was defined.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+55
+
+
# File 'lib/rspec/core/example.rb', line 55
+
+ :file_path
+
+
+ +
+

+ + - (String) full_description + + + + + +

+
+ +

Returns the full description (including the docstrings of all parent +example groups).

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the full description (including the docstrings of all parent example +groups).

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+58
+
+
# File 'lib/rspec/core/example.rb', line 58
+
+ :full_description
+
+
+ +
+

+ + - (String) location + + + + + +

+
+ +

Returns the exact source location of this example in a form like +./path/to/spec.rb:17

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the exact source location of this example in a form like +./path/to/spec.rb:17

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+61
+
+
# File 'lib/rspec/core/example.rb', line 61
+
+ :location
+
+
+ +
+

+ + - (Boolean) pending + + + + Also known as: + pending? + + + + +

+
+ +

Returns flag that indicates that the example is not expected to pass. It +will be run and will either have a pending result (if a failure occurs) or +a failed result (if no failure occurs).

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    flag that indicates that the example is not expected to pass. It will be +run and will either have a pending result (if a failure occurs) or a failed +result (if no failure occurs).

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+65
+
+
# File 'lib/rspec/core/example.rb', line 65
+
+ :pending
+
+
+ +
+

+ + - (void) run(example_group_instance, reporter) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

instance_execs the block passed to the constructor in the context of the +instance of RSpec::Core::ExampleGroup.

+ + +
+
+
+

Parameters:

+
    + +
  • + + example_group_instance + + + + + + + — +
    +

    the instance of an ExampleGroup subclass

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+
+
# File 'lib/rspec/core/example.rb', line 135
+
+def run(example_group_instance, reporter)
+  @example_group_instance = example_group_instance
+  RSpec.current_example = self
+
+  start(reporter)
+
+  begin
+    if skipped?
+      Pending.mark_pending! self, skip
+    elsif !RSpec.configuration.dry_run?
+      with_around_example_hooks do
+        begin
+          run_before_example
+          @example_group_instance.instance_exec(self, &@example_block)
+
+          if pending?
+            Pending.mark_fixed! self
+
+            raise Pending::PendingExampleFixedError,
+              'Expected example to fail since it is pending, but it passed.',
+              [location]
+          end
+        rescue Pending::SkipDeclaredInExample
+          # no-op, required metadata has already been set by the `skip`
+          # method.
+        rescue Exception => e
+          set_exception(e)
+        ensure
+          run_after_example
+        end
+      end
+    end
+  rescue Exception => e
+    set_exception(e)
+  ensure
+    @example_group_instance.instance_variables.each do |ivar|
+      @example_group_instance.instance_variable_set(ivar, nil)
+    end
+    @example_group_instance = nil
+  end
+
+  finish(reporter)
+ensure
+  RSpec.current_example = nil
+end
+
+
+ +
+

+ + - (Boolean) skip + + + + Also known as: + skipped? + + + + +

+
+ +

Returns flag that will cause the example to not run. The ExecutionResult +status will be :pending.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    flag that will cause the example to not run. The ExecutionResult status +will be :pending.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+68
+
+
# File 'lib/rspec/core/example.rb', line 68
+
+ :skip
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Example/ExecutionResult.html b/source/documentation/3.0/rspec-core/RSpec/Core/Example/ExecutionResult.html new file mode 100644 index 000000000..cdd392601 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Example/ExecutionResult.html @@ -0,0 +1,957 @@ + + + + + + Class: RSpec::Core::Example::ExecutionResult + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Example::ExecutionResult + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/example.rb
+ +
+
+ +

Overview

+
+ +

Represents the result of executing an example. Behaves like a hash for +backwards compatibility.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Exception?) exception + + + + + + + + + + + + + + + + +
    +

    The failure, if there was one.

    +
    + +
  • + + +
  • + + + - (Time) finished_at + + + + + + + + + + + + + + + + +
    +

    When the example finished.

    +
    + +
  • + + +
  • + + + - (Exception?) pending_exception + + + + + + + + + + + + + + + + +
    +

    The exception triggered while executing the pending example.

    +
    + +
  • + + +
  • + + + - (Boolean) pending_fixed + + + + (also: #pending_fixed?) + + + + + + + + + + + + + + +
    +

    For examples tagged with :pending, this indicates whether or +not it now passes.

    +
    + +
  • + + +
  • + + + - (String?) pending_message + + + + + + + + + + + + + + + + +
    +

    The reason the example was pending, or nil if the example was not pending.

    +
    + +
  • + + +
  • + + + - (Float) run_time + + + + + + + + + + + + + + + + +
    +

    How long the example took in seconds.

    +
    + +
  • + + +
  • + + + - (Time) started_at + + + + + + + + + + + + + + + + +
    +

    When the example started.

    +
    + +
  • + + +
  • + + + - (Symbol) status + + + + + + + + + + + + + + + + +
    +

    :passed, :failed or :pending.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Exception?) exception + + + + + +

+
+ +

Returns The failure, if there was one.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Exception, nil) + + + + — +
    +

    The failure, if there was one.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+396
+397
+398
+
+
# File 'lib/rspec/core/example.rb', line 396
+
+def exception
+  @exception
+end
+
+
+ + + +
+

+ + - (Time) finished_at + + + + + +

+
+ +

Returns When the example finished.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Time) + + + + — +
    +

    When the example finished.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+402
+403
+404
+
+
# File 'lib/rspec/core/example.rb', line 402
+
+def finished_at
+  @finished_at
+end
+
+
+ + + +
+

+ + - (Exception?) pending_exception + + + + + +

+
+ +

Returns The exception triggered while executing the pending example. If no +exception was triggered it would no longer get a status of +:pending unless it was tagged with :skip.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Exception, nil) + + + + — +
    +

    The exception triggered while executing the pending example. If no +exception was triggered it would no longer get a status of +:pending unless it was tagged with :skip.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+415
+416
+417
+
+
# File 'lib/rspec/core/example.rb', line 415
+
+def pending_exception
+  @pending_exception
+end
+
+
+ + + +
+

+ + - (Boolean) pending_fixed + + + + Also known as: + pending_fixed? + + + + +

+
+ +

Returns For examples tagged with :pending, this indicates +whether or not it now passes.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    For examples tagged with :pending, this indicates whether or +not it now passes.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+419
+420
+421
+
+
# File 'lib/rspec/core/example.rb', line 419
+
+def pending_fixed
+  @pending_fixed
+end
+
+
+ + + +
+

+ + - (String?) pending_message + + + + + +

+
+ +

Returns The reason the example was pending, or nil if the example was not +pending.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String, nil) + + + + — +
    +

    The reason the example was pending, or nil if the example was not pending.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+409
+410
+411
+
+
# File 'lib/rspec/core/example.rb', line 409
+
+def pending_message
+  @pending_message
+end
+
+
+ + + +
+

+ + - (Float) run_time + + + + + +

+
+ +

Returns How long the example took in seconds.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    How long the example took in seconds.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+405
+406
+407
+
+
# File 'lib/rspec/core/example.rb', line 405
+
+def run_time
+  @run_time
+end
+
+
+ + + +
+

+ + - (Time) started_at + + + + + +

+
+ +

Returns When the example started.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Time) + + + + — +
    +

    When the example started.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+399
+400
+401
+
+
# File 'lib/rspec/core/example.rb', line 399
+
+def started_at
+  @started_at
+end
+
+
+ + + +
+

+ + - (Symbol) status + + + + + +

+
+ +

Returns :passed, :failed or +:pending.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Symbol) + + + + — +
    +

    :passed, :failed or :pending.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+393
+394
+395
+
+
# File 'lib/rspec/core/example.rb', line 393
+
+def status
+  @status
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) record_finished(status, finished_at) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Records the finished status of the example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+425
+426
+427
+428
+429
+
+
# File 'lib/rspec/core/example.rb', line 425
+
+def record_finished(status, finished_at)
+  self.status      = status
+  self.finished_at = finished_at
+  self.run_time    = (finished_at - started_at).to_f
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Example/Procsy.html b/source/documentation/3.0/rspec-core/RSpec/Core/Example/Procsy.html new file mode 100644 index 000000000..bec117fec --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Example/Procsy.html @@ -0,0 +1,324 @@ + + + + + + Class: RSpec::Core::Example::Procsy + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Example::Procsy + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/example.rb
+ +
+
+ +

Overview

+
+ +
+ Note: +
+

This class also exposes the instance methods of RSpec::Core::Example, proxying them +through to the wrapped RSpec::Core::Example instance.

+
+
+ + +

Wraps both a Proc and an RSpec::Core::Example for use in around hooks. In around hooks we need to yield this special kind of object +(rather than the raw RSpec::Core::Example) because when there are multiple +around hooks we have to wrap them recursively.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |c|
+  c.around do |ex| # Procsy which wraps the example
+    if ex.[:key] == :some_value && some_global_condition
+      raise "some message"
+    end
+    ex.run         # run delegates to ex.call
+  end
+end
+ +
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Procsy) initialize(example, &block) + + + + + +

+
+ +

Returns a new instance of Procsy

+ + +
+
+
+ + +
+ + + + +
+
+
+
+214
+215
+216
+217
+
+
# File 'lib/rspec/core/example.rb', line 214
+
+def initialize(example, &block)
+  @example = example
+  @proc    = block
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) example (readonly) + + + + + +

+
+ +

The RSpec::Core::Example instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+201
+202
+203
+
+
# File 'lib/rspec/core/example.rb', line 201
+
+def example
+  @example
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/ExampleGroup.html b/source/documentation/3.0/rspec-core/RSpec/Core/ExampleGroup.html new file mode 100644 index 000000000..e60690f50 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/ExampleGroup.html @@ -0,0 +1,3627 @@ + + + + + + Class: RSpec::Core::ExampleGroup + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::ExampleGroup + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + +
Extended by:
+
Hooks, MemoizedHelpers::ClassMethods, SharedExampleGroup
+ + + + +
Includes:
+
MemoizedHelpers, Pending
+ + + + + +
Defined in:
+
lib/rspec/core/example_group.rb
+ +
+
+ +

Overview

+
+ +

ExampleGroup and Example are the main structural elements of rspec-core. +Consider this example:

+ +
describe Thing do
+  it "does something" do
+  end
+end
+ +

The object returned by describe Thing is a subclass of +ExampleGroup. The object returned by it "does +something" is an instance of Example, which serves as a wrapper +for an instance of the ExampleGroup in which it is declared.

+ +

Example group bodies (e.g. describe or context +blocks) are evaluated in the context of a new subclass of ExampleGroup. +Individual examples are evalutaed in the context of an instance of the +specific ExampleGroup subclass to which they belong.

+ +

Besides the class methods defined here, there are other interesting macros +defined in Hooks, MemoizedHelpers::ClassMethods and +SharedExampleGroup. There are additional instance methods available to +your examples defined in MemoizedHelpers and Pending.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Metadata + (collapse) +

+ +
    + +
  • + + + + (String) description + + + + + + + + + + + + + +
    +

    The current example group description.

    +
    + +
  • + + +
  • + + + + (void) metadata + + + + + + + + + + + + + +
    +

    The Metadata object associated with this group.

    +
    + +
  • + + +
  • + + + - (void) described_class + + + + + + + + + + + + + +
    +

    Returns the class or module passed to the describe method (or +alias).

    +
    + +
  • + + +
+ +

+ Defining Examples + (collapse) +

+ + + +

+ Defining Example Groups + (collapse) +

+ + + +

+ Including Shared Example Groups + (collapse) +

+ +
    + +
  • + + + + (void) include_context(name, *args, &block) + + + + + + + + + + + + + +
    +

    Includes shared content mapped to name directly in the group +in which it is declared, as opposed to it_behaves_like, which +creates a nested group.

    +
    + +
  • + + +
  • + + + + (void) include_examples(name, *args, &block) + + + + + + + + + + + + + +
    +

    Includes shared content mapped to name directly in the group +in which it is declared, as opposed to it_behaves_like, which +creates a nested group.

    +
    + +
  • + + +
  • + + + + (void) it_behaves_like + + + + + + + + + + + + + +
    +

    Generates a nested example group and includes the shared content mapped to +name in the nested group.

    +
    + +
  • + + +
  • + + + + (void) it_should_behave_like + + + + + + + + + + + + + +
    +

    Generates a nested example group and includes the shared content mapped to +name in the nested group.

    +
    + +
  • + + +
+ +

+ Class Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from SharedExampleGroup

+

shared_examples

+ + + + + + + + + +

Methods included from MemoizedHelpers::ClassMethods

+

let, let!, subject, subject!

+ + + + + + + + + +

Methods included from Hooks

+

after, append_after, around, before, prepend_before

+ + + + + + + + + +

Methods included from Pending

+

#pending, #skip

+ + + + + + + + + +

Methods included from MemoizedHelpers

+

#is_expected, #should, #should_not, #subject

+ + +
+

Class Method Details

+ + +
+

+ + + (void) context { ... } + + + + + +

+
+ +

An alias of example_group. Generally used when grouping +examples contextually (e.g. “with xyz”, “when xyz” or “if xyz”). Generates +a subclass of this example group which inherits everything except the +examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  context "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+249
+
+
# File 'lib/rspec/core/example_group.rb', line 249
+
+define_example_group_method :context
+
+
+ +
+

+ + + (void) describe { ... } + + + + + +

+
+ +

An alias of example_group. Generally used when grouping +examples by a thing you are describing (e.g. an object, class or method). +Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  describe "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+244
+
+
# File 'lib/rspec/core/example_group.rb', line 244
+
+define_example_group_method :describe
+
+
+ +
+

+ + + (String) description + + + + + +

+
+ +

Returns the current example group description

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current example group description

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+64
+65
+66
+67
+
+
# File 'lib/rspec/core/example_group.rb', line 64
+
+def self.description
+  description = [:description]
+  RSpec.configuration.format_docstrings_block.call(description)
+end
+
+
+ +
+

+ + + (void) example {|Example| ... } + + + + + +

+
+ +

Defines an example within a group.

+ + +
+
+
+ +
+

Examples:

+ + +
example do
+end
+
+example "does something" do
+end
+
+example "does something", :with => 'additional metadata' do
+end
+
+example "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+131
+
+
# File 'lib/rspec/core/example_group.rb', line 131
+
+define_example_method :example
+
+
+ +
+

+ + + (void) example_group { ... } + + + + + +

+
+ +

Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  example_group "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+239
+
+
# File 'lib/rspec/core/example_group.rb', line 239
+
+define_example_group_method :example_group
+
+
+ +
+

+ + + (void) fcontext { ... } + + + + + +

+
+ +

Shortcut to define an example group with :focus => true. +Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  fcontext "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+265
+
+
# File 'lib/rspec/core/example_group.rb', line 265
+
+define_example_group_method :fcontext,  :focus => true
+
+
+ +
+

+ + + (void) fdescribe { ... } + + + + + +

+
+ +

Shortcut to define an example group with :focus => true. +Generates a subclass of this example group which inherits everything except +the examples themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  fdescribe "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+261
+
+
# File 'lib/rspec/core/example_group.rb', line 261
+
+define_example_group_method :fdescribe, :focus => true
+
+
+ +
+

+ + + (void) fexample {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
fexample do
+end
+
+fexample "does something" do
+end
+
+fexample "does something", :with => 'additional metadata' do
+end
+
+fexample "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+150
+
+
# File 'lib/rspec/core/example_group.rb', line 150
+
+define_example_method :fexample, :focus => true
+
+
+ +
+

+ + + (void) fit {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
fit do
+end
+
+fit "does something" do
+end
+
+fit "does something", :with => 'additional metadata' do
+end
+
+fit "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+153
+
+
# File 'lib/rspec/core/example_group.rb', line 153
+
+define_example_method :fit,      :focus => true
+
+
+ +
+

+ + + (void) focus {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
focus do
+end
+
+focus "does something" do
+end
+
+focus "does something", :with => 'additional metadata' do
+end
+
+focus "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+147
+
+
# File 'lib/rspec/core/example_group.rb', line 147
+
+define_example_method :focus,    :focus => true
+
+
+ +
+

+ + + (void) fspecify {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :focus => true

+ + +
+
+
+ +
+

Examples:

+ + +
fspecify do
+end
+
+fspecify "does something" do
+end
+
+fspecify "does something", :with => 'additional metadata' do
+end
+
+fspecify "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+156
+
+
# File 'lib/rspec/core/example_group.rb', line 156
+
+define_example_method :fspecify, :focus => true
+
+
+ +
+

+ + + (void) include_context(name, *args, &block) + + + + + +

+
+ +

Includes shared content mapped to name directly in the group +in which it is declared, as opposed to it_behaves_like, which +creates a nested group. If given a block, that block is also eval'd in +the current context.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+301
+302
+303
+
+
# File 'lib/rspec/core/example_group.rb', line 301
+
+def self.include_context(name, *args, &block)
+  find_and_eval_shared("context", name, *args, &block)
+end
+
+
+ +
+

+ + + (void) include_examples(name, *args, &block) + + + + + +

+
+ +

Includes shared content mapped to name directly in the group +in which it is declared, as opposed to it_behaves_like, which +creates a nested group. If given a block, that block is also eval'd in +the current context.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+310
+311
+312
+
+
# File 'lib/rspec/core/example_group.rb', line 310
+
+def self.include_examples(name, *args, &block)
+  find_and_eval_shared("examples", name, *args, &block)
+end
+
+
+ +
+

+ + + (void) it {|Example| ... } + + + + + +

+
+ +

Defines an example within a group. This is the primary API to define a code +example.

+ + +
+
+
+ +
+

Examples:

+ + +
it do
+end
+
+it "does something" do
+end
+
+it "does something", :with => 'additional metadata' do
+end
+
+it "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+134
+
+
# File 'lib/rspec/core/example_group.rb', line 134
+
+define_example_method :it
+
+
+ +
+

+ + + (void) it_behaves_like + + + + + +

+
+ +

Generates a nested example group and includes the shared content mapped to +name in the nested group.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+291
+
+
# File 'lib/rspec/core/example_group.rb', line 291
+
+define_nested_shared_group_method :it_behaves_like, "behaves like"
+
+
+ +
+

+ + + (void) it_should_behave_like + + + + + +

+
+ +

Generates a nested example group and includes the shared content mapped to +name in the nested group.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+294
+
+
# File 'lib/rspec/core/example_group.rb', line 294
+
+define_nested_shared_group_method :it_should_behave_like
+
+
+ +
+

+ + + (void) metadata + + + + + +

+
+ +

The Metadata object associated with this group.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+44
+45
+46
+
+
# File 'lib/rspec/core/example_group.rb', line 44
+
+def self.
+  @metadata if defined?(@metadata)
+end
+
+
+ +
+

+ + + (void) pending {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :pending => true

+ + +
+
+
+ +
+

Examples:

+ + +
pending do
+end
+
+pending "does something" do
+end
+
+pending "does something", :with => 'additional metadata' do
+end
+
+pending "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+171
+
+
# File 'lib/rspec/core/example_group.rb', line 171
+
+define_example_method :pending,  :pending => true
+
+
+ +
+

+ + + (void) run(reporter) + + + + + +

+
+ +

Runs all the examples in this group

+ + +
+
+
+ + +
+ + + + +
+
+
+
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+
+
# File 'lib/rspec/core/example_group.rb', line 448
+
+def self.run(reporter)
+  if RSpec.world.wants_to_quit
+    RSpec.world.clear_remaining_example_groups if top_level?
+    return
+  end
+  reporter.example_group_started(self)
+
+  begin
+    run_before_context_hooks(new)
+    result_for_this_group = run_examples(reporter)
+    results_for_descendants = ordering_strategy.order(children).map { |child| child.run(reporter) }.all?
+    result_for_this_group && results_for_descendants
+  rescue Pending::SkipDeclaredInExample => ex
+    for_filtered_examples(reporter) {|example| example.skip_with_exception(reporter, ex) }
+  rescue Exception => ex
+    RSpec.world.wants_to_quit = true if fail_fast?
+    for_filtered_examples(reporter) {|example| example.fail_with_exception(reporter, ex) }
+  ensure
+    run_after_context_hooks(new)
+    before_context_ivars.clear
+    reporter.example_group_finished(self)
+  end
+end
+
+
+ +
+

+ + + (void) skip {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => true

+ + +
+
+
+ +
+

Examples:

+ + +
skip do
+end
+
+skip "does something" do
+end
+
+skip "does something", :with => 'additional metadata' do
+end
+
+skip "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+168
+
+
# File 'lib/rspec/core/example_group.rb', line 168
+
+define_example_method :skip,     :skip => true
+
+
+ +
+

+ + + (void) specify {|Example| ... } + + + + + +

+
+ +

Defines an example within a group. Useful for when your docstring does not +read well off of it.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.describe MyClass do
+  specify "#do_something is deprecated" do
+    # ...
+  end
+end
+ + +
specify do
+end
+
+specify "does something" do
+end
+
+specify "does something", :with => 'additional metadata' do
+end
+
+specify "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+143
+
+
# File 'lib/rspec/core/example_group.rb', line 143
+
+define_example_method :specify
+
+
+ +
+

+ + + (void) xcontext { ... } + + + + + +

+
+ +

Shortcut to temporarily make an example group skipped. Generates a subclass +of this example group which inherits everything except the examples +themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  xcontext "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+257
+
+
# File 'lib/rspec/core/example_group.rb', line 257
+
+define_example_group_method :xcontext,  :skip => "Temporarily skipped with xcontext"
+
+
+ +
+

+ + + (void) xdescribe { ... } + + + + + +

+
+ +

Shortcut to temporarily make an example group skipped. Generates a subclass +of this example group which inherits everything except the examples +themselves.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.describe "something" do # << This describe method is defined in
+                              # << RSpec::Core::DSL, included in the
+                              # << global namespace (optional)
+  before do
+    do_something_before
+  end
+
+  let(:thing) { Thing.new }
+
+  xdescribe "attribute (of something)" do
+    # examples in the group get the before hook
+    # declared above, and can access `thing`
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    The example group doc string

    +
    + +
  • + +
  • + + metadata + + + (Hash) + + + + — +
    +

    Additional metadata to attach to the example group

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    The example group definition

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+253
+
+
# File 'lib/rspec/core/example_group.rb', line 253
+
+define_example_group_method :xdescribe, :skip => "Temporarily skipped with xdescribe"
+
+
+ +
+

+ + + (void) xexample {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => 'Temporarily +skipped with xexample'

+ + +
+
+
+ +
+

Examples:

+ + +
xexample do
+end
+
+xexample "does something" do
+end
+
+xexample "does something", :with => 'additional metadata' do
+end
+
+xexample "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+159
+
+
# File 'lib/rspec/core/example_group.rb', line 159
+
+define_example_method :xexample, :skip => 'Temporarily skipped with xexample'
+
+
+ +
+

+ + + (void) xit {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => 'Temporarily +skipped with xit'

+ + +
+
+
+ +
+

Examples:

+ + +
xit do
+end
+
+xit "does something" do
+end
+
+xit "does something", :with => 'additional metadata' do
+end
+
+xit "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+162
+
+
# File 'lib/rspec/core/example_group.rb', line 162
+
+define_example_method :xit,      :skip => 'Temporarily skipped with xit'
+
+
+ +
+

+ + + (void) xspecify {|Example| ... } + + + + + +

+
+ +

Shortcut to define an example with :skip => 'Temporarily +skipped with xspecify'

+ + +
+
+
+ +
+

Examples:

+ + +
xspecify do
+end
+
+xspecify "does something" do
+end
+
+xspecify "does something", :with => 'additional metadata' do
+end
+
+xspecify "does something" do |ex|
+  # ex is the Example object that contains metadata about the example
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String) + + + +
  • + +
  • + + extra_options + + + (Hash) + + + +
  • + +
  • + + implementation + + + (Block) + + + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example object

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+165
+
+
# File 'lib/rspec/core/example_group.rb', line 165
+
+define_example_method :xspecify, :skip => 'Temporarily skipped with xspecify'
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (void) described_class + + + + + +

+
+ +

Returns the class or module passed to the describe method (or +alias). Returns nil if the subject is not a class or module.

+ + +
+
+
+ +
+

Examples:

+ + +
describe Thing do
+  it "does something" do
+    described_class == Thing
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+79
+80
+81
+
+
# File 'lib/rspec/core/example_group.rb', line 79
+
+def described_class
+  self.class.described_class
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters.html new file mode 100644 index 000000000..596ff7cc2 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters.html @@ -0,0 +1,354 @@ + + + + + + Module: RSpec::Core::Formatters + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Formatters + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/formatters.rb,
+ lib/rspec/core/formatters/helpers.rb,
lib/rspec/core/formatters/html_printer.rb,
lib/rspec/core/formatters/console_codes.rb,
lib/rspec/core/formatters/base_formatter.rb,
lib/rspec/core/formatters/html_formatter.rb,
lib/rspec/core/formatters/json_formatter.rb,
lib/rspec/core/formatters/snippet_extractor.rb,
lib/rspec/core/formatters/profile_formatter.rb,
lib/rspec/core/formatters/progress_formatter.rb,
lib/rspec/core/formatters/base_text_formatter.rb,
lib/rspec/core/formatters/deprecation_formatter.rb,
lib/rspec/core/formatters/documentation_formatter.rb
+
+ +
+
+ +

Overview

+
+ +

Built-in Formatters

+
  • +

    progress (default) - prints dots for passing examples, F for +failures, * for pending

    +
  • +

    documentation - prints the docstrings passed to describe and +it methods (and their aliases)

    +
  • +

    html

    +
  • +

    json - useful for archiving data for subsequent analysis

    +
+ +

The progress formatter is the default, but you can choose any one or more +of the other formatters by passing with the --format (or +-f for short) command-line option, e.g.

+ +
rspec --format documentation
+ +

You can also send the output of multiple formatters to different streams, +e.g.

+ +
rspec --format documentation --format html --out results.html
+ +

This example sends the output of the documentation formatter to +$stdout, and the output of the html formatter to results.html.

+ +

Custom Formatters

+ +

You can tell RSpec to use a custom formatter by passing its path and name +to the rspec commmand. For example, if you define +MyCustomFormatter in path/to/my_custom_formatter.rb, you would type this +command:

+ +
rspec --require path/to/my_custom_formatter.rb --format MyCustomFormatter
+
+ +

The reporter calls every formatter with this protocol:

+
  • +

    To start

    +
  • +

    start(StartNotification)

    +
  • +

    Once per example group

    +
  • +

    example_group_started(GroupNotification)

    +
  • +

    Once per example

    +
  • +

    example_started(ExampleNotification)

    +
  • +

    One of these per example, depending on outcome

    +
  • +

    example_passed(ExampleNotification)

    +
  • +

    example_failed(FailedExampleNotification)

    +
  • +

    example_pending(ExampleNotification)

    +
  • +

    Optionally at any time

    +
  • +

    message(MessageNotification)

    +
  • +

    At the end of the suite

    +
  • +

    stop(ExamplesNotification)

    +
  • +

    start_dump(NullNotification)

    +
  • +

    dump_pending(ExamplesNotification)

    +
  • +

    dump_failures(ExamplesNotification)

    +
  • +

    dump_summary(SummaryNotification)

    +
  • +

    seed(SeedNotification)

    +
  • +

    close(NullNotification)

    +
+ +

Only the notifications to which you subscribe your formatter will be called +on your formatter. To subscribe your formatter use: +RSpec::Core::Formatters#register e.g.

+ +

RSpec::Core::Formatters.register FormatterClassName, :example_passed, +:example_failed

+ +

We recommend you implement the methods yourself; for simplicity we provide +the default formatter output via our notification objects but if you prefer +you can subclass RSpec::Core::Formatters::BaseTextFormatter +and override the methods you wish to enhance.

+ + +
+
+
+ + +

See Also:

+ + +

Defined Under Namespace

+

+ + + Modules: ConsoleCodes, Helpers + + + + Classes: BaseFormatter, BaseTextFormatter, Loader, ProfileFormatter, SnippetExtractor + + +

+ + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (void) register(formatter_class, *notifications) + + + + + +

+
+ +

Register the formatter class

+ + +
+
+
+

Parameters:

+
    + +
  • + + formatter_class + + + (Class) + + + + — +
    +

    formatter class to register

    +
    + +
  • + +
  • + + notifications + + + (Symbol, ...) + + + + — +
    +

    one or more notifications to be registered to the specified formatter

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+77
+78
+79
+
+
# File 'lib/rspec/core/formatters.rb', line 77
+
+def self.register(formatter_class, *notifications)
+  Loader.formatters[formatter_class] = notifications
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseFormatter.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseFormatter.html new file mode 100644 index 000000000..39e341bab --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseFormatter.html @@ -0,0 +1,1629 @@ + + + + + + Class: RSpec::Core::Formatters::BaseFormatter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::BaseFormatter + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/base_formatter.rb
+ +
+
+ +

Overview

+
+ +

RSpec's built-in formatters are all subclasses of +RSpec::Core::Formatters::BaseTextFormatter, but the BaseTextFormatter +documents all of the notifications implemented as part of the standard +interface. The reporter will issue these during a normal test suite run, +but a formatter will only receive those notifications it has registered +itself to receive.

+ + +
+
+
+ + +

See Also:

+ + +
+

Direct Known Subclasses

+

BaseTextFormatter

+
+ + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (void) example_group + + + + + + + + + + + + + + + + +
    +

    Returns the value of attribute example_group.

    +
    + +
  • + + +
  • + + + - (void) output + + + + + + + + + readonly + + + + + + + + + +
    +

    Returns the value of attribute output.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (void) close(notification) + + + + + + + + + + + + + +
    +

    Invoked at the very end, close allows the formatter to clean +up resources, e.g.

    +
    + +
  • + + +
  • + + + - (void) dump_failures + + + + + + + + + + + + + +
    +

    Dumps detailed information about each example failure.

    +
    + +
  • + + +
  • + + + - (void) dump_pending + + + + + + + + + + + + + +
    +

    Outputs a report of pending examples.

    +
    + +
  • + + +
  • + + + - (void) dump_profile + + + + + + + + + + + + + +
    +

    This method is invoked after the dumping the summary if profiling is +enabled.

    +
    + +
  • + + +
  • + + + - (void) dump_summary + + + + + + + + + + + + + +
    +

    This method is invoked after the dumping of examples and failures.

    +
    + +
  • + + +
  • + + + - (void) example_failed + + + + + + + + + + + + + +
    +

    Invoked when an example fails.

    +
    + +
  • + + +
  • + + + - (void) example_group_finished + + + + + + + + + + + + + +
    +

    Invoked at the end of the execution of each example group.

    +
    + +
  • + + +
  • + + + - (void) example_group_started(notification) + + + + + + + + + + + + + +
    +

    This method is invoked at the beginning of the execution of each example +group.

    +
    + +
  • + + +
  • + + + - (void) example_passed + + + + + + + + + + + + + +
    +

    Invoked when an example passes.

    +
    + +
  • + + +
  • + + + - (void) example_pending + + + + + + + + + + + + + +
    +

    Invoked when an example is pending.

    +
    + +
  • + + +
  • + + + - (void) example_started + + + + + + + + + + + + + +
    +

    Invoked at the beginning of the execution of each example.

    +
    + +
  • + + +
  • + + + - (BaseFormatter) initialize(output) + + + + + + + constructor + + + + + + + + +
    +

    A new instance of BaseFormatter.

    +
    + +
  • + + +
  • + + + - (void) message + + + + + + + + + + + + + +
    +

    Used by the reporter to send messages to the output stream.

    +
    + +
  • + + +
  • + + + - (void) start(notification) + + + + + + + + + + + + + +
    +

    This method is invoked before any examples are run, right after they have +all been collected.

    +
    + +
  • + + +
  • + + + - (void) start_dump + + + + + + + + + + + + + +
    +

    This method is invoked after all of the examples have executed.

    +
    + +
  • + + +
  • + + + - (void) stop + + + + + + + + + + + + + +
    +

    Invoked after all examples have executed, before dumping post-run reports.

    +
    + +
  • + + +
+ + +
+

Constructor Details

+ +
+

+ + - (BaseFormatter) initialize(output) + + + + + +

+
+ +

Returns a new instance of BaseFormatter

+ + +
+
+
+

Parameters:

+
    + +
  • + + output + + + (IO) + + + + — +
    +

    the formatter output

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 24
+
+def initialize(output)
+  @output = output || StringIO.new
+  @example_group = nil
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) example_group + + + + + +

+
+ +

Returns the value of attribute example_group

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 18
+
+def example_group
+  @example_group
+end
+
+
+ + + +
+

+ + - (void) output (readonly) + + + + + +

+
+ +

Returns the value of attribute output

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 19
+
+def output
+  @output
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) close(notification) + + + + + +

+
+ +

Invoked at the very end, close allows the formatter to clean +up resources, e.g. open streams, etc.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+151
+152
+153
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 151
+
+def close(notification)
+  restore_sync_output
+end
+
+
+ +
+

+ + - (void) dump_failures + + + + + +

+
+ +

Dumps detailed information about each example failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 112
+
+
+
+
+ +
+

+ + - (void) dump_pending + + + + + +

+
+ +

Outputs a report of pending examples. This gets invoked after the summary +if option is set to do so.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 137
+
+
+
+
+ +
+

+ + - (void) dump_profile + + + + + +

+
+ +

This method is invoked after the dumping the summary if profiling is +enabled.

+ + +
+
+
+

Parameters:

+
    + +
  • + + profile + + + (ProfileNotification) + + + + — +
    +

    containing duration, slowest_examples and slowest_example_groups

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 128
+
+
+
+
+ +
+

+ + - (void) dump_summary + + + + + +

+
+ +

This method is invoked after the dumping of examples and failures. Each +parameter is assigned to a corresponding attribute.

+ + +
+
+
+

Parameters:

+
    + +
  • + + summary + + + (SummaryNotification) + + + + — +
    +

    containing duration, example_count, failure_count and pending_count

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 119
+
+
+
+
+ +
+

+ + - (void) example_failed + + + + + +

+
+ +

Invoked when an example fails.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 82
+
+
+
+
+ +
+

+ + - (void) example_group_finished + + + + + +

+
+ +

Invoked at the end of the execution of each example group.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (GroupNotification) + + + + — +
    +

    containing example_group subclass of RSpec::Core::ExampleGroup

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 56
+
+
+
+
+ +
+

+ + - (void) example_group_started(notification) + + + + + +

+
+ +

This method is invoked at the beginning of the execution of each example +group.

+ +

The next method to be invoked after this is #example_passed, +#example_pending, or #example_group_finished.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (GroupNotification) + + + + — +
    +

    containing example_group subclass of RSpec::Core::ExampleGroup

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 52
+
+def example_group_started(notification)
+  @example_group = notification.group
+end
+
+
+ +
+

+ + - (void) example_passed + + + + + +

+
+ +

Invoked when an example passes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 70
+
+
+
+
+ +
+

+ + - (void) example_pending + + + + + +

+
+ +

Invoked when an example is pending.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 77
+
+
+
+
+ +
+

+ + - (void) example_started + + + + + +

+
+ +

Invoked at the beginning of the execution of each example.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (ExampleNotification) + + + + — +
    +

    containing example subclass of RSpec::Core::Example

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 63
+
+
+
+
+ +
+

+ + - (void) message + + + + + +

+
+ +

Used by the reporter to send messages to the output stream.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (MessageNotification) + + + + — +
    +

    containing message

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 89
+
+
+
+
+ +
+

+ + - (void) start(notification) + + + + + +

+
+ +

This method is invoked before any examples are run, right after they have +all been collected. This can be useful for special formatters that need to +provide progress on feedback (graphical ones).

+ +

This will only be invoked once, and the next one to be invoked is +#example_group_started.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (StartNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+39
+40
+41
+42
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 39
+
+def start(notification)
+  start_sync_output
+  @example_count = notification.count
+end
+
+
+ +
+

+ + - (void) start_dump + + + + + +

+
+ +

This method is invoked after all of the examples have executed. The next +method to be invoked after this one is #dump_failures (BaseTextFormatter +then calls #dump_failure once for each failed example.)

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 103
+
+
+
+
+ +
+

+ + - (void) stop + + + + + +

+
+ +

Invoked after all examples have executed, before dumping post-run reports.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/core/formatters/base_formatter.rb', line 96
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html new file mode 100644 index 000000000..59e8d9444 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/BaseTextFormatter.html @@ -0,0 +1,524 @@ + + + + + + Class: RSpec::Core::Formatters::BaseTextFormatter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::BaseTextFormatter + + + +

+ +
+ +
Inherits:
+
+ BaseFormatter + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/base_text_formatter.rb
+ +
+
+ +

Overview

+
+ +

Base for all of RSpec's built-in formatters. See +RSpec::Core::Formatters::BaseFormatter to learn more about all of the +methods called by the reporter.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + +

Instance Attribute Summary

+ +

Attributes inherited from BaseFormatter

+

#example_group, #output

+ + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (void) close(notification) + + + + + + + + + + + + + +
    +

    Invoked at the very end, close allows the formatter to clean +up resources, e.g.

    +
    + +
  • + + +
  • + + + - (void) dump_failures + + + + + + + + + + + + + +
    +

    Dumps detailed information about each example failure.

    +
    + +
  • + + +
  • + + + - (void) dump_summary + + + + + + + + + + + + + +
    +

    This method is invoked after the dumping of examples and failures.

    +
    + +
  • + + +
  • + + + - (void) message + + + + + + + + + + + + + +
    +

    Used by the reporter to send messages to the output stream.

    +
    + +
  • + + +
+ + + + + + + + + + + +

Methods inherited from BaseFormatter

+

#dump_profile, #example_failed, #example_group_finished, #example_group_started, #example_passed, #example_pending, #example_started, #initialize, #start, #start_dump, #stop

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Core::Formatters::BaseFormatter

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) close(notification) + + + + + +

+
+ +

Invoked at the very end, close allows the formatter to clean +up resources, e.g. open streams, etc.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 68
+
+def close(notification)
+  return unless IO === output
+  return if output.closed? || output == $stdout
+
+  output.close
+end
+
+
+ +
+

+ + - (void) dump_failures + + + + + +

+
+ +

Dumps detailed information about each example failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (NullNotification) + + + +
  • + +
+ + +
+ + + + +
+
+
+
+33
+34
+35
+36
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 33
+
+def dump_failures(notification)
+  return if notification.failure_notifications.empty?
+  output.puts notification.fully_formatted_failed_examples
+end
+
+
+ +
+

+ + - (void) dump_summary + + + + + +

+
+ +

This method is invoked after the dumping of examples and failures. Each +parameter is assigned to a corresponding attribute.

+ + +
+
+
+

Parameters:

+
    + +
  • + + summary + + + (SummaryNotification) + + + + — +
    +

    containing duration, example_count, failure_count and pending_count

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 46
+
+def dump_summary(summary)
+  output.puts summary.fully_formatted
+end
+
+
+ +
+

+ + - (void) message + + + + + +

+
+ +

Used by the reporter to send messages to the output stream.

+ + +
+
+
+

Parameters:

+
    + +
  • + + notification + + + (MessageNotification) + + + + — +
    +

    containing message

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/core/formatters/base_text_formatter.rb', line 23
+
+def message(notification)
+  output.puts notification.message
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html new file mode 100644 index 000000000..40d1d2983 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ConsoleCodes.html @@ -0,0 +1,387 @@ + + + + + + Module: RSpec::Core::Formatters::ConsoleCodes + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Formatters::ConsoleCodes + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/console_codes.rb
+ +
+
+ +

Overview

+
+ +

ConsoleCodes provides helpers for formatting console output with ANSI +codes, e.g. color's and bold.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Fixnum) console_code_for(code_or_symbol) + + + + + +

+
+ +

Fetches the correct code for the supplied symbol, or checks that a code is +valid. Defaults to white (37).

+ + +
+
+
+

Parameters:

+
    + +
  • + + code_or_symbol + + + (Symbol, Fixnum) + + + + — +
    +

    Symbol or code to check

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    a console code

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+
+
# File 'lib/rspec/core/formatters/console_codes.rb', line 30
+
+def console_code_for(code_or_symbol)
+  if RSpec.configuration.respond_to?(:#{code_or_symbol}_color")
+    console_code_for configuration_color(code_or_symbol)
+  elsif VT100_CODE_VALUES.has_key?(code_or_symbol)
+    code_or_symbol
+  else
+    VT100_CODES.fetch(code_or_symbol) do
+      console_code_for(:white)
+    end
+  end
+end
+
+
+ +
+

+ + + (String) wrap(text, code_or_symbol) + + + + + +

+
+ +

Wraps a piece of text in ANSI codes with the supplied code. Will only apply +the control code if RSpec.configuration.color_enabled? returns +true.

+ + +
+
+
+

Parameters:

+
    + +
  • + + text + + + (String) + + + + — +
    +

    the text to wrap

    +
    + +
  • + +
  • + + code_or_symbol + + + (Symbol, Fixnum) + + + + — +
    +

    the desired control code

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the wrapped text

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+49
+50
+51
+52
+53
+54
+55
+
+
# File 'lib/rspec/core/formatters/console_codes.rb', line 49
+
+def wrap(text, code_or_symbol)
+  if RSpec.configuration.color_enabled?
+    "\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m"
+  else
+    text
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Helpers.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Helpers.html new file mode 100644 index 000000000..accf044a8 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Helpers.html @@ -0,0 +1,533 @@ + + + + + + Module: RSpec::Core::Formatters::Helpers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Formatters::Helpers + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/helpers.rb
+ +
+
+ +

Overview

+
+ +

Formatters helpers

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (String) format_duration(duration) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Formats seconds into a human-readable string.

+ + +
+
+
+ +
+

Examples:

+ + +
format_duration(1) #=>  "1 minute 1 second"
+format_duration(135.14) #=> "2 minutes 15.14 seconds"
+ +
+

Parameters:

+
    + +
  • + + duration + + + (Float, Fixnum) + + + + — +
    +

    in seconds

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    human-readable time

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+
# File 'lib/rspec/core/formatters/helpers.rb', line 23
+
+def self.format_duration(duration)
+  precision = case
+              when duration < 1;    SUB_SECOND_PRECISION
+              when duration < 120;  DEFAULT_PRECISION
+              when duration < 300;  1
+              else                  0
+              end
+
+  if duration > 60
+    minutes = (duration.to_i / 60).to_i
+    seconds = duration - minutes * 60
+
+    "#{pluralize(minutes, 'minute')} #{pluralize(format_seconds(seconds, precision), 'second')}"
+  else
+    pluralize(format_seconds(duration, precision), 'second')
+  end
+end
+
+
+ +
+

+ + + (String) format_seconds(float, precision = nil) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Formats seconds to have 5 digits of precision with trailing zeros removed +if the number is less than 1 or with 2 digits of precision if the number is +greater than zero.

+ +

The precision used is set in SUB_SECOND_PRECISION and +DEFAULT_PRECISION.

+ + +
+
+
+ +
+

Examples:

+ + +
format_seconds(0.000006) #=> "0.00001"
+format_seconds(0.020000) #=> "0.02"
+format_seconds(1.00000000001) #=> "1"
+ +
+

Parameters:

+
    + +
  • + + float + + + (Float) + + + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    formatted float

    +
    + +
  • + +
+ +

See Also:

+
    + +
  • #strip_trailing_zeroes
  • + +
+ +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+
+
# File 'lib/rspec/core/formatters/helpers.rb', line 57
+
+def self.format_seconds(float, precision = nil)
+  precision ||= (float < 1) ? SUB_SECOND_PRECISION : DEFAULT_PRECISION
+  formatted = sprintf("%.#{precision}f", float)
+  strip_trailing_zeroes(formatted)
+end
+
+
+ +
+

+ + + (String) pluralize(count, string) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Pluralize a word based on a count.

+ + +
+
+
+

Parameters:

+
    + +
  • + + count + + + (Fixnum) + + + + — +
    +

    number of objects

    +
    + +
  • + +
  • + + string + + + (String) + + + + — +
    +

    word to be pluralized

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    pluralized word

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+82
+83
+84
+
+
# File 'lib/rspec/core/formatters/helpers.rb', line 82
+
+def self.pluralize(count, string)
+  "#{count} #{string}#{'s' unless count.to_f == 1}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Loader.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Loader.html new file mode 100644 index 000000000..11d86328a --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/Loader.html @@ -0,0 +1,601 @@ + + + + + + Class: RSpec::Core::Formatters::Loader + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::Loader + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

RSpec::Core::Formatters::Loader is an internal class for +managing formatters used by a particular configuration. It is not expected +to be used directly, but only through the configuration interface.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (String) default_formatter + + + + + + + + + + + + + + private + + +
    +

    The default formatter to setup, defaults to progress.

    +
    + +
  • + + +
  • + + + - (Array) formatters + + + + + + + + + readonly + + + + + + + private + + +
    +

    The loaded formatters.

    +
    + +
  • + + +
  • + + + - (Reporter) reporter + + + + + + + + + readonly + + + + + + + private + + +
    +

    The reporter.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + (collapse) +

+ +
    + +
  • + + + + (void) formatters + + + + + + + + + + + private + + +
    +

    Internal formatters are stored here when loaded.

    +
    + +
  • + + +
+ +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Loader) initialize(reporter) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of Loader

+ + +
+
+
+ + +
+ + + + +
+
+
+
+96
+97
+98
+99
+100
+
+
# File 'lib/rspec/core/formatters.rb', line 96
+
+def initialize(reporter)
+  @formatters = []
+  @reporter = reporter
+  self.default_formatter = 'progress'
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (String) default_formatter + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns the default formatter to setup, defaults to progress

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the default formatter to setup, defaults to progress

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+109
+110
+111
+
+
# File 'lib/rspec/core/formatters.rb', line 109
+
+def default_formatter
+  @default_formatter
+end
+
+
+ + + +
+

+ + - (Array) formatters (readonly) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns the loaded formatters

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array) + + + + — +
    +

    the loaded formatters

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+103
+104
+105
+
+
# File 'lib/rspec/core/formatters.rb', line 103
+
+def formatters
+  @formatters
+end
+
+
+ + + +
+

+ + - (Reporter) reporter (readonly) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns the reporter

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Reporter) + + + + — +
    +

    the reporter

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+106
+107
+108
+
+
# File 'lib/rspec/core/formatters.rb', line 106
+
+def reporter
+  @reporter
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (void) formatters + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Internal formatters are stored here when loaded

+ + +
+
+
+ + +
+ + + + +
+
+
+
+91
+92
+93
+
+
# File 'lib/rspec/core/formatters.rb', line 91
+
+def self.formatters
+  @formatters ||= {}
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html new file mode 100644 index 000000000..c78930297 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/ProfileFormatter.html @@ -0,0 +1,316 @@ + + + + + + Class: RSpec::Core::Formatters::ProfileFormatter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::ProfileFormatter + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/profile_formatter.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

Formatter for providing profile output

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ProfileFormatter) initialize(output) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of ProfileFormatter

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'lib/rspec/core/formatters/profile_formatter.rb', line 12
+
+def initialize(output)
+  @output = output
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) dump_profile + + + + + +

+
+ +

This method is invoked after the dumping the summary if profiling is +enabled.

+ + +
+
+
+

Parameters:

+
    + +
  • + + profile + + + (ProfileNotification) + + + + — +
    +

    containing duration, slowest_examples and slowest_example_groups

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+27
+28
+29
+30
+
+
# File 'lib/rspec/core/formatters/profile_formatter.rb', line 27
+
+def dump_profile(profile)
+  dump_profile_slowest_examples(profile)
+  dump_profile_slowest_example_groups(profile)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html new file mode 100644 index 000000000..f0ccfc62a --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Formatters/SnippetExtractor.html @@ -0,0 +1,681 @@ + + + + + + Class: RSpec::Core::Formatters::SnippetExtractor + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Formatters::SnippetExtractor + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/formatters/snippet_extractor.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

Extracts code snippets by looking at the backtrace of the passed error and +applies synax highlighting and line numbers using html.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (String) lines_around(file, line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Extract lines of code centered around a particular line within a source +file.

+ + +
+
+
+

Parameters:

+
    + +
  • + + file + + + (String) + + + + — +
    +

    filename

    +
    + +
  • + +
  • + + line + + + (Fixnum) + + + + — +
    +

    line number

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    lines around the target line within the file (2 above and 1 below).

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 68
+
+def lines_around(file, line)
+  if File.file?(file)
+    lines = File.read(file).split("\n")
+    min = [0, line-3].max
+    max = [line+1, lines.length-1].min
+    selected_lines = []
+    selected_lines.join("\n")
+    lines[min..max].join("\n")
+  else
+    "# Couldn't get snippet for #{file}"
+  end
+rescue SecurityError
+  "# Couldn't get snippet for #{file}"
+end
+
+
+ +
+

+ + - (String) post_process(highlighted, offending_line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Adds line numbers to all lines and highlights the line where the failure +occurred using html span tags.

+ + +
+
+
+

Parameters:

+
    + +
  • + + highlighted + + + (String) + + + + — +
    +

    syntax-highlighted snippet surrounding the offending line of code

    +
    + +
  • + +
  • + + offending_line + + + (Fixnum) + + + + — +
    +

    line where failure occured

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    completed snippet

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+90
+91
+92
+93
+94
+95
+96
+97
+98
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 90
+
+def post_process(highlighted, offending_line)
+  new_lines = []
+  highlighted.split("\n").each_with_index do |line, i|
+    new_line = "<span class=\"linenum\">#{offending_line+i-2}</span>#{line}"
+    new_line = "<span class=\"offending\">#{new_line}</span>" if i == 2
+    new_lines << new_line
+  end
+  new_lines.join("\n")
+end
+
+
+ +
+

+ + - (String) snippet(backtrace) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Extract lines of code corresponding to a backtrace.

+ + +
+
+
+

Parameters:

+
    + +
  • + + backtrace + + + (String) + + + + — +
    +

    the backtrace from a test failure

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    highlighted code snippet indicating where the test failure occured

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+37
+38
+39
+40
+41
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 37
+
+def snippet(backtrace)
+  raw_code, line = snippet_for(backtrace[0])
+  highlighted = @@converter.convert(raw_code)
+  post_process(highlighted, line)
+end
+
+
+ +
+

+ + - (String) snippet_for(error_line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Create a snippet from a line of code.

+ + +
+
+
+

Parameters:

+
    + +
  • + + error_line + + + (String) + + + + — +
    +

    file name with line number (i.e. 'foo_spec.rb:12')

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    lines around the target line within the file

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+51
+52
+53
+54
+55
+56
+57
+58
+59
+
+
# File 'lib/rspec/core/formatters/snippet_extractor.rb', line 51
+
+def snippet_for(error_line)
+  if error_line =~ /(.*):(\d+)/
+    file = $1
+    line = $2.to_i
+    [lines_around(file, line), line]
+  else
+    ["# Couldn't get snippet for #{error_line}", 1]
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Hooks.html b/source/documentation/3.0/rspec-core/RSpec/Core/Hooks.html new file mode 100644 index 000000000..a75d9ffd2 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Hooks.html @@ -0,0 +1,1233 @@ + + + + + + Module: RSpec::Core::Hooks + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Hooks + + + +

+ +
+ + + + + + + +
Included in:
+
Configuration, ExampleGroup, World
+ + + +
Defined in:
+
lib/rspec/core/hooks.rb
+ +
+
+ +

Overview

+
+ +

Provides before, after and around +hooks as a means of supporting common setup and teardown. This module is +extended onto ExampleGroup, making the methods available from any +describe or context block and included in +Configuration, making them available off of the configuration object to +define global setup or teardown logic.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (void) after(*args, &block) + + + + (also: #prepend_after) + + + + + + + + + + + +
    +

    Declare a block of code to be run after each example (using +:example) or once after all examples n the context (using +:context).

    +
    + +
  • + + +
  • + + + - (void) append_after(*args, &block) + + + + + + + + + + + + + +
    +

    Adds block to the back of the list of after +blocks in the same scope (:example, :context, or +:suite).

    +
    + +
  • + + +
  • + + + - (void) around(*args) {|Example| ... } + + + + + + + + + + + + + +
    +

    Declare a block of code, parts of which will be run before and parts after +the example.

    +
    + +
  • + + +
  • + + + - (void) before(*args, &block) + + + + (also: #append_before) + + + + + + + + + + + +
    +

    Declare a block of code to be run before each example (using +:example) or once before any example (using +:context).

    +
    + +
  • + + +
  • + + + - (void) prepend_before(*args, &block) + + + + + + + + + + + + + +
    +

    Adds block to the front of the list of before +blocks in the same scope (:example, :context, or +:suite).

    +
    + +
  • + + +
+ + + + +
+

Instance Method Details

+ + +
+

+ + + - (void) after(&block) + + - (void) after(scope, &block) + + - (void) after(scope, conditions, &block) + + - (void) after(conditions, &block) + + + + + Also known as: + prepend_after + + + + +

+
+ +
+ Note: +
+

The :example and :context scopes are also +available as :each and :all, respectively. Use +whichever you prefer.

+
+
+ + +

Declare a block of code to be run after each example (using +:example) or once after all examples n the context (using +:context). See #before for more information about ordering.

+ +

Exceptions

+ +

after hooks are guaranteed to run even when there are +exceptions in before hooks or examples. When an exception is +raised in an after block, the exception is captured for later reporting, +and subsequent after blocks are run.

+ +

Order

+ +

after hooks are stored in three scopes, which are run in +order: :example, :context, and +:suite. They can also be declared in several different places: +RSpec.configure, a parent group, the current group. They are +run in the following order:

+ +
after(:example) # declared in the current group
+after(:example) # declared in a parent group
+after(:example) # declared in RSpec.configure
+after(:context) # declared in the current group
+after(:context) # declared in a parent group
+after(:context) # declared in RSpec.configure
+after(:suite)   # declared in RSpec.configure
+ +

This is the reverse of the order in which before hooks are +run. Similarly, if more than one after is declared within any +one scope, they are run in reverse order of that in which they are +declared.

+ + +
+
+
+ +

Overloads:

+
    + + + +
  • + - (void) after(scope, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) after(scope, conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +after(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) after(conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +after(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+253
+254
+255
+
+
# File 'lib/rspec/core/hooks.rb', line 253
+
+def after(*args, &block)
+  hooks.register :prepend, :after, *args, &block
+end
+
+
+ +
+

+ + - (void) append_after(*args, &block) + + + + + +

+
+ +

Adds block to the back of the list of after +blocks in the same scope (:example, :context, or +:suite).

+ +

See #after for scoping semantics.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+263
+264
+265
+
+
# File 'lib/rspec/core/hooks.rb', line 263
+
+def append_after(*args, &block)
+  hooks.register :append, :after, *args, &block
+end
+
+
+ +
+

+ + + - (void) around(&block) + + - (void) around(scope, &block) + + - (void) around(scope, conditions, &block) + + - (void) around(conditions, &block) + + + + + + +

+
+ +
+ Note: +
+

the syntax of around is similar to that of before +and after but the semantics are quite different. +before and after hooks are run in the context of +of the examples with which they are associated, whereas around +hooks are actually responsible for running the examples. Consequently, +around hooks do not have direct access to resources that are +made available within the examples and their associated before +and after hooks.

+
+
+ +
+ Note: +
+

:example/:each is the only supported scope.

+
+
+ + +

Declare a block of code, parts of which will be run before and parts after +the example. It is your responsibility to run the example:

+ +
around(:example) do |ex|
+  # do some stuff before
+  ex.run
+  # do some stuff after
+end
+
+ +

The yielded example aliases run with call, which +lets you treat it like a Proc. This is especially handy when +working with libaries that manage their own setup and teardown using a +block or proc syntax, e.g.

+ +
around(:example) {|ex| Database.transaction(&ex)}
+around(:example) {|ex| FakeFS(&ex)}
+
+ + +
+
+
+ +

Overloads:

+
    + + + +
  • + - (void) around(scope, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example (defaults to :example) present for +syntax parity with before and after, but +:example/:each is the only supported value.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) around(scope, conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example (defaults to :example) present for +syntax parity with before and after, but +:example/:each is the only supported value.

      +
      + +
    • + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +around(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) around(conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +around(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Yields:

+
    + +
  • + + + (Example) + + + + — +
    +

    the example to run

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+316
+317
+318
+
+
# File 'lib/rspec/core/hooks.rb', line 316
+
+def around(*args, &block)
+  hooks.register :prepend, :around, *args, &block
+end
+
+
+ +
+

+ + + - (void) before(&block) + + - (void) before(scope, &block) + + - (void) before(scope, conditions, &block) + + - (void) before(conditions, &block) + + + + + Also known as: + append_before + + + + +

+
+ +
+ Note: +
+

The :example and :context scopes are also +available as :each and :all, respectively. Use +whichever you prefer.

+
+
+ + +

Declare a block of code to be run before each example (using +:example) or once before any example (using +:context). These are usually declared directly in the +ExampleGroup to which they apply, but they can also be shared across +multiple groups.

+ +

You can also use before(:suite) to run a block of code before +any example groups are run. This should be declared in RSpec.configure

+ +

Instance variables declared in before(:example) or +before(:context) are accessible within each example.

+ +

Order

+ +

before hooks are stored in three scopes, which are run in +order: :suite, :context, and +:example. They can also be declared in several different +places: RSpec.configure, a parent group, the current group. +They are run in the following order:

+ +
before(:suite)    # declared in RSpec.configure
+before(:context)  # declared in RSpec.configure
+before(:context)  # declared in a parent group
+before(:context)  # declared in the current group
+before(:example)  # declared in RSpec.configure
+before(:example)  # declared in a parent group
+before(:example)  # declared in the current group
+ +

If more than one before is declared within any one scope, they +are run in the order in which they are declared.

+ +

Conditions

+ +

When you add a conditions hash to before(:example) or +before(:context), RSpec will only apply that hook to groups or +examples that match the conditions. e.g.

+ +
RSpec.configure do |config|
+  config.before(:example, :authorized => true) do
+     :authorized_user
+  end
+end
+
+describe Something, :authorized => true do
+  # the before hook will run in before each example in this group
+end
+
+describe SomethingElse do
+  it "does something", :authorized => true do
+    # the before hook will run before this example
+  end
+
+  it "does something else" do
+    # the hook will not run before this example
+  end
+end
+
+ +

Warning: before(:suite, :with => :conditions)

+ +

The conditions hash is used to match against specific examples. Since +before(:suite) is not run in relation to any specific example +or group, conditions passed along with :suite are effectively +ignored.

+ +

Exceptions

+ +

When an exception is raised in a before block, RSpec skips any +subsequent before blocks and the example, but runs all of the +after(:example) and after(:context) hooks.

+ +

Warning: implicit before blocks

+ +

before hooks can also be declared in shared contexts which get +included implicitly either by you or by extension libraries. Since RSpec +runs these in the order in which they are declared within each scope, load +order matters, and can lead to confusing results when one before block +depends on state that is prepared in another before block that gets run +later.

+ +

Warning: before(:context)

+ +

It is very tempting to use before(:context) to speed things +up, but we recommend that you avoid this as there are a number of gotchas, +as well as things that simply don't work.

+ +

context

+ +

before(:context) is run in an example that is generated to +provide group context for the block.

+ +

instance variables

+ +

Instance variables declared in before(:context) are shared +across all the examples in the group. This means that each example can +change the state of a shared object, resulting in an ordering dependency +that can make it difficult to reason about failures.

+ +

unsupported rspec constructs

+ +

RSpec has several constructs that reset state between each example +automatically. These are not intended for use from within +before(:context):

+
  • +

    let declarations

    +
  • +

    subject declarations

    +
  • +

    Any mocking, stubbing or test double declaration

    +
+ +

other frameworks

+ +

Mock object frameworks and database transaction managers (like +ActiveRecord) are typically designed around the idea of setting up before +an example, running that one example, and then tearing down. This means +that mocks and stubs can (sometimes) be declared in +before(:context), but get torn down before the first real +example is ever run.

+ +

You can create database-backed model objects in a +before(:context) in rspec-rails, but it will not be wrapped in +a transaction for you, so you are on your own to clean up in an +after(:context) block.

+ + +
+
+
+ +
+

Examples:

+ + +

+

before(:example) declared in an ExampleGroup

+

+ +

+describe Thing do
+  before(:example) do
+    @thing = Thing.new
+  end
+
+  it "does something" do
+    # here you can access @thing
+  end
+end
+ + +

+

before(:context) declared in an ExampleGroup

+

+ +

+describe Parser do
+  before(:context) do
+    File.open(file_to_parse, 'w') do |f|
+      f.write <<-CONTENT
+        stuff in the file
+      CONTENT
+    end
+  end
+
+  it "parses the file" do
+    Parser.parse(file_to_parse)
+  end
+
+  after(:context) do
+    File.delete(file_to_parse)
+  end
+end
+ +
+ +

Overloads:

+
    + + + +
  • + - (void) before(scope, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) before(scope, conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + scope + + + (Symbol) + + + + — +
      +

      :example, :context, or :suite +(defaults to :example)

      +
      + +
    • + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +before(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) before(conditions, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + conditions + + + (Hash) + + + + — +
      +

      constrains this hook to examples matching these conditions e.g. +before(:example, :ui => true) { ... } will only run with +examples or groups declared with :ui => true.

      +
      + +
    • + +
    + + +
    +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+184
+185
+186
+
+
# File 'lib/rspec/core/hooks.rb', line 184
+
+def before(*args, &block)
+  hooks.register :append, :before, *args, &block
+end
+
+
+ +
+

+ + - (void) prepend_before(*args, &block) + + + + + +

+
+ +

Adds block to the front of the list of before +blocks in the same scope (:example, :context, or +:suite).

+ +

See #before for scoping semantics.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+194
+195
+196
+
+
# File 'lib/rspec/core/hooks.rb', line 194
+
+def prepend_before(*args, &block)
+  hooks.register :prepend, :before, *args, &block
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers.html b/source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers.html new file mode 100644 index 000000000..9daa372cc --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers.html @@ -0,0 +1,603 @@ + + + + + + Module: RSpec::Core::MemoizedHelpers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::MemoizedHelpers + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/memoized_helpers.rb
+ +
+
+ +

Overview

+
+ +

This module is included in ExampleGroup, making the methods available to +be called from within example blocks.

+ + +
+
+
+ + +

See Also:

+ + +

Defined Under Namespace

+

+ + + Modules: ClassMethods + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (void) is_expected + + + + + +

+
+ +
+ Note: +
+

This only works if you are using rspec-expectations.

+
+
+ + +

Wraps the subject in expect to make it the target +of an expectation. Designed to read nicely for one-liners.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe [1, 2, 3] do
+  it { is_expected.to be_an Array }
+  it { is_expected.not_to include 4 }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+118
+119
+120
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 118
+
+def is_expected
+  expect(subject)
+end
+
+
+ +
+

+ + - (void) should(matcher = nil, message = nil) + + + + + +

+
+ +
+ Note: +
+

This only works if you are using rspec-expectations.

+
+
+ +
+ Note: +
+

If you are using RSpec's newer expect-based syntax you may want to use +is_expected.to instead of should.

+
+
+ + +

When should is called with no explicit receiver, the call is +delegated to the object returned by subject. Combined with an +implicit subject this supports very concise expressions.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe Person do
+  it { should be_eligible_to_vote }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+80
+81
+82
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 80
+
+def should(matcher=nil, message=nil)
+  RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
+end
+
+
+ +
+

+ + - (void) should_not(matcher = nil, message = nil) + + + + + +

+
+ +
+ Note: +
+

This only works if you are using rspec-expectations.

+
+
+ +
+ Note: +
+

If you are using RSpec's newer expect-based syntax you may want to use +is_expected.to_not instead of should_not.

+
+
+ + +

Just like should, should_not delegates to the +subject (implicit or explicit) of the example group.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe Person do
+  it { should_not be_eligible_to_vote }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+99
+100
+101
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 99
+
+def should_not(matcher=nil, message=nil)
+  RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
+end
+
+
+ +
+

+ + - (void) subject + + + + + +

+
+ +
+ Note: +
+

subject was contributed by Joe Ferris to support the one-liner +syntax embraced by shoulda matchers:

+ +
describe Widget do
+  it { is_expected.to validate_presence_of(:name) }
+  # or
+  it { should validate_presence_of(:name) }
+end
+ +

While the examples below demonstrate how to use subject +explicitly in examples, we recommend that you define a method with an +intention revealing name instead.

+
+
+ +
+ Note: +
+

Because subject is designed to create state that is reset +between each example, and before(:context) is designed to +setup state that is shared across all examples in an example +group, subject is not intended to be used in a +before(:context) hook.

+
+
+ + + +
+
+
+ +
+

Examples:

+ + +

+# explicit declaration of subject
+describe Person do
+  subject { Person.new(:birthdate => 19.years.ago) }
+  it "should be eligible to vote" do
+    subject.should be_eligible_to_vote
+    # ^ ^ explicit reference to subject not recommended
+  end
+end
+
+# implicit subject => { Person.new }
+describe Person do
+  it "should be eligible to vote" do
+    subject.should be_eligible_to_vote
+    # ^ ^ explicit reference to subject not recommended
+  end
+end
+
+# one-liner syntax - expectation is set on the subject
+describe Person do
+  it { is_expected.to be_eligible_to_vote }
+  # or
+  it { should be_eligible_to_vote }
+end
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+60
+61
+62
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 55
+
+def subject
+  __memoized.fetch(:subject) do
+    __memoized[:subject] = begin
+      described = described_class || self.class.description
+      Class === described ? described.new : described
+    end
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html b/source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html new file mode 100644 index 000000000..057d7838c --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/MemoizedHelpers/ClassMethods.html @@ -0,0 +1,690 @@ + + + + + + Module: RSpec::Core::MemoizedHelpers::ClassMethods + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::MemoizedHelpers::ClassMethods + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/memoized_helpers.rb
+ +
+
+ +

Overview

+
+ +

This module is extended onto ExampleGroup, making the methods available +to be called from within example group blocks. You can think of them as +being analagous to class macros.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (void) let(name, &block) + + + + + + + + + + + + + +
    +

    Generates a method whose return value is memoized after the first call.

    +
    + +
  • + + +
  • + + + - (void) let!(name, &block) + + + + + + + + + + + + + +
    +

    Just like let, except the block is invoked by an implicit +before hook.

    +
    + +
  • + + +
  • + + + - (void) subject(name = nil, &block) + + + + + + + + + + + + + +
    +

    Declares a subject for an example group which can then be +wrapped with expect using is_expected to make it +the target of an expectation in a concise, one-line example.

    +
    + +
  • + + +
  • + + + - (void) subject!(name = nil, &block) + + + + + + + + + + + + + +
    +

    Just like subject, except the block is invoked by an implicit +before hook.

    +
    + +
  • + + +
+ + + + +
+

Instance Method Details

+ + +
+

+ + - (void) let(name, &block) + + + + + +

+
+ +
+ Note: +
+

let can enhance readability when used sparingly (1,2, +or maybe 3 declarations) in any given example group, but that can quickly +degrade with overuse. YMMV.

+
+
+ +
+ Note: +
+

let uses an ||= conditional that has the +potential to behave in surprising ways in examples that spawn separate +threads, though we have yet to see this in practice. You've been +warned.

+
+
+ +
+ Note: +
+

Because let is designed to create state that is reset between +each example, and before(:context) is designed to setup state +that is shared across all examples in an example group, +let is not intended to be used in a +before(:context) hook.

+
+
+ + +

Generates a method whose return value is memoized after the first call. +Useful for reducing duplication between examples that assign values to the +same local variable.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe Thing do
+  let(:thing) { Thing.new }
+
+  it "does something" do
+    # first invocation, executes block, memoizes and returns result
+    thing.do_something
+
+    # second invocation, returns the memoized value
+    thing.should be_something
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 231
+
+def let(name, &block)
+  # We have to pass the block directly to `define_method` to
+  # allow it to use method constructs like `super` and `return`.
+  raise "#let or #subject called without a block" if block.nil?
+  MemoizedHelpers.module_for(self).__send__(:define_method, name, &block)
+
+  # Apply the memoization. The method has been defined in an ancestor
+  # module so we can use `super` here to get the value.
+  if block.arity == 1
+    define_method(name) { __memoized.fetch(name) { |k| __memoized[k] = super(RSpec.current_example, &nil) } }
+  else
+    define_method(name) { __memoized.fetch(name) { |k| __memoized[k] = super(&nil) } }
+  end
+end
+
+
+ +
+

+ + - (void) let!(name, &block) + + + + + +

+
+ +

Just like let, except the block is invoked by an implicit +before hook. This serves a dual purpose of setting up state +and providing a memoized reference to that state.

+ + +
+
+
+ +
+

Examples:

+ + +

+class Thing
+  def self.count
+    @count ||= 0
+  end
+
+  def self.count=(val)
+    @count += val
+  end
+
+  def self.reset_count
+    @count = 0
+  end
+
+  def initialize
+    self.class.count += 1
+  end
+end
+
+describe Thing do
+  after(:example) { Thing.reset_count }
+
+  context "using let" do
+    let(:thing) { Thing.new }
+
+    it "is not invoked implicitly" do
+      Thing.count.should eq(0)
+    end
+
+    it "can be invoked explicitly" do
+      thing
+      Thing.count.should eq(1)
+    end
+  end
+
+  context "using let!" do
+    let!(:thing) { Thing.new }
+
+    it "is invoked implicitly" do
+      Thing.count.should eq(1)
+    end
+
+    it "returns memoized version on first invocation" do
+      thing
+      Thing.count.should eq(1)
+    end
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+299
+300
+301
+302
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 299
+
+def let!(name, &block)
+  let(name, &block)
+  before { __send__(name) }
+end
+
+
+ +
+

+ + - (void) subject(name = nil, &block) + + + + + +

+
+ +

Declares a subject for an example group which can then be +wrapped with expect using is_expected to make it +the target of an expectation in a concise, one-line example.

+ +

Given a name, defines a method with that name which returns +the subject. This lets you declare the subject once and access +it implicitly in one-liners and explicitly using an intention revealing +name.

+ + +
+
+
+ +
+

Examples:

+ + +

+describe CheckingAccount, "with $50" do
+  subject { CheckingAccount.new(Money.new(50, :USD)) }
+  it { is_expected.to have_a_balance_of(Money.new(50, :USD)) }
+  it { is_expected.not_to be_overdrawn }
+end
+
+describe CheckingAccount, "with a non-zero starting balance" do
+  subject(:account) { CheckingAccount.new(Money.new(50, :USD)) }
+  it { is_expected.not_to be_overdrawn }
+  it "has a balance equal to the starting balance" do
+    .balance.should eq(Money.new(50, :USD))
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + name + + + (String, Symbol) + + + (defaults to: nil) + + + — +
    +

    used to define an accessor with an intention revealing name

    +
    + +
  • + +
  • + + block + + + + + + + — +
    +

    defines the value to be returned by subject in examples

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 336
+
+def subject(name=nil, &block)
+  if name
+    let(name, &block)
+    alias_method :subject, name
+
+    self::NamedSubjectPreventSuper.__send__(:define_method, name) do
+      raise NotImplementedError, "`super` in named subjects is not supported"
+    end
+  else
+    let(:subject, &block)
+  end
+end
+
+
+ +
+

+ + - (void) subject!(name = nil, &block) + + + + + +

+
+ +

Just like subject, except the block is invoked by an implicit +before hook. This serves a dual purpose of setting up state +and providing a memoized reference to that state.

+ + +
+
+
+ +
+

Examples:

+ + +

+class Thing
+  def self.count
+    @count ||= 0
+  end
+
+  def self.count=(val)
+    @count += val
+  end
+
+  def self.reset_count
+    @count = 0
+  end
+
+  def initialize
+    self.class.count += 1
+  end
+end
+
+describe Thing do
+  after(:example) { Thing.reset_count }
+
+  context "using subject" do
+    subject { Thing.new }
+
+    it "is not invoked implicitly" do
+      Thing.count.should eq(0)
+    end
+
+    it "can be invoked explicitly" do
+      subject
+      Thing.count.should eq(1)
+    end
+  end
+
+  context "using subject!" do
+    subject!(:thing) { Thing.new }
+
+    it "is invoked implicitly" do
+      Thing.count.should eq(1)
+    end
+
+    it "returns memoized version on first invocation" do
+      subject
+      Thing.count.should eq(1)
+    end
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+402
+403
+404
+405
+
+
# File 'lib/rspec/core/memoized_helpers.rb', line 402
+
+def subject!(name=nil, &block)
+  subject(name, &block)
+  before { subject }
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Metadata.html b/source/documentation/3.0/rspec-core/RSpec/Core/Metadata.html new file mode 100644 index 000000000..ca60ed964 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Metadata.html @@ -0,0 +1,287 @@ + + + + + + Module: RSpec::Core::Metadata + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Metadata + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/metadata.rb
+ +
+
+ +

Overview

+
+ +

Each ExampleGroup class and Example instance owns an instance of Metadata, +which is Hash extended to support lazy evaluation of values associated with +keys that may or may not be used by any example or group.

+ +

In addition to metadata that is used internally, this also stores +user-supplied metadata, e.g.

+ +
describe Something, :type => :ui do
+  it "does something", :slow => true do
+    # ...
+  end
+end
+
+ +

:type => :ui is stored in the Metadata owned by the example +group, and :slow => true is stored in the Metadata owned by +the example. These can then be used to select which examples are run using +the --tag option on the command line, or several methods on +Configuration used to filter a run (e.g. +filter_run_including, filter_run_excluding, etc).

+ + +
+
+ +

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (String) relative_path(line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns relative path to line

+ + +
+
+
+

Parameters:

+
    + +
  • + + line + + + (String) + + + + — +
    +

    current code line

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    relative path to line

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+32
+33
+34
+35
+36
+37
+38
+39
+
+
# File 'lib/rspec/core/metadata.rb', line 32
+
+def self.relative_path(line)
+  line = line.sub(File.expand_path("."), ".")
+  line = line.sub(/\A([^:]+:\d+)$/, '\\1')
+  return nil if line == '-e:1'
+  line
+rescue SecurityError
+  nil
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/MetadataFilter.html b/source/documentation/3.0/rspec-core/RSpec/Core/MetadataFilter.html new file mode 100644 index 000000000..2ab6714db --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/MetadataFilter.html @@ -0,0 +1,128 @@ + + + + + + Module: RSpec::Core::MetadataFilter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::MetadataFilter + + + +

+ +
+ + + +
Extended by:
+
MetadataFilter
+ + + + + + +
Included in:
+
MetadataFilter
+ + + +
Defined in:
+
lib/rspec/core/metadata_filter.rb
+ +
+
+ +

Overview

+
+ +

Contains metadata filtering logic. This has been extracted from the +metadata classes because it operates ON a metadata hash but does not manage +any of the state in the hash. We're moving towards having metadata be a +raw hash (not a custom subclass), so externalizing this filtering logic +helps us move in that direction.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications.html new file mode 100644 index 000000000..f47ffe8ed --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications.html @@ -0,0 +1,127 @@ + + + + + + Module: RSpec::Core::Notifications + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Notifications + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

Notifications are value objects passed to formatters to provide them with +information about a particular event of interest.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: DeprecationNotification, ExampleNotification, ExamplesNotification, FailedExampleNotification, GroupNotification, MessageNotification, NullNotification, PendingExampleFixedNotification, ProfileNotification, SeedNotification, StartNotification, SummaryNotification + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html new file mode 100644 index 000000000..d17bdcff0 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/DeprecationNotification.html @@ -0,0 +1,498 @@ + + + + + + Class: RSpec::Core::Notifications::DeprecationNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::DeprecationNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The DeprecationNotification is issued by the reporter when a +deprecated part of RSpec is encountered. It represents information about +the deprecated call site.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (String) call_site + + + + + + + + + + + + + + + + +
    +

    An optional call site from which the deprecation was issued.

    +
    + +
  • + + +
  • + + + - (String) deprecated + + + + + + + + + + + + + + + + +
    +

    A custom message about the deprecation (alias of message).

    +
    + +
  • + + +
  • + + + - (String) message + + + + + + + + + + + + + + + + +
    +

    A custom message about the deprecation.

    +
    + +
  • + + +
  • + + + - (String) replacement + + + + + + + + + + + + + + + + +
    +

    An optional replacement for the deprecation.

    +
    + +
  • + + +
+ + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (String) call_site + + + + + +

+
+ +

An optional call site from which the deprecation was issued

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of call_site

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+530
+531
+532
+
+
# File 'lib/rspec/core/notifications.rb', line 530
+
+def call_site
+  @call_site
+end
+
+
+ + + +
+

+ + - (String) deprecated + + + + + +

+
+ +

A custom message about the deprecation (alias of message)

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of deprecated

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+530
+531
+532
+
+
# File 'lib/rspec/core/notifications.rb', line 530
+
+def deprecated
+  @deprecated
+end
+
+
+ + + +
+

+ + - (String) message + + + + + +

+
+ +

A custom message about the deprecation

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+530
+531
+532
+
+
# File 'lib/rspec/core/notifications.rb', line 530
+
+def message
+  @message
+end
+
+
+ + + +
+

+ + - (String) replacement + + + + + +

+
+ +

An optional replacement for the deprecation

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of replacement

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+530
+531
+532
+
+
# File 'lib/rspec/core/notifications.rb', line 530
+
+def replacement
+  @replacement
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExampleNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExampleNotification.html new file mode 100644 index 000000000..dfa17fdb2 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExampleNotification.html @@ -0,0 +1,248 @@ + + + + + + Class: RSpec::Core::Notifications::ExampleNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::ExampleNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The ExampleNotification represents notifications sent by the +reporter which contain information about the current (or soon to be) +example. It is used by formatters to access information about that example.

+ + +
+
+
+ +
+

Examples:

+ + +
def example_started(notification)
+  puts "Hey I started #{notification.example.description}"
+end
+ +
+ + +
+

Direct Known Subclasses

+

FailedExampleNotification

+
+ + + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::Example) example + + + + + +

+
+ +

the current example

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/core/notifications.rb', line 36
+
+def example
+  @example
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html new file mode 100644 index 000000000..87e026a0f --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ExamplesNotification.html @@ -0,0 +1,861 @@ + + + + + + Class: RSpec::Core::Notifications::ExamplesNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::ExamplesNotification + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The ExamplesNotification represents notifications sent by the +reporter which contain information about the suites examples.

+ + +
+
+
+ +
+

Examples:

+ + +
def stop(notification)
+  puts "Hey I ran #{notification.examples.size}"
+end
+ +
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ExamplesNotification) initialize(reporter) + + + + + +

+
+ +

Returns a new instance of ExamplesNotification

+ + +
+
+
+ + +
+ + + + +
+
+
+
+60
+61
+62
+
+
# File 'lib/rspec/core/notifications.rb', line 60
+
+def initialize(reporter)
+  @reporter = reporter
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Array(RSpec::Core::Example)) examples + + + + + +

+
+ +

Returns list of examples

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+65
+66
+67
+
+
# File 'lib/rspec/core/notifications.rb', line 65
+
+def examples
+  @reporter.examples
+end
+
+
+ +
+

+ + - (Array(RSpec::Core::Example)) failed_examples + + + + + +

+
+ +

Returns list of failed examples

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+70
+71
+72
+
+
# File 'lib/rspec/core/notifications.rb', line 70
+
+def failed_examples
+  @reporter.failed_examples
+end
+
+
+ +
+

+ + - (Array(Rspec::Core::Notifications::FailedExampleNotification] +returns failed examples as notifications) failure_notifications + + + + + +

+
+ +

Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed +examples as notifications

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(Rspec::Core::Notifications::FailedExampleNotification] +returns failed examples as notifications) + + + + — +
    +

    Array(Rspec::Core::Notifications::FailedExampleNotification] returns failed +examples as notifications

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+87
+88
+89
+
+
# File 'lib/rspec/core/notifications.rb', line 87
+
+def failure_notifications
+  @failed_notifications ||= format(failed_examples)
+end
+
+
+ +
+

+ + - (String) fully_formatted_failed_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns The list of failed examples, fully formatted in the way that +RSpec's built-in formatters emit.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The list of failed examples, fully formatted in the way that RSpec's +built-in formatters emit.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+93
+94
+95
+96
+97
+98
+99
+100
+101
+
+
# File 'lib/rspec/core/notifications.rb', line 93
+
+def fully_formatted_failed_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
+  formatted = "\nFailures:\n"
+
+  failure_notifications.each_with_index do |failure, index|
+    formatted << failure.fully_formatted(index.next, colorizer)
+  end
+
+  formatted
+end
+
+
+ +
+

+ + - (String) fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns The list of pending examples, fully formatted in the way that +RSpec's built-in formatters emit.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The list of pending examples, fully formatted in the way that RSpec's +built-in formatters emit.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+
+
# File 'lib/rspec/core/notifications.rb', line 105
+
+def fully_formatted_pending_examples(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
+  formatted = "\nPending:\n"
+
+  pending_examples.each do |example|
+    formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location)
+
+    formatted <<
+      "  #{colorizer.wrap(example.full_description, :pending)}\n" <<
+      "    # #{colorizer.wrap(example.execution_result.pending_message, :detail)}\n" <<
+      "    # #{colorizer.wrap(formatted_caller, :detail)}\n"
+  end
+
+  formatted
+end
+
+
+ +
+

+ + - (Array(Rspec::Core::Notifications::ExampleNotification] +returns examples as notifications) notifications + + + + + +

+
+ +

Array(Rspec::Core::Notifications::ExampleNotification] returns examples as +notifications

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(Rspec::Core::Notifications::ExampleNotification] +returns examples as notifications) + + + + — +
    +

    Array(Rspec::Core::Notifications::ExampleNotification] returns examples as +notifications

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+81
+82
+83
+
+
# File 'lib/rspec/core/notifications.rb', line 81
+
+def notifications
+  @notifications ||= format(examples)
+end
+
+
+ +
+

+ + - (Array(RSpec::Core::Example)) pending_examples + + + + + +

+
+ +

Returns list of pending examples

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+75
+76
+77
+
+
# File 'lib/rspec/core/notifications.rb', line 75
+
+def pending_examples
+  @reporter.pending_examples
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html new file mode 100644 index 000000000..d9140286a --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/FailedExampleNotification.html @@ -0,0 +1,937 @@ + + + + + + Class: RSpec::Core::Notifications::FailedExampleNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::FailedExampleNotification + + + +

+ +
+ +
Inherits:
+
+ ExampleNotification + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The FailedExampleNotification extends +ExampleNotification with things useful for failed specs.

+ + +
+
+
+ +
+

Examples:

+ + +
def example_failed(notification)
+  puts "Hey I failed :("
+  puts "Here's my stack trace"
+  puts notification.exception.backtrace.join("\n")
+end
+ +
+ + +

See Also:

+ + +
+

Direct Known Subclasses

+

PendingExampleFixedNotification

+
+ + + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::Example) example + + + + + +

+
+ +

the current example

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+142
+143
+144
+
+
# File 'lib/rspec/core/notifications.rb', line 142
+
+def example
+  @example
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Array(String)) colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns the failures colorized formatted backtrace.

+ + +
+
+
+

Parameters:

+
    + +
  • + + colorizer + + + (#wrap) + + + (defaults to: ::RSpec::Core::Formatters::ConsoleCodes) + + + — +
    +

    An object to colorize the message_lines by

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    the examples colorized backtrace lines

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+183
+184
+185
+186
+187
+
+
# File 'lib/rspec/core/notifications.rb', line 183
+
+def colorized_formatted_backtrace(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
+  formatted_backtrace.map do |backtrace_info|
+    colorizer.wrap "# #{backtrace_info}", RSpec.configuration.detail_color
+  end
+end
+
+
+ +
+

+ + - (Array(String)) colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns the message generated for this failure colorized line by line.

+ + +
+
+
+

Parameters:

+
    + +
  • + + colorizer + + + (#wrap) + + + (defaults to: ::RSpec::Core::Formatters::ConsoleCodes) + + + — +
    +

    An object to colorize the message_lines by

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message colorized

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+166
+167
+168
+169
+170
+
+
# File 'lib/rspec/core/notifications.rb', line 166
+
+def colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
+  add_shared_group_line(failure_lines, colorizer).map do |line|
+    colorizer.wrap line, RSpec.configuration.failure_color
+  end
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+ +

Returns The example description

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The example description

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+151
+152
+153
+
+
# File 'lib/rspec/core/notifications.rb', line 151
+
+def description
+  example.full_description
+end
+
+
+ +
+

+ + - (Exception) exception + + + + + +

+
+ +

Returns The example failure

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Exception) + + + + — +
    +

    The example failure

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+146
+147
+148
+
+
# File 'lib/rspec/core/notifications.rb', line 146
+
+def exception
+  example.execution_result.exception
+end
+
+
+ +
+

+ + - (Array(String)) formatted_backtrace + + + + + +

+
+ +

Returns the failures formatted backtrace.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    the examples backtrace lines

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+175
+176
+177
+
+
# File 'lib/rspec/core/notifications.rb', line 175
+
+def formatted_backtrace
+  backtrace_formatter.format_backtrace(exception.backtrace, example.)
+end
+
+
+ +
+

+ + - (String) fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns The failure information fully formatted in the way that RSpec's +built-in formatters emit.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The failure information fully formatted in the way that RSpec's +built-in formatters emit.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+
+
# File 'lib/rspec/core/notifications.rb', line 191
+
+def fully_formatted(failure_number, colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
+  formatted = "\n  #{failure_number}) #{description}\n"
+
+  colorized_message_lines(colorizer).each do |line|
+    formatted << RSpec::Support::EncodedString.new("     #{line}\n", encoding_of(formatted))
+  end
+
+  colorized_formatted_backtrace(colorizer).each do |line|
+    formatted << RSpec::Support::EncodedString.new("     #{line}\n", encoding_of(formatted))
+  end
+
+  formatted
+end
+
+
+ +
+

+ + - (Array(String)) message_lines + + + + + +

+
+ +

Returns the message generated for this failure line by line.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+158
+159
+160
+
+
# File 'lib/rspec/core/notifications.rb', line 158
+
+def message_lines
+  add_shared_group_line(failure_lines, NullColorizer)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/GroupNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/GroupNotification.html new file mode 100644 index 000000000..c8442fe22 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/GroupNotification.html @@ -0,0 +1,245 @@ + + + + + + Class: RSpec::Core::Notifications::GroupNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::GroupNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The GroupNotification represents notifications sent by the +reporter which contain information about the currently running (or soon to +be) example group It is used by formatters to access information about that +group.

+ + +
+
+
+ +
+

Examples:

+ + +
def example_group_started(notification)
+  puts "Hey I started #{notification.group.description}"
+end
+ +
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::ExampleGroup) group + + + + + +

+
+ +

the current group

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+329
+330
+331
+
+
# File 'lib/rspec/core/notifications.rb', line 329
+
+def group
+  @group
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/MessageNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/MessageNotification.html new file mode 100644 index 000000000..c08506b8e --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/MessageNotification.html @@ -0,0 +1,233 @@ + + + + + + Class: RSpec::Core::Notifications::MessageNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::MessageNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The MessageNotification encapsulates generic messages that the +reporter sends to formatters.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (String) message + + + + + +

+
+ +

the message

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    the current value of message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+335
+336
+337
+
+
# File 'lib/rspec/core/notifications.rb', line 335
+
+def message
+  @message
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/NullNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/NullNotification.html new file mode 100644 index 000000000..fd9afe0b6 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/NullNotification.html @@ -0,0 +1,133 @@ + + + + + + Class: RSpec::Core::Notifications::NullNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::NullNotification + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

NullNotification represents a placeholder value for +notifications that currently require no information, but we may wish to +extend in future.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html new file mode 100644 index 000000000..4a109e8e1 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/PendingExampleFixedNotification.html @@ -0,0 +1,550 @@ + + + + + + Class: RSpec::Core::Notifications::PendingExampleFixedNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::PendingExampleFixedNotification + + + +

+ +
+ +
Inherits:
+
+ FailedExampleNotification + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The PendingExampleFixedNotification extends +ExampleNotification with things useful for specs that pass +when they are expected to fail.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from FailedExampleNotification

+

#colorized_formatted_backtrace, #exception, #formatted_backtrace, #fully_formatted

+ + + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (RSpec::Core::Example) example + + + + + +

+
+ +

the current example

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+294
+295
+296
+
+
# File 'lib/rspec/core/notifications.rb', line 294
+
+def example
+  @example
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Array(String)) colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes) + + + + + +

+
+ +

Returns the message generated for this failure colorized line by line.

+ + +
+
+
+

Parameters:

+
    + +
  • + + colorizer + + + (#wrap) + + + (defaults to: ::RSpec::Core::Formatters::ConsoleCodes) + + + — +
    +

    An object to colorize the message_lines by

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message colorized

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+315
+316
+317
+
+
# File 'lib/rspec/core/notifications.rb', line 315
+
+def colorized_message_lines(colorizer = ::RSpec::Core::Formatters::ConsoleCodes)
+  message_lines.map { |line| colorizer.wrap(line, RSpec.configuration.fixed_color) }
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+ +

Returns the examples description

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The example description

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+300
+301
+302
+
+
# File 'lib/rspec/core/notifications.rb', line 300
+
+def description
+  "#{example.full_description} FIXED"
+end
+
+
+ +
+

+ + - (Array(String)) message_lines + + + + + +

+
+ +

Returns the message generated for this failure line by line.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(String)) + + + + — +
    +

    The example failure message

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+307
+308
+309
+
+
# File 'lib/rspec/core/notifications.rb', line 307
+
+def message_lines
+  ["Expected pending '#{example.execution_result.pending_message}' to fail. No Error was raised."]
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ProfileNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ProfileNotification.html new file mode 100644 index 000000000..013962764 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/ProfileNotification.html @@ -0,0 +1,410 @@ + + + + + + Class: RSpec::Core::Notifications::ProfileNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::ProfileNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The ProfileNotification holds information about the results of +running a test suite when profiling is enabled. It is used by formatters to +provide information at the end of the test run for profiling information.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Float) duration + + + + + +

+
+ +

the time taken (in seconds) to run the suite

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of duration

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+463
+464
+465
+
+
# File 'lib/rspec/core/notifications.rb', line 463
+
+def duration
+  @duration
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) examples + + + + + +

+
+ +

the examples run

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+463
+464
+465
+
+
# File 'lib/rspec/core/notifications.rb', line 463
+
+def examples
+  @examples
+end
+
+
+ + + +
+

+ + - (Fixnum) number_of_examples + + + + + +

+
+ +

the number of examples to profile

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    the current value of number_of_examples

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+463
+464
+465
+
+
# File 'lib/rspec/core/notifications.rb', line 463
+
+def number_of_examples
+  @number_of_examples
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SeedNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SeedNotification.html new file mode 100644 index 000000000..24fbc6e4a --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SeedNotification.html @@ -0,0 +1,321 @@ + + + + + + Class: RSpec::Core::Notifications::SeedNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::SeedNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The SeedNotification holds the seed used to randomize examples +and wether that seed has been used or not.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Fixnum) seed + + + + + + + + + + + + + + + + +
    +

    the seed used to randomize ordering.

    +
    + +
  • + + +
  • + + + - (Boolean) used + + + + + + + + + + + + + + + + +
    +

    wether the seed has been used or not.

    +
    + +
  • + + +
+ + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Fixnum) seed + + + + + +

+
+ +

the seed used to randomize ordering

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    the current value of seed

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+342
+343
+344
+
+
# File 'lib/rspec/core/notifications.rb', line 342
+
+def seed
+  @seed
+end
+
+
+ + + +
+

+ + - (Boolean) used + + + + + +

+
+ +

wether the seed has been used or not

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    the current value of used

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+342
+343
+344
+
+
# File 'lib/rspec/core/notifications.rb', line 342
+
+def used
+  @used
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/StartNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/StartNotification.html new file mode 100644 index 000000000..a411189fa --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/StartNotification.html @@ -0,0 +1,322 @@ + + + + + + Class: RSpec::Core::Notifications::StartNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::StartNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The StartNotification represents a notification sent by the +reporter when the suite is started. It contains the expected amount of +examples to be executed, and the load time of RSpec.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Fixnum) count + + + + + + + + + + + + + + + + +
    +

    the number counted.

    +
    + +
  • + + +
  • + + + - (Float) load_time + + + + + + + + + + + + + + + + +
    +

    the number of seconds taken to boot RSpec and load the spec files.

    +
    + +
  • + + +
+ + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Fixnum) count + + + + + +

+
+ +

the number counted

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    the current value of count

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lib/rspec/core/notifications.rb', line 24
+
+def count
+  @count
+end
+
+
+ + + +
+

+ + - (Float) load_time + + + + + +

+
+ +

the number of seconds taken to boot RSpec and load the spec files

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of load_time

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lib/rspec/core/notifications.rb', line 24
+
+def load_time
+  @load_time
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SummaryNotification.html b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SummaryNotification.html new file mode 100644 index 000000000..e713d6d32 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Notifications/SummaryNotification.html @@ -0,0 +1,586 @@ + + + + + + Class: RSpec::Core::Notifications::SummaryNotification + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Notifications::SummaryNotification + + + +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/notifications.rb
+ +
+
+ +

Overview

+
+ +

The SummaryNotification holds information about the results of +running a test suite. It is used by formatters to provide information at +the end of the test run.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+ + + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Float) duration + + + + + +

+
+ +

the time taken (in seconds) to run the suite

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of duration

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+367
+368
+369
+
+
# File 'lib/rspec/core/notifications.rb', line 367
+
+def duration
+  @duration
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) examples + + + + + +

+
+ +

the examples run

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+367
+368
+369
+
+
# File 'lib/rspec/core/notifications.rb', line 367
+
+def examples
+  @examples
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) failed_examples + + + + + +

+
+ +

the failed examples

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(RSpec::Core::Example)) + + + + — +
    +

    the current value of failed_examples

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+367
+368
+369
+
+
# File 'lib/rspec/core/notifications.rb', line 367
+
+def failed_examples
+  @failed_examples
+end
+
+
+ + + +
+

+ + - (Float) load_time + + + + + +

+
+ +

the number of seconds taken to boot RSpec and load the spec files

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Float) + + + + — +
    +

    the current value of load_time

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+367
+368
+369
+
+
# File 'lib/rspec/core/notifications.rb', line 367
+
+def load_time
+  @load_time
+end
+
+
+ + + +
+

+ + - (Array(RSpec::Core::Example)) pending_examples + + + + + +

+
+ +

the pending examples

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Array(RSpec::Core::Example)) + + + + — +
    +

    the current value of pending_examples

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+367
+368
+369
+
+
# File 'lib/rspec/core/notifications.rb', line 367
+
+def pending_examples
+  @pending_examples
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Pending.html b/source/documentation/3.0/rspec-core/RSpec/Core/Pending.html new file mode 100644 index 000000000..f92884ad8 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Pending.html @@ -0,0 +1,473 @@ + + + + + + Module: RSpec::Core::Pending + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Pending + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/pending.rb
+ +
+
+ +

Overview

+
+ +

Provides methods to mark examples as pending. These methods are available +to be called from within any example or hook.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: SkipDeclaredInExample + + +

+ +

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + + - (void) pending + + - (void) pending(message) + + + + + + +

+
+ +
+ Note: +
+

before(:example) hooks are eval'd when you use the +pending method within an example. If you want to declare an +example pending and bypass the before hooks as +well, you can pass :pending => true to the it +method:

+ +
it "does something", :pending => true do
+  # ...
+end
+
+ +

or pass :pending => "something else getting +finished" to add a message to the summary report:

+ +
it "does something", :pending => "something else getting finished" do
+  # ...
+end
+
+
+
+ + +

Marks an example as pending. The rest of the example will still be +executed, and if it passes the example will fail to indicate that the +pending can be removed.

+ + +
+
+
+ +
+

Examples:

+ + +
describe "an example" do
+  # reported as "Pending: no reason given"
+  it "is pending with no message" do
+    pending
+    raise "broken"
+  end
+
+  # reported as "Pending: something else getting finished"
+  it "is pending with a custom message" do
+    pending("something else getting finished")
+    raise "broken"
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + message + + + (String) + + + (defaults to: nil) + + + — +
    +

    optional message to add to the summary report.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+
+
# File 'lib/rspec/core/pending.rb', line 68
+
+def pending(message=nil)
+  current_example = RSpec.current_example
+
+  if block_given?
+    raise ArgumentError, <<-EOS.gsub(/^\s+\|/, '')
+      |The semantics of `RSpec::Core::Pending#pending` have changed in
+      |RSpec 3.  In RSpec 2.x, it caused the example to be skipped. In
+      |RSpec 3, the rest of the example is still run but is expected to
+      |fail, and will be marked as a failure (rather than as pending) if
+      |the example passes.
+      |
+      |Passing a block within an example is now deprecated. Marking the
+      |example as pending provides the same behavior in RSpec 3 which was
+      |provided only by the block in RSpec 2.x.
+      |
+      |Move the code in the block provided to `pending` into the rest of
+      |the example body.
+      |
+      |Called from #{CallerFilter.first_non_rspec_line}.
+      |
+    EOS
+  elsif current_example
+    Pending.mark_pending! current_example, message
+  else
+    raise "`pending` may not be used outside of examples, such as in " +
+          "before(:context). Maybe you want `skip`?"
+  end
+end
+
+
+ +
+

+ + + - (void) skip + + - (void) skip(message) + + + + + + +

+
+ +

Marks an example as pending and skips execution.

+ + +
+
+
+ +
+

Examples:

+ + +
describe "an example" do
+  # reported as "Pending: no reason given"
+  it "is skipped with no message" do
+    skip
+  end
+
+  # reported as "Pending: something else getting finished"
+  it "is skipped with a custom message" do
+    skip "something else getting finished"
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + message + + + (String) + + + (defaults to: nil) + + + — +
    +

    optional message to add to the summary report.

    +
    + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+116
+117
+118
+119
+120
+121
+122
+123
+124
+
+
# File 'lib/rspec/core/pending.rb', line 116
+
+def skip(message=nil)
+  current_example = RSpec.current_example
+
+  if current_example
+    Pending.mark_skipped! current_example, message
+  end
+
+  raise SkipDeclaredInExample.new(message)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html b/source/documentation/3.0/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html new file mode 100644 index 000000000..186d50b71 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Pending/SkipDeclaredInExample.html @@ -0,0 +1,299 @@ + + + + + + Exception: RSpec::Core::Pending::SkipDeclaredInExample + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Exception: RSpec::Core::Pending::SkipDeclaredInExample + + + +

+ +
+ +
Inherits:
+
+ StandardError + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/pending.rb
+ +
+
+ +

Overview

+
+ +

Raised in the middle of an example to indicate that it should be marked as +skipped.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (void) argument + + + + + + + + + readonly + + + + + + + + + +
    +

    Returns the value of attribute argument.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + +
+

Constructor Details

+ +
+

+ + - (SkipDeclaredInExample) initialize(argument) + + + + + +

+
+ +

Returns a new instance of SkipDeclaredInExample

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/core/pending.rb', line 10
+
+def initialize(argument)
+  @argument = argument
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) argument (readonly) + + + + + +

+
+ +

Returns the value of attribute argument

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/core/pending.rb', line 8
+
+def argument
+  @argument
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/RakeTask.html b/source/documentation/3.0/rspec-core/RSpec/Core/RakeTask.html new file mode 100644 index 000000000..cec05b0f0 --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/RakeTask.html @@ -0,0 +1,870 @@ + + + + + + Class: RSpec::Core::RakeTask + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::RakeTask + + + +

+ +
+ +
Inherits:
+
+ Rake::TaskLib + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + +
Includes:
+
Rake::DSL
+ + + + + +
Defined in:
+
lib/rspec/core/rake_task.rb
+ +
+
+ +

Overview

+
+ +

Rspec rake task

+ + +
+
+
+ + +

See Also:

+
    + +
  • Rakefile
  • + +
+ +
+

Constant Summary

+ +
+ +
DEFAULT_RSPEC_PATH = +
+
+ +

Default path to the rspec executable

+ + +
+
+
+ + +
+
+
File.expand_path('../../../../exe/rspec', __FILE__)
+ +
DEFAULT_PATTERN = +
+
+ +

Default pattern for spec files.

+ + +
+
+
+ + +
+
+
'./spec{,/*/**}/*_spec.rb'
+ +
+ + + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (void) fail_on_error + + + + + + + + + + + + + + + + +
    +

    Whether or not to fail Rake when an error occurs (typically when examples +fail).

    +
    + +
  • + + +
  • + + + - (void) failure_message + + + + + + + + + + + + + + + + +
    +

    A message to print to stderr when there are failures.

    +
    + +
  • + + +
  • + + + - (void) name + + + + + + + + + + + + + + + + +
    +

    Name of task.

    +
    + +
  • + + +
  • + + + - (void) pattern + + + + + + + + + + + + + + + + +
    +

    Glob pattern to match files.

    +
    + +
  • + + +
  • + + + - (void) rspec_opts + + + + + + + + + + + + + + + + +
    +

    Command line options to pass to rspec.

    +
    + +
  • + + +
  • + + + - (void) rspec_path + + + + + + + + + + + + + + + + +
    +

    Path to rspec.

    +
    + +
  • + + +
  • + + + - (void) ruby_opts + + + + + + + + + + + + + + + + +
    +

    Command line options to pass to ruby.

    +
    + +
  • + + +
  • + + + - (void) verbose + + + + + + + + + + + + + + + + +
    +

    Use verbose output.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Constructor Details

+ +
+

+ + - (RakeTask) initialize(*args, &task_block) + + + + + +

+
+ +

Returns a new instance of RakeTask

+ + +
+
+
+ + +
+ + + + +
+
+
+
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+
+
# File 'lib/rspec/core/rake_task.rb', line 69
+
+def initialize(*args, &task_block)
+  @name          = args.shift || :spec
+  @ruby_opts     = nil
+  @rspec_opts    = nil
+  @verbose       = true
+  @fail_on_error = true
+  @rspec_path    = DEFAULT_RSPEC_PATH
+  @pattern       = DEFAULT_PATTERN
+
+  define(args, &task_block)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) fail_on_error + + + + + +

+
+ +

Whether or not to fail Rake when an error occurs (typically when examples +fail).

+ +

default: true

+ + +
+
+
+ + +
+ + + + +
+
+
+
+39
+40
+41
+
+
# File 'lib/rspec/core/rake_task.rb', line 39
+
+def fail_on_error
+  @fail_on_error
+end
+
+
+ + + +
+

+ + - (void) failure_message + + + + + +

+
+ +

A message to print to stderr when there are failures.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/rspec/core/rake_task.rb', line 42
+
+def failure_message
+  @failure_message
+end
+
+
+ + + +
+

+ + - (void) name + + + + + +

+
+ +

Name of task.

+ +

default: :spec

+ + +
+
+
+ + +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lib/rspec/core/rake_task.rb', line 27
+
+def name
+  @name
+end
+
+
+ + + +
+

+ + - (void) pattern + + + + + +

+
+ +

Glob pattern to match files.

+ +

default: 'spec/*_/__spec.rb'

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/core/rake_task.rb', line 33
+
+def pattern
+  @pattern
+end
+
+
+ + + +
+

+ + - (void) rspec_opts + + + + + +

+
+ +

Command line options to pass to rspec.

+ +

default: nil

+ + +
+
+
+ + +
+ + + + +
+
+
+
+67
+68
+69
+
+
# File 'lib/rspec/core/rake_task.rb', line 67
+
+def rspec_opts
+  @rspec_opts
+end
+
+
+ + + +
+

+ + - (void) rspec_path + + + + + +

+
+ +

Path to rspec

+ +

default: 'rspec'

+ + +
+
+
+ + +
+ + + + +
+
+
+
+61
+62
+63
+
+
# File 'lib/rspec/core/rake_task.rb', line 61
+
+def rspec_path
+  @rspec_path
+end
+
+
+ + + +
+

+ + - (void) ruby_opts + + + + + +

+
+ +

Command line options to pass to ruby.

+ +

default: nil

+ + +
+
+
+ + +
+ + + + +
+
+
+
+55
+56
+57
+
+
# File 'lib/rspec/core/rake_task.rb', line 55
+
+def ruby_opts
+  @ruby_opts
+end
+
+
+ + + +
+

+ + - (void) verbose + + + + + +

+
+ +

Use verbose output. If this is set to true, the task will print the +executed spec command to stdout.

+ +

default: true

+ + +
+
+
+ + +
+ + + + +
+
+
+
+49
+50
+51
+
+
# File 'lib/rspec/core/rake_task.rb', line 49
+
+def verbose
+  @verbose
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Reporter.html b/source/documentation/3.0/rspec-core/RSpec/Core/Reporter.html new file mode 100644 index 000000000..ed8b90eff --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Reporter.html @@ -0,0 +1,468 @@ + + + + + + Class: RSpec::Core::Reporter + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Reporter + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/reporter.rb
+ +
+
+ +

Overview

+
+ +

A reporter will send notifications to listeners, usually formatters for the +spec suite run.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Reporter) initialize(configuration) + + + + + +

+
+ +

Returns a new instance of Reporter

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lib/rspec/core/reporter.rb', line 6
+
+def initialize(configuration)
+  @configuration = configuration
+  @listeners = Hash.new { |h,k| h[k] = Set.new }
+  @examples = []
+  @failed_examples = []
+  @pending_examples = []
+  @duration = @start = @load_time = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) register_listener(listener, *notifications) + + + + + +

+
+ +

Registers a listener to a list of notifications. The reporter will send +notification of events to all registered listeners

+ + +
+
+
+

Parameters:

+
    + +
  • + + listener + + + (Object) + + + + — +
    +

    An obect that wishes to be notified of reporter events

    +
    + +
  • + +
  • + + notifications + + + (Array) + + + + — +
    +

    Array of symbols represents the events a listener wishes to subscribe too

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+
+
# File 'lib/rspec/core/reporter.rb', line 23
+
+def register_listener(listener, *notifications)
+  notifications.each do |notification|
+    @listeners[notification.to_sym] << listener
+  end
+  true
+end
+
+
+ +
+

+ + + - (void) report(count, &block) + + - (void) report(count, &block) + + + + + + +

+
+ +

Initializes the report run and yields itself for further reporting. The +block is required, so that the reporter can manage cleaning up after the +run.

+ + +
+
+
+ +
+

Examples:

+ + +

+reporter.report(group.examples.size) do |r|
+  example_groups.map {|g| g.run(r) }
+end
+ +
+

Parameters:

+
    + +
  • + + expected_example_count + + + (Integer) + + + + — +
    +

    the number of examples being run

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + (Block) + + + + — +
    +

    block yields itself for further reporting.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+51
+52
+53
+54
+55
+56
+57
+58
+
+
# File 'lib/rspec/core/reporter.rb', line 51
+
+def report(expected_example_count)
+  start(expected_example_count)
+  begin
+    yield self
+  ensure
+    finish
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Runner.html b/source/documentation/3.0/rspec-core/RSpec/Core/Runner.html new file mode 100644 index 000000000..5425a1b9c --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Runner.html @@ -0,0 +1,929 @@ + + + + + + Class: RSpec::Core::Runner + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::Runner + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/core/runner.rb
+ +
+
+ +

Overview

+
+ +

Provides the main entry point to run a suite of RSpec examples.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Runner) initialize(options, configuration = RSpec.configuration, world = RSpec.world) + + + + + +

+
+ +

Returns a new instance of Runner

+ + +
+
+
+ + +
+ + + + +
+
+
+
+74
+75
+76
+77
+78
+
+
# File 'lib/rspec/core/runner.rb', line 74
+
+def initialize(options, configuration=RSpec.configuration, world=RSpec.world)
+  @options       = options
+  @configuration = configuration
+  @world         = world
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (void) autorun + + + + + +

+
+ +
+ Note: +
+

This is not generally needed. The rspec command takes care of +running examples for you without involving an at_exit hook. +This is only needed if you are running specs using the ruby +command, and even then, the normal way to invoke this is by requiring +rspec/autorun.

+
+
+ + +

Register an at_exit hook that runs the suite when the process +exits.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+
+
# File 'lib/rspec/core/runner.rb', line 13
+
+def self.autorun
+  if autorun_disabled?
+    RSpec.deprecate("Requiring `rspec/autorun` when running RSpec via the `rspec` command")
+    return
+  elsif installed_at_exit? || running_in_drb?
+    return
+  end
+
+  at_exit do
+    # Don't bother running any specs and just let the program terminate
+    # if we got here due to an unrescued exception (anything other than
+    # SystemExit, which is raised when somebody calls Kernel#exit).
+    next unless $!.nil? || $!.kind_of?(SystemExit)
+
+    # We got here because either the end of the program was reached or
+    # somebody called Kernel#exit.  Run the specs and then override any
+    # existing exit status with RSpec's exit status if any specs failed.
+    invoke
+  end
+  @installed_at_exit = true
+end
+
+
+ +
+

+ + + (void) invoke + + + + + +

+
+ +

Runs the suite of specs and exits the process with an appropriate exit +code.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+39
+40
+
+
# File 'lib/rspec/core/runner.rb', line 36
+
+def self.invoke
+  disable_autorun!
+  status = run(ARGV, $stderr, $stdout).to_i
+  exit(status) if status != 0
+end
+
+
+ +
+

+ + + (Fixnum) run(args, err = $stderr, out = $stdout) + + + + + +

+
+ +

Run a suite of RSpec examples. Does not exit.

+ +

This is used internally by RSpec to run a suite, but is available for use +by any other automation tool.

+ +

If you want to run this multiple times in the same process, and you want +files like spec_helper.rb to be reloaded, be sure to load +load instead of require.

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array) + + + + — +
    +

    command-line-supported arguments

    +
    + +
  • + +
  • + + err + + + (IO) + + + (defaults to: $stderr) + + + — +
    +

    error stream

    +
    + +
  • + +
  • + + out + + + (IO) + + + (defaults to: $stdout) + + + — +
    +

    output stream

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    exit status code. 0 if all specs passed, or the configured failure exit +code (1 by default) if specs failed.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+
+
# File 'lib/rspec/core/runner.rb', line 57
+
+def self.run(args, err=$stderr, out=$stdout)
+  trap_interrupt
+  options = ConfigurationOptions.new(args)
+
+  if options.options[:drb]
+    require 'rspec/core/drb'
+    begin
+      DRbRunner.new(options).run(err, out)
+    rescue DRb::DRbConnError
+      err.puts "No DRb server is running. Running in local process instead ..."
+      new(options).run(err, out)
+    end
+  else
+    new(options).run(err, out)
+  end
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (void) run(err, out) + + + + + +

+
+ +

Configures and runs a spec suite.

+ + +
+
+
+

Parameters:

+
    + +
  • + + err + + + (IO) + + + + — +
    +

    error stream

    +
    + +
  • + +
  • + + out + + + (IO) + + + + — +
    +

    output stream

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+84
+85
+86
+87
+
+
# File 'lib/rspec/core/runner.rb', line 84
+
+def run(err, out)
+  setup(err, out)
+  run_specs(@world.ordered_example_groups)
+end
+
+
+ +
+

+ + - (Fixnum) run_specs(example_groups) + + + + + +

+
+ +

Runs the provided example groups.

+ + +
+
+
+

Parameters:

+ + +

Returns:

+
    + +
  • + + + (Fixnum) + + + + — +
    +

    exit status code. 0 if all specs passed, or the configured failure exit +code (1 by default) if specs failed.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+
+
# File 'lib/rspec/core/runner.rb', line 107
+
+def run_specs(example_groups)
+  @configuration.reporter.report(@world.example_count(example_groups)) do |reporter|
+    begin
+      hook_context = SuiteHookContext.new
+      @configuration.hooks.run(:before, :suite, hook_context)
+      example_groups.map { |g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
+    ensure
+      @configuration.hooks.run(:after, :suite, hook_context)
+    end
+  end
+end
+
+
+ +
+

+ + - (void) setup(err, out) + + + + + +

+
+ +

Wires together the various configuration objects and state holders.

+ + +
+
+
+

Parameters:

+
    + +
  • + + err + + + (IO) + + + + — +
    +

    error stream

    +
    + +
  • + +
  • + + out + + + (IO) + + + + — +
    +

    output stream

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+93
+94
+95
+96
+97
+98
+99
+
+
# File 'lib/rspec/core/runner.rb', line 93
+
+def setup(err, out)
+  @configuration.error_stream = err
+  @configuration.output_stream = out if @configuration.output_stream == $stdout
+  @options.configure(@configuration)
+  @configuration.load_spec_files
+  @world.announce_filters
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/SharedContext.html b/source/documentation/3.0/rspec-core/RSpec/Core/SharedContext.html new file mode 100644 index 000000000..79607e18b --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/SharedContext.html @@ -0,0 +1,136 @@ + + + + + + Module: RSpec::Core::SharedContext + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::SharedContext + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/shared_context.rb
+ +
+
+ +

Overview

+
+ +

Exposes ExampleGroup-level methods to a module, so you can include that +module in an ExampleGroup.

+ + +
+
+
+ +
+

Examples:

+ + +

+module LoggedInAsAdmin
+  extend RSpec::Core::SharedContext
+  before(:example) do
+     :admin
+  end
+end
+
+describe "admin section" do
+  include LoggedInAsAdmin
+  # ...
+end
+ +
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup.html b/source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup.html new file mode 100644 index 000000000..ea6dfd6fb --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup.html @@ -0,0 +1,457 @@ + + + + + + Module: RSpec::Core::SharedExampleGroup + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::SharedExampleGroup + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleGroup
+ + + +
Defined in:
+
lib/rspec/core/shared_example_group.rb
+ +
+
+ +

Overview

+
+ +

Shared example groups let you define common context and/or common examples +that you wish to use in multiple example groups.

+ +

When defined, the shared group block is stored for later evaluation. It can +later be included in an example group either explicitly (using +include_examples, include_context or +it_behaves_like) or implicitly (via matching metadata).

+ +

Named shared example groups are scoped based on where they are defined. +Shared groups defined in an example group are available for inclusion in +that example group or any child example groups, but not in any parent or +sibling example groups. Shared example groups defined at the top level can +be included from any example group.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: TopLevelDSL + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + + - (void) shared_examples(name, &block) + + - (void) shared_examples(name, metadata, &block) + + - (void) shared_examples(metadata, &block) + + + + + Also known as: + shared_context, shared_examples_for + + + + +

+
+ +

Stores the block for later use. The block will be evaluated in the context +of an example group via include_examples, +include_context, or it_behaves_like.

+ + +
+
+
+ +
+

Examples:

+ + +
shared_examples "auditable" do
+  it "stores an audit record on save!" do
+    expect { auditable.save! }.to change(Audit, :count).by(1)
+  end
+end
+
+describe Account do
+  it_behaves_like "auditable" do
+    let(:auditable) { Account.new }
+  end
+end
+ +
+ +

Overloads:

+
    + + +
  • + - (void) shared_examples(name, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String, Symbol, Module) + + + + — +
      +

      identifer to use when looking up this shared group

      +
      + +
    • + +
    • + + block + + + + + + + — +
      +

      The block to be eval'd

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) shared_examples(name, metadata, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String, Symbol, Module) + + + + — +
      +

      identifer to use when looking up this shared group

      +
      + +
    • + +
    • + + metadata + + + (Array<Symbol>, Hash) + + + + — +
      +

      metadata to attach to this group; any example group with matching metadata +will automatically include this shared example group.

      +
      + +
    • + +
    • + + block + + + + + + + — +
      +

      The block to be eval'd

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (void) shared_examples(metadata, &block) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + metadata + + + (Array<Symbol>, Hash) + + + + — +
      +

      metadata to attach to this group; any example group with matching metadata +will automatically include this shared example group.

      +
      + +
    • + +
    • + + block + + + + + + + — +
      +

      The block to be eval'd

      +
      + +
    • + +
    + + +
    +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+
+
# File 'lib/rspec/core/shared_example_group.rb', line 50
+
+def shared_examples(name, *args, &block)
+  top_level = self == ExampleGroup
+  if top_level && RSpec.[:in_example_group]
+    raise "Creating isolated shared examples from within a context is " +
+          "not allowed. Remove `RSpec.` prefix or move this to a " +
+          "top-level scope."
+  end
+
+  RSpec.world.shared_example_group_registry.add(self, name, *args, &block)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html b/source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html new file mode 100644 index 000000000..d63d2a6ea --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/SharedExampleGroup/TopLevelDSL.html @@ -0,0 +1,295 @@ + + + + + + Module: RSpec::Core::SharedExampleGroup::TopLevelDSL + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::SharedExampleGroup::TopLevelDSL + + + Private +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/shared_example_group.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+ +

Shared examples top level DSL

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ +
    + +
  • + + + + (void) expose_globally! + + + + + + + + + + + private + + +
    +

    Adds the top level DSL methods to Module and the top level binding.

    +
    + +
  • + + +
  • + + + + (void) remove_globally! + + + + + + + + + + + private + + +
    +

    Removes the top level DSL methods to Module and the top level binding.

    +
    + +
  • + + +
+ + + + +
+

Class Method Details

+ + +
+

+ + + (void) expose_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Adds the top level DSL methods to Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+86
+87
+88
+89
+90
+
+
# File 'lib/rspec/core/shared_example_group.rb', line 86
+
+def self.expose_globally!
+  return if exposed_globally?
+  Core::DSL.change_global_dsl(&definitions)
+  @exposed_globally = true
+end
+
+
+ +
+

+ + + (void) remove_globally! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Removes the top level DSL methods to Module and the top level binding

+ + +
+
+
+ + +
+ + + + +
+
+
+
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+
+
# File 'lib/rspec/core/shared_example_group.rb', line 95
+
+def self.remove_globally!
+  return unless exposed_globally?
+
+  Core::DSL.change_global_dsl do
+    undef shared_examples
+    undef shared_context
+    undef shared_examples_for
+  end
+
+  @exposed_globally = false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/Version.html b/source/documentation/3.0/rspec-core/RSpec/Core/Version.html new file mode 100644 index 000000000..4e9986aff --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/Version.html @@ -0,0 +1,139 @@ + + + + + + Module: RSpec::Core::Version + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Core::Version + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/core/version.rb
+ +
+
+ +

Overview

+
+ +

Version information for RSpec Core.

+ + +
+
+
+ + +
+

Constant Summary

+ +
+ +
STRING = +
+
+ +

Current version of RSpec Core, in semantic versioning format.

+ + +
+
+
+ + +
+
+
'3.0.4'
+ +
+ + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/RSpec/Core/World.html b/source/documentation/3.0/rspec-core/RSpec/Core/World.html new file mode 100644 index 000000000..b310ef06b --- /dev/null +++ b/source/documentation/3.0/rspec-core/RSpec/Core/World.html @@ -0,0 +1,983 @@ + + + + + + Class: RSpec::Core::World + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Core::World + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Hooks
+ + + + + +
Defined in:
+
lib/rspec/core/world.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

Internal container for global non-configuration data

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (void) wants_to_quit + + + + + + + + + + + + + + private + + +
    +

    Used internally to determine what to do when a SIGINT is received.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Hooks

+

#after, #append_after, #around, #before, #prepend_before

+
+

Constructor Details

+ +
+

+ + - (World) initialize(configuration = RSpec.configuration) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of World

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+
+
# File 'lib/rspec/core/world.rb', line 16
+
+def initialize(configuration=RSpec.configuration)
+  @configuration = configuration
+  @example_groups = []
+  @filtered_examples = Hash.new { |hash,group|
+    hash[group] = begin
+      examples = group.examples.dup
+      examples = filter_manager.prune(examples)
+      examples.uniq!
+      examples
+    end
+  }
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (void) wants_to_quit + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Used internally to determine what to do when a SIGINT is received

+ + +
+
+
+ + +
+ + + + +
+
+
+
+14
+15
+16
+
+
# File 'lib/rspec/core/world.rb', line 14
+
+def wants_to_quit
+  @wants_to_quit
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (void) announce_exclusion_filter(announcements) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Add exclusion filters to announcement message

+ + +
+
+
+ + +
+ + + + +
+
+
+
+167
+168
+169
+170
+171
+
+
# File 'lib/rspec/core/world.rb', line 167
+
+def announce_exclusion_filter(announcements)
+  unless exclusion_filter.empty?
+    announcements << "exclude #{exclusion_filter.description}"
+  end
+end
+
+
+ +
+

+ + - (void) announce_filters + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Notify reporter of filters

+ + +
+
+
+ + +
+ + + + +
+
+
+
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+
+
# File 'lib/rspec/core/world.rb', line 114
+
+def announce_filters
+  filter_announcements = []
+
+  announce_inclusion_filter filter_announcements
+  announce_exclusion_filter filter_announcements
+
+  unless filter_manager.empty?
+    if filter_announcements.length == 1
+      reporter.message("Run options: #{filter_announcements[0]}")
+    else
+      reporter.message("Run options:\n  #{filter_announcements.join("\n  ")}")
+    end
+  end
+
+  if @configuration.run_all_when_everything_filtered? && example_count.zero?
+    reporter.message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}")
+    filtered_examples.clear
+    inclusion_filter.clear
+  end
+
+  if example_count.zero?
+    example_groups.clear
+    if filter_manager.empty?
+      reporter.message("No examples found.")
+    elsif exclusion_filter.empty?
+      message = everything_filtered_message
+      if @configuration.run_all_when_everything_filtered?
+        message << "; ignoring #{inclusion_filter.description}"
+      end
+      reporter.message(message)
+    elsif inclusion_filter.empty?
+      reporter.message(everything_filtered_message)
+    end
+  end
+end
+
+
+ +
+

+ + - (void) announce_inclusion_filter(announcements) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Add inclusion filters to announcement message

+ + +
+
+
+ + +
+ + + + +
+
+
+
+158
+159
+160
+161
+162
+
+
# File 'lib/rspec/core/world.rb', line 158
+
+def announce_inclusion_filter(announcements)
+  unless inclusion_filter.empty?
+    announcements << "include #{inclusion_filter.description}"
+  end
+end
+
+
+ +
+

+ + - (void) example_count(groups = example_groups) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Get count of examples to be run

+ + +
+
+
+ + +
+ + + + +
+
+
+
+92
+93
+94
+95
+
+
# File 'lib/rspec/core/world.rb', line 92
+
+def example_count(groups=example_groups)
+  FlatMap.flat_map(groups) {|g| g.descendants}.
+    inject(0) {|sum, g| sum + g.filtered_examples.size}
+end
+
+
+ +
+

+ + - (void) ordered_example_groups + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Apply ordering strategy from configuration to example groups

+ + +
+
+
+ + +
+ + + + +
+
+
+
+43
+44
+45
+46
+
+
# File 'lib/rspec/core/world.rb', line 43
+
+def ordered_example_groups
+  ordering_strategy = @configuration.ordering_registry.fetch(:global)
+  ordering_strategy.order(@example_groups)
+end
+
+
+ +
+

+ + - (void) preceding_declaration_line(filter_line) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Find line number of previous declaration

+ + +
+
+
+ + +
+ + + + +
+
+
+
+100
+101
+102
+103
+104
+
+
# File 'lib/rspec/core/world.rb', line 100
+
+def preceding_declaration_line(filter_line)
+  declaration_line_numbers.sort.inject(nil) do |highest_prior_declaration_line, line|
+    line <= filter_line ? line : highest_prior_declaration_line
+  end
+end
+
+
+ +
+

+ + - (void) register(example_group) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Register an example group

+ + +
+
+
+ + +
+ + + + +
+
+
+
+64
+65
+66
+67
+
+
# File 'lib/rspec/core/world.rb', line 64
+
+def register(example_group)
+  example_groups << example_group
+  example_group
+end
+
+
+ +
+

+ + - (void) reset + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Reset world to 'scratch' before running suite

+ + +
+
+
+ + +
+ + + + +
+
+
+
+51
+52
+53
+54
+
+
# File 'lib/rspec/core/world.rb', line 51
+
+def reset
+  example_groups.clear
+  @shared_example_group_registry = nil
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/_index.html b/source/documentation/3.0/rspec-core/_index.html new file mode 100644 index 000000000..7e72db117 --- /dev/null +++ b/source/documentation/3.0/rspec-core/_index.html @@ -0,0 +1,550 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Documentation by YARD 0.8.7.6

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
    +
  • H
  • +
      + +
    • + Helpers + + (RSpec::Core::Formatters) + +
    • + +
    • + Hooks + + (RSpec::Core) + +
    • + +
    +
+ + +
+ + +
    +
  • L
  • +
      + +
    • + Loader + + (RSpec::Core::Formatters) + +
    • + +
    +
+ + + + + + + + + + + +
    +
  • R
  • + +
+ + + + + +
    +
  • T
  • +
      + +
    • + TopLevelDSL + + (RSpec::Core::SharedExampleGroup) + +
    • + +
    +
+ + +
    +
  • V
  • +
      + +
    • + Version + + (RSpec::Core) + +
    • + +
    +
+ + +
+ + +
    +
  • W
  • +
      + +
    • + World + + (RSpec::Core) + +
    • + +
    +
+ +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/class_list.html b/source/documentation/3.0/rspec-core/class_list.html new file mode 100644 index 000000000..0c83f707c --- /dev/null +++ b/source/documentation/3.0/rspec-core/class_list.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + Class List + + + + +
+

Class List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-core/file.Changelog.html b/source/documentation/3.0/rspec-core/file.Changelog.html new file mode 100644 index 000000000..595e8a820 --- /dev/null +++ b/source/documentation/3.0/rspec-core/file.Changelog.html @@ -0,0 +1,2368 @@ + + + + + + File: Changelog + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

3.0.5 Development

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Change how we assign constant names to example group classes so that it +avoids a problem with describe "Core". (Daniela +Wellisz, #1679)

    +
  • +

    Handle rendering exceptions that have a different encoding than that of +their original source file. (Jon Rowe, #1681)

    +
  • +

    Allow access to message_lines without colour for failed examples even when +they're part of a shared example group. (tomykaira, #1689)

    +
+ +

3.0.4 / 2014-08-14

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix processing order of CLI options so that if +config.files_to_run is accessed from a file loaded by +--require, --pattern is still applied. (Myron +Marston, #1652)

    +
  • +

    Fix config.pattern= so that it still takes affect even if +config.files_to_run has already been accessed. (Myron Marston, +#1652)

    +
+ +

3.0.3 / 2014-07-21

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Properly convert both parts of a description into strings before +concatenation. (@nicklink483, #1636)

    +
  • +

    Exclude the working directory when figuring out folders to ignore. (Jon +Rowe, Myron Marston, #1616)

    +
  • +

    Allow +::RSpec::Core::Notifications::FailedExampleNotification#message_lines +to be accessed without a colouriser. (@tomykaira, #1637)

    +
+ +

3.0.2 / 2014-06-19

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix regression in CLI option handling that prevented --tag +slow passed at the command line from overriding --tag +~slow in .rspec. (Colin Jones, #1602)

    +
  • +

    Fix metadata :example_group deprecation warning so that it +gets issued at the call site of the configuration that specified it as a +filter rather than later when an example group is defined. (Myron Marston, +#1562)

    +
  • +

    Make the line that is printed when a shared example group fails indicating +where the concrete example group is white, separating it from the stack +trace that is produced for the failure. (Sam Phippen, Jon Rowe, #1606)

    +
+ +

3.0.1 / 2014-06-12

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix a couple ruby warnings caused by rspec-core when loaded. (Prem +Sichanugrist, #1584)

    +
  • +

    Example groups named Config will no longer cause a Ruby +warning to be issued. (Jimmy Cuadra, #1580)

    +
+ +

3.0.0 / 2014-06-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix BaseTextFormatter so that it does not re-close a closed +output stream. (Myron Marston)

    +
  • +

    Fix regression in metadata that caused the metadata hash of a top-level +example group to have a :parent_example_group key even though +it has no parent example group. (Myron Marston)

    +
+ +

Enhancements:

+
  • +

    Alter the default spec_helper.rb to no longer recommend +config.full_backtrace = true see #1536 for discussion. (Jon +Rowe)

    +
+ +

3.0.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Change described_class so that in a nested group like +describe MyClass, it returns MyClass rather +than the outer group's described class. (Myron Marston)

    +
  • +

    Refactor filter manager so that it no longer subclasses Hash and has a +tighter, more domain-specific interface. (Sergey Pchelincev)

    +
  • +

    Remove legacy colours definitions from BaseTextFormatter. (Jon +Rowe)

    +
  • +

    Remove console color definitions from BaseTextFormatter. (Jon +Rowe)

    +
  • +

    Restructure example group metadata so that the computed keys are exposed +directly off of the metadata hash rather than being on a nested +:example_group subhash. In addition, the parent example group +metadata is now available as [:parent_example_group] rather +than [:example_group][:example_group]. Deprecated access via +the old key structure is still provided. (Myron Marston)

    +
  • +

    Remove :describes metadata key. It duplicates +:described_class for no good reason. Deprecated access via +:describes is still provided. (Myron Marston)

    +
  • +

    Rename :example_group_block metadata key to +:block. (Myron Marston)

    +
  • +

    Remove deprecated RSpec::Core::Example#options. (Myron +Marston)

    +
  • +

    Move BaseTextFormatter#colorize_summary to +SummaryNotification#colorize_with (Jon Rowe).

    +
  • +

    describe some_hash treated some_hash as metadata +in RSpec 2.x but will treat it as the described object in RSpec 3.0. +Metadata must always come after the description args. (Myron Marston)

    +
  • +

    Remove deprecated display_name alias of +ExampleGroup.description. (Myron Marston)

    +
  • +

    Remove deprecated describes alias of +ExampleGroup.described_class. (Myron Marston)

    +
  • +

    Remove deprecated +RSpec::Core::ExampleGroup.alias_it_behaves_like_to. Use +RSpec::Core::Configuration#alias_it_behaves_like_to instead. +(Myron Marston)

    +
  • +

    Remove deprecated RSpec::Core::ExampleGroup.alias_example_to. +Use RSpec::Core::Configuration#alias_example_to instead. +(Myron Marston)

    +
  • +

    Removed focused example alias and change example/group aliases +fit, focus, fcontext and +fdescribe to no longer include :focused => +true metadata. They only contain :focus => true +metadata now. This means that you will need to filter them with +filter_run :focus, not filter_run :focused. +(Myron Marston)

    +
  • +

    Remove --line-number filtering. It's semantically dubious +since it's a global filter (potentially applied to multiple files) but +there's no meaningful connection between the same line number in +multiple files. Instead use the rspec path/to/spec.rb:23:46 +form, which is terser and makes more sense as it is scoped to a file. +(Myron Marston)

    +
  • +

    Remove --default_path as an alias for +--default-path. (Jon Rowe)

    +
  • +

    Remove deprecated share_examples_for. There's still +shared_examples and shared_examples_for. (Myron +Marston)

    +
  • +

    Rename RSpec::Core::Configuration#warnings to +RSpec::Core::Configuration#warnings? since it's a boolean +flag. (Myron Marston)

    +
  • +

    RSpec's global state is no longer reset after a spec run. This gives +more flexibility to alternate runners to decide when and if they want the +state reset. Alternate runners are now responsible for calling this (or +doing a similar reset) if they are going to run the spec suite multiple +times in the same process. (Sam Phippen)

    +
  • +

    Merge RSpec::Core::CommandLine (never formally declared +public) into RSpec::Core::Runner. (Myron Marston)

    +
  • +

    Remove color_enabled as an alias of color. (Jon +Rowe)

    +
  • +

    Remove backtrace_cleaner as an alias of +backtrace_formatter. (Jon Rowe)

    +
  • +

    Remove filename_pattern as an alias of pattern. +(Jon Rowe)

    +
  • +

    Extract support for legacy formatters to +rspec-legacy_formatters. (Jon Rowe)

    +
  • +

    RSpec::Configuration#formatters now returns a dup to prevent +mutation. (Jon Rowe)

    +
  • +

    Replace stdlib as an available expectation framework with +test_unit and minitest. (Aaron Kromer)

    +
  • +

    Remove backtrace formatting helpers from BaseTextFormatter. +(Jon Rowe)

    +
  • +

    Extract profiler support to ProfileFormatter and +ProfileNotification. Formatters should implement +dump_profile if they wish to respond to +--profile. (Jon Rowe)

    +
  • +

    Extract remaining formatter state to reporter and notifications. Introduce +ExamplesNotification to share information about examples that +was previously held in BaseFormatter. (Jon Rowe)

    +
+ +

Enhancements:

+
  • +

    Add config.default_formatter attribute, which can be used to +set a formatter which will only be used if no other formatter is set +(e.g. via --formatter). (Myron Marston)

    +
  • +

    Support legacy colour definitions in LegacyFormatterAdaptor. +(Jon Rowe)

    +
  • +

    Migrate execution_result (exposed by metadata) from a hash to +a first-class object with appropriate attributes. status is +now stored and returned as a symbol rather than a string. It retains +deprecated hash behavior for backwards compatibility. (Myron Marston)

    +
  • +

    Provide console code helper for formatters. (Jon Rowe)

    +
  • +

    Use raw ruby hashes for the metadata hashes rather than a subclass of a +hash. Computed metadata entries are now computed in advance rather than +being done lazily on first access. (Myron Marston)

    +
  • +

    Add :block metadata entry to the example metadata, bringing +parity with :block in the example group metadata. (Myron +Marston)

    +
  • +

    Add fspecify and fexample as aliases of +specify and example with :focus => +true metadata for parity with fit. (Myron Marston)

    +
  • +

    Add legacy support for colorize_summary. (Jon Rowe)

    +
  • +

    Restructure runner so it can be more easily customized in a subclass for +an alternate runner. (Ben Hoskings)

    +
  • +

    Document RSpec::Core::ConfigurationOptions as an officially +supported public API. (Myron Marston)

    +
  • +

    Add --deprecation-out CLI option which directs deprecation +warnings to the named file. (Myron Marston)

    +
  • +

    Minitest 5 compatability for expect_with :stdlib (now +available as expect_with :minitest). (Xavier Shay)

    +
  • +

    Reporter now notifies formatters of the load time of RSpec and your specs +via StartNotification and SummaryNotification. +(Jon Rowe)

    +
  • +

    Add disable_monkey_patching! config option that disables all +monkey patching from whatever pieces of RSpec you use. (Alexey Fedorov)

    +
  • +

    Add Pathname support for setting all output streams. (Aaron +Kromer)

    +
  • +

    Add config.define_derived_metadata, which can be used to apply +additional metadata to all groups or examples that match a given filter. +(Myron Marston)

    +
  • +

    Provide formatted and colorized backtraces via +FailedExampleNotification and send +PendingExampleFixedNotifications when the error is due to a +passing spec you expect to fail. (Jon Rowe)

    +
  • +

    Add dump_profile to formatter API to allow formatters to +implement support for --profile. (Jon Rowe)

    +
  • +

    Allow colourising text via ConsoleCodes with RSpec +'states' (e.g. :success, :failure) +rather than direct colour codes. (Jon Rowe)

    +
  • +

    Expose fully_formatted methods off the formatter notification +objects that make it easy for a custom formatter to produce formatted +output like rspec-core's. (Myron Marston)

    +
+ +

Bug Fixes:

+
  • +

    Fix spec_helper.rb file generated by rspec --init +so that the recommended settings correctly use the documentation formatter +when running one file. (Myron Marston)

    +
  • +

    Fix ordering problem where descriptions were generated after tearing down +mocks, which resulted in unexpected exceptions. (Bradley Schaefer, Aaron +Kromer, Andrey Savchenko)

    +
  • +

    Allow a symbol to be used as an implicit subject (e.g. describe +:foo). (Myron Marston)

    +
  • +

    Prevent creating an isolated context (i.e. using +RSpec.describe) when already inside a context. There is no +reason to do this, and it could potentially cause unexpected bugs. (Xavier +Shay)

    +
  • +

    Fix shared example group scoping so that when two shared example groups +share the same name at different levels of nested contexts, the one in the +nearest context is used. (Myron Marston)

    +
  • +

    Fix --warnings option so that it enables warnings immediately +so that it applies to files loaded by --require. (Myron +Marston)

    +
  • +

    Issue a warning when you set config.deprecation_stream too +late for it to take effect because the reporter has already been setup. +(Myron Marston)

    +
  • +

    Add the full RSpec::Core::Example interface to the argument +yielded to around hooks. (Myron Marston)

    +
  • +

    Line number always takes precendence when running specs with filters. +(Xavier Shay)

    +
  • +

    Ensure :if and :unless metadata filters are treated as a special case and +are always in-effect. (Bradley Schaefer)

    +
  • +

    Ensure the currently running installation of RSpec is used when the rake +task shells out to rspec, even if a newer version is also +installed. (Postmodern)

    +
  • +

    Using a legacy formatter as default no longer causes an infinite loop. +(Xavier Shay)

    +
+ +

3.0.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Make mock_with option more strict. Strings are no longer +supported (e.g. mock_with "mocha") – use a symbol +instead. Also, unrecognized values will now result in an error rather than +falling back to the null mocking adapter. If you want to use the null +mocking adapter, use mock_with :nothing (as has been +documented for a long time). (Myron Marston)

    +
  • +

    Remove support for overriding RSpec's built-in :if and +:unless filters. (Ashish Dixit)

    +
  • +

    Custom formatters are now required to call +RSpec::Core::Formatters.register(formatter_class, +*notifications) where notifications is the list of +events the formatter wishes to be notified about. Notifications are +handled by methods matching the names on formatters. This allows us to add +or remove notifications without breaking existing formatters. (Jon Rowe)

    +
  • +

    Change arguments passed to formatters. Rather than passing multiple +arguments (which limits are ability to add additional arguments as doing +so would break existing formatters), we now pass a notification value +object that exposes the same data via attributes. This will allow us to +add new bits of data to a notification event without breaking existing +formatters. (Jon Rowe)

    +
  • +

    Remove support for deprecated :alias option for +RSpec.configuration.add_setting. (Myron Marston)

    +
  • +

    Remove support for deprecated RSpec.configuration.requires = +[...]. (Myron Marston)

    +
  • +

    Remove support for deprecated --formatter CLI option. (Myron +Marston)

    +
  • +

    Remove support for deprecated --configure CLI option. (Myron +Marston)

    +
  • +

    Remove support for deprecated +RSpec::Core::RakeTask#spec_opts=. (Myron Marston)

    +
  • +

    An example group level pending block or :pending +metadata now executes the example and cause a failure if it passes, +otherwise it will be pending if it fails. The old “never run” behaviour is +still used for xexample, xit, and +xspecify, or via a new skip method or +:skip metadata option. (Xavier Shay)

    +
  • +

    After calling pending inside an example, the remainder of the +example will now be run. If it passes a failure is raised, otherwise the +example is marked pending. The old “never run” behaviour is provided a by +a new skip method. (Xavier Shay)

    +
  • +

    Pending blocks inside an example have been removed as a feature with no +direct replacement. Use skip or pending without a +block. (Xavier Shay)

    +
  • +

    Pending statement is no longer allowed in before(:all) hooks. +Use skip instead. (Xavier Shay)

    +
  • +

    Remove show_failures_in_pending_blocks configuration option. +(Xavier Shay)

    +
  • +

    Remove support for specifying the documentation formatter using +'s', 'n', 'spec' or 'nested'. (Jon Rowe)

    +
+ +

Enhancements:

+
  • +

    Add example run time to JSON formatter output. (Karthik Kastury)

    +
  • +

    Add more suggested settings to the files generated by rspec +--init. (Myron Marston)

    +
  • +

    Add config.alias_example_group_to, which can be used to define +a new method that defines an example group with the provided metadata. +(Michi Huber)

    +
  • +

    Add xdescribe and xcontext as shortcuts to skip +an example group. (Myron Marston)

    +
  • +

    Add fdescribe and fcontext as shortcuts to focus +an example group. (Myron Marston)

    +
  • +

    Don't autorun specs via #at_exit by default. require +'rspec/autorun' is only needed when running specs via +ruby, as it always has been. Running specs via +rake or rspec are both unaffected. (Ben Hoskings)

    +
  • +

    Add expose_dsl_globally config option, defaulting to true. +When disabled it will remove the monkey patches rspec-core adds to +main and Module (e.g. describe, +shared_examples_for, etc). (Jon Rowe)

    +
  • +

    Expose RSpec DSL entry point methods (describe, +shared_examples_for, etc) on the RSpec constant. +Intended for use when expose_dsl_globally is set to +false. (Jon Rowe)

    +
  • +

    For consistency, expose all example group aliases (including +context) on the RSpec constant. If +expose_dsl_globally is set to true, also expose +them on main and Module. Historically, only +describe was exposed. (Jon Rowe, Michi Huber)

    +
  • +

    Add hook scope :example as an alias for :each, +and :context as an alias for :all. (John +Feminella)

    +
+ +

Bug Fixes:

+
  • +

    Fix failure (undefined method path) in end-of-run summary +when raise_errors_for_deprecations! is configured. (Myron +Marston)

    +
  • +

    Issue error when attempting to use -i or --I on +command line, too close to -I to be considered short hand for +--init. (Jon Rowe)

    +
  • +

    Prevent adding formatters to an output target if the same formatter has +already been added to that output. (Alex Peattie)

    +
  • +

    Allow a matcher-generated example description to be used when the example +is pending. (Myron Marston)

    +
  • +

    Ensure the configured failure_exit_code is used by the rake +task when there is a failure. (Jon Rowe)

    +
  • +

    Restore behaviour whereby system exclusion filters take priority over +working directory (was broken in beta1). (Jon Rowe)

    +
  • +

    Prevent RSpec mangling file names that have substrings containing +line_number or default_path. (Matijs van +Zuijlen)

    +
+ +

3.0.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Remove explicit support for 1.8.6. (Jon Rowe)

    +
  • +

    Remove RSpec::Core::ExampleGroup#example and +RSpec::Core::ExampleGroup#running_example methods. If you need +access to the example (e.g. to get its metadata), use a block arg instead. +(David Chelimsky)

    +
  • +

    Remove TextMateFormatter, it has been moved to +rspec-tmbundle. (Aaron Kromer)

    +
  • +

    Remove RCov integration. (Jon Rowe)

    +
  • +

    Remove deprecated support for RSpec 1 constructs (Myron Marston):

    +
  • +

    The Spec and Rspec constants (rather than +RSpec).

    +
  • +

    Spec::Runner.configure rather than +RSpec.configure.

    +
  • +

    Rake::SpecTask rather than RSpec::Core::RakeTask.

    +
  • +

    Remove deprecated support for share_as. (Myron Marston)

    +
  • +

    Remove --debug option (and corresponding option on +RSpec::Core::Configuration). Instead, use -r<debugger +gem name> to load whichever debugger gem you wish to use (e.g. +ruby-debug, debugger, or pry). +(Myron Marston)

    +
  • +

    Extract Autotest support to a seperate gem. (Jon Rowe)

    +
  • +

    Raise an error when a let or subject declaration +is accessed in a before(:all) or after(:all) +hook. (Myron Marston)

    +
  • +

    Extract its support to a separate gem. (Peter Alfvin)

    +
  • +

    Disallow use of a shared example group from sibling contexts, making them +fully isolated. 2.14 and 2.99 allowed this but printed a deprecation +warning. (Jon Rowe)

    +
  • +

    Remove RSpec::Core::Configuration#output and +RSpec::Core::Configuration#out aliases of +RSpec::Core::Configuration#output_stream. (Myron Marston)

    +
  • +

    Remove legacy ordering APIs deprecated in 2.99.0.beta1. (Myron Marston)

    +
+ +

Enhancements:

+
  • +

    Replace unmaintained syntax gem with coderay gem. (Xavier Shay)

    +
  • +

    Times in profile output are now bold instead of failure_color. +(Matthew Boedicker)

    +
  • +

    Add --no-fail-fast command line option. (Gonzalo +Rodríguez-Baltanás Díaz)

    +
  • +

    Runner now considers the local system ip address when running under Drb. +(Adrian CB)

    +
  • +

    JsonFormatter now includes --profile information. (Alex / +@MasterLambaster)

    +
  • +

    Always treat symbols passed as metadata args as hash keys with true +values. RSpec 2 supported this with the +treat_symbols_as_metadata_keys_with_true_values but now this +behavior is always enabled. (Myron Marston)

    +
  • +

    Add --dry-run option, which prints the formatter output of +your suite without running any examples or hooks. (Thomas Stratmann, Myron +Marston)

    +
  • +

    Document the configuration options and default values in the +spec_helper.rb file that is generated by RSpec. (Parker +Selbert)

    +
  • +

    Give generated example group classes a friendly name derived from the +docstring, rather than something like “Nested_2”. (Myron Marston)

    +
  • +

    Avoid affecting randomization of user code when shuffling examples so that +users can count on their own seeds working. (Travis Herrick)

    +
  • +

    Ordering is no longer a single global property of the test suite. Each +group can pick an ordering using :order metadata. (Andy +Lindeman, Sam Phippen, Myron Marston)

    +
  • +

    Allow named custom ordering strategies to be registered, which can then be +used on individual example groups. (Andy Lindeman, Sam Phippen, Myron +Marston)

    +
+ +

Deprecations:

+
  • +

    treat_symbols_as_metadata_keys_with_true_values is deprecated +and no longer has an affect now that the behavior it enabled is always +enabled. (Myron Marston)

    +
+ +

2.99.2 / 2014-08-19

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Improve deprecation warning for RSpec 3 change in describe <a +symbol> behavior. (Jon Rowe, #1667)

    +
+ +

2.99.1 / 2014-06-19

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Add missing deprecation warning for when RSpec::Core::Runner +is used multiple times in the same process. In 2.x RSpec's global +state was automatically cleared between runs but in 3.0 you need to call +RSpec.reset manually in these situations. (Sam Phippen, +#1587)

    +
  • +

    Prevent deprecation being accidentally issues when doubles used with +be_ matchers due to automatically generated descriptions. +(Jon Rowe, #1573)

    +
  • +

    Load rspec/core when loading rspec/core/rake_task +to ensure we can issue deprecations correctly. (Jon Rowe, #1612)

    +
+ +

2.99.0 / 2014-06-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix BaseTextFormatter so that it does not re-close a closed +output stream. (Myron Marston)

    +
  • +

    Use RSpec::Configuration#backtrace_exclusion_patterns rather +than the deprecated +RSpec::Configuration#backtrace_clean_patterns when mocking +with rr. (David Dollar)

    +
+ +

2.99.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Add --deprecation-out CLI option which directs deprecation +warnings to the named file. (Myron Marston)

    +
  • +

    Backport support for skip in metadata to skip execution of an +example. (Xavier Shay, #1472)

    +
  • +

    Add Pathname support for setting all output streams. (Aaron +Kromer)

    +
  • +

    Add test_unit and minitest expectation +frameworks. (Aaron Kromer)

    +
+ +

Deprecations:

+
  • +

    Deprecate RSpec::Core::Pending::PendingDeclaredInExample, use +SkipDeclaredInExample instead. (Xavier Shay)

    +
  • +

    Issue a deprecation when described_class is accessed from +within a nested describe <SomeClass> example group, +since described_class will return the innermost described +class in RSpec 3 rather than the outermost described class, as it behaved +in RSpec 2. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::FilterManager::DEFAULT_EXCLUSIONS, +RSpec::Core::FilterManager::STANDALONE_FILTERS and use of +#empty_without_conditional_filters? on those filters. (Sergey +Pchelincev)

    +
  • +

    Deprecate RSpec::Core::Example#options in favor of +RSpec::Core::Example#metadata. (Myron Marston)

    +
  • +

    Issue warning when passing a symbol or hash to describe or +context as the first argument. In RSpec 2.x this would be +treated as metadata but in RSpec 3 it'll be treated as the described +object. To continue having it treated as metadata, pass a description +before the symbol or hash. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::BaseTextFormatter::VT100_COLORS and +RSpec::Core::BaseTextFormatter::VT100_COLOR_CODES in favour +of RSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODES +and +RSpec::Core::BaseTextFormatter::ConsoleCodes::VT100_CODE_VALUES. +(Jon Rowe)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.display_name in favor of +RSpec::Core::ExampleGroup.description. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.describes in favor of +RSpec::Core::ExampleGroup.described_class. (Myron Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.alias_example_to in favor +of RSpec::Core::Configuration#alias_example_to. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.alias_it_behaves_like_to +in favor of +RSpec::Core::Configuration#alias_it_behaves_like_to. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Core::ExampleGroup.focused in favor of +RSpec::Core::ExampleGroup.focus. (Myron Marston)

    +
  • +

    Add deprecation warning for config.filter_run :focused since +example aliases fit and focus will no longer +include :focused metadata but will continue to include +:focus. (Myron Marston)

    +
  • +

    Deprecate filtering by :line_number (e.g. +--line-number from the CLI). Use location filtering instead. +(Myron Marston)

    +
  • +

    Deprecate --default_path as an alternative to +--default-path. (Jon Rowe)

    +
  • +

    Deprecate RSpec::Core::Configuration#warnings in favor of +RSpec::Core::Configuration#warnings?. (Myron Marston)

    +
  • +

    Deprecate share_examples_for in favor of +shared_examples_for or just shared_examples. +(Myron Marston)

    +
  • +

    Deprecate RSpec::Core::CommandLine in favor of +RSpec::Core::Runner. (Myron Marston)

    +
  • +

    Deprecate #color_enabled, #color_enabled= and +#color? in favour of #color, +#color= and #color_enabled? output. (Jon Rowe)

    +
  • +

    Deprecate #filename_pattern in favour of +#pattern. (Jon Rowe)

    +
  • +

    Deprecate #backtrace_cleaner in favour of +#backtrace_formatter. (Jon Rowe)

    +
  • +

    Deprecate mutating RSpec::Configuration#formatters. (Jon Rowe)

    +
  • +

    Deprecate stdlib as an available expectation framework in +favour of test_unit and minitest. (Aaron Kromer)

    +
+ +

Bug Fixes:

+
  • +

    Issue a warning when you set config.deprecation_stream too +late for it to take effect because the reporter has already been setup. +(Myron Marston)

    +
  • +

    skip with a block should not execute the block. (Xavier Shay)

    +
+ +

2.99.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Add is_expected for one-liners that read well with the +expect-based syntax. is_expected is simply +defined as expect(subject) and can be used in an expression +like: it { is_expected.to read_well }. (Myron Marston)

    +
  • +

    Backport skip from RSpec 3, which acts like +pending did in RSpec 2 when not given a block, since the +behavior of pending is changing in RSpec 3. (Xavier Shay)

    +
+ +

Deprecations:

+
  • +

    Deprecate inexact mock_with config options. RSpec 3 will only +support the exact symbols :rspec, :mocha, +:flexmock, :rr or :nothing (or any +module that implements the adapter interface). RSpec 2 did fuzzy matching +but this will not be supported going forward. (Myron Marston)

    +
  • +

    Deprecate show_failures_in_pending_blocks config option. To +achieve the same behavior as the option enabled, you can use a custom +formatter instead. (Xavier Shay)

    +
  • +

    Add a deprecation warning for the fact that the behavior of +pending is changing in RSpec 3 – rather than skipping the +example (as it did in 2.x when no block was provided), it will run the +example and mark it as failed if no exception is raised. Use +skip instead to preserve the old behavior. (Xavier Shay)

    +
  • +

    Deprecate 's', 'n', 'spec' and 'nested' as +aliases for documentation formatter. (Jon Rowe)

    +
  • +

    Deprecate RSpec::Core::Reporter#abort in favor of +RSpec::Core::Reporter#finish. (Jon Rowe)

    +
+ +

Bug Fixes:

+
  • +

    Fix failure (undefined method path) in end-of-run summary +when raise_errors_for_deprecations! is configured. (Myron +Marston)

    +
  • +

    Fix issue were overridding spec ordering from the command line wasn't +fully recognised interally. (Jon Rowe)

    +
+ +

2.99.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Block-based DSL methods that run in the context of an example +(it, before(:each), after(:each), +let and subject) now yield the example as a +block argument. (David Chelimsky)

    +
  • +

    Warn when the name of more than one example group is submitted to +include_examples and it's aliases. (David Chelimsky)

    +
  • +

    Add expose_current_running_example_as config option for use +during the upgrade process when external gems use the deprecated +RSpec::Core::ExampleGroup#example and +RSpec::Core::ExampleGroup#running_example methods. (Myron +Marston)

    +
  • +

    Limit spamminess of deprecation messages. (Bradley Schaefer, Loren Segal)

    +
  • +

    Add config.raise_errors_for_deprecations! option, which turns +deprecations warnings into errors to surface the full backtrace of the +call site. (Myron Marston)

    +
+ +

Deprecations

+
  • +

    Deprecate RSpec::Core::ExampleGroup#example and +RSpec::Core::ExampleGroup#running_example methods. If you need +access to the example (e.g. to get its metadata), use a block argument +instead. (David Chelimsky)

    +
  • +

    Deprecate use of autotest/rspec2 in favour of +rspec-autotest. (Jon Rowe)

    +
  • +

    Deprecate RSpec's built-in debugger support. Use a CLI option like +-rruby-debug (for the ruby-debug gem) or +-rdebugger (for the debugger gem) instead. (Myron Marston)

    +
  • +

    Deprecate +RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values = +false. RSpec 3 will not support having this option set to +false. (Myron Marston)

    +
  • +

    Deprecate accessing a let or subject declaration +in a after(:all) hook. (Myron Marston, Jon Rowe)

    +
  • +

    Deprecate built-in its usage in favor of +rspec-its gem due to planned removal in RSpec 3. (Peter +Alfvin)

    +
  • +

    Deprecate RSpec::Core::PendingExampleFixedError in favor of +RSpec::Core::Pending::PendingExampleFixedError. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Core::Configuration#out and +RSpec::Core::Configuration#output in favor of +RSpec::Core::Configuration#output_stream. (Myron Marston)

    +
  • +

    Deprecate legacy ordering APIs.

    +
  • +

    You should use register_ordering(:global) instead of these:

    +
    • +

      RSpec::Core::Configuration#order_examples

      +
    • +

      RSpec::Core::Configuration#order_groups

      +
    • +

      RSpec::Core::Configuration#order_groups_and_examples

      +
    +
  • +

    These are deprecated with no replacement because in RSpec 3 ordering is a +property of individual example groups rather than just a global property of +the entire test suite:

    +
    • +

      RSpec::Core::Configuration#order

      +
    • +

      RSpec::Core::Configuration#randomize?

      +
    +
  • +

    --order default is deprecated in favor of --order +defined (Myron Marston)

    +
+ +

2.14.8 / 2014-02-27

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Fix regression with the textmateformatter that prevented +backtrace links from being clickable. (Stefan Daschek)

    +
+ +

2.14.7 / 2013-10-29

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Fix regression in 2.14.6 that broke the Fivemat formatter. It depended +upon either +example.execution_result[:exception].pending_fixed? (which +was removed in 2.14.6 to fix an issue with frozen error objects) or +RSpec::Core::PendingExampleFixedError (which was renamed to +RSpec::Core::Pending::PendingExampleFixedError in 2.8. This +fix makes a constant alias for the old error name. (Myron Marston)

    +
+ +

2.14.6 / 2013-10-15

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Format stringified numbers correctly when mathn library is loaded. (Jay +Hayes)

    +
  • +

    Fix an issue that prevented the use of frozen error objects. (Lars Gierth)

    +
+ +

2.14.5 / 2013-08-13

+ +

Full +Changelog

+ +

Bug fixes:

+
  • +

    Fix a NoMethodError that was being raised when there were no +shared examples or contexts declared and RSpec.world.reset is +invoked. (thepoho, Jon Rowe, Myron Marston)

    +
  • +

    Fix a deprecation warning that was being incorrectly displayed when +shared_examples are declared at top level in a +module scope. (Jon Rowe)

    +
  • +

    Fix after(:all) hooks so consecutive (same context) scopes will run even if +one raises an error. (Jon Rowe, Trejkaz)

    +
  • +

    JsonFormatter no longer dies if dump_profile isn't defined +(Alex / @MasterLambaster, Jon Rowe)

    +
+ +

2.14.4 / 2013-07-21

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix regression in 2.14: ensure configured requires (via -r +option) are loaded before spec files are loaded. This allows the spec +files to programatically change the file pattern (Jon Rowe).

    +
  • +

    Autoload RSpec::Mocks and RSpec::Expectations +when referenced if they are not already loaded +(RSpec::Matches has been autoloaded for a while). In the +rspec gem, we changed it recently to stop loading +rspec/mocks and rspec/expectations by default, as +some users reported problems where they were intending to use mocha, not +rspec-mocks, but rspec-mocks was loaded and causing a conflict. rspec-core +loads mocks and expectations at the appropriate time, so it seemed like a +safe change – but caused a problem for some authors of libraries that +integrate with RSpec. This fixes that problem. (Myron Marston)

    +
  • +

    Gracefully handle a command like rspec --profile +path/to/spec.rb: the path/to/spec.rb arg was being +wrongly treated as the profile integer arg, which got cast +0 using to_i, causing no profiled examples to be +printed. (Jon Rowe)

    +
+ +

2.14.3 / 2013-07-13

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix deprecation notices issued from RSpec::Core::RakeTask so +that they work properly when all of rspec-core is not loaded. (This was a +regression in 2.14) (Jon Rowe)

    +
+ +

2.14.2 / 2013-07-09

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix regression caused by 2.14.1 release: formatters that report that they +respond_to? a notification, but had no corresponding method +would raise an error when registered. The new fix is to just implement +start on the deprecation formatter to fix the original +JRuby/ruby-debug issue. (Jon Rowe)

    +
+ +

2.14.1 / 2013-07-08

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Address deprecation formatter failure when using ruby-debug on +JRuby: fix RSpec::Core::Reporter to not send a notification +when the formatter's implementation of the notification method comes +from Kernel (Alex Portnov, Jon Rowe).

    +
+ +

2.14.0 / 2013-07-06

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Apply focus to examples defined with fit (equivalent of +it "description", focus: true) (Michael de Silva)

    +
+ +

Bug fix

+
  • +

    Ensure methods defined by let take precedence over others +when there is a name collision (e.g. from an included module). (Jon Rowe, +Andy Lindeman and Myron Marston)

    +
+ +

2.14.0.rc1 / 2013-05-27

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Improved Windows detection inside Git Bash, for better --color +handling.

    +
  • +

    Add profiling of the slowest example groups to --profile +option. The output is sorted by the slowest average example groups.

    +
  • +

    Don't show slow examples if there's a failure and both +--fail-fast and --profile options are used +(Paweł Gościcki).

    +
  • +

    Rather than always adding spec to the load path, add the +configured --default-path to the load path (which defaults to +spec). This better supports folks who choose to put their +specs in a different directory (John Feminella).

    +
  • +

    Add some logic to test time duration precision. Make it a function of +time, dropping precision as the time increases. (Aaron Kromer)

    +
  • +

    Add new backtrace_inclusion_patterns config option. Backtrace +lines that match one of these patterns will always be included in +the backtrace, even if they match an exclusion pattern, too (Sam Phippen).

    +
  • +

    Support ERB trim mode using the - when parsing +.rspec as ERB (Gabor Garami).

    +
  • +

    Give a better error message when let and subject are called without a +block. (Sam Phippen).

    +
  • +

    List the precedence of .rspec-local in the configuration +documentation (Sam Phippen)

    +
  • +

    Support {a,b} shell expansion syntax in --pattern +option (Konstantin Haase).

    +
  • +

    Add cucumber documentation for –require command line option (Bradley +Schaefer)

    +
  • +

    Expose configuration options via config:

    +
  • +

    config.libs returns the libs configured to be added onto the +load path

    +
  • +

    full_backtrace? returns the state of the backtrace cleaner

    +
  • +

    debug? returns true when the debugger is loaded

    +
  • +

    line_numbers returns the line numbers we are filtering by (if +any)

    +
  • +

    full_description returns the RegExp used to filter +descriptions (Jon Rowe)

    +
  • +

    Add setters for RSpec.world and RSpec.configuration (Alex Soulim)

    +
  • +

    Configure ruby's warning behaviour with --warnings (Jon +Rowe)

    +
  • +

    Fix an obscure issue on old versions of 1.8.7 where +Time.dup wouldn't allow access to Time.now +(Jon Rowe)

    +
  • +

    Make shared_examples_for context aware, so that keys may be +safely reused in multiple contexts without colliding. (Jon Rowe)

    +
  • +

    Add a configurable deprecation_stream (Jon Rowe)

    +
  • +

    Publish deprecations through a formatter (David Chelimsky)

    +
+ +

Bug fixes

+
  • +

    Make JSON formatter behave the same when it comes to --profile +as the text formatter (Paweł Gościcki).

    +
  • +

    Fix named subjects so that if an inner group defines a method that +overrides the named method, subject still retains the +originally declared value (Myron Marston).

    +
  • +

    Fix random ordering so that it does not cause rand in examples +in nested sibling contexts to return the same value (Max Shytikov).

    +
  • +

    Use the new backtrace_inclusion_patterns config option to +ensure that folks who develop code in a directory matching one of the +default exclusion patterns (e.g. gems) still get the normal +backtrace filtering (Sam Phippen).

    +
  • +

    Fix ordering of before hooks so that before hooks +declared in RSpec.configure run before before +hooks declared in a shared context (Michi Huber and Tejas Dinkar).

    +
  • +

    Fix Example#full_description so that it gets filled in by the +last matcher description (as Example#description already did) +when no doc string has been provided (David Chelimsky).

    +
  • +

    Fix the memoized methods (let and subject) +leaking define_method as a public method. +(Thomas Holmes and Jon Rowe) (#873)

    +
  • +

    Fix warnings coming from the test suite. (Pete Higgins)

    +
+ +

Deprecations

+
  • +

    Deprecate Configuration#backtrace_clean_patterns in favor of +Configuration#backtrace_exclusion_patterns for greater +consistency and symmetry with new +backtrace_inclusion_patterns config option (Sam Phippen).

    +
  • +

    Deprecate Configuration#requires= in favor of using ruby's +require. Requires specified by the command line can still be +accessed by the Configuration#require reader. (Bradley +Schaefer)

    +
  • +

    Deprecate calling SharedExampleGroups defined across sibling +contexts (Jon Rowe)

    +
+ +

2.13.1 / 2013-03-12

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Use hook classes as proxies rather than extending hook blocks to support +lambdas for before/after/around hooks. (David Chelimsky)

    +
  • +

    Fix regression in 2.13.0 that caused confusing behavior when overriding a +named subject with an unnamed subject in an inner group and then +referencing the outer group subject's name. The fix for this required +us to disallow using super in a named subject (which is +confusing, anyway – named subjects create 2 methods, so which method on +the parent example group are you supering to?) but +super in an unnamed subject continues to work (Myron +Marston).

    +
  • +

    Do not allow a referenced let or subject in +before(:all) to cause other let declarations to +leak across examples (Myron Marston).

    +
  • +

    Work around odd ruby 1.9 bug with String#match that was +triggered by passing it a regex from a let declaration. For +more info, see bugs.ruby-lang.org/issues/8059 +(Aaron Kromer).

    +
  • +

    Add missing require 'set' to +base_text_formatter.rb (Tom Anderson).

    +
+ +

Deprecations

+
  • +

    Deprecate accessing let or subject declarations +in before(:all). These were not intended to be called in a +before(:all) hook, as they exist to define state that is +reset between each example, while before(:all) exists to +define state that is shared across examples in an example group (Myron +Marston).

    +
+ +

2.13.0 / 2013-02-23

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Allow --profile option to take a count argument that +determines the number of slow examples to dump (Greggory Rothmeier).

    +
  • +

    Add subject! that is the analog to let!. It +defines an explicit subject and sets a before hook that will +invoke the subject (Zubin Henner).

    +
  • +

    Fix let and subject declaration so that +super and return can be used in them, just like +in a normal method. (Myron Marston)

    +
  • +

    Allow output colors to be configured individually. (Charlie Maffitt)

    +
  • +

    Always dump slow examples when --profile option is given, +even when an example failed (Myron Marston).

    +
+ +

Bug fixes

+
  • +

    Don't blow up when dumping error output for instances of anonymous +error classes (Myron Marston).

    +
  • +

    Fix default backtrace filters so lines from projects containing “gems” in +the name are not filtered, but lines from installed gems still are (Myron +Marston).

    +
  • +

    Fix autotest command so that is uses double quotes rather than single +quotes for windows compatibility (Jonas Tingeborn).

    +
  • +

    Fix its so that uses of subject in a +before or let declaration in the parent group +continue to reference the parent group's subject. (Olek Janiszewski)

    +
+ +

2.12.2 / 2012-12-13

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix RSpec::Core::RakeTask so that it is compatible with rake +0.8.7 on ruby 1.8.7. We had accidentally broke it in the 2.12 release +(Myron Marston).

    +
  • +

    Fix RSpec::Core::RakeTask so it is tolerant of the +Rspec constant for backwards compatibility (Patrick Van Stee)

    +
+ +

2.12.1 / 2012-12-01

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Specs are run even if another at_exit hook calls exit. This +allows Test::Unit and RSpec to run together. (Suraj N. Kurapati)

    +
  • +

    Fix full doc string concatenation so that it handles the case of a method +string (e.g. “#foo”) being nested under a context string (e.g. “when it is +tuesday”), so that we get “when it is tuesday #foo” rather than “when it +is tuesday#foo”. (Myron Marston)

    +
  • +

    Restore public API I unintentionally broke in 2.12.0: +RSpec::Core::Formatters::BaseFormatter#format_backtrce(backtrace, +example) (Myron Marston).

    +
+ +

2.12.0 / 2012-11-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Add support for custom ordering strategies for groups and examples. (Myron +Marston)

    +
  • +

    JSON Formatter (Alex Chaffee)

    +
  • +

    Refactor rake task internals (Sam Phippen)

    +
  • +

    Refactor HtmlFormatter (Pete Hodgson)

    +
  • +

    Autotest supports a path to Ruby that contains spaces (dsisnero)

    +
  • +

    Provide a helpful warning when a shared example group is redefined. (Mark +Burns).

    +
  • +

    --default_path can be specified as +--default-line. --line_number can be specified +as --line-number. Hyphens are more idiomatic command line +argument separators (Sam Phippen).

    +
  • +

    A more useful error message is shown when an invalid command line option is +used (Jordi Polo).

    +
  • +

    Add format_docstrings { |str| } config option. It can be used +to apply formatting rules to example group and example docstrings. (Alex +Tan)

    +
  • +

    Add support for an .rspec-local options file. This is intended +to allow individual developers to set options in a git-ignored file that +override the common project options in .rspec. (Sam Phippen)

    +
  • +

    Support for mocha 0.13.0. (Andy Lindeman)

    +
+ +

Bug fixes

+
  • +

    Remove override of ExampleGroup#ancestors. This is a core ruby +method that RSpec shouldn't override. Instead, define +ExampleGroup#parent_groups. (Myron Marston)

    +
  • +

    Limit monkey patching of shared example/context declaration methods +(shared_examples_for, etc.) to just the objects that need it +rather than every object in the system (Myron Marston).

    +
  • +

    Fix Metadata#fetch to support computed values (Sam Goldman).

    +
  • +

    Named subject can now be referred to from within subject block in a nested +group (tomykaira).

    +
  • +

    Fix fail_fast so that it properly exits when an error occurs +in a before(:all) hook (Bradley Schaefer).

    +
  • +

    Make the order spec files are loaded consistent, regardless of the order +of the files returned by the OS or the order passed at the command line +(Jo Liss and Sam Phippen).

    +
  • +

    Ensure instance variables from before(:all) are always exposed +from after(:all), even if an error occurs in +before(:all) (Sam Phippen).

    +
  • +

    rspec --init no longer generates an incorrect warning about +--configure being deprecated (Sam Phippen).

    +
  • +

    Fix pluralization of 1 seconds (Odin Dutton)

    +
  • +

    Fix ANSICON url (Jarmo Pertman)

    +
  • +

    Use dup of Time so reporting isn't clobbered by examples that modify +Time without properly restoring it. (David Chelimsky)

    +
+ +

Deprecations

+
  • +

    share_as is no longer needed. shared_context +and/or RSpec::SharedContext provide better mechanisms (Sam +Phippen).

    +
  • +

    Deprecate RSpec.configuration with a block (use +RSpec.configure).

    +
+ +

2.11.1 / 2012-07-18

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix the way we autoload RSpec::Matchers so that custom matchers can be +defined before rspec-core has been configured to definitely use +rspec-expectations. (Myron Marston)

    +
  • +

    Fix typo in –help message printed for -e option. (Jo Liss)

    +
  • +

    Fix ruby warnings. (Myron Marston)

    +
  • +

    Ignore mock expectation failures when the example has already failed. Mock +expectation failures have always been ignored in this situation, but due +to my changes in 27059bf1 it was printing a confusing message. (Myron +Marston).

    +
+ +

2.11.0 / 2012-07-07

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Support multiple --example options. (Daniel Doubrovkine +@dblock)

    +
  • +

    Named subject e.g. subject(:article) { Article.new }

    + +
  • +

    config.mock_with and config.expect_with yield +custom config object to a block if given

    +
    • +

      aids decoupling from rspec-core's configuation

      +
    +
  • +

    include_context and include_examples support a +block, which gets eval'd in the current context (vs the nested context +generated by it_behaves_like).

    +
  • +

    Add config.order = 'random' to the +spec_helper.rb generated by rspec --init.

    +
  • +

    Delay the loading of DRb (Myron Marston).

    +
  • +

    Limit monkey patching of describe onto just the objects that +need it rather than every object in the system (Myron Marston).

    +
+ +

Bug fixes

+
  • +

    Support alternative path separators. For example, on Windows, you can now +do this: rspec spec\subdir. (Jarmo Pertman @jarmo)

    +
  • +

    When an example raises an error and an after or around hook does as well, +print out the hook error. Previously, the error was silenced and the user +got no feedback about what happened. (Myron Marston)

    +
  • +

    --require and -I are merged among different +configuration sources (Andy Lindeman)

    +
  • +

    Delegate to mocha methods instead of aliasing them in mocha adapter.

    +
+ +

2.10.1 / 2012-05-19

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    RSpec.reset properly reinits configuration and world

    +
  • +

    Call to_s before split on exception messages that +might not always be Strings (slyphon)

    +
+ +

2.10.0 / 2012-05-03

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Add prepend_before and append_after hooks +(preethiramdev)

    +
    • +

      intended for extension libs

      +
    • +

      restores rspec-1 behavior

      +
    +
  • +

    Reporting of profiled examples (moro)

    +
    • +

      Report the total amount of time taken for the top slowest examples.

      +
    • +

      Report what percentage the slowest examples took from the total runtime.

      +
    +
+ +

Bug fixes

+
  • +

    Properly parse SPEC_OPTS options.

    +
  • +

    example.description returns the location of the example if +there is no explicit description or matcher-generated description.

    +
  • +

    RDoc fixes (Grzegorz Świrski)

    +
  • +

    Do not modify example ancestry when dumping errors (Michael Grosser)

    +
+ +

2.9.0 / 2012-03-17

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Support for “X minutes X seconds” spec run duration in formatter. (uzzz)

    +
  • +

    Strip whitespace from group and example names in doc formatter.

    +
  • +

    Removed spork-0.9 shim. If you're using spork-0.8.x, you'll need to +upgrade to 0.9.0.

    +
+ +

Bug fixes

+
  • +

    Restore --full_backtrace option

    +
  • +

    Ensure that values passed to config.filter_run are respected +when running over DRb (using spork).

    +
  • +

    Ensure shared example groups are reset after a run (as example groups are).

    +
  • +

    Remove rescue false from calls to filters represented as Procs

    +
  • +

    Ensure described_class gets the closest constant (pyromaniac)

    +
  • +

    In “autorun”, don't run the specs in the at_exit hook if +there was an exception (most likely due to a SyntaxError). (sunaku)

    +
  • +

    Don't extend groups with modules already used to extend ancestor +groups.

    +
  • +

    its correctly memoizes nil or false values (Yamada Masaki)

    +
+ +

2.8.0 / 2012-01-04

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    For metadata filtering, restore passing the entire array to the proc, +rather than each item in the array (weidenfreak)

    +
  • +

    Ensure each spec file is loaded only once

    +
    • +

      Fixes a bug that caused all the examples in a file to be run when +referenced twice with line numbers in a command, e.g.

      +
      • +

        rspec path/to/file:37 path/to/file:42

        +
      +
    +
+ +

2.8.0.rc2 / 2011-12-19

+ +

Full +Changelog

+ +

Enhancments

+
  • +

    new --init command (Peter Schröder)

    +
    • +

      generates spec/spec_helper.rb

      +
    • +

      deletes obsolete files (on confirmation)

      +
    • +

      merged with and deprecates --configure command, which +generated .rspec

      +
    +
  • +

    use require_relative when available (Ian Leitch)

    +
  • +

    include_context and include_examples accept +params (Calvin Bascom)

    +
  • +

    print the time for every example in the html formatter (Richie Vos)

    +
  • +

    several tasty refactoring niblets (Sasha)

    +
  • +

    `it “does something”, :x => [:foo,'bar',/baz/] (Ivan Neverov)

    +
    • +

      supports matching n command line tag values with an example or group

      +
    +
+ +

2.8.0.rc1 / 2011-11-06

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    --order (Justin Ko)

    +
    • +

      run examples in random order: --order rand

      +
    • +

      specify the seed: --order rand:123

      +
    +
  • +

    --seed SEED

    +
    • +

      equivalent of --order rand:SEED

      +
    +
  • +

    SharedContext supports let (David Chelimsky)

    +
  • +

    Filter improvements (David Chelimsky)

    +
    • +

      override opposing tags from the command line

      +
    • +

      override RSpec.configure tags from the command line

      +
    • +

      --line_number 37 overrides all other filters

      +
    • +

      path/to/file.rb:37 overrides all other filters

      +
    • +

      refactor: consolidate filter management in a FilterManger object

      +
    +
  • +

    Eliminate Ruby warnings (Matijs van Zuijlen)

    +
  • +

    Make reporter.report an API (David Chelimsky)

    +
    • +

      supports extension tools like interative_rspec

      +
    +
+ +

Changes

+
  • +

    change config.color_enabled (getter/setter/predicate) to +color to align with --[no]-color CLI option.

    +
    • +

      color_enabled is still supported for now, but will likley be +deprecated in a 2.x release so we can remove it in 3.0.

      +
    +
+ +

Bug fixes

+
  • +

    Make sure the bar in --tag foo:bar makes it to +DRb (Aaron Gibralter)

    +
  • +

    Fix bug where full descriptions of groups nested 3 deep were repeated.

    +
  • +

    Restore report of time to run to start after files are loaded.

    +
    • +

      fixes bug where run times were cumalitive in spork

      +
    • +

      fixes compatibility with time-series metrics

      +
    • +

      fixes bug where run times were cumalitive in spork

      +
    • +

      fixes compatibility with time-series metrics

      +
    +
  • +

    Don't error out when config.mock_with or +expect_with is re-specifying the current config (Myron +Marston)

    +
  • +

    Deprecations

    +
    • +

      :alias option on configuration.add_setting. Use +:alias_with on the original setting declaration instead.

      +
    +
+ +

2.7.1 / 2011-10-20

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    tell autotest the correct place to find the rspec executable

    +
+ +

2.7.0 / 2011-10-16

+ +

Full +Changelog

+ +

NOTE: RSpec's release policy dictates that there should not be any +backward incompatible changes in minor releases, but we're making an +exception to release a change to how RSpec interacts with other command +line tools.

+ +

As of 2.7.0, you must explicity require +"rspec/autorun" unless you use the rspec +command (which already does this for you).

+ +

Enhancements

+
  • +

    Add example.exception (David Chelimsky)

    +
  • +

    --default_path command line option (Justin Ko)

    +
  • +

    support multiple --line_number options (David J. Hamilton)

    +
    • +

      also supports path/to/file.rb:5:9 (runs examples on lines 5 +and 9)

      +
    +
  • +

    Allow classes/modules to be used as shared example group identifiers +(Arthur Gunn)

    +
  • +

    Friendly error message when shared context cannot be found (Sławosz +Sławiński)

    +
  • +

    Clear formatters when resetting config (John Bintz)

    +
  • +

    Add xspecify and xexample as temp-pending methods (David +Chelimsky)

    +
  • +

    Add --no-drb option (Iain Hecker)

    +
  • +

    Provide more accurate run time by registering start time before code is +loaded (David Chelimsky)

    +
    • +

      reverted in 2.8.0

      +
    +
  • +

    Rake task default pattern finds specs in symlinked dirs (Kelly Felkins)

    +
  • +

    Rake task no longer does anything to invoke bundler since Bundler already +handles it for us. Thanks to Andre Arko for the tip.

    +
  • +

    Add --failure-exit-code option (Chris Griego)

    +
+ +

Bug fixes

+
  • +

    Include Rake::DSL to remove deprecation warnings in Rake > +0.8.7 (Pivotal Casebook)

    +
  • +

    Only eval let block once even if it returns nil +(Adam Meehan)

    +
  • +

    Fix --pattern option (wasn't being recognized) (David +Chelimsky)

    +
  • +

    Only implicitly require "rspec/autorun" with the +rspec command (David Chelimsky)

    +
  • +

    Ensure that rspec's at_exit defines the exit code (Daniel +Doubrovkine)

    +
  • +

    Show the correct snippet in the HTML and TextMate formatters (Brian +Faherty)

    +
+ +

2.6.4 / 2011-06-06

+ +

Full +Changelog

+ +

NOTE: RSpec's release policy dictates that there should not be new +functionality in patch releases, but this minor enhancement slipped in by +accident. As it doesn't add a new API, we decided to leave it in rather +than roll back this release.

+ +

Enhancements

+
  • +

    Add summary of commands to run individual failed examples.

    +
+ +

Bug fixes

+
  • +

    Support exclusion filters in DRb. (Yann Lugrin)

    +
  • +

    Fix –example escaping when run over DRb. (Elliot Winkler)

    +
  • +

    Use standard ANSI codes for color formatting so colors work in a wider set +of color schemes.

    +
+ +

2.6.3 / 2011-05-24

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Explicitly convert exit code to integer, avoiding TypeError when return +value of run is IO object proxied by DRb::DRbObject (Julian +Scheid)

    +
  • +

    Clarify behavior of --example command line option

    +
  • +

    Build using a rubygems-1.6.2 to avoid downstream yaml parsing error

    +
+ +

2.6.2 / 2011-05-21

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Warn rather than raise when HOME env var is not defined

    +
  • +

    Properly merge command-line exclusions with default :if and :unless +(joshcooper)

    +
+ +

2.6.1 / 2011-05-19

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Don't extend nil when filters are nil

    +
  • +

    require 'rspec/autorun' when running rcov.

    +
+ +

2.6.0 / 2011-05-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    shared_context (Damian Nurzynski)

    +
    • +

      extend groups matching specific metadata with:

      +
      • +

        method definitions

        +
      • +

        subject declarations

        +
      • +

        let/let! declarations

        +
      • +

        etc (anything you can do in a group)

        +
      +
    +
  • +

    its([:key]) works for any subject with #[]. (Peter Jaros)

    +
  • +

    treat_symbols_as_metadata_keys_with_true_values (Myron +Marston)

    +
  • +

    Print a deprecation warning when you configure RSpec after defining an +example. All configuration should happen before any examples are defined. +(Myron Marston)

    +
  • +

    Pass the exit status of a DRb run to the invoking process. This causes +specs run via DRb to not just return true or false. (Ilkka Laukkanen)

    +
  • +

    Refactoring of ConfigurationOptions#parse_options (Rodrigo +Rosenfeld Rosas)

    +
  • +

    Report excluded filters in runner output (tip from andyl)

    +
  • +

    Clean up messages for filters/tags.

    +
  • +

    Restore –pattern/-P command line option from rspec-1

    +
  • +

    Support false as well as true in config.full_backtrace= (Andreas Tolf +Tolfsen)

    +
+ +

Bug fixes

+
  • +

    Don't stumble over an exception without a message (Hans Hasselberg)

    +
  • +

    Remove non-ascii characters from comments that were choking rcov (Geoffrey +Byers)

    +
  • +

    Fixed backtrace so it doesn't include lines from before the autorun +at_exit hook (Myron Marston)

    +
  • +

    Include RSpec::Matchers when first example group is defined, rather than +just before running the examples. This works around an obscure bug in ruby +1.9 that can cause infinite recursion. (Myron Marston)

    +
  • +

    Don't send example_group_[started|finished] to formatters +for empty groups.

    +
  • +

    Get specs passing on jruby (Sidu Ponnappa)

    +
  • +

    Fix bug where mixing nested groups and outer-level examples gave +unpredictable :line_number behavior (Artur Małecki)

    +
  • +

    Regexp.escape the argument to –example (tip from Elliot Winkler)

    +
  • +

    Correctly pass/fail pending block with message expectations

    +
  • +

    CommandLine returns exit status (0/1) instead of true/false

    +
  • +

    Create path to formatter output file if it doesn't exist (marekj).

    +
+ +

2.5.1 / 2011-02-06

+ +

Full +Changelog

+ +

NOTE: this release breaks compatibility with rspec/autotest/bundler +integration, but does so in order to greatly simplify it.

+ +

With this release, if you want the generated autotest command to include +'bundle exec', require Autotest's bundler plugin in a .autotest +file in the project's root directory or in your home directory:

+ +
require "autotest/bundler"
+
+ +

Now you can just type 'autotest' on the commmand line and it will +work as you expect.

+ +

If you don't want 'bundle exec', there is nothing you have to +do.

+ +

2.5.0 / 2011-02-05

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Autotest::Rspec2 parses command line args passed to autotest after +'–'

    +
  • +

    –skip-bundler option for autotest command

    +
  • +

    Autotest regexp fixes (Jon Rowe)

    +
  • +

    Add filters to html and textmate formatters (Daniel Quimper)

    +
  • +

    Explicit passing of block (need for JRuby 1.6) (John Firebaugh)

    +
+ +

Bug fixes

+
  • +

    fix dom IDs in HTML formatter (Brian Faherty)

    +
  • +

    fix bug with –drb + formatters when not running in drb

    +
  • +

    include –tag options in drb args (monocle)

    +
  • +

    fix regression so now SPEC_OPTS take precedence over CLI options again +(Roman Chernyatchik)

    +
  • +

    only call its(:attribute) once (failing example from Brian Dunn)

    +
  • +

    fix bizarre bug where rspec would hang after String.alias :to_int :to_i +(Damian Nurzynski)

    +
+ +

Deprecations

+
  • +

    implicit inclusion of 'bundle exec' when Gemfile present (use +autotest's bundler plugin instead)

    +
+ +

2.4.0 / 2011-01-02

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    start the debugger on -d so the stack trace is visible when it stops +(Clifford Heath)

    +
  • +

    apply hook filtering to examples as well as groups (Myron Marston)

    +
  • +

    support multiple formatters, each with their own output

    +
  • +

    show exception classes in failure messages unless they come from RSpec +matchers or message expectations

    +
  • +

    before(:all) { pending } sets all examples to pending

    +
+ +

Bug fixes

+
  • +

    fix bug due to change in behavior of reject in Ruby 1.9.3-dev (Shota +Fukumori)

    +
  • +

    fix bug when running in jruby: be explicit about passing block to super +(John Firebaugh)

    +
  • +

    rake task doesn't choke on paths with quotes (Janmejay Singh)

    +
  • +

    restore –options option from rspec-1

    +
  • +

    require 'ostruct' to fix bug with its() (Kim +Burgestrand)

    +
  • +

    –configure option generates .rspec file instead of autotest/discover.rb

    +
+ +

2.3.1 / 2010-12-16

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    send debugger warning message to $stdout if +RSpec.configuration.error_stream has not been defined yet.

    +
  • +

    HTML Formatter finally properly displays nested groups (Jarmo +Pertman)

    +
  • +

    eliminate some warnings when running RSpec's own suite (Jarmo Pertman)

    +
+ +

2.3.0 / 2010-12-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    tell autotest to use “rspec2” if it sees a .rspec file in the project's +root directory

    +
    • +

      replaces the need for ./autotest/discover.rb, which will not work with all +versions of ZenTest and/or autotest

      +
    +
  • +

    config.expect_with

    +
    • +

      :rspec # => rspec/expectations

      +
    • +

      :stdlib # => test/unit/assertions

      +
    • +

      :rspec, :stdlib # => both

      +
    +
+ +

Bug fixes

+
  • +

    fix dev Gemfile to work on non-mac-os machines (Lake Denman)

    +
  • +

    ensure explicit subject is only eval'd once (Laszlo Bacsi)

    +
+ +

2.2.1 / 2010-11-28

+ +

Full +Changelog

+ +

Bug fixes * alias_method instead of override Kernel#method_missing (John +Wilger) * changed –autotest to –tty in generated command (MIKAMI Yoshiyuki) +* revert change to debugger (had introduced conflict with Rails) * also +restored –debugger/-debug option

+ +

2.2.0 / 2010-11-28

+ +

Full +Changelog

+ +

Deprecations/changes

+
  • +

    –debug/-d on command line is deprecated and now has no effect

    +
  • +

    win32console is now ignored; Windows users must use ANSICON for color +support (Bosko Ivanisevic)

    +
+ +

Enhancements

+
  • +

    When developing locally rspec-core now works with the rspec-dev setup or +your local gems

    +
  • +

    Raise exception with helpful message when rspec-1 is loaded alongside +rspec-2 (Justin Ko)

    +
  • +

    debugger statements just work as long as ruby-debug is installed

    +
  • +

    otherwise you get warned, but not fired

    +
  • +

    Expose example.metadata in around hooks

    +
  • +

    Performance improvments (much faster now)

    +
+ +

Bug fixes

+
  • +

    Make sure –fail-fast makes it across drb

    +
  • +

    Pass -Ilib:spec to rcov

    +
+ +

2.1.0 / 2010-11-07

+ +

Full +Changelog

+ +

Enhancments

+
  • +

    Add skip_bundler option to rake task to tell rake task to ignore the +presence of a Gemfile (jfelchner)

    +
  • +

    Add gemfile option to rake task to tell rake task what Gemfile to look for +(defaults to 'Gemfile')

    +
  • +

    Allow passing caller trace into Metadata to support extensions (Glenn +Vanderburg)

    +
  • +

    Add deprecation warning for Spec::Runner.configure to aid upgrade from +RSpec-1

    +
  • +

    Add deprecated Spec::Rake::SpecTask to aid upgrade from RSpec-1

    +
  • +

    Add 'autospec' command with helpful message to aid upgrade from +RSpec-1

    +
  • +

    Add support for filtering with tags on CLI (Lailson Bandeira)

    +
  • +

    Add a helpful message about RUBYOPT when require fails in bin/rspec +(slyphon)

    +
  • +

    Add “-Ilib” to the default rcov options (Tianyi Cui)

    +
  • +

    Make the expectation framework configurable (default rspec, of course) +(Justin Ko)

    +
  • +

    Add 'pending' to be conditional (Myron Marston)

    +
  • +

    Add explicit support for :if and :unless as metadata keys for conditional +run of examples (Myron Marston)

    +
  • +

    Add –fail-fast command line option (Jeff Kreeftmeijer)

    +
+ +

Bug fixes

+
  • +

    Eliminate stack overflow with “subject { self }”

    +
  • +

    Require 'rspec/core' in the Raketask (ensures it required when +running rcov)

    +
+ +

2.0.1 / 2010-10-18

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Restore color when using spork + autotest

    +
  • +

    Pending examples without docstrings render the correct message (Josep M. +Bach)

    +
  • +

    Fixed bug where a failure in a spec file ending in anything but _spec.rb +would fail in a confusing way.

    +
  • +

    Support backtrace lines from erb templates in html formatter (Alex +Crichton)

    +
+ +

2.0.0 / 2010-10-10

+ +

Full +Changelog

+ +

RSpec-1 compatibility

+
  • +

    Rake task uses ENV as file list if present

    +
+ +

Bug fixes

+
  • +

    Bug Fix: optparse –out foo.txt (Leonardo Bessa)

    +
  • +

    Suppress color codes for non-tty output (except autotest)

    +
+ +

2.0.0.rc / 2010-10-05

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    implicitly require unknown formatters so you don't have to require the +file explicitly on the commmand line (Michael Grosser)

    +
  • +

    add –out/-o option to assign output target

    +
  • +

    added fail_fast configuration option to abort on first failure

    +
  • +

    support a Hash subject (its() { should == value }) +(Josep M. Bach)

    +
+ +

Bug fixes

+
  • +

    Explicitly require rspec version to fix broken rdoc task (Hans de Graaff)

    +
  • +

    Ignore backtrace lines that come from other languages, like Java or +Javascript (Charles Lowell)

    +
  • +

    Rake task now does what is expected when setting (or not setting) +fail_on_error and verbose

    +
  • +

    Fix bug in which before/after(:all) hooks were running on excluded nested +groups (Myron Marston)

    +
  • +

    Fix before(:all) error handling so that it fails examples in nested groups, +too (Myron Marston)

    +
+ +

2.0.0.beta.22 / 2010-09-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    removed at_exit hook

    +
  • +

    CTRL-C stops the run (almost) immediately

    +
    • +

      first it cleans things up by running the appropriate after(:all) and +after(:suite) hooks

      +
    • +

      then it reports on any examples that have already run

      +
    +
  • +

    cleaned up rake task

    +
    • +

      generate correct task under variety of conditions

      +
    • +

      options are more consistent

      +
    • +

      deprecated redundant options

      +
    +
  • +

    run 'bundle exec autotest' when Gemfile is present

    +
  • +

    support ERB in .rspec options files (Justin Ko)

    +
  • +

    depend on bundler for development tasks (Myron Marston)

    +
  • +

    add example_group_finished to formatters and reporter (Roman Chernyatchik)

    +
+ +

Bug fixes

+
  • +

    support paths with spaces when using autotest (Andreas Neuhaus)

    +
  • +

    fix module_exec with ruby 1.8.6 (Myron Marston)

    +
  • +

    remove context method from top-level

    +
    • +

      was conflicting with irb, for example

      +
    +
  • +

    errors in before(:all) are now reported correctly (Chad Humphries)

    +
+ +

Removals

+
  • +

    removed -o –options-file command line option

    +
    • +

      use ./.rspec and ~/.rspec

      +
    +
+
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/file.License.html b/source/documentation/3.0/rspec-core/file.License.html new file mode 100644 index 000000000..1d8362fa6 --- /dev/null +++ b/source/documentation/3.0/rspec-core/file.License.html @@ -0,0 +1,73 @@ + + + + + + File: License + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
(The MIT License)

Copyright (c) 2012 Chad Humphries, David Chelimsky, Myron Marston
Copyright (c) 2009 Chad Humphries, David Chelimsky
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
Copyright (c) 2005 Steven Baker

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/file.README.html b/source/documentation/3.0/rspec-core/file.README.html new file mode 100644 index 000000000..6c0aaf6be --- /dev/null +++ b/source/documentation/3.0/rspec-core/file.README.html @@ -0,0 +1,315 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

rspec-core

+ +

rspec-core provides the structure for writing executable examples of how +your code should behave, and an rspec command with tools to +constrain which examples get run and tailor the output.

+ +

install

+ +
gem install rspec      # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-core # for rspec-core only
+rspec --help
+ +

basic structure

+ +

RSpec uses the words “describe” and “it” so we can express concepts like a +conversation:

+ +
"Describe an order."
+"It sums the prices of its line items."
+ +
RSpec.describe Order do
+  it "sums the prices of its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe method creates an ExampleGroup. +Within the block passed to describe you can declare examples +using the it method.

+ +

Under the hood, an example group is a class in which the block passed to +describe is evaluated. The blocks passed to it +are evaluated in the context of an instance of that class.

+ +

nested groups

+ +

You can also declare nested nested groups using the describe +or context methods:

+ +
RSpec.describe Order do
+  context "with no items" do
+    it "behaves one way" do
+      # ...
+    end
+  end
+
+  context "with one item" do
+    it "behaves another way" do
+      # ...
+    end
+  end
+end
+
+ +

aliases

+ +

You can declare example groups using either describe or +context. For a top level example group, describe +and context are available off of RSpec. For +backwards compatibility, they are also available off of the +main object and Module unless you disable monkey +patching.

+ +

You can declare examples within a group using any of it, +specify, or example.

+ +

shared examples and contexts

+ +

Declare a shared example group using shared_examples, and then +include it in any group using include_examples.

+ +
RSpec.shared_examples "collections" do |collection_class|
+  it "is empty when first created" do
+    expect(collection_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections", Array
+end
+
+RSpec.describe Hash do
+  include_examples "collections", Hash
+end
+
+ +

Nearly anything that can be declared within an example group can be +declared within a shared example group. This includes before, +after, and around hooks, let +declarations, and nested groups/contexts.

+ +

You can also use the names shared_context and +include_context. These are pretty much the same as +shared_examples and include_examples, providing +more accurate naming when you share hooks, let declarations, +helper methods, etc, but no examples.

+ +

metadata

+ +

rspec-core stores a metadata hash with every example and group, which +contains their descriptions, the locations at which they were declared, +etc, etc. This hash powers many of rspec-core's features, including +output formatters (which access descriptions and locations), and filtering +before and after hooks.

+ +

Although you probably won't ever need this unless you are writing an +extension, you can access it from an example like this:

+ +
it "does something" do
+  expect(example.[:description]).to eq("does something")
+end
+
+ +

described_class

+ +

When a class is passed to describe, you can access it from an +example using the described_class method, which is a wrapper +for example.metadata[:described_class].

+ +
RSpec.describe Widget do
+  example do
+    expect(described_class).to equal(Widget)
+  end
+end
+
+ +

This is useful in extensions or shared example groups in which the specific +class is unknown. Taking the collections shared example group from above, +we can clean it up a bit using described_class:

+ +
RSpec.shared_examples "collections" do
+  it "is empty when first created" do
+    expect(described_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections"
+end
+
+RSpec.describe Hash do
+  include_examples "collections"
+end
+
+ +

the rspec command

+ +

When you install the rspec-core gem, it installs the rspec +executable, which you'll use to run rspec. The rspec +command comes with many useful options. Run rspec --help to +see the complete list.

+ +

store command line options .rspec

+ +

You can store command line options in a .rspec file in the +project's root directory, and the rspec command will read +them as though you typed them on the command line.

+ +

autotest integration

+ +

rspec-core no longer ships with an Autotest extension, if you require +Autotest integration, please use the rspec-autotest gem and +see rspec/rspec-autotest for +details

+ +

get started

+ +

Start with a simple example of behavior you expect from your system. Do +this before you write any implementation code:

+ +
# in spec/calculator_spec.rb
+RSpec.describe Calculator do
+  describe '#add' do
+    it 'returns the sum of its arguments' do
+      expect(Calculator.new.add(1, 2)).to eq(3)
+    end
+  end
+end
+
+ +

Run this with the rspec command, and watch it fail:

+ +
$ rspec spec/calculator_spec.rb
+./spec/calculator_spec.rb:1: uninitialized constant Calculator
+ +

Implement the simplest solution:

+ +
# in lib/calculator.rb
+class Calculator
+  def add(a,b)
+    a + b
+  end
+end
+
+ +

Be sure to require the implementation file in the spec:

+ +
# in spec/calculator_spec.rb
+# - RSpec adds ./lib to the $LOAD_PATH
+require "calculator"
+
+ +

Now run the spec again, and watch it pass:

+ +
$ rspec spec/calculator_spec.rb
+.
+
+Finished in 0.000315 seconds
+1 example, 0 failures
+ +

Use the documentation formatter to see the resulting spec:

+ +
$ rspec spec/calculator_spec.rb --format doc
+Calculator
+  #add
+    returns the sum of its arguments
+
+Finished in 0.000379 seconds
+1 example, 0 failures
+ +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/file_list.html b/source/documentation/3.0/rspec-core/file_list.html new file mode 100644 index 000000000..4fbe39987 --- /dev/null +++ b/source/documentation/3.0/rspec-core/file_list.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + File List + + + + +
+

File List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-core/frames.html b/source/documentation/3.0/rspec-core/frames.html new file mode 100644 index 000000000..87a4a6df1 --- /dev/null +++ b/source/documentation/3.0/rspec-core/frames.html @@ -0,0 +1,26 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + diff --git a/source/documentation/3.0/rspec-core/index.html b/source/documentation/3.0/rspec-core/index.html new file mode 100644 index 000000000..6c0aaf6be --- /dev/null +++ b/source/documentation/3.0/rspec-core/index.html @@ -0,0 +1,315 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

rspec-core

+ +

rspec-core provides the structure for writing executable examples of how +your code should behave, and an rspec command with tools to +constrain which examples get run and tailor the output.

+ +

install

+ +
gem install rspec      # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-core # for rspec-core only
+rspec --help
+ +

basic structure

+ +

RSpec uses the words “describe” and “it” so we can express concepts like a +conversation:

+ +
"Describe an order."
+"It sums the prices of its line items."
+ +
RSpec.describe Order do
+  it "sums the prices of its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe method creates an ExampleGroup. +Within the block passed to describe you can declare examples +using the it method.

+ +

Under the hood, an example group is a class in which the block passed to +describe is evaluated. The blocks passed to it +are evaluated in the context of an instance of that class.

+ +

nested groups

+ +

You can also declare nested nested groups using the describe +or context methods:

+ +
RSpec.describe Order do
+  context "with no items" do
+    it "behaves one way" do
+      # ...
+    end
+  end
+
+  context "with one item" do
+    it "behaves another way" do
+      # ...
+    end
+  end
+end
+
+ +

aliases

+ +

You can declare example groups using either describe or +context. For a top level example group, describe +and context are available off of RSpec. For +backwards compatibility, they are also available off of the +main object and Module unless you disable monkey +patching.

+ +

You can declare examples within a group using any of it, +specify, or example.

+ +

shared examples and contexts

+ +

Declare a shared example group using shared_examples, and then +include it in any group using include_examples.

+ +
RSpec.shared_examples "collections" do |collection_class|
+  it "is empty when first created" do
+    expect(collection_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections", Array
+end
+
+RSpec.describe Hash do
+  include_examples "collections", Hash
+end
+
+ +

Nearly anything that can be declared within an example group can be +declared within a shared example group. This includes before, +after, and around hooks, let +declarations, and nested groups/contexts.

+ +

You can also use the names shared_context and +include_context. These are pretty much the same as +shared_examples and include_examples, providing +more accurate naming when you share hooks, let declarations, +helper methods, etc, but no examples.

+ +

metadata

+ +

rspec-core stores a metadata hash with every example and group, which +contains their descriptions, the locations at which they were declared, +etc, etc. This hash powers many of rspec-core's features, including +output formatters (which access descriptions and locations), and filtering +before and after hooks.

+ +

Although you probably won't ever need this unless you are writing an +extension, you can access it from an example like this:

+ +
it "does something" do
+  expect(example.[:description]).to eq("does something")
+end
+
+ +

described_class

+ +

When a class is passed to describe, you can access it from an +example using the described_class method, which is a wrapper +for example.metadata[:described_class].

+ +
RSpec.describe Widget do
+  example do
+    expect(described_class).to equal(Widget)
+  end
+end
+
+ +

This is useful in extensions or shared example groups in which the specific +class is unknown. Taking the collections shared example group from above, +we can clean it up a bit using described_class:

+ +
RSpec.shared_examples "collections" do
+  it "is empty when first created" do
+    expect(described_class.new).to be_empty
+  end
+end
+
+RSpec.describe Array do
+  include_examples "collections"
+end
+
+RSpec.describe Hash do
+  include_examples "collections"
+end
+
+ +

the rspec command

+ +

When you install the rspec-core gem, it installs the rspec +executable, which you'll use to run rspec. The rspec +command comes with many useful options. Run rspec --help to +see the complete list.

+ +

store command line options .rspec

+ +

You can store command line options in a .rspec file in the +project's root directory, and the rspec command will read +them as though you typed them on the command line.

+ +

autotest integration

+ +

rspec-core no longer ships with an Autotest extension, if you require +Autotest integration, please use the rspec-autotest gem and +see rspec/rspec-autotest for +details

+ +

get started

+ +

Start with a simple example of behavior you expect from your system. Do +this before you write any implementation code:

+ +
# in spec/calculator_spec.rb
+RSpec.describe Calculator do
+  describe '#add' do
+    it 'returns the sum of its arguments' do
+      expect(Calculator.new.add(1, 2)).to eq(3)
+    end
+  end
+end
+
+ +

Run this with the rspec command, and watch it fail:

+ +
$ rspec spec/calculator_spec.rb
+./spec/calculator_spec.rb:1: uninitialized constant Calculator
+ +

Implement the simplest solution:

+ +
# in lib/calculator.rb
+class Calculator
+  def add(a,b)
+    a + b
+  end
+end
+
+ +

Be sure to require the implementation file in the spec:

+ +
# in spec/calculator_spec.rb
+# - RSpec adds ./lib to the $LOAD_PATH
+require "calculator"
+
+ +

Now run the spec again, and watch it pass:

+ +
$ rspec spec/calculator_spec.rb
+.
+
+Finished in 0.000315 seconds
+1 example, 0 failures
+ +

Use the documentation formatter to see the resulting spec:

+ +
$ rspec spec/calculator_spec.rb --format doc
+Calculator
+  #add
+    returns the sum of its arguments
+
+Finished in 0.000379 seconds
+1 example, 0 failures
+ +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-core/method_list.html b/source/documentation/3.0/rspec-core/method_list.html new file mode 100644 index 000000000..6c84a3a17 --- /dev/null +++ b/source/documentation/3.0/rspec-core/method_list.html @@ -0,0 +1,1623 @@ + + + + + + + + + + + + + + + + + Method List + + + + +
+

Method List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-core/top-level-namespace.html b/source/documentation/3.0/rspec-core/top-level-namespace.html new file mode 100644 index 000000000..4fd9261d3 --- /dev/null +++ b/source/documentation/3.0/rspec-core/top-level-namespace.html @@ -0,0 +1,112 @@ + + + + + + Top Level Namespace + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Top Level Namespace + + + +

+ +
+ + + + + + + + +
+
+ +

Defined Under Namespace

+

+ + + Modules: RSpec + + + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/BasicObject.html b/source/documentation/3.0/rspec-expectations/BasicObject.html new file mode 100644 index 000000000..45bf316e7 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/BasicObject.html @@ -0,0 +1,392 @@ + + + + + + Class: BasicObject + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: BasicObject + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/expectations/syntax.rb
+ +
+
+ +

Overview

+
+

The legacy :should syntax adds the following methods directly to +BasicObject so that they are available off of any object. Note, however, +that this syntax does not always play nice with delegate/proxy objects. +We recommend you use the non-monkeypatching :expect syntax instead.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) should + + + + + +

+
+ +
+ Note: +

This is only available when you have enabled the :should syntax.

+
+
+ +

Passes if matcher returns true. Available on every Object.

+ + +
+
+
+ +
+

Examples:

+ + +
actual.should eq expected
+actual.should match /expression/
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + +
  • + +
  • + + message + + + (String) + + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/expectations/syntax.rb', line 109
+
+
+
+
+ +
+

+ + - (Boolean) should_not + + + + + +

+
+ +
+ Note: +

This is only available when you have enabled the :should syntax.

+
+
+ +

Passes if matcher returns false. Available on every Object.

+ + +
+
+
+ +
+

Examples:

+ + +
actual.should_not eq expected
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + +
  • + +
  • + + message + + + (String) + + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    false if the negative expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/expectations/syntax.rb', line 131
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec.html b/source/documentation/3.0/rspec-expectations/RSpec.html new file mode 100644 index 000000000..1c026c9cd --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec.html @@ -0,0 +1,128 @@ + + + + + + Module: RSpec + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/matchers.rb,
+ lib/rspec/matchers/dsl.rb,
lib/rspec/expectations.rb,
lib/rspec/matchers/pretty.rb,
lib/rspec/matchers/built_in.rb,
lib/rspec/matchers/composable.rb,
lib/rspec/expectations/syntax.rb,
lib/rspec/expectations/version.rb,
lib/rspec/expectations/handler.rb,
lib/rspec/matchers/built_in/be.rb,
lib/rspec/matchers/built_in/eq.rb,
lib/rspec/matchers/built_in/all.rb,
lib/rspec/matchers/built_in/has.rb,
lib/rspec/matchers/built_in/eql.rb,
lib/rspec/expectations/fail_with.rb,
lib/rspec/matchers/built_in/yield.rb,
lib/rspec/matchers/built_in/equal.rb,
lib/rspec/matchers/built_in/exist.rb,
lib/rspec/matchers/built_in/match.rb,
lib/rspec/matchers/built_in/cover.rb,
lib/rspec/matchers/aliased_matcher.rb,
lib/rspec/matchers/built_in/output.rb,
lib/rspec/matchers/built_in/change.rb,
lib/rspec/matchers/built_in/include.rb,
lib/rspec/matchers/built_in/satisfy.rb,
lib/rspec/matchers/matcher_delegator.rb,
lib/rspec/matchers/built_in/compound.rb,
lib/rspec/expectations/configuration.rb,
lib/rspec/matchers/built_in/operators.rb,
lib/rspec/matchers/built_in/be_within.rb,
lib/rspec/matchers/built_in/respond_to.rb,
lib/rspec/matchers/built_in/be_between.rb,
lib/rspec/matchers/built_in/be_kind_of.rb,
lib/rspec/matchers/built_in/raise_error.rb,
lib/rspec/matchers/built_in/throw_symbol.rb,
lib/rspec/matchers/built_in/base_matcher.rb,
lib/rspec/expectations/expectation_target.rb,
lib/rspec/matchers/generated_descriptions.rb,
lib/rspec/matchers/built_in/be_instance_of.rb,
lib/rspec/expectations/minitest_integration.rb,
lib/rspec/matchers/built_in/contain_exactly.rb,
lib/rspec/matchers/built_in/start_and_end_with.rb
+
+ +
+
+ +

Overview

+
+

RSpec's top level namespace. All of rspec-expectations is contained +in the RSpec::Expectations and RSpec::Matchers namespaces.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Expectations, Matchers + + + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Expectations.html b/source/documentation/3.0/rspec-expectations/RSpec/Expectations.html new file mode 100644 index 000000000..740e9db68 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Expectations.html @@ -0,0 +1,436 @@ + + + + + + Module: RSpec::Expectations + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Expectations + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/expectations.rb,
+ lib/rspec/expectations/syntax.rb,
lib/rspec/expectations/version.rb,
lib/rspec/expectations/handler.rb,
lib/rspec/expectations/fail_with.rb,
lib/rspec/expectations/configuration.rb,
lib/rspec/expectations/expectation_target.rb,
lib/rspec/expectations/minitest_integration.rb
+
+ +
+
+ +

Overview

+
+

RSpec::Expectations provides a simple, readable API to express +the expected outcomes in a code example. To express an expected +outcome, wrap an object or block in expect, call to or to_not +(aliased as not_to) and pass it a matcher object:

+ +
expect(order.total).to eq(Money.new(5.55, :USD))
+expect(list).to include(user)
+expect(message).not_to match(/foo/)
+expect { do_something }.to raise_error
+
+ +

The last form (the block form) is needed to match against ruby constructs +that are not objects, but can only be observed when executing a block +of code. This includes raising errors, throwing symbols, yielding, +and changing values.

+ +

When expect(...).to is invoked with a matcher, it turns around +and calls matcher.matches?(<object wrapped by expect>). For example, +in the expression:

+ +
expect(order.total).to eq(Money.new(5.55, :USD))
+
+ +

...eq(Money.new(5.55, :USD)) returns a matcher object, and it results +in the equivalent of eq.matches?(order.total). If matches? returns +true, the expectation is met and execution continues. If false, then +the spec fails with the message returned by eq.failure_message.

+ +

Given the expression:

+ +
expect(order.entries).not_to include(entry)
+
+ +

...the not_to method (also available as to_not) invokes the equivalent of +include.matches?(order.entries), but it interprets false as success, and +true as a failure, using the message generated by +include.failure_message_when_negated.

+ +

rspec-expectations ships with a standard set of useful matchers, and writing +your own matchers is quite simple.

+ +

See RSpec::Matchers for more information about the +built-in matchers that ship with rspec-expectations, and how to write your +own custom matchers.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Syntax + + + + Classes: Configuration, ExpectationTarget + + +

+ +

Constant Summary

+ +
+ +
ExpectationNotMetError = +
+
+ +
+ Note: +

We subclass Exception so that in a stub implementation if

+
+
+ +

Exception raised when an expectation fails.

+ +

the user sets an expectation, it can't be caught in their +code by a bare rescue.

+ + +
+
+
+ + +
+
+
::Minitest::Assertion
+ +
+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (RSpec::Expectations::Configuration) configuration + + + + + +

+
+

The configuration object.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+128
+129
+130
+
+
# File 'lib/rspec/expectations/configuration.rb', line 128
+
+def self.configuration
+  @configuration ||= Configuration.new
+end
+
+
+ +
+

+ + + (Object) fail_with(message, expected = nil, actual = nil) + + + + + +

+
+

Raises an RSpec::Expectations::ExpectationNotMetError with message. +Adds a diff to the failure message when expected and actual are +both present.

+ + +
+
+
+

Parameters:

+
    + +
  • + + message + + + (String) + + + +
  • + +
  • + + expected + + + (Object) + + + (defaults to: nil) + + +
  • + +
  • + + actual + + + (Object) + + + (defaults to: nil) + + +
  • + +
+ +

Raises:

+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/rspec/expectations/fail_with.rb', line 21
+
+def fail_with(message, expected=nil, actual=nil)
+  unless message
+    raise ArgumentError, "Failure message is nil. Does your matcher define the " \
+                         "appropriate failure_message[_when_negated] method to return a string?"
+  end
+
+  diff = differ.diff(actual, expected)
+  message = "#{message}\nDiff:#{diff}" unless diff.empty?
+
+  raise RSpec::Expectations::ExpectationNotMetError, message
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Expectations/Configuration.html b/source/documentation/3.0/rspec-expectations/RSpec/Expectations/Configuration.html new file mode 100644 index 000000000..ed1f5f0bc --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Expectations/Configuration.html @@ -0,0 +1,732 @@ + + + + + + Class: RSpec::Expectations::Configuration + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Expectations::Configuration + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/expectations/configuration.rb
+ +
+
+ +

Overview

+
+

Provides configuration options for rspec-expectations. +If you are using rspec-core, you can access this via a +block passed to RSpec::Core::Configuration#expect_with. +Otherwise, you can access it via RSpec::Expectations.configuration.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |rspec|
+  rspec.expect_with :rspec do |c|
+    # c is the config object
+  end
+end
+
+# or
+
+RSpec::Expectations.configuration
+ +
+ + +
+

Constant Summary

+ +
+ +
NullBacktraceFormatter = +
+
+

+ This constant is part of a private API. + You should avoid using this constant if possible, as it may be removed or be changed in the future. +

+

Null implementation of a backtrace formatter used by default +when rspec-core is not loaded. Does no filtering.

+ + +
+
+
+ + +
+
+
Module.new do
+  def self.format_backtrace(backtrace)
+    backtrace
+  end
+end
+ +
+ + + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Object) backtrace_formatter + + + + + + + + + + + + + + + + +

    Sets or gets the backtrace formatter.

    +
    + +
  • + + +
  • + + + - (Object) color + + + + + + + + + + writeonly + + + + + + + + +

    Indicates whether or not diffs should be colored.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) backtrace_formatter + + + + + +

+
+

Sets or gets the backtrace formatter. The backtrace formatter should +implement #format_backtrace(Array<String>). This is used +to format backtraces of errors handled by the raise_error +matcher.

+ +

If you are using rspec-core, rspec-core's backtrace formatting +will be used (including respecting the presence or absence of +the --backtrace option).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+101
+
+
# File 'lib/rspec/expectations/configuration.rb', line 101
+
+attr_writer :backtrace_formatter
+
+
+ + + +
+

+ + - (Object) color=(value) (writeonly) + + + + + +

+
+

Indicates whether or not diffs should be colored. +Delegates to rspec-core's color option if rspec-core +is loaded; otherwise you can set it here.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+68
+69
+70
+
+
# File 'lib/rspec/expectations/configuration.rb', line 68
+
+def color=(value)
+  @color = value
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) add_should_and_should_not_to(*modules) + + + + + +

+
+

Adds should and should_not to the given classes +or modules. This can be used to ensure should works +properly on things like proxy objects (particular +Delegator-subclassed objects on 1.8).

+ + +
+
+
+

Parameters:

+
    + +
  • + + modules + + + (Array<Module>) + + + + — +

    the list of classes or modules +to add should and should_not to.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+85
+86
+87
+88
+89
+
+
# File 'lib/rspec/expectations/configuration.rb', line 85
+
+def add_should_and_should_not_to(*modules)
+  modules.each do |mod|
+    Expectations::Syntax.enable_should(mod)
+  end
+end
+
+
+ +
+

+ + - (Boolean) color? + + + + + +

+
+

Indicates whether or not diffs should be colored. +Delegates to rspec-core's color option if rspec-core +is loaded; otherwise you can set it here.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+73
+74
+75
+
+
# File 'lib/rspec/expectations/configuration.rb', line 73
+
+def color?
+  ::RSpec.configuration.color_enabled?
+end
+
+
+ +
+

+ + - (Array<Symbol>) syntax + + + + + +

+
+

The list of configured syntaxes.

+ + +
+
+
+ +
+

Examples:

+ + +
unless RSpec::Matchers.configuration.syntax.include?(:expect)
+  raise "this RSpec extension gem requires the rspec-expectations `:expect` syntax"
+end
+ +
+ +

Returns:

+
    + +
  • + + + (Array<Symbol>) + + + + — +

    the list of configured syntaxes.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+53
+54
+55
+56
+57
+58
+
+
# File 'lib/rspec/expectations/configuration.rb', line 53
+
+def syntax
+  syntaxes = []
+  syntaxes << :should if Expectations::Syntax.should_enabled?
+  syntaxes << :expect if Expectations::Syntax.expect_enabled?
+  syntaxes
+end
+
+
+ +
+

+ + - (Object) syntax=(values) + + + + + +

+
+

Configures the supported syntax.

+ + +
+
+
+ +
+

Examples:

+ + +
RSpec.configure do |rspec|
+  rspec.expect_with :rspec do |c|
+    c.syntax = :should
+    # or
+    c.syntax = :expect
+    # or
+    c.syntax = [:should, :expect]
+  end
+end
+ +
+

Parameters:

+
    + +
  • + + values + + + (Array<Symbol>, Symbol) + + + + — +

    the syntaxes to enable

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lib/rspec/expectations/configuration.rb', line 33
+
+def syntax=(values)
+  if Array(values).include?(:expect)
+    Expectations::Syntax.enable_expect
+  else
+    Expectations::Syntax.disable_expect
+  end
+
+  if Array(values).include?(:should)
+    Expectations::Syntax.enable_should
+  else
+    Expectations::Syntax.disable_should
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Expectations/ExpectationTarget.html b/source/documentation/3.0/rspec-expectations/RSpec/Expectations/ExpectationTarget.html new file mode 100644 index 000000000..fc4a5f039 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Expectations/ExpectationTarget.html @@ -0,0 +1,515 @@ + + + + + + Class: RSpec::Expectations::ExpectationTarget + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Expectations::ExpectationTarget + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/expectations/expectation_target.rb
+ +
+
+ +

Overview

+
+ +
+ Note: +

ExpectationTarget is not intended to be instantiated +directly by users. Use expect instead.

+
+
+ +

Wraps the target of an expectation.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(something)       # => ExpectationTarget wrapping something
+expect { do_something } # => ExpectationTarget wrapping the block
+
+# used with `to`
+expect(actual).to eq(3)
+
+# with `not_to`
+expect(actual).not_to eq(3)
+ +
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (ExpectationTarget) initialize(value) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ExpectationTarget

+ + +
+
+
+ + +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lib/rspec/expectations/expectation_target.rb', line 25
+
+def initialize(value)
+  @target = value
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) not_to(matcher = nil, message = nil, &block) + + + + Also known as: + to_not + + + + +

+
+

Runs the given expectation, passing if matcher returns false.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(value).not_to eq(5)
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + (defaults to: nil) + + +
  • + +
  • + + message + + + (String or Proc) + + + (defaults to: nil) + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    false if the negative expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+65
+66
+67
+68
+
+
# File 'lib/rspec/expectations/expectation_target.rb', line 65
+
+def not_to(matcher=nil, message=nil, &block)
+  prevent_operator_matchers(:not_to) unless matcher
+  RSpec::Expectations::NegativeExpectationHandler.handle_matcher(@target, matcher, message, &block)
+end
+
+
+ +
+

+ + - (Boolean) to(matcher = nil, message = nil, &block) + + + + + +

+
+

Runs the given expectation, passing if matcher returns true.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(value).to eq(5)
+expect { perform }.to raise_error
+ +
+

Parameters:

+
    + +
  • + + matcher + + + (Matcher) + + + (defaults to: nil) + + +
  • + +
  • + + message + + + (String or Proc) + + + (defaults to: nil) + + + — +

    optional message to display when the expectation fails

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the expectation succeeds (else raises)

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+52
+53
+54
+55
+
+
# File 'lib/rspec/expectations/expectation_target.rb', line 52
+
+def to(matcher=nil, message=nil, &block)
+  prevent_operator_matchers(:to) unless matcher
+  RSpec::Expectations::PositiveExpectationHandler.handle_matcher(@target, matcher, message, &block)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Expectations/Syntax.html b/source/documentation/3.0/rspec-expectations/RSpec/Expectations/Syntax.html new file mode 100644 index 000000000..a94926af3 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Expectations/Syntax.html @@ -0,0 +1,838 @@ + + + + + + Module: RSpec::Expectations::Syntax + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Expectations::Syntax + + + Private +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/expectations/syntax.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+

Provides methods for enabling and disabling the available +syntaxes provided by rspec-expectations.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) default_should_host + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Determines where we add should and should_not.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lib/rspec/expectations/syntax.rb', line 11
+
+def default_should_host
+  @default_should_host ||= ::Object.ancestors.last
+end
+
+
+ +
+

+ + + (Object) disable_expect(syntax_host = ::RSpec::Matchers) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Disables the expect syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+80
+81
+82
+83
+84
+85
+86
+
+
# File 'lib/rspec/expectations/syntax.rb', line 80
+
+def disable_expect(syntax_host=::RSpec::Matchers)
+  return unless expect_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    undef expect
+  end
+end
+
+
+ +
+

+ + + (Object) disable_should(syntax_host = default_should_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Disables the should syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+62
+63
+64
+
+
# File 'lib/rspec/expectations/syntax.rb', line 57
+
+def disable_should(syntax_host=default_should_host)
+  return unless should_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    undef should
+    undef should_not
+  end
+end
+
+
+ +
+

+ + + (Object) enable_expect(syntax_host = ::RSpec::Matchers) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Enables the expect syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+74
+75
+76
+
+
# File 'lib/rspec/expectations/syntax.rb', line 68
+
+def enable_expect(syntax_host=::RSpec::Matchers)
+  return if expect_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    def expect(value=::RSpec::Expectations::ExpectationTarget::UndefinedValue, &block)
+      ::RSpec::Expectations::ExpectationTarget.for(value, block)
+    end
+  end
+end
+
+
+ +
+

+ + + (Object) enable_should(syntax_host = default_should_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Enables the should syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/rspec/expectations/syntax.rb', line 38
+
+def enable_should(syntax_host=default_should_host)
+  @warn_about_should = false if syntax_host == default_should_host
+  return if should_enabled?(syntax_host)
+
+  syntax_host.module_exec do
+    def should(matcher=nil, message=nil, &block)
+      ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__)
+      ::RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
+    end
+
+    def should_not(matcher=nil, message=nil, &block)
+      ::RSpec::Expectations::Syntax.warn_about_should_unless_configured(__method__)
+      ::RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
+    end
+  end
+end
+
+
+ +
+

+ + + (Boolean) expect_enabled?(syntax_host = ::RSpec::Matchers) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates whether or not the expect syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+96
+97
+98
+
+
# File 'lib/rspec/expectations/syntax.rb', line 96
+
+def expect_enabled?(syntax_host=::RSpec::Matchers)
+  syntax_host.method_defined?(:expect)
+end
+
+
+ +
+

+ + + (Boolean) should_enabled?(syntax_host = default_should_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates whether or not the should syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+90
+91
+92
+
+
# File 'lib/rspec/expectations/syntax.rb', line 90
+
+def should_enabled?(syntax_host=default_should_host)
+  syntax_host.method_defined?(:should)
+end
+
+
+ +
+

+ + + (Object) warn_about_should! + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Instructs rspec-expectations to warn on first usage of should or should_not. +Enabled by default. This is largely here to facilitate testing.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lib/rspec/expectations/syntax.rb', line 18
+
+def warn_about_should!
+  @warn_about_should = true
+end
+
+
+ +
+

+ + + (Object) warn_about_should_unless_configured(method_name) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Generates a deprecation warning for the given method if no warning +has already been issued.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+
+
# File 'lib/rspec/expectations/syntax.rb', line 25
+
+def warn_about_should_unless_configured(method_name)
+  return unless @warn_about_should
+
+  RSpec.deprecate(
+    "Using `#{method_name}` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax",
+    :replacement => "the new `:expect` syntax or explicitly enable `:should`"
+  )
+
+  @warn_about_should = false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers.html new file mode 100644 index 000000000..cdfe47fbe --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers.html @@ -0,0 +1,3655 @@ + + + + + + Module: RSpec::Matchers + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers + + + +

+ +
+ + + + + + + +
Included in:
+
DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers.rb,
+ lib/rspec/matchers/dsl.rb,
lib/rspec/matchers/pretty.rb,
lib/rspec/matchers/built_in.rb,
lib/rspec/matchers/composable.rb,
lib/rspec/matchers/built_in/be.rb,
lib/rspec/matchers/built_in/eq.rb,
lib/rspec/matchers/built_in/all.rb,
lib/rspec/matchers/built_in/has.rb,
lib/rspec/matchers/built_in/eql.rb,
lib/rspec/matchers/built_in/yield.rb,
lib/rspec/matchers/built_in/equal.rb,
lib/rspec/matchers/built_in/exist.rb,
lib/rspec/matchers/built_in/match.rb,
lib/rspec/matchers/built_in/cover.rb,
lib/rspec/matchers/aliased_matcher.rb,
lib/rspec/matchers/built_in/output.rb,
lib/rspec/matchers/built_in/change.rb,
lib/rspec/matchers/built_in/include.rb,
lib/rspec/matchers/built_in/satisfy.rb,
lib/rspec/matchers/matcher_delegator.rb,
lib/rspec/matchers/built_in/compound.rb,
lib/rspec/matchers/built_in/operators.rb,
lib/rspec/matchers/built_in/be_within.rb,
lib/rspec/matchers/built_in/respond_to.rb,
lib/rspec/matchers/built_in/be_between.rb,
lib/rspec/matchers/built_in/be_kind_of.rb,
lib/rspec/matchers/built_in/raise_error.rb,
lib/rspec/matchers/built_in/throw_symbol.rb,
lib/rspec/matchers/built_in/base_matcher.rb,
lib/rspec/matchers/generated_descriptions.rb,
lib/rspec/matchers/built_in/be_instance_of.rb,
lib/rspec/matchers/built_in/contain_exactly.rb,
lib/rspec/matchers/built_in/start_and_end_with.rb
+
+ +
+
+ +

Overview

+
+

RSpec::Matchers provides a number of useful matchers we use to define +expectations. A matcher is any object that responds to the following:

+ +
matches?(actual)
+failure_message
+
+ +

These methods are also part of the matcher protocol, but are optional:

+ +
does_not_match?(actual)
+failure_message_when_negated
+description
+supports_block_expectations?
+
+ +

Predicates

+ +

In addition to matchers that are defined explicitly, RSpec will create +custom matchers on the fly for any arbitrary predicate, giving your specs a +much more natural language feel.

+ +

A Ruby predicate is a method that ends with a "?" and returns true or false. +Common examples are empty?, nil?, and instance_of?.

+ +

All you need to do is write expect(..).to be_ followed by the predicate +without the question mark, and RSpec will figure it out from there. +For example:

+ +
expect([]).to be_empty     # => [].empty?() | passes
+expect([]).not_to be_empty # => [].empty?() | fails
+
+ +

In addtion to prefixing the predicate matchers with "be", you can also use "be_a" +and "bean", making your specs read much more naturally:

+ +
expect("a string").to be_an_instance_of(String) # =>"a string".instance_of?(String) # passes
+
+expect(3).to be_a_kind_of(Fixnum)        # => 3.kind_of?(Numeric)     | passes
+expect(3).to be_a_kind_of(Numeric)       # => 3.kind_of?(Numeric)     | passes
+expect(3).to be_an_instance_of(Fixnum)   # => 3.instance_of?(Fixnum)  | passes
+expect(3).not_to be_an_instance_of(Numeric) # => 3.instance_of?(Numeric) | fails
+
+ +

RSpec will also create custom matchers for predicates like has_key?. To +use this feature, just state that the object should have_key(:key) and RSpec will +call has_key?(:key) on the target. For example:

+ +
expect(:a => "A").to have_key(:a)
+expect(:a => "A").to have_key(:b) # fails
+
+ +

You can use this feature to invoke any predicate that begins with "has_", whether it is +part of the Ruby libraries (like Hash#has_key?) or a method you wrote on your own class.

+ +

Note that RSpec does not provide composable aliases for these dynamic predicate +matchers. You can easily define your own aliases, though:

+ +
RSpec::Matchers.alias_matcher :a_user_who_is_an_admin, :be_an_admin
+expect(user_list).to include(a_user_who_is_an_admin)
+
+ +

Custom Matchers

+ +

When you find that none of the stock matchers provide a natural feeling +expectation, you can very easily write your own using RSpec's matcher DSL +or writing one from scratch.

+ +

Matcher DSL

+ +

Imagine that you are writing a game in which players can be in various +zones on a virtual board. To specify that bob should be in zone 4, you +could say:

+ +
expect(bob.current_zone).to eql(Zone.new("4"))
+
+ +

But you might find it more expressive to say:

+ +
expect(bob).to be_in_zone("4")
+
+ +

and/or

+ +
expect(bob).not_to be_in_zone("3")
+
+ +

You can create such a matcher like so:

+ +
RSpec::Matchers.define :be_in_zone do |zone|
+  match do |player|
+    player.in_zone?(zone)
+  end
+end
+
+ +

This will generate a be_in_zone method that returns a matcher +with logical default messages for failures. You can override the failure +messages and the generated description as follows:

+ +
RSpec::Matchers.define :be_in_zone do |zone|
+  match do |player|
+    player.in_zone?(zone)
+  end
+
+  failure_message do |player|
+    # generate and return the appropriate string.
+  end
+
+  failure_message_when_negated do |player|
+    # generate and return the appropriate string.
+  end
+
+  description do
+    # generate and return the appropriate string.
+  end
+end
+
+ +

Each of the message-generation methods has access to the block arguments +passed to the create method (in this case, zone). The +failure message methods (failure_message and +failure_message_when_negated) are passed the actual value (the +receiver of expect(..) or expect(..).not_to).

+ +

Custom Matcher from scratch

+ +

You could also write a custom matcher from scratch, as follows:

+ +
class BeInZone
+  def initialize(expected)
+    @expected = expected
+  end
+
+  def matches?(target)
+    @target = target
+    @target.current_zone.eql?(Zone.new(@expected))
+  end
+
+  def failure_message
+    "expected #{@target.inspect} to be in Zone #{@expected}"
+  end
+
+  def failure_message_when_negated
+    "expected #{@target.inspect} not to be in Zone #{@expected}"
+  end
+end
+
+ +

... and a method like this:

+ +
def be_in_zone(expected)
+  BeInZone.new(expected)
+end
+
+ +

And then expose the method to your specs. This is normally done +by including the method and the class in a module, which is then +included in your spec:

+ +
module CustomGameMatchers
+  class BeInZone
+    # ...
+  end
+
+  def be_in_zone(expected)
+    # ...
+  end
+end
+
+describe "Player behaviour" do
+  include CustomGameMatchers
+  # ...
+end
+
+ +

or you can include in globally in a spec_helper.rb file required +from your spec file(s):

+ +
RSpec::configure do |config|
+  config.include(CustomGameMatchers)
+end
+
+ +

Making custom matchers composable

+ +

RSpec's built-in matchers are designed to be composed, in expressions like:

+ +
expect(["barn", 2.45]).to contain_exactly(
+  a_value_within(0.1).of(2.5),
+  a_string_starting_with("bar")
+)
+
+ +

Custom matchers can easily participate in composed matcher expressions like these. +Include Composable in your custom matcher to make it support +being composed (matchers defined using the DSL have this included automatically). +Within your matcher's matches? method (or the match block, if using the DSL), +use values_match?(expected, actual) rather than expected == actual. +Under the covers, values_match? is able to match arbitrary +nested data structures containing a mix of both matchers and non-matcher objects. +It uses === and == to perform the matching, considering the values to +match if either returns true. The Composable mixin also provides some helper +methods for surfacing the matcher descriptions within your matcher's description +or failure messages.

+ +

RSpec's built-in matchers each have a number of aliases that rephrase the matcher +from a verb phrase (such as be_within) to a noun phrase (such as a_value_within), +which reads better when the matcher is passed as an argument in a composed matcher +expressions, and also uses the noun-phrase wording in the matcher's description, +for readable failure messages. You can alias your custom matchers in similar fashion +using Matchers.alias_matcher.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: BuiltIn, Composable, DSL, Pretty + + + + Classes: AliasedMatcher + + +

+ +

Constant Summary

+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (Object) all(expected) + + + + + + + + + + + + + +

    Passes if actual all expected objects pass.

    +
    + +
  • + + +
  • + + + - (Object) be(*args) + + + + (also: #a_value) + + + + + + + + + + + +

    Given true, false, or nil, will pass if actual value is true, false or nil (respectively).

    +
    + +
  • + + +
  • + + + - (Object) be_a(klass) + + + + (also: #be_an) + + + + + + + + + + + +

    passes if target.kind_of?(klass).

    +
    + +
  • + + +
  • + + + - (Object) be_a_kind_of(expected) + + + + (also: #be_kind_of, #a_kind_of) + + + + + + + + + + + +

    Passes if actual.kind_of?(expected).

    +
    + +
  • + + +
  • + + + - (Object) be_an_instance_of(expected) + + + + (also: #be_instance_of, #an_instance_of) + + + + + + + + + + + +

    Passes if actual.instance_of?(expected).

    +
    + +
  • + + +
  • + + + - (Object) be_between(min, max) + + + + (also: #a_value_between) + + + + + + + + + + + +

    Passes if actual.between?(min, max).

    +
    + +
  • + + +
  • + + + - (Object) be_falsey + + + + (also: #be_falsy, #a_falsey_value, #a_falsy_value) + + + + + + + + + + + +

    Passes if actual is falsey (false or nil).

    +
    + +
  • + + +
  • + + + - (Object) be_nil + + + + (also: #a_nil_value) + + + + + + + + + + + +

    Passes if actual is nil.

    +
    + +
  • + + +
  • + + + - (Object) be_truthy + + + + (also: #a_truthy_value) + + + + + + + + + + + +

    Passes if actual is truthy (anything but false or nil).

    +
    + +
  • + + +
  • + + + - (Object) be_within(delta) + + + + (also: #a_value_within, #within) + + + + + + + + + + + +

    Passes if actual == expected +/- delta.

    +
    + +
  • + + +
  • + + + - (Object) change(receiver = nil, message = nil, &block) + + + + (also: #a_block_changing, #changing) + + + + + + + + + + + +

    Applied to a proc, specifies that its execution will cause some value to change.

    +
    + +
  • + + +
  • + + + - (Object) contain_exactly(*items) + + + + (also: #a_collection_containing_exactly, #containing_exactly) + + + + + + + + + + + +

    Passes if actual contains all of the expected regardless of order.

    +
    + +
  • + + +
  • + + + - (Object) cover(*values) + + + + (also: #a_range_covering, #covering) + + + + + + + + + + + +

    Passes if actual covers expected.

    +
    + +
  • + + +
  • + + + - (Object) end_with(*expected) + + + + (also: #a_collection_ending_with, #a_string_ending_with, #ending_with) + + + + + + + + + + + +

    Matches if the actual value ends with the expected value(s).

    +
    + +
  • + + +
  • + + + - (Object) eq(expected) + + + + (also: #an_object_eq_to, #eq_to) + + + + + + + + + + + +

    Passes if actual == expected.

    +
    + +
  • + + +
  • + + + - (Object) eql(expected) + + + + (also: #an_object_eql_to, #eql_to) + + + + + + + + + + + +

    Passes if actual.eql?(expected).

    +
    + +
  • + + +
  • + + + - (Object) equal(expected) + + + + (also: #an_object_equal_to, #equal_to) + + + + + + + + + + + +

    Passes if actual.equal?(expected) (object identity).

    +
    + +
  • + + +
  • + + + - (Object) exist(*args) + + + + (also: #an_object_existing, #existing) + + + + + + + + + + + +

    Passes if actual.exist? or actual.exists?.

    +
    + +
  • + + +
  • + + + - (ExpectationTarget) expect + + + + + + + + + + + + + +

    Supports expect(actual).to matcher syntax by wrapping actual in an ExpectationTarget.

    +
    + +
  • + + +
  • + + + - (Object) include(*expected) + + + + (also: #a_collection_including, #a_string_including, #a_hash_including, #including) + + + + + + + + + + + +

    Passes if actual includes expected.

    +
    + +
  • + + +
  • + + + - (Object) match(expected) + + + + (also: #match_regex, #an_object_matching, #a_string_matching, #matching) + + + + + + + + + + + +

    Given a Regexp or String, passes if actual.match(pattern) Given an arbitrary nested data structure (e.g. arrays and hashes), matches if expected === actual || actual == expected for each pair of elements.

    +
    + +
  • + + +
  • + + + - (Object) match_array(items) + + + + + + + + + + + + + +

    An alternate form of contain_exactly that accepts the expected contents as a single array arg rather that splatted out as individual items.

    +
    + +
  • + + +
  • + + + - (Object) output(expected = nil) + + + + (also: #a_block_outputting) + + + + + + + + + + + +

    With no arg, passes if the block outputs to_stdout or to_stderr.

    +
    + +
  • + + +
  • + + + - (Object) raise_error(error = Exception, message = nil, &block) + + + + (also: #raise_exception, #a_block_raising, #raising) + + + + + + + + + + + +

    With no args, matches if any error is raised.

    +
    + +
  • + + +
  • + + + - (Object) respond_to(*names) + + + + (also: #an_object_responding_to, #responding_to) + + + + + + + + + + + +

    Matches if the target object responds to all of the names provided.

    +
    + +
  • + + +
  • + + + - (Object) satisfy(&block) + + + + (also: #an_object_satisfying, #satisfying) + + + + + + + + + + + +

    Passes if the submitted block returns true.

    +
    + +
  • + + +
  • + + + - (Object) start_with(*expected) + + + + (also: #a_collection_starting_with, #a_string_starting_with, #starting_with) + + + + + + + + + + + +

    Matches if the actual value starts with the expected value(s).

    +
    + +
  • + + +
  • + + + - (Object) throw_symbol(expected_symbol = nil, expected_arg = nil) + + + + (also: #a_block_throwing, #throwing) + + + + + + + + + + + +

    Given no argument, matches if a proc throws any Symbol.

    +
    + +
  • + + +
  • + + + - (Object) yield_control + + + + (also: #a_block_yielding_control, #yielding_control) + + + + + + + + + + + +

    Passes if the method called in the expect block yields, regardless of whether or not arguments are yielded.

    +
    + +
  • + + +
  • + + + - (Object) yield_successive_args(*args) + + + + (also: #a_block_yielding_successive_args, #yielding_successive_args) + + + + + + + + + + + +

    Designed for use with methods that repeatedly yield (such as iterators).

    +
    + +
  • + + +
  • + + + - (Object) yield_with_args(*args) + + + + (also: #a_block_yielding_with_args, #yielding_with_args) + + + + + + + + + + + +

    Given no arguments, matches if the method called in the expect block yields with arguments (regardless of what they are or how many there are).

    +
    + +
  • + + +
  • + + + - (Object) yield_with_no_args + + + + (also: #a_block_yielding_with_no_args, #yielding_with_no_args) + + + + + + + + + + + +

    Passes if the method called in the expect block yields with no arguments.

    +
    + +
  • + + +
+ + +
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing(method, *args, &block) (private) + + + + + +

+ + + + +
+
+
+
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+
+
# File 'lib/rspec/matchers.rb', line 895
+
+def method_missing(method, *args, &block)
+  case method.to_s
+  when BE_PREDICATE_REGEX
+    BuiltIn::BePredicate.new(method, *args, &block)
+  when HAS_REGEX
+    BuiltIn::Has.new(method, *args, &block)
+  else
+    super
+  end
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (Object) alias_matcher(new_name, old_name) {|String| ... } + + + + + +

+
+

Defines a matcher alias. The returned matcher's description will be overriden +to reflect the phrasing of the new name, which will be used in failure messages +when passed as an argument to another matcher in a composed matcher expression.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.alias_matcher :a_list_that_sums_to, :sum_to
+sum_to(3).description # => "sum to 3"
+a_list_that_sums_to(3).description # => "a list that sums to 3"
+ + +

+RSpec::Matchers.alias_matcher :a_list_sorted_by, :be_sorted_by do |description|
+  description.sub("be sorted by", "a list sorted by")
+end
+
+be_sorted_by(:age).description # => "be sorted by age"
+a_list_sorted_by(:age).description # => "a list sorted by age"
+ +
+

Parameters:

+
    + +
  • + + new_name + + + (Symbol) + + + + — +

    the new name for the matcher

    +
    + +
  • + +
  • + + old_name + + + (Symbol) + + + + — +

    the original name for the matcher

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + (String) + + + + — +

    optional block that, when given is used to define the overriden +description. The yielded arg is the original description. If no block is +provided, a default description override is used based on the old and +new names.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+
+
# File 'lib/rspec/matchers.rb', line 252
+
+def self.alias_matcher(new_name, old_name, &description_override)
+  description_override ||= lambda do |old_desc|
+    old_desc.gsub(Pretty.split_words(old_name), Pretty.split_words(new_name))
+  end
+
+  define_method(new_name) do |*args, &block|
+    matcher = __send__(old_name, *args, &block)
+    AliasedMatcher.new(matcher, description_override)
+  end
+end
+
+
+ +
+

+ + + (Object) clear_generated_description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Used by rspec-core to clear the state used to generate +descriptions after an example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/generated_descriptions.rb', line 11
+
+def self.clear_generated_description
+  self.last_matcher = nil
+  self.last_expectation_handler = nil
+end
+
+
+ +
+

+ + + (RSpec::Expectations::Configuration) configuration + + + + + +

+
+

Delegates to Expectations.configuration. +This is here because rspec-core's expect_with option +looks for a configuration method on the mixin +(RSpec::Matchers) to yield to a block.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+886
+887
+888
+
+
# File 'lib/rspec/matchers.rb', line 886
+
+def self.configuration
+  Expectations.configuration
+end
+
+
+ +
+

+ + + (Object) generated_description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Generates an an example description based on the last expectation. +Used by rspec-core's one-liner syntax.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+19
+20
+21
+22
+
+
# File 'lib/rspec/matchers/generated_descriptions.rb', line 19
+
+def self.generated_description
+  return nil if last_expectation_handler.nil?
+  "#{last_expectation_handler.verb} #{last_description}"
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Object) all(expected) + + + + + +

+
+ +
+ Note: +

The negative form not_to all is not supported. Instead +use not_to include or pass a negative form of a matcher +as the argument (e.g. all exclude(:foo)).

+
+
+ +
+ Note: +

You can also use this with compound matchers as well.

+
+
+ +

Passes if actual all expected objects pass. This works for +any enumerable object.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect([1, 3, 5]).to all be_odd
+expect([1, 3, 6]).to all be_odd # fails
+ + +
expect([1, 3, 5]).to all( be_odd.and be_an(Integer) )
+ +
+ + +
+ + + + +
+
+
+
+599
+600
+601
+
+
# File 'lib/rspec/matchers.rb', line 599
+
+def all(expected)
+  BuiltIn::All.new(expected)
+end
+
+
+ +
+

+ + - (Object) be(*args) + + + + Also known as: + a_value + + + + +

+
+

Given true, false, or nil, will pass if actual value is true, false or +nil (respectively). Given no args means the caller should satisfy an if +condition (to be or not to be).

+ +

Predicates are any Ruby method that ends in a "?" and returns true or +false. Given be_ followed by arbitrary_predicate (without the "?"), +RSpec will match convert that into a query against the target object.

+ +

The arbitrarypredicate feature will handle any predicate prefixed with +"be_an" (e.g. bean_instance_of), "be_a" (e.g. bea_kind_of) or "be" +(e.g. be_empty), letting you choose the prefix that best suits the +predicate.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(actual).to     be_truthy
+expect(actual).to     be_falsey
+expect(actual).to     be_nil
+expect(actual).to     be_[arbitrary_predicate](*args)
+expect(actual).not_to be_nil
+expect(actual).not_to be_[arbitrary_predicate](*args)
+ +
+ + +
+ + + + +
+
+
+
+303
+304
+305
+
+
# File 'lib/rspec/matchers.rb', line 303
+
+def be(*args)
+  args.empty? ? Matchers::BuiltIn::Be.new : equal(*args)
+end
+
+
+ +
+

+ + - (Object) be_a(klass) + + + + Also known as: + be_an + + + + +

+
+

passes if target.kind_of?(klass)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+309
+310
+311
+
+
# File 'lib/rspec/matchers.rb', line 309
+
+def be_a(klass)
+  be_a_kind_of(klass)
+end
+
+
+ +
+

+ + - (Object) be_a_kind_of(expected) + + + + Also known as: + be_kind_of, a_kind_of + + + + +

+
+

Passes if actual.kind_of?(expected)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     be_a_kind_of(Fixnum)
+expect(5).to     be_a_kind_of(Numeric)
+expect(5).not_to be_a_kind_of(Float)
+ +
+ + +
+ + + + +
+
+
+
+334
+335
+336
+
+
# File 'lib/rspec/matchers.rb', line 334
+
+def be_a_kind_of(expected)
+  BuiltIn::BeAKindOf.new(expected)
+end
+
+
+ +
+

+ + - (Object) be_an_instance_of(expected) + + + + Also known as: + be_instance_of, an_instance_of + + + + +

+
+

Passes if actual.instance_of?(expected)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     be_an_instance_of(Fixnum)
+expect(5).not_to be_an_instance_of(Numeric)
+expect(5).not_to be_an_instance_of(Float)
+ +
+ + +
+ + + + +
+
+
+
+321
+322
+323
+
+
# File 'lib/rspec/matchers.rb', line 321
+
+def be_an_instance_of(expected)
+  BuiltIn::BeAnInstanceOf.new(expected)
+end
+
+
+ +
+

+ + - (Object) be_between(min, max) + + + + Also known as: + a_value_between + + + + +

+
+

Passes if actual.between?(min, max). Works with any Comparable object, +including String, Symbol, Time, or Numeric (Fixnum, Bignum, Integer, +Float, Complex, and Rational).

+ +

By default, be_between is inclusive (i.e. passes when given either the max or min value), +but you can make it exclusive by chaining that off the matcher.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to      be_between(1, 10)
+expect(11).not_to be_between(1, 10)
+expect(10).not_to be_between(1, 10).exclusive
+ +
+ + +
+ + + + +
+
+
+
+352
+353
+354
+
+
# File 'lib/rspec/matchers.rb', line 352
+
+def be_between(min, max)
+  BuiltIn::BeBetween.new(min, max)
+end
+
+
+ +
+

+ + - (Object) be_falsey + + + + Also known as: + be_falsy, a_falsey_value, a_falsy_value + + + + +

+
+

Passes if actual is falsey (false or nil)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+270
+271
+272
+
+
# File 'lib/rspec/matchers.rb', line 270
+
+def be_falsey
+  BuiltIn::BeFalsey.new
+end
+
+
+ +
+

+ + - (Object) be_nil + + + + Also known as: + a_nil_value + + + + +

+
+

Passes if actual is nil

+ + +
+
+
+ + +
+ + + + +
+
+
+
+278
+279
+280
+
+
# File 'lib/rspec/matchers.rb', line 278
+
+def be_nil
+  BuiltIn::BeNil.new
+end
+
+
+ +
+

+ + - (Object) be_truthy + + + + Also known as: + a_truthy_value + + + + +

+
+

Passes if actual is truthy (anything but false or nil)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+264
+265
+266
+
+
# File 'lib/rspec/matchers.rb', line 264
+
+def be_truthy
+  BuiltIn::BeTruthy.new
+end
+
+
+ +
+

+ + - (Object) be_within(delta) + + + + Also known as: + a_value_within, within + + + + +

+
+

Passes if actual == expected +/- delta

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(result).to     be_within(0.5).of(3.0)
+expect(result).not_to be_within(0.5).of(3.0)
+ +
+ + +
+ + + + +
+
+
+
+363
+364
+365
+
+
# File 'lib/rspec/matchers.rb', line 363
+
+def be_within(delta)
+  BuiltIn::BeWithin.new(delta)
+end
+
+
+ +
+

+ + - (Object) change(receiver = nil, message = nil, &block) + + + + Also known as: + a_block_changing, changing + + + + +

+
+

Applied to a proc, specifies that its execution will cause some value to +change.

+ +

You can either pass receiver and message, or a block, +but not both.

+ +

When passing a block, it must use the { ... } format, not +do/end, as { ... } binds to the change method, whereas do/end +would errantly bind to the expect(..).to or expect(...).not_to method.

+ +

You can chain any of the following off of the end to specify details +about the change:

+ +
    +
  • by
  • +
  • by_at_least
  • +
  • by_at_most
  • +
  • from
  • +
  • to
  • +
+ +

== Notes

+ +

Evaluates receiver.message or block before and after it +evaluates the block passed to expect.

+ +

expect( ... ).not_to change supports the form that specifies from +(which specifies what you expect the starting, unchanged value to be) +but does not support forms with subsequent calls to by, by_at_least, +by_at_most or to.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect {
+  team.add_player(player)
+}.to change(roster, :count)
+
+expect {
+  team.add_player(player)
+}.to change(roster, :count).by(1)
+
+expect {
+  team.add_player(player)
+}.to change(roster, :count).by_at_least(1)
+
+expect {
+  team.add_player(player)
+}.to change(roster, :count).by_at_most(1)
+
+string = "string"
+expect {
+  string.reverse!
+}.to change { string }.from("string").to("gnirts")
+
+string = "string"
+expect {
+  string
+}.not_to change { string }.from("string")
+
+expect {
+  person.happy_birthday
+}.to change(person, :birthday).from(32).to(33)
+
+expect {
+  employee.develop_great_new_social_networking_app
+}.to change(employee, :title).from("Mail Clerk").to("CEO")
+
+expect {
+  doctor.leave_office
+}.to change(doctor, :sign).from(/is in/).to(/is out/)
+
+user = User.new(:type => "admin")
+expect {
+  user.symbolize_type
+}.to change(user, :type).from(String).to(Symbol)
+ +
+

Parameters:

+
    + +
  • + + receiver + + + (Object) + + + (defaults to: nil) + + +
  • + +
  • + + message + + + (Symbol) + + + (defaults to: nil) + + + — +

    the message to send the receiver

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+445
+446
+447
+
+
# File 'lib/rspec/matchers.rb', line 445
+
+def change(receiver=nil, message=nil, &block)
+  BuiltIn::Change.new(receiver, message, &block)
+end
+
+
+ +
+

+ + - (Object) contain_exactly(*items) + + + + Also known as: + a_collection_containing_exactly, containing_exactly + + + + +

+
+ +
+ Note: +

This is also available using the =~ operator with should, +but =~ is not supported with expect.

+
+
+ +
+ Note: +

This matcher only supports positive expectations. +expect(...).not_to contain_exactly(other_array) is not supported.

+
+
+ +

Passes if actual contains all of the expected regardless of order. +This works for collections. Pass in multiple args and it will only +pass if all args are found in collection.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect([1, 2, 3]).to contain_exactly(1, 2, 3)
+expect([1, 2, 3]).to contain_exactly(1, 3, 2)
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+467
+468
+469
+
+
# File 'lib/rspec/matchers.rb', line 467
+
+def contain_exactly(*items)
+  BuiltIn::ContainExactly.new(items)
+end
+
+
+ +
+

+ + - (Object) cover(*values) + + + + Also known as: + a_range_covering, covering + + + + +

+
+

Passes if actual covers expected. This works for +Ranges. You can also pass in multiple args +and it will only pass if all args are found in Range.

+ +

Warning:: Ruby >= 1.9 only

+ + +
+
+
+ +
+

Examples:

+ + +
expect(1..10).to     cover(5)
+expect(1..10).to     cover(4, 6)
+expect(1..10).to     cover(4, 6, 11) # fails
+expect(1..10).not_to cover(11)
+expect(1..10).not_to cover(5)        # fails
+ +
+ + +
+ + + + +
+
+
+
+485
+486
+487
+
+
# File 'lib/rspec/matchers.rb', line 485
+
+def cover(*values)
+  BuiltIn::Cover.new(*values)
+end
+
+
+ +
+

+ + - (Object) end_with(*expected) + + + + Also known as: + a_collection_ending_with, a_string_ending_with, ending_with + + + + +

+
+

Matches if the actual value ends with the expected value(s). In the case +of a string, matches against the last expected.length characters of the +actual string. In the case of an array, matches against the last +expected.length elements of the actual array.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect("this string").to   end_with "string"
+expect([0, 1, 2, 3, 4]).to end_with 4
+expect([0, 2, 3, 4, 4]).to end_with 3, 4
+ +
+ + +
+ + + + +
+
+
+
+501
+502
+503
+
+
# File 'lib/rspec/matchers.rb', line 501
+
+def end_with(*expected)
+  BuiltIn::EndWith.new(*expected)
+end
+
+
+ +
+

+ + - (Object) eq(expected) + + + + Also known as: + an_object_eq_to, eq_to + + + + +

+
+

Passes if actual == expected.

+ +

See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more +information about equality in Ruby.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     eq(5)
+expect(5).not_to eq(3)
+ +
+ + +
+ + + + +
+
+
+
+517
+518
+519
+
+
# File 'lib/rspec/matchers.rb', line 517
+
+def eq(expected)
+  BuiltIn::Eq.new(expected)
+end
+
+
+ +
+

+ + - (Object) eql(expected) + + + + Also known as: + an_object_eql_to, eql_to + + + + +

+
+

Passes if actual.eql?(expected)

+ +

See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more +information about equality in Ruby.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to     eql(5)
+expect(5).not_to eql(3)
+ +
+ + +
+ + + + +
+
+
+
+532
+533
+534
+
+
# File 'lib/rspec/matchers.rb', line 532
+
+def eql(expected)
+  BuiltIn::Eql.new(expected)
+end
+
+
+ +
+

+ + - (Object) equal(expected) + + + + Also known as: + an_object_equal_to, equal_to + + + + +

+
+

Passes if actual.equal?(expected) (object identity).

+ +

See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more +information about equality in Ruby.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to       equal(5)   # Fixnums are equal
+expect("5").not_to equal("5") # Strings that look the same are not the same object
+ +
+ + +
+ + + + +
+
+
+
+547
+548
+549
+
+
# File 'lib/rspec/matchers.rb', line 547
+
+def equal(expected)
+  BuiltIn::Equal.new(expected)
+end
+
+
+ +
+

+ + - (Object) exist(*args) + + + + Also known as: + an_object_existing, existing + + + + +

+
+

Passes if actual.exist? or actual.exists?

+ + +
+
+
+ +
+

Examples:

+ + +
expect(File).to exist("path/to/file")
+ +
+ + +
+ + + + +
+
+
+
+557
+558
+559
+
+
# File 'lib/rspec/matchers.rb', line 557
+
+def exist(*args)
+  BuiltIn::Exist.new(*args)
+end
+
+
+ +
+

+ + - (ExpectationTarget) expect + + + + + +

+
+

Supports expect(actual).to matcher syntax by wrapping actual in an +ExpectationTarget.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(actual).to eq(expected)
+expect(actual).not_to eq(expected)
+ +
+ +

Returns:

+
    + +
  • + + + (ExpectationTarget) + + + +
  • + +
+ +

See Also:

+
    + +
  • ExpectationTarget#to
  • + +
  • ExpectationTarget#not_to
  • + +
+ +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/matchers.rb', line 213
+
+
+
+
+ +
+

+ + - (Object) include(*expected) + + + + Also known as: + a_collection_including, a_string_including, a_hash_including, including + + + + +

+
+

Passes if actual includes expected. This works for +collections and Strings. You can also pass in multiple args +and it will only pass if all args are found in collection.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect([1,2,3]).to      include(3)
+expect([1,2,3]).to      include(2,3)
+expect([1,2,3]).to      include(2,3,4) # fails
+expect([1,2,3]).not_to  include(4)
+expect("spread").to     include("read")
+expect("spread").not_to include("red")
+ +
+ + +
+ + + + +
+
+
+
+575
+576
+577
+
+
# File 'lib/rspec/matchers.rb', line 575
+
+def include(*expected)
+  BuiltIn::Include.new(*expected)
+end
+
+
+ +
+

+ + - (Object) match(expected) + + + + Also known as: + match_regex, an_object_matching, a_string_matching, matching + + + + +

+
+ +
+ Note: +

The match_regex alias is deprecated and is not recommended for use. +It was added in 2.12.1 to facilitate its use from within custom +matchers (due to how the custom matcher DSL was evaluated in 2.x, +match could not be used there), but is no longer needed in 3.x.

+
+
+ +

Given a Regexp or String, passes if actual.match(pattern) +Given an arbitrary nested data structure (e.g. arrays and hashes), +matches if expected === actual || actual == expected for each +pair of elements.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(email).to match(/^([^\s]+)((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
+expect(email).to match("@example.com")
+ + +

+hash = {
+  :a => {
+    :b => ["foo", 5],
+    :c => { :d => 2.05 }
+  }
+}
+
+expect(hash).to match(
+  :a => {
+    :b => a_collection_containing_exactly(
+      a_string_starting_with("f"),
+      an_instance_of(Fixnum)
+    ),
+    :c => { :d => (a_value < 3) }
+  }
+)
+ +
+ + +
+ + + + +
+
+
+
+636
+637
+638
+
+
# File 'lib/rspec/matchers.rb', line 636
+
+def match(expected)
+  BuiltIn::Match.new(expected)
+end
+
+
+ +
+

+ + - (Object) match_array(items) + + + + + +

+
+

An alternate form of contain_exactly that accepts +the expected contents as a single array arg rather +that splatted out as individual items.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(results).to contain_exactly(1, 2)
+# is identical to:
+expect(results).to match_array([1, 2])
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+655
+656
+657
+
+
# File 'lib/rspec/matchers.rb', line 655
+
+def match_array(items)
+  contain_exactly(*items)
+end
+
+
+ +
+

+ + - (Object) output(expected = nil) + + + + Also known as: + a_block_outputting + + + + +

+
+ +
+ Note: +

This matcher works by temporarily replacing $stdout or $stderr, +so it's not able to intercept stream output that explicitly uses STDOUT/STDERR +or that uses a reference to $stdout/$stderr that was stored before the +matcher is used.

+
+
+ +

With no arg, passes if the block outputs to_stdout or to_stderr. +With a string, passes if the blocks outputs that specific string to_stdout or to_stderr. +With a regexp or matcher, passes if the blocks outputs a string to_stdout or to_stderr that matches.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { print 'foo' }.to output.to_stdout
+expect { print 'foo' }.to output('foo').to_stdout
+expect { print 'foo' }.to output(/foo/).to_stdout
+
+expect { do_something }.to_not output.to_stdout
+
+expect { warn('foo') }.to output.to_stderr
+expect { warn('foo') }.to output('foo').to_stderr
+expect { warn('foo') }.to output(/foo/).to_stderr
+
+expect { do_something }.to_not output.to_stderr
+ +
+ + +
+ + + + +
+
+
+
+681
+682
+683
+
+
# File 'lib/rspec/matchers.rb', line 681
+
+def output(expected=nil)
+  BuiltIn::Output.new(expected)
+end
+
+
+ +
+

+ + - (Object) raise_error(error = Exception, message = nil, &block) + + + + Also known as: + raise_exception, a_block_raising, raising + + + + +

+
+

With no args, matches if any error is raised. +With a named error, matches only if that specific error is raised. +With a named error and messsage specified as a String, matches only if both match. +With a named error and messsage specified as a Regexp, matches only if both match. +Pass an optional block to perform extra verifications on the exception matched

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { do_something_risky }.to raise_error
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError)
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError) { |error| expect(error.data).to eq 42 }
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError, "that was too risky")
+expect { do_something_risky }.to raise_error(PoorRiskDecisionError, /oo ri/)
+
+expect { do_something_risky }.not_to raise_error
+ +
+ + +
+ + + + +
+
+
+
+701
+702
+703
+
+
# File 'lib/rspec/matchers.rb', line 701
+
+def raise_error(error=Exception, message=nil, &block)
+  BuiltIn::RaiseError.new(error, message, &block)
+end
+
+
+ +
+

+ + - (Object) respond_to(*names) + + + + Also known as: + an_object_responding_to, responding_to + + + + +

+
+

Matches if the target object responds to all of the names +provided. Names can be Strings or Symbols.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect("string").to respond_to(:length)
+ +
+ + +
+ + + + +
+
+
+
+721
+722
+723
+
+
# File 'lib/rspec/matchers.rb', line 721
+
+def respond_to(*names)
+  BuiltIn::RespondTo.new(*names)
+end
+
+
+ +
+

+ + - (Object) satisfy(&block) + + + + Also known as: + an_object_satisfying, satisfying + + + + +

+
+

Passes if the submitted block returns true. Yields target to the +block.

+ +

Generally speaking, this should be thought of as a last resort when +you can't find any other way to specify the behaviour you wish to +specify.

+ +

If you do find yourself in such a situation, you could always write +a custom matcher, which would likely make your specs more expressive.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(5).to satisfy { |n| n > 3 }
+ +
+ + +
+ + + + +
+
+
+
+740
+741
+742
+
+
# File 'lib/rspec/matchers.rb', line 740
+
+def satisfy(&block)
+  BuiltIn::Satisfy.new(&block)
+end
+
+
+ +
+

+ + - (Object) start_with(*expected) + + + + Also known as: + a_collection_starting_with, a_string_starting_with, starting_with + + + + +

+
+

Matches if the actual value starts with the expected value(s). In the +case of a string, matches against the first expected.length characters +of the actual string. In the case of an array, matches against the first +expected.length elements of the actual array.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect("this string").to   start_with "this s"
+expect([0, 1, 2, 3, 4]).to start_with 0
+expect([0, 2, 3, 4, 4]).to start_with 0, 1
+ +
+ + +
+ + + + +
+
+
+
+756
+757
+758
+
+
# File 'lib/rspec/matchers.rb', line 756
+
+def start_with(*expected)
+  BuiltIn::StartWith.new(*expected)
+end
+
+
+ +
+

+ + - (Object) throw_symbol(expected_symbol = nil, expected_arg = nil) + + + + Also known as: + a_block_throwing, throwing + + + + +

+
+

Given no argument, matches if a proc throws any Symbol.

+ +

Given a Symbol, matches if the given proc throws the specified Symbol.

+ +

Given a Symbol and an arg, matches if the given proc throws the +specified Symbol with the specified arg.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { do_something_risky }.to throw_symbol
+expect { do_something_risky }.to throw_symbol(:that_was_risky)
+expect { do_something_risky }.to throw_symbol(:that_was_risky, 'culprit')
+
+expect { do_something_risky }.not_to throw_symbol
+expect { do_something_risky }.not_to throw_symbol(:that_was_risky)
+expect { do_something_risky }.not_to throw_symbol(:that_was_risky, 'culprit')
+ +
+ + +
+ + + + +
+
+
+
+779
+780
+781
+
+
# File 'lib/rspec/matchers.rb', line 779
+
+def throw_symbol(expected_symbol=nil, expected_arg=nil)
+  BuiltIn::ThrowSymbol.new(expected_symbol, expected_arg)
+end
+
+
+ +
+

+ + - (Object) yield_control + + + + Also known as: + a_block_yielding_control, yielding_control + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +
+ Note: +

This matcher is not designed for use with methods that yield +multiple times.

+
+
+ +

Passes if the method called in the expect block yields, regardless +of whether or not arguments are yielded.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| 5.tap(&b) }.to yield_control
+expect { |b| "a".to_sym(&b) }.not_to yield_control
+ +
+ + +
+ + + + +
+
+
+
+803
+804
+805
+
+
# File 'lib/rspec/matchers.rb', line 803
+
+def yield_control
+  BuiltIn::YieldControl.new
+end
+
+
+ +
+

+ + - (Object) yield_successive_args(*args) + + + + Also known as: + a_block_yielding_successive_args, yielding_successive_args + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +

Designed for use with methods that repeatedly yield (such as +iterators). Passes if the method called in the expect block yields +multiple times with arguments matching those given.

+ +

Argument matching is done using === (the case match operator) +and ==. If the expected and actual arguments match with either +operator, the matcher will pass.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
+expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2])
+expect { |b| [1, 2, 3].each(&b) }.not_to yield_successive_args(1, 2)
+ +
+ + +
+ + + + +
+
+
+
+875
+876
+877
+
+
# File 'lib/rspec/matchers.rb', line 875
+
+def yield_successive_args(*args)
+  BuiltIn::YieldSuccessiveArgs.new(*args)
+end
+
+
+ +
+

+ + - (Object) yield_with_args(*args) + + + + Also known as: + a_block_yielding_with_args, yielding_with_args + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +
+ Note: +

This matcher is not designed for use with methods that yield +multiple times.

+
+
+ +

Given no arguments, matches if the method called in the expect +block yields with arguments (regardless of what they are or how +many there are).

+ +

Given arguments, matches if the method called in the expect block +yields with arguments that match the given arguments.

+ +

Argument matching is done using === (the case match operator) +and ==. If the expected and actual arguments match with either +operator, the matcher will pass.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| 5.tap(&b) }.to yield_with_args # because #tap yields an arg
+expect { |b| 5.tap(&b) }.to yield_with_args(5) # because 5 == 5
+expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum) # because Fixnum === 5
+expect { |b| File.open("f.txt", &b) }.to yield_with_args(/txt/) # because /txt/ === "f.txt"
+
+expect { |b| User.transaction(&b) }.not_to yield_with_args # because it yields no args
+expect { |b| 5.tap(&b) }.not_to yield_with_args(1, 2, 3)
+ +
+ + +
+ + + + +
+
+
+
+853
+854
+855
+
+
# File 'lib/rspec/matchers.rb', line 853
+
+def yield_with_args(*args)
+  BuiltIn::YieldWithArgs.new(*args)
+end
+
+
+ +
+

+ + - (Object) yield_with_no_args + + + + Also known as: + a_block_yielding_with_no_args, yielding_with_no_args + + + + +

+
+ +
+ Note: +

Your expect block must accept a parameter and pass it on to +the method-under-test as a block.

+
+
+ +
+ Note: +

This matcher is not designed for use with methods that yield +multiple times.

+
+
+ +

Passes if the method called in the expect block yields with +no arguments. Fails if it does not yield, or yields with arguments.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect { |b| User.transaction(&b) }.to yield_with_no_args
+expect { |b| 5.tap(&b) }.not_to yield_with_no_args # because it yields with `5`
+expect { |b| "a".to_sym(&b) }.not_to yield_with_no_args # because it does not yield
+ +
+ + +
+ + + + +
+
+
+
+822
+823
+824
+
+
# File 'lib/rspec/matchers.rb', line 822
+
+def yield_with_no_args
+  BuiltIn::YieldWithNoArgs.new
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/AliasedMatcher.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/AliasedMatcher.html new file mode 100644 index 000000000..1868795cf --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/AliasedMatcher.html @@ -0,0 +1,394 @@ + + + + + + Class: RSpec::Matchers::AliasedMatcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::AliasedMatcher + + + Private +

+ +
+ +
Inherits:
+
+ MatcherDelegator + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/aliased_matcher.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Decorator that wraps a matcher and overrides description +using the provided block in order to support an alias +of a matcher. This is intended for use when composing +matchers, so that you can use an expression like +include( a_value_within(0.1).of(3) ) rather than +include( be_within(0.1).of(3) ), and have the corresponding +description read naturally.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + +
+

Constructor Details

+ +
+

+ + - (AliasedMatcher) initialize(base_matcher, description_block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of AliasedMatcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 13
+
+def initialize(base_matcher, description_block)
+  @description_block = description_block
+  super(base_matcher)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Forward messages on to the wrapped matcher. +Since many matchers provide a fluent interface +(e.g. a_value_within(0.1).of(3)), we need to wrap +the returned value if it responds to description, +so that our override can be applied when it is eventually +used.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 24
+
+def method_missing(*)
+  return_val = super
+  return return_val unless return_val.respond_to?(:description)
+  AliasedMatcher.new(return_val, @description_block)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides the description of the aliased matcher. Aliased matchers +are designed to behave identically to the original matcher except +for this method. The description is different to reflect the aliased +name.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/matchers/aliased_matcher.rb', line 36
+
+def description
+  @description_block.call(super)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn.html new file mode 100644 index 000000000..b0dd3fd78 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn.html @@ -0,0 +1,133 @@ + + + + + + Module: RSpec::Matchers::BuiltIn + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::BuiltIn + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in.rb,
+ lib/rspec/matchers/built_in/be.rb,
lib/rspec/matchers/built_in/eq.rb,
lib/rspec/matchers/built_in/all.rb,
lib/rspec/matchers/built_in/has.rb,
lib/rspec/matchers/built_in/eql.rb,
lib/rspec/matchers/built_in/yield.rb,
lib/rspec/matchers/built_in/equal.rb,
lib/rspec/matchers/built_in/exist.rb,
lib/rspec/matchers/built_in/match.rb,
lib/rspec/matchers/built_in/cover.rb,
lib/rspec/matchers/built_in/output.rb,
lib/rspec/matchers/built_in/change.rb,
lib/rspec/matchers/built_in/include.rb,
lib/rspec/matchers/built_in/satisfy.rb,
lib/rspec/matchers/built_in/compound.rb,
lib/rspec/matchers/built_in/operators.rb,
lib/rspec/matchers/built_in/be_within.rb,
lib/rspec/matchers/built_in/respond_to.rb,
lib/rspec/matchers/built_in/be_between.rb,
lib/rspec/matchers/built_in/be_kind_of.rb,
lib/rspec/matchers/built_in/raise_error.rb,
lib/rspec/matchers/built_in/throw_symbol.rb,
lib/rspec/matchers/built_in/base_matcher.rb,
lib/rspec/matchers/built_in/be_instance_of.rb,
lib/rspec/matchers/built_in/contain_exactly.rb,
lib/rspec/matchers/built_in/start_and_end_with.rb
+
+ +
+
+ +

Overview

+
+

Container module for all built-in matchers. The matcher classes are here +(rather than directly under RSpec::Matchers) in order to prevent name +collisions, since RSpec::Matchers gets included into the user's namespace.

+ +

Autoloading is used to delay when the matcher classes get loaded, allowing +rspec-matchers to boot faster, and avoiding loading matchers the user is +not using.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: All, BaseMatcher, Be, BeAKindOf, BeAnInstanceOf, BeBetween, BeComparedTo, BeFalsey, BeNil, BePredicate, BeTruthy, BeWithin, Change, ChangeFromValue, ChangeRelatively, ChangeToValue, Compound, ContainExactly, Cover, EndWith, Eq, Eql, Equal, Exist, Has, Include, Match, OperatorMatcher, Output, RaiseError, RespondTo, Satisfy, SpecificValuesChange, StartAndEndWith, StartWith, ThrowSymbol, YieldControl, YieldSuccessiveArgs, YieldWithArgs, YieldWithNoArgs + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/All.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/All.html new file mode 100644 index 000000000..ae310578a --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/All.html @@ -0,0 +1,435 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::All + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::All + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/all.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for all. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #failure_message_when_negated, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (All) initialize(matcher) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of All

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/built_in/all.rb', line 11
+
+def initialize(matcher)
+  @matcher = matcher
+  @failed_objects = {}
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/built_in/all.rb', line 33
+
+def description
+  improve_hash_formatting "all #{description_of matcher}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'lib/rspec/matchers/built_in/all.rb', line 23
+
+def failure_message
+  all_messages = [improve_hash_formatting(super)]
+  failed_objects.each do |index, matcher_failure_message|
+    all_messages << failure_message_for_item(index, matcher_failure_message)
+  end
+  all_messages.join("\n\n")
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html new file mode 100644 index 000000000..2b45a6370 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BaseMatcher.html @@ -0,0 +1,868 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BaseMatcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BaseMatcher + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable, Pretty
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/base_matcher.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used internally as a base class for matchers that ship with +rspec-expectations and rspec-rails.

+ +

Warning:

+ +

This class is for internal use, and subject to change without notice. We +strongly recommend that you do not base your custom matchers on this +class. If/when this changes, we will announce it and remove this warning.

+ + +
+
+
+ + +
+ +

Constant Summary

+ +
+ +
UNDEFINED = +
+
+

+ This constant is part of a private API. + You should avoid using this constant if possible, as it may be removed or be changed in the future. +

+

Used to detect when no arg is passed to initialize. +nil cannot be used because it's a valid value to pass.

+ + +
+
+
+ + +
+
+
Object.new.freeze
+ +
+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BaseMatcher) initialize(expected = UNDEFINED) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BaseMatcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+26
+27
+28
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 26
+
+def initialize(expected=UNDEFINED)
+  @expected = expected unless UNDEFINED.equal?(expected)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Generates a "pretty" description using the logic in Pretty.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+78
+79
+80
+81
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 78
+
+def description
+  return name_to_sentence unless defined?(@expected)
+  "#{name_to_sentence}#{to_sentence @expected}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Matchers are not diffable by default. Override this to make your +subclass diffable.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+86
+87
+88
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 86
+
+def diffable?
+  false
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides a good generic failure message. Based on description. +When subclassing, if you are not satisfied with this failure message +you often only need to override description.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+60
+61
+62
+63
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 60
+
+def failure_message
+  assert_ivars :@actual
+  "expected #{@actual.inspect} to #{description}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides a good generic negative failure message. Based on description. +When subclassing, if you are not satisfied with this failure message +you often only need to override description.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+70
+71
+72
+73
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 70
+
+def failure_message_when_negated
+  assert_ivars :@actual
+  "expected #{@actual.inspect} not to #{description}"
+end
+
+
+ +
+

+ + - (Object) match_unless_raises(*exceptions) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Used to wrap a block of code that will indicate failure by +raising one of the named exceptions.

+ +

This is used by rspec-rails for some of its matchers that +wrap rails' assertions.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 45
+
+def match_unless_raises(*exceptions)
+  exceptions.unshift Exception if exceptions.empty?
+  begin
+    yield
+    true
+  rescue *exceptions => @rescued_exception
+    false
+  end
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates if the match is successful. Delegates to match, which +should be defined on a subclass. Takes care of consistently +initializing the actual attribute.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+34
+35
+36
+37
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 34
+
+def matches?(actual)
+  @actual = actual
+  match(expected, actual)
+end
+
+
+ +
+

+ + - (Boolean) supports_block_expectations? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Most matchers are value matchers (i.e. meant to work with expect(value)) +rather than block matchers (i.e. meant to work with expect { }), so +this defaults to false. Block matchers must override this to return true.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+94
+95
+96
+
+
# File 'lib/rspec/matchers/built_in/base_matcher.rb', line 94
+
+def supports_block_expectations?
+  false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html new file mode 100644 index 000000000..4b296a584 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Be.html @@ -0,0 +1,431 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Be + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Be + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Be) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Be

+ + +
+
+
+ + +
+ + + + +
+
+
+
+104
+105
+106
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 104
+
+def initialize(*args)
+  @args = args
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+110
+111
+112
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 110
+
+def failure_message
+  "expected #{@actual.inspect} to evaluate to true"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+116
+117
+118
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 116
+
+def failure_message_when_negated
+  "expected #{@actual.inspect} to evaluate to false"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html new file mode 100644 index 000000000..9a5f2e10a --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAKindOf.html @@ -0,0 +1,185 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeAKindOf + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeAKindOf + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_kind_of.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_a_kind_of. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from BaseMatcher

+

#description, #diffable?, #failure_message, #failure_message_when_negated, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html new file mode 100644 index 000000000..cd4c01b2f --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeAnInstanceOf.html @@ -0,0 +1,280 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeAnInstanceOf + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeAnInstanceOf + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_instance_of.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_an_instance_of. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #failure_message, #failure_message_when_negated, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/be_instance_of.rb', line 10
+
+def description
+  "be an instance of #{expected}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html new file mode 100644 index 000000000..4abfa12c3 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeBetween.html @@ -0,0 +1,673 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeBetween + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeBetween + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_between.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_between. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #failure_message_when_negated, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BeBetween) initialize(min, max) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BeBetween

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 8
+
+def initialize(min, max)
+  @min, @max = min, max
+  inclusive
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+57
+58
+59
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 57
+
+def description
+  "be between #{@min.inspect} and #{@max.inspect} (#{@mode})"
+end
+
+
+ +
+

+ + - (Object) exclusive + + + + + +

+
+

Makes the between comparison exclusive.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(3).to be_between(2, 4).exclusive
+ +
+ + +
+ + + + +
+
+
+
+33
+34
+35
+36
+37
+38
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 33
+
+def exclusive
+  @less_than_operator = :<
+  @greater_than_operator = :>
+  @mode = :exclusive
+  self
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+51
+52
+53
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 51
+
+def failure_message
+  "#{super}#{not_comparable_clause}"
+end
+
+
+ +
+

+ + - (Object) inclusive + + + + + +

+
+ +
+ Note: +

The matcher is inclusive by default; this simply provides +a way to be more explicit about it.

+
+
+ +

Makes the between comparison inclusive.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(3).to be_between(2, 3).inclusive
+ +
+ + +
+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 21
+
+def inclusive
+  @less_than_operator = :<=
+  @greater_than_operator = :>=
+  @mode = :inclusive
+  self
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+42
+43
+44
+45
+46
+47
+
+
# File 'lib/rspec/matchers/built_in/be_between.rb', line 42
+
+def matches?(actual)
+  @actual = actual
+  comparable? && compare
+rescue ArgumentError
+  false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html new file mode 100644 index 000000000..c84769147 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeComparedTo.html @@ -0,0 +1,601 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeComparedTo + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeComparedTo + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation of be <operator> value. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BeComparedTo) initialize(operand, operator) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BeComparedTo

+ + +
+
+
+ + +
+ + + + +
+
+
+
+139
+140
+141
+142
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 139
+
+def initialize(operand, operator)
+  @expected, @operator = operand, operator
+  @args = []
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+168
+169
+170
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 168
+
+def description
+  "be #{@operator} #{expected_to_sentence}#{args_to_sentence}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+151
+152
+153
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 151
+
+def failure_message
+  "expected: #{@operator} #{@expected.inspect}\n     got: #{@operator.to_s.gsub(/./, ' ')} #{@actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+157
+158
+159
+160
+161
+162
+163
+164
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 157
+
+def failure_message_when_negated
+  message = "`expect(#{@actual.inspect}).not_to be #{@operator} #{@expected.inspect}`"
+  if [:<, :>, :<=, :>=].include?(@operator)
+    message + " not only FAILED, it is a bit confusing."
+  else
+    message
+  end
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+144
+145
+146
+147
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 144
+
+def matches?(actual)
+  @actual = actual
+  @actual.__send__ @operator, @expected
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html new file mode 100644 index 000000000..d2bf0438d --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeFalsey.html @@ -0,0 +1,358 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeFalsey + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeFalsey + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_falsey. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 33
+
+def failure_message
+  "expected: falsey value\n     got: #{actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+39
+40
+41
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 39
+
+def failure_message_when_negated
+  "expected: truthy value\n     got: #{actual.inspect}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html new file mode 100644 index 000000000..b4cab7556 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeNil.html @@ -0,0 +1,358 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeNil + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeNil + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_nil. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 56
+
+def failure_message
+  "expected: nil\n     got: #{actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 62
+
+def failure_message_when_negated
+  "expected: not nil\n     got: nil"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html new file mode 100644 index 000000000..9f584a4f7 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BePredicate.html @@ -0,0 +1,677 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BePredicate + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BePredicate + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation of be_<predicate>. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (BePredicate) initialize(*args, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BePredicate

+ + +
+
+
+ + +
+ + + + +
+
+
+
+179
+180
+181
+182
+183
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 179
+
+def initialize(*args, &block)
+  @expected = parse_expected(args.shift)
+  @args = args
+  @block = block
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+211
+212
+213
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 211
+
+def description
+  "#{prefix_to_sentence}#{expected_to_sentence}#{args_to_sentence}"
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(actual, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+191
+192
+193
+194
+195
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 191
+
+def does_not_match?(actual, &block)
+  @actual  = actual
+  @block ||= block
+  predicate_accessible? && !predicate_matches?
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+199
+200
+201
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 199
+
+def failure_message
+  failure_message_expecting(true)
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+205
+206
+207
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 205
+
+def failure_message_when_negated
+  failure_message_expecting(false)
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+185
+186
+187
+188
+189
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 185
+
+def matches?(actual, &block)
+  @actual  = actual
+  @block ||= block
+  predicate_accessible? && predicate_matches?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html new file mode 100644 index 000000000..f2a6897b0 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeTruthy.html @@ -0,0 +1,358 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeTruthy + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeTruthy + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_truthy. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

RSpec::Matchers::BuiltIn::BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 10
+
+def failure_message
+  "expected: truthy value\n     got: #{actual.inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/be.rb', line 16
+
+def failure_message_when_negated
+  "expected: falsey value\n     got: #{actual.inspect}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html new file mode 100644 index 000000000..1599199d2 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/BeWithin.html @@ -0,0 +1,613 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::BeWithin + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::BeWithin + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/be_within.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for be_within. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (BeWithin) initialize(delta) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of BeWithin

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 10
+
+def initialize(delta)
+  @delta = delta
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+54
+55
+56
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 54
+
+def description
+  "be within #{@delta}#{@unit} of #{@expected}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 42
+
+def failure_message
+  "expected #{@actual.inspect} to #{description}#{not_numeric_clause}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+48
+49
+50
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 48
+
+def failure_message_when_negated
+  "expected #{@actual.inspect} not to #{description}"
+end
+
+
+ +
+

+ + - (Object) of(expected) + + + + + +

+
+

Sets the expected value.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 16
+
+def of(expected)
+  @expected  = expected
+  @tolerance = @delta
+  @unit      = ''
+  self
+end
+
+
+ +
+

+ + - (Object) percent_of(expected) + + + + + +

+
+

Sets the expected value, and makes the matcher do +a percent comparison.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/rspec/matchers/built_in/be_within.rb', line 26
+
+def percent_of(expected)
+  @expected  = expected
+  @tolerance = @delta * @expected.abs / 100.0
+  @unit      = '%'
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html new file mode 100644 index 000000000..cc917cf94 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Change.html @@ -0,0 +1,808 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Change + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Change + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for change. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) by(expected_delta) + + + + + +

+
+

Specifies the delta of the expected change.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+16
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 12
+
+def by(expected_delta)
+  ChangeRelatively.new(@change_details, expected_delta, :by) do |actual_delta|
+    values_match?(expected_delta, actual_delta)
+  end
+end
+
+
+ +
+

+ + - (Object) by_at_least(minimum) + + + + + +

+
+

Specifies a minimum delta of the expected change.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+20
+21
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 20
+
+def by_at_least(minimum)
+  ChangeRelatively.new(@change_details, minimum, :by_at_least) do |actual_delta|
+    actual_delta >= minimum
+  end
+end
+
+
+ +
+

+ + - (Object) by_at_most(maximum) + + + + + +

+
+

Specifies a maximum delta of the expected change.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+28
+29
+30
+31
+32
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 28
+
+def by_at_most(maximum)
+  ChangeRelatively.new(@change_details, maximum, :by_at_most) do |actual_delta|
+    actual_delta <= maximum
+  end
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+74
+75
+76
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 74
+
+def description
+  "change #{@change_details.message}"
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(event_proc) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+55
+56
+57
+58
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 55
+
+def does_not_match?(event_proc)
+  raise_block_syntax_error if block_given?
+  !matches?(event_proc) && Proc === event_proc
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 62
+
+def failure_message
+  "expected #{@change_details.message} to have changed, but #{positive_failure_reason}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+68
+69
+70
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 68
+
+def failure_message_when_negated
+  "expected #{@change_details.message} not to have changed, but #{negative_failure_reason}"
+end
+
+
+ +
+

+ + - (Object) from(value) + + + + + +

+
+

Specifies the original value.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 42
+
+def from(value)
+  ChangeFromValue.new(@change_details, value)
+end
+
+
+ +
+

+ + - (Object) to(value) + + + + + +

+
+

Specifies the new value you expect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 36
+
+def to(value)
+  ChangeToValue.new(@change_details, value)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html new file mode 100644 index 000000000..8fe39bee4 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeFromValue.html @@ -0,0 +1,316 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ChangeFromValue + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ChangeFromValue + + + Private +

+ +
+ +
Inherits:
+
+ SpecificValuesChange + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used to specify a change from a specific value +(and, optionally, to a specific value).

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (ChangeFromValue) initialize(change_details, expected_before) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ChangeFromValue

+ + +
+
+
+ + +
+ + + + +
+
+
+
+227
+228
+229
+230
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 227
+
+def initialize(change_details, expected_before)
+  @description_suffix = nil
+  super(change_details, expected_before, MATCH_ANYTHING)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) to(value) + + + + + +

+
+

Specifies the new value you expect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+234
+235
+236
+237
+238
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 234
+
+def to(value)
+  @expected_after     = value
+  @description_suffix = " to #{description_of value}"
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html new file mode 100644 index 000000000..58621655d --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeRelatively.html @@ -0,0 +1,239 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ChangeRelatively + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ChangeRelatively + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used to specify a relative change.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (ChangeRelatively) initialize(change_details, expected_delta, relativity, &comparer) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ChangeRelatively

+ + +
+
+
+ + +
+ + + + +
+
+
+
+110
+111
+112
+113
+114
+115
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 110
+
+def initialize(change_details, expected_delta, relativity, &comparer)
+  @change_details = change_details
+  @expected_delta = expected_delta
+  @relativity     = relativity
+  @comparer       = comparer
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html new file mode 100644 index 000000000..37a4a88c6 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ChangeToValue.html @@ -0,0 +1,316 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ChangeToValue + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ChangeToValue + + + Private +

+ +
+ +
Inherits:
+
+ SpecificValuesChange + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Used to specify a change to a specific value +(and, optionally, from a specific value).

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (ChangeToValue) initialize(change_details, expected_after) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ChangeToValue

+ + +
+
+
+ + +
+ + + + +
+
+
+
+270
+271
+272
+273
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 270
+
+def initialize(change_details, expected_after)
+  @description_suffix = nil
+  super(change_details, MATCH_ANYTHING, expected_after)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) from(value) + + + + + +

+
+

Specifies the original value.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+277
+278
+279
+280
+281
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 277
+
+def from(value)
+  @expected_before    = value
+  @description_suffix = " from #{description_of value}"
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html new file mode 100644 index 000000000..dc12a137a --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound.html @@ -0,0 +1,362 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Base class for and and or compound matchers.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

And, Or

+
+

Defined Under Namespace

+

+ + + + + Classes: And, Or + + +

+ +

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #failure_message, #failure_message_when_negated, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Compound) initialize(matcher_1, matcher_2) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Compound

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 10
+
+def initialize(matcher_1, matcher_2)
+  @matcher_1 = matcher_1
+  @matcher_2 = matcher_2
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 23
+
+def description
+  singleline_message(matcher_1.description, matcher_2.description)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html new file mode 100644 index 000000000..697af038a --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/And.html @@ -0,0 +1,300 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound::And + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound::And + + + +

+ +
+ +
Inherits:
+
+ RSpec::Matchers::BuiltIn::Compound + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

Matcher used to represent a compound and expectation.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from RSpec::Matchers::BuiltIn::Compound

+

#description, #initialize

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #failure_message_when_negated, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::Compound

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+73
+74
+75
+76
+77
+78
+79
+80
+81
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 73
+
+def failure_message
+  if @matcher_1_matches
+    matcher_2.failure_message
+  elsif @matcher_2_matches
+    matcher_1.failure_message
+  else
+    compound_failure_message
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html new file mode 100644 index 000000000..4623745c5 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Compound/Or.html @@ -0,0 +1,288 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Compound::Or + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Compound::Or + + + +

+ +
+ +
Inherits:
+
+ RSpec::Matchers::BuiltIn::Compound + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/compound.rb
+ +
+
+ +

Overview

+
+

Matcher used to represent a compound or expectation.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from RSpec::Matchers::BuiltIn::Compound

+

#description, #initialize

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #failure_message_when_negated, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::Compound

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+102
+103
+104
+
+
# File 'lib/rspec/matchers/built_in/compound.rb', line 102
+
+def failure_message
+  compound_failure_message
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html new file mode 100644 index 000000000..e8ba80c6e --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ContainExactly.html @@ -0,0 +1,454 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ContainExactly + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ContainExactly + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/contain_exactly.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for contain_exactly and match_array. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+31
+32
+33
+
+
# File 'lib/rspec/matchers/built_in/contain_exactly.rb', line 31
+
+def description
+  "contain exactly#{to_sentence(surface_descriptions_in expected)}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/rspec/matchers/built_in/contain_exactly.rb', line 10
+
+def failure_message
+  if Array === actual
+    message  = "expected collection contained:  #{safe_sort(surface_descriptions_in expected).inspect}\n"
+    message += "actual collection contained:    #{safe_sort(actual).inspect}\n"
+    message += "the missing elements were:      #{safe_sort(surface_descriptions_in missing_items).inspect}\n" unless missing_items.empty?
+    message += "the extra elements were:        #{safe_sort(extra_items).inspect}\n" unless extra_items.empty?
+    message
+  else
+    "expected a collection that can be converted to an array with " \
+    "`#to_ary` or `#to_a`, but got #{actual.inspect}"
+  end
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lib/rspec/matchers/built_in/contain_exactly.rb', line 25
+
+def failure_message_when_negated
+  "`contain_exactly` does not support negation"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html new file mode 100644 index 000000000..4264b7370 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Cover.html @@ -0,0 +1,429 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Cover + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Cover + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/cover.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for cover. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #failure_message, #failure_message_when_negated, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Cover) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Cover

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/cover.rb', line 8
+
+def initialize(*expected)
+  @expected = expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) does_not_match?(range) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+17
+18
+19
+20
+
+
# File 'lib/rspec/matchers/built_in/cover.rb', line 17
+
+def does_not_match?(range)
+  @actual = range
+  expected.none? { |e| range.cover?(e) }
+end
+
+
+ +
+

+ + - (Boolean) matches?(range) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+12
+13
+14
+15
+
+
# File 'lib/rspec/matchers/built_in/cover.rb', line 12
+
+def matches?(range)
+  @actual = range
+  @expected.all? { |e| range.cover?(e) }
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html new file mode 100644 index 000000000..42d9b8e67 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/EndWith.html @@ -0,0 +1,198 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::EndWith + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::EndWith + + + Private +

+ +
+ +
Inherits:
+
+ StartAndEndWith + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/start_and_end_with.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for end_with. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from StartAndEndWith

+

#description, #failure_message, #initialize

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #failure_message, #failure_message_when_negated, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::StartAndEndWith

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html new file mode 100644 index 000000000..12ad09598 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eq.html @@ -0,0 +1,514 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Eq + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Eq + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/eq.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for eq. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 22
+
+def description
+  "#{name_to_sentence} #{@expected.inspect}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 28
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 10
+
+def failure_message
+  "\nexpected: #{format_object(expected)}\n     got: #{format_object(actual)}\n\n(compared using ==)\n"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/eq.rb', line 16
+
+def failure_message_when_negated
+  "\nexpected: value != #{format_object(expected)}\n     got: #{format_object(actual)}\n\n(compared using ==)\n"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html new file mode 100644 index 000000000..84180690d --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Eql.html @@ -0,0 +1,436 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Eql + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Eql + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/eql.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for eql. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/eql.rb', line 22
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/eql.rb', line 10
+
+def failure_message
+  "\nexpected: #{expected.inspect}\n     got: #{actual.inspect}\n\n(compared using eql?)\n"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/eql.rb', line 16
+
+def failure_message_when_negated
+  "\nexpected: value != #{expected.inspect}\n     got: #{actual.inspect}\n\n(compared using eql?)\n"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html new file mode 100644 index 000000000..a2ecc2c40 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Equal.html @@ -0,0 +1,458 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Equal + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Equal + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/equal.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for equal. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/built_in/equal.rb', line 33
+
+def diffable?
+  !expected_is_a_literal_singleton?
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'lib/rspec/matchers/built_in/equal.rb', line 10
+
+def failure_message
+  if expected_is_a_literal_singleton?
+    simple_failure_message
+  else
+    detailed_failure_message
+  end
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'lib/rspec/matchers/built_in/equal.rb', line 20
+
+def failure_message_when_negated
+  <<-MESSAGE
+
+expected not #{inspect_object(actual)}
+ got #{inspect_object(expected)}
+
+Compared using equal?, which compares object identity.
+
+MESSAGE
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html new file mode 100644 index 000000000..f3187fa05 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist.html @@ -0,0 +1,599 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Exist + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Exist + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/exist.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for exist. +Not intended to be instantiated directly.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: ExistenceTest + + +

+ +

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Exist) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Exist

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 8
+
+def initialize(*expected)
+  @expected = expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) does_not_match?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+25
+26
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 22
+
+def does_not_match?(actual)
+  @actual = actual
+  @test = ExistenceTest.new @actual, @expected
+  @test.valid_test? && !@test.actual_exists?
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 30
+
+def failure_message
+  "expected #{@actual.inspect} to exist#{@test.validity_message}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 36
+
+def failure_message_when_negated
+  "expected #{@actual.inspect} not to exist#{@test.validity_message}"
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+14
+15
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 14
+
+def matches?(actual)
+  @actual = actual
+  @test = ExistenceTest.new @actual, @expected
+  @test.valid_test? && @test.actual_exists?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html new file mode 100644 index 000000000..3eb214b68 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Exist/ExistenceTest.html @@ -0,0 +1,583 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Exist::ExistenceTest + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Exist::ExistenceTest + + + Private +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/exist.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Simple class for memoizing actual/expected for this matcher +and examining the match

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Object) actual + + + + + + + + + + + + + + + + +

    Returns the value of attribute actual.

    +
    + +
  • + + +
  • + + + - (Object) expected + + + + + + + + + + + + + + + + +

    Returns the value of attribute expected.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) actual + + + + + +

+
+

Returns the value of attribute actual

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Object) + + + + — +

    the current value of actual

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+43
+44
+45
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
+
+def actual
+  @actual
+end
+
+
+ + + +
+

+ + - (Object) expected + + + + + +

+
+

Returns the value of attribute expected

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Object) + + + + — +

    the current value of expected

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+43
+44
+45
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 43
+
+def expected
+  @expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) actual_exists? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 52
+
+def actual_exists?
+  existence_values.first
+end
+
+
+ +
+

+ + - (Boolean) valid_test? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 46
+
+def valid_test?
+  uniq_truthy_values.size == 1
+end
+
+
+ +
+

+ + - (String) validity_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+
+
# File 'lib/rspec/matchers/built_in/exist.rb', line 58
+
+def validity_message
+  case uniq_truthy_values.size
+  when 0
+    " but it does not respond to either `exist?` or `exists?`"
+  when 2
+    " but `exist?` and `exists?` returned different values:\n\n"\
+    " exist?: #{existence_values.first}\n"\
+    "exists?: #{existence_values.last}"
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html new file mode 100644 index 000000000..5945eca1c --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Has.html @@ -0,0 +1,474 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Has + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Has + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/has.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for has_<predicate>. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (Has) initialize(method_name, *args, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Has

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 10
+
+def initialize(method_name, *args, &block)
+  @method_name, @args, @block = method_name, args, block
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 42
+
+def description
+  [method_description, args_description].compact.join(' ')
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 30
+
+def failure_message
+  validity_message || "expected ##{predicate}#{failure_message_args_description} to return true, got false"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/matchers/built_in/has.rb', line 36
+
+def failure_message_when_negated
+  validity_message || "expected ##{predicate}#{failure_message_args_description} to return false, got true"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html new file mode 100644 index 000000000..afa1a4178 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Include.html @@ -0,0 +1,743 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Include + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Include + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/include.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for include. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#match_unless_raises, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Include) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Include

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 8
+
+def initialize(*expected)
+  @expected = expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+31
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 28
+
+def description
+  described_items = surface_descriptions_in(expected)
+  improve_hash_formatting "include#{to_sentence(described_items)}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 47
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+21
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 21
+
+def does_not_match?(actual)
+  @actual = actual
+  perform_match(:none?, :any?)
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 35
+
+def failure_message
+  improve_hash_formatting(super) + invalid_type_message
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+41
+42
+43
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 41
+
+def failure_message_when_negated
+  improve_hash_formatting(super) + invalid_type_message
+end
+
+
+ +
+

+ + - (Boolean) matches?(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+14
+15
+16
+17
+
+
# File 'lib/rspec/matchers/built_in/include.rb', line 14
+
+def matches?(actual)
+  @actual = actual
+  perform_match(:all?, :all?)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html new file mode 100644 index 000000000..36f0746e7 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Match.html @@ -0,0 +1,358 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Match + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Match + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/match.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for match. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#failure_message, #failure_message_when_negated, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/match.rb', line 10
+
+def description
+  "match #{surface_descriptions_in(expected).inspect}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lib/rspec/matchers/built_in/match.rb', line 16
+
+def diffable?
+  true
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html new file mode 100644 index 000000000..6addb1ee6 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/OperatorMatcher.html @@ -0,0 +1,304 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::OperatorMatcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::OperatorMatcher + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/operators.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for operator matchers. +Not intended to be instantiated directly. +Only available for use with should.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (OperatorMatcher) initialize(actual) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of OperatorMatcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+41
+42
+43
+
+
# File 'lib/rspec/matchers/built_in/operators.rb', line 41
+
+def initialize(actual)
+  @actual = actual
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+76
+77
+78
+
+
# File 'lib/rspec/matchers/built_in/operators.rb', line 76
+
+def description
+  "#{@operator} #{@expected.inspect}"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html new file mode 100644 index 000000000..902e6cbdd --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Output.html @@ -0,0 +1,963 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Output + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Output + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/output.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for output. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#match_unless_raises

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (Output) initialize(expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Output

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 10
+
+def initialize(expected)
+  @expected = expected
+  @stream_capturer = NullCapture
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+54
+55
+56
+57
+58
+59
+60
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 54
+
+def description
+  if @expected
+    "output #{description_of @expected} to #{@stream_capturer.name}"
+  else
+    "output to #{@stream_capturer.name}"
+  end
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+64
+65
+66
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 64
+
+def diffable?
+  true
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 22
+
+def does_not_match?(block)
+  !matches?(block) && Proc === block
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 42
+
+def failure_message
+  "expected block to #{description}, but #{positive_failure_reason}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+48
+49
+50
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 48
+
+def failure_message_when_negated
+  "expected block to not #{description}, but #{negative_failure_reason}"
+end
+
+
+ +
+

+ + - (Boolean) matches?(block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 15
+
+def matches?(block)
+  @block = block
+  return false unless Proc === block
+  @actual = @stream_capturer.capture(block)
+  @expected ? values_match?(@expected, @actual) : captured?
+end
+
+
+ +
+

+ + - (True) supports_block_expectations? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates this matcher matches against a block.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (True) + + + +
  • + +
+ +
+ + + + +
+
+
+
+71
+72
+73
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 71
+
+def supports_block_expectations?
+  true
+end
+
+
+ +
+

+ + - (Object) to_stderr + + + + + +

+
+

Tells the matcher to match against stderr.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+38
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 35
+
+def to_stderr
+  @stream_capturer = CaptureStderr
+  self
+end
+
+
+ +
+

+ + - (Object) to_stdout + + + + + +

+
+

Tells the matcher to match against stdout.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+28
+29
+30
+31
+
+
# File 'lib/rspec/matchers/built_in/output.rb', line 28
+
+def to_stdout
+  @stream_capturer = CaptureStdout
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html new file mode 100644 index 000000000..e857b711b --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RaiseError.html @@ -0,0 +1,555 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::RaiseError + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::RaiseError + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/raise_error.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for raise_error. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (RaiseError) initialize(expected_error_or_message = Exception, expected_message = nil, &block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of RaiseError

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 10
+
+def initialize(expected_error_or_message=Exception, expected_message=nil, &block)
+  @block = block
+  @actual_error = nil
+  case expected_error_or_message
+  when String, Regexp
+    @expected_error, @expected_message = Exception, expected_error_or_message
+  else
+    @expected_error, @expected_message = expected_error_or_message, expected_message
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+83
+84
+85
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 83
+
+def description
+  "raise #{expected_error}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+71
+72
+73
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 71
+
+def failure_message
+  @eval_block ? @actual_error.message : "expected #{expected_error}#{given_error}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+77
+78
+79
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 77
+
+def failure_message_when_negated
+  "expected no #{expected_error}#{given_error}"
+end
+
+
+ +
+

+ + - (Object) with_message(expected_message) + + + + + +

+
+

Specifies the expected error message.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+26
+27
+
+
# File 'lib/rspec/matchers/built_in/raise_error.rb', line 23
+
+def with_message(expected_message)
+  raise_message_already_set if @expected_message
+  @expected_message = expected_message
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html new file mode 100644 index 000000000..398946acd --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/RespondTo.html @@ -0,0 +1,626 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::RespondTo + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::RespondTo + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/respond_to.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for respond_to. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (RespondTo) initialize(*names) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of RespondTo

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 12
+
+def initialize(*names)
+  @names = names
+  @expected_arity = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) argument + + + + Also known as: + arguments + + + + +

+
+

No-op. Intended to be used as syntactic sugar when using with.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(obj).to respond_to(:message).with(3).arguments
+ +
+ + +
+ + + + +
+
+
+
+32
+33
+34
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 32
+
+def argument
+  self
+end
+
+
+ +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+61
+62
+63
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 61
+
+def description
+  "respond to #{pp_names}#{with_arity}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+49
+50
+51
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 49
+
+def failure_message
+  "expected #{@actual.inspect} to respond to #{@failing_method_names.map { |name| name.inspect }.join(', ')}#{with_arity}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+55
+56
+57
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 55
+
+def failure_message_when_negated
+  failure_message.sub(/to respond to/, 'not to respond to')
+end
+
+
+ +
+

+ + - (Object) with(n) + + + + + +

+
+

Specifies the number of expected arguments.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(obj).to respond_to(:message).with(3).arguments
+ +
+ + +
+ + + + +
+
+
+
+22
+23
+24
+25
+
+
# File 'lib/rspec/matchers/built_in/respond_to.rb', line 22
+
+def with(n)
+  @expected_arity = n
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html new file mode 100644 index 000000000..a8e22b685 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/Satisfy.html @@ -0,0 +1,474 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::Satisfy + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::Satisfy + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/satisfy.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for satisfy. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (Satisfy) initialize(&block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Satisfy

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 10
+
+def initialize(&block)
+  @block = block
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 35
+
+def description
+  "satisfy block"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 23
+
+def failure_message
+  "expected #{@actual} to satisfy block"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'lib/rspec/matchers/built_in/satisfy.rb', line 29
+
+def failure_message_when_negated
+  "expected #{@actual} not to satisfy block"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html new file mode 100644 index 000000000..23cddcbce --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/SpecificValuesChange.html @@ -0,0 +1,244 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::SpecificValuesChange + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::SpecificValuesChange + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/change.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Base class for specifying a change from and/or to specific values.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

ChangeFromValue, ChangeToValue

+
+ +

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (SpecificValuesChange) initialize(change_details, from, to) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of SpecificValuesChange

+ + +
+
+
+ + +
+ + + + +
+
+
+
+160
+161
+162
+163
+164
+
+
# File 'lib/rspec/matchers/built_in/change.rb', line 160
+
+def initialize(change_details, from, to)
+  @change_details  = change_details
+  @expected_before = from
+  @expected_after  = to
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html new file mode 100644 index 000000000..d9d3da2a3 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartAndEndWith.html @@ -0,0 +1,445 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::StartAndEndWith + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::StartAndEndWith + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/start_and_end_with.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Base class for the end_with and start_with matchers. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

EndWith, StartWith

+
+ +

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#diffable?, #failure_message_when_negated, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (StartAndEndWith) initialize(*expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of StartAndEndWith

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+
+
# File 'lib/rspec/matchers/built_in/start_and_end_with.rb', line 8
+
+def initialize(*expected)
+  @actual_does_not_have_ordered_elements = false
+  @expected = expected.length == 1 ? expected.first : expected
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+27
+28
+29
+30
+
+
# File 'lib/rspec/matchers/built_in/start_and_end_with.rb', line 27
+
+def description
+  return super unless Hash === expected
+  "#{name_to_sentence} #{surface_descriptions_in(expected).inspect}"
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lib/rspec/matchers/built_in/start_and_end_with.rb', line 15
+
+def failure_message
+  super.tap do |msg|
+    if @actual_does_not_have_ordered_elements
+      msg << ", but it does not have ordered elements"
+    elsif !actual.respond_to?(:[])
+      msg << ", but it cannot be indexed using #[]"
+    end
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html new file mode 100644 index 000000000..19aa2cac6 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/StartWith.html @@ -0,0 +1,198 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::StartWith + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::StartWith + + + Private +

+ +
+ +
Inherits:
+
+ StartAndEndWith + + + show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/start_and_end_with.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for start_with. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from StartAndEndWith

+

#description, #failure_message, #initialize

+ + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #failure_message, #failure_message_when_negated, #initialize, #match_unless_raises, #matches?, #supports_block_expectations?

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::StartAndEndWith

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html new file mode 100644 index 000000000..a0636d7b4 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/ThrowSymbol.html @@ -0,0 +1,638 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::ThrowSymbol + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::ThrowSymbol + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/throw_symbol.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for throw_symbol. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (ThrowSymbol) initialize(expected_symbol = nil, expected_arg = nil) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of ThrowSymbol

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 10
+
+def initialize(expected_symbol=nil, expected_arg=nil)
+  @expected_symbol = expected_symbol
+  @expected_arg = expected_arg
+  @caught_symbol = @caught_arg = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (String) description + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+86
+87
+88
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 86
+
+def description
+  "throw #{expected}"
+end
+
+
+ +
+

+ + - (Boolean) does_not_match?(given_proc) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

rubocop:enable MethodLength

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+68
+69
+70
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 68
+
+def does_not_match?(given_proc)
+  !matches?(given_proc) && Proc === given_proc
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+74
+75
+76
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 74
+
+def failure_message
+  "expected #{expected} to be thrown, #{actual_result}"
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+80
+81
+82
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 80
+
+def failure_message_when_negated
+  "expected #{expected('no Symbol')}#{' not' if @expected_symbol} to be thrown, #{actual_result}"
+end
+
+
+ +
+

+ + - (True) supports_block_expectations? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Indicates this matcher matches against a block.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (True) + + + +
  • + +
+ +
+ + + + +
+
+
+
+93
+94
+95
+
+
# File 'lib/rspec/matchers/built_in/throw_symbol.rb', line 93
+
+def supports_block_expectations?
+  true
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html new file mode 100644 index 000000000..79850fc9c --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldControl.html @@ -0,0 +1,815 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldControl + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldControl + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_control. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods inherited from BaseMatcher

+

#description, #diffable?, #match_unless_raises

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +
+

+ + - (YieldControl) initialize + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of YieldControl

+ + +
+
+
+ + +
+ + + + +
+
+
+
+82
+83
+84
+85
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 82
+
+def initialize
+  @expectation_type = nil
+  @expected_yields_count = nil
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) at_least(number) + + + + + +

+
+

Specifies the minimum number of times the method is expected to yield

+ + +
+
+
+ + +
+ + + + +
+
+
+
+117
+118
+119
+120
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 117
+
+def at_least(number)
+  set_expected_yields_count(:>=, number)
+  self
+end
+
+
+ +
+

+ + - (Object) at_most(number) + + + + + +

+
+

Specifies the maximum number of times the method is expected to yield

+ + +
+
+
+ + +
+ + + + +
+
+
+
+110
+111
+112
+113
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 110
+
+def at_most(number)
+  set_expected_yields_count(:<=, number)
+  self
+end
+
+
+ +
+

+ + - (Object) exactly(number) + + + + + +

+
+

Specifies that the method is expected to yield the given number of times.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+103
+104
+105
+106
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 103
+
+def exactly(number)
+  set_expected_yields_count(:==, number)
+  self
+end
+
+
+ +
+

+ + - (String) failure_message + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+147
+148
+149
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 147
+
+def failure_message
+  'expected given block to yield control' + failure_reason
+end
+
+
+ +
+

+ + - (String) failure_message_when_negated + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + +
  • + +
+ +
+ + + + +
+
+
+
+153
+154
+155
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 153
+
+def failure_message_when_negated
+  'expected given block not to yield control' + failure_reason
+end
+
+
+ +
+

+ + - (Object) once + + + + + +

+
+

Specifies that the method is expected to yield once.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+89
+90
+91
+92
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 89
+
+def once
+  exactly(1)
+  self
+end
+
+
+ +
+

+ + - (Object) times + + + + + +

+
+

No-op. Provides syntactic sugar.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+124
+125
+126
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 124
+
+def times
+  self
+end
+
+
+ +
+

+ + - (Object) twice + + + + + +

+
+

Specifies that the method is expected to yield once.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+96
+97
+98
+99
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 96
+
+def twice
+  exactly(2)
+  self
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html new file mode 100644 index 000000000..25a77bace --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldSuccessiveArgs.html @@ -0,0 +1,318 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldSuccessiveArgs + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldSuccessiveArgs + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_successive_args. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (YieldSuccessiveArgs) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of YieldSuccessiveArgs

+ + +
+
+
+ + +
+ + + + +
+
+
+
+336
+337
+338
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 336
+
+def initialize(*args)
+  @expected = args
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) does_not_match?(block) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+348
+349
+350
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 348
+
+def does_not_match?(block)
+  !matches?(block) && @probe.has_block?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html new file mode 100644 index 000000000..9e40dec5a --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithArgs.html @@ -0,0 +1,234 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldWithArgs + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldWithArgs + + + Private +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
Composable
+ + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_with_args. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+
+

Constructor Details

+ +
+

+ + - (YieldWithArgs) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of YieldWithArgs

+ + +
+
+
+ + +
+ + + + +
+
+
+
+247
+248
+249
+
+
# File 'lib/rspec/matchers/built_in/yield.rb', line 247
+
+def initialize(*args)
+  @expected = args
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html new file mode 100644 index 000000000..33f70b7e1 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/BuiltIn/YieldWithNoArgs.html @@ -0,0 +1,185 @@ + + + + + + Class: RSpec::Matchers::BuiltIn::YieldWithNoArgs + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::BuiltIn::YieldWithNoArgs + + + Private +

+ +
+ +
Inherits:
+
+ BaseMatcher + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/built_in/yield.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Provides the implementation for yield_with_no_args. +Not intended to be instantiated directly.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + +

Constant Summary

+ +

Constants inherited + from BaseMatcher

+

BaseMatcher::UNDEFINED

+ + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from BaseMatcher

+

#description, #diffable?, #initialize, #match_unless_raises

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+
+

Constructor Details

+ +

This class inherits a constructor from RSpec::Matchers::BuiltIn::BaseMatcher

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable.html new file mode 100644 index 000000000..471db49f5 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable.html @@ -0,0 +1,779 @@ + + + + + + Module: RSpec::Matchers::Composable + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::Composable + + + +

+ +
+ + + + + + + +
Included in:
+
BuiltIn::BaseMatcher, BuiltIn::BeWithin, BuiltIn::Change, BuiltIn::ChangeRelatively, BuiltIn::Has, BuiltIn::RaiseError, BuiltIn::RespondTo, BuiltIn::Satisfy, BuiltIn::SpecificValuesChange, BuiltIn::ThrowSymbol, BuiltIn::YieldSuccessiveArgs, BuiltIn::YieldWithArgs, DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/composable.rb
+ +
+
+ +

Overview

+
+

Mixin designed to support the composable matcher features +of RSpec 3+. Mix it into your custom matcher classes to +allow them to be used in a composable fashion.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: DescribableItem + + +

+ + + + + + + + +

+ Class Method Summary + (collapse) +

+ +
    + +
  • + + + + (Boolean) enumerable?(item) + + + + + + + + + + + private + + +
    + +
  • + + +
  • + + + + (Object) surface_descriptions_in(item) + + + + + + + + + + + + + +

    Transforms the given data structue (typically a hash or array) into a new data structure that, when #inspect is called on it, will provide descriptions of any contained matchers rather than the normal #inspect output.

    +
    + +
  • + + +
+ +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Boolean) enumerable?(item) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+164
+165
+166
+167
+
+
# File 'lib/rspec/matchers/composable.rb', line 164
+
+def enumerable?(item)
+  return false if String === item
+  Enumerable === item
+end
+
+
+ +
+

+ + + (Object) surface_descriptions_in(item) + + + + + +

+
+

Transforms the given data structue (typically a hash or array) +into a new data structure that, when #inspect is called on it, +will provide descriptions of any contained matchers rather than +the normal #inspect output.

+ +

You are encouraged to use this in your custom matcher's +description, failure_message or +failure_message_when_negated implementation if you are +supporting any arguments which may be a data structure +containing matchers.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+
+
# File 'lib/rspec/matchers/composable.rb', line 99
+
+def surface_descriptions_in(item)
+  if Matchers.is_a_describable_matcher?(item)
+    DescribableItem.new(item)
+  elsif Hash === item
+    Hash[surface_descriptions_in(item.to_a)]
+  elsif Struct === item
+    item.inspect
+  elsif enumerable?(item)
+    begin
+      item.map { |subitem| surface_descriptions_in(subitem) }
+    rescue IOError # STDOUT is enumerable but `map` raises an error
+      item.inspect
+    end
+  else
+    item
+  end
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Object) ===(value) + + + + + +

+
+

Delegates to #matches?. Allows matchers to be used in composable +fashion and also supports using matchers in case statements.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lib/rspec/matchers/composable.rb', line 45
+
+def ===(value)
+  matches?(value)
+end
+
+
+ +
+

+ + - (Object) and(matcher) + + + + Also known as: + & + + + + +

+
+ +
+ Note: +

The negative form (expect(...).not_to matcher.and other) +is not supported at this time.

+
+
+ +

Creates a compound and expectation. The matcher will +only pass if both sub-matchers pass. +This can be chained together to form an arbitrarily long +chain of matchers.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(alphabet).to start_with("a").and end_with("z")
+expect(alphabet).to start_with("a") & end_with("z")
+ +
+ + +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/matchers/composable.rb', line 22
+
+def and(matcher)
+  BuiltIn::Compound::And.new self, matcher
+end
+
+
+ +
+

+ + - (Object) description_of(object) + + + + + +

+
+

Returns the description of the given object in a way that is +aware of composed matchers. If the object is a matcher with +a description method, returns the description; otherwise +returns object.inspect.

+ +

You are encouraged to use this in your custom matcher's +description, failure_message or +failure_message_when_negated implementation if you are +supporting matcher arguments.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+82
+83
+84
+85
+
+
# File 'lib/rspec/matchers/composable.rb', line 82
+
+def description_of(object)
+  return object.description if Matchers.is_a_describable_matcher?(object)
+  object.inspect
+end
+
+
+ +
+

+ + - (Object) or(matcher) + + + + Also known as: + | + + + + +

+
+ +
+ Note: +

The negative form (expect(...).not_to matcher.or other) +is not supported at this time.

+
+
+ +

Creates a compound or expectation. The matcher will +pass if either sub-matcher passes. +This can be chained together to form an arbitrarily long +chain of matchers.

+ + +
+
+
+ +
+

Examples:

+ + +
expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
+expect(stoplight.color).to eq("red") | eq("green") | eq("yellow")
+ +
+ + +
+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'lib/rspec/matchers/composable.rb', line 38
+
+def or(matcher)
+  BuiltIn::Compound::Or.new self, matcher
+end
+
+
+ +
+

+ + - (Boolean) values_match?(expected, actual) + + + + + +

+
+

This provides a generic way to fuzzy-match an expected value against +an actual value. It understands nested data structures (e.g. hashes +and arrays) and is able to match against a matcher being used as +the expected value or within the expected value at any level of +nesting.

+ +

Within a custom matcher you are encouraged to use this whenever your +matcher needs to match two values, unless it needs more precise semantics. +For example, the eq matcher does not use this as it is meant to +use == (and only ==) for matching.

+ + +
+
+
+

Parameters:

+
    + +
  • + + expected + + + (Object) + + + + — +

    what is expected

    +
    + +
  • + +
  • + + actual + + + (Object) + + + + — +

    the actual value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+69
+
+
# File 'lib/rspec/matchers/composable.rb', line 66
+
+def values_match?(expected, actual)
+  expected = with_matchers_cloned(expected)
+  Support::FuzzyMatcher.values_match?(expected, actual)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html new file mode 100644 index 000000000..3223e1c2d --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Composable/DescribableItem.html @@ -0,0 +1,137 @@ + + + + + + Class: RSpec::Matchers::Composable::DescribableItem + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::Composable::DescribableItem + + + Private +

+ +
+ +
Inherits:
+
+ Struct + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/matchers/composable.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+

Wraps an item in order to surface its description via inspect.

+ + +
+
+
+ + +
+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL.html new file mode 100644 index 000000000..81012292d --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL.html @@ -0,0 +1,224 @@ + + + + + + Module: RSpec::Matchers::DSL + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

Defines the custom matcher DSL.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: DefaultImplementations, Macros + + + + Classes: Matcher + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) define(name, &declarations) + + + + Also known as: + matcher + + + + +

+
+

Defines a custom matcher.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+
+
# File 'lib/rspec/matchers/dsl.rb', line 7
+
+def define(name, &declarations)
+  define_method name do |*expected|
+    RSpec::Matchers::DSL::Matcher.new(name, declarations, self, *expected)
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html new file mode 100644 index 000000000..be976a2e7 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/DefaultImplementations.html @@ -0,0 +1,485 @@ + + + + + + Module: RSpec::Matchers::DSL::DefaultImplementations + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL::DefaultImplementations + + + +

+ +
+ + + + + + + +
Included in:
+
Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

Defines default implementations of the matcher +protocol methods for custom matchers. You can +override any of these using the Macros methods +from within an RSpec::Matchers.define block.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) description + + + + + +

+
+

The default description.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+251
+252
+253
+
+
# File 'lib/rspec/matchers/dsl.rb', line 251
+
+def description
+  "#{name_to_sentence}#{to_sentence expected}"
+end
+
+
+ +
+

+ + - (Boolean) diffable? + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Used internally by objects returns by should and should_not.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+246
+247
+248
+
+
# File 'lib/rspec/matchers/dsl.rb', line 246
+
+def diffable?
+  false
+end
+
+
+ +
+

+ + - (Object) failure_message + + + + + +

+
+

The default failure message for positive expectations.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+256
+257
+258
+
+
# File 'lib/rspec/matchers/dsl.rb', line 256
+
+def failure_message
+  "expected #{actual.inspect} to #{name_to_sentence}#{to_sentence expected}"
+end
+
+
+ +
+

+ + - (Object) failure_message_when_negated + + + + + +

+
+

The default failure message for negative expectations.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+261
+262
+263
+
+
# File 'lib/rspec/matchers/dsl.rb', line 261
+
+def failure_message_when_negated
+  "expected #{actual.inspect} not to #{name_to_sentence}#{to_sentence expected}"
+end
+
+
+ +
+

+ + - (Boolean) supports_block_expectations? + + + + + +

+
+

Matchers do not support block expectations by default. You +must opt-in.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+267
+268
+269
+
+
# File 'lib/rspec/matchers/dsl.rb', line 267
+
+def supports_block_expectations?
+  false
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros.html new file mode 100644 index 000000000..179abd6b3 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros.html @@ -0,0 +1,977 @@ + + + + + + Module: RSpec::Matchers::DSL::Macros + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL::Macros + + + +

+ +
+ + + + + + + +
Included in:
+
Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

Contains the methods that are available from within the +RSpec::Matchers.define DSL for creating custom matchers.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Deprecated + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) chain(name, &definition) + + + + + +

+
+

Convenience for defining methods on this matcher to create a fluent +interface. The trick about fluent interfaces is that each method must +return self in order to chain methods together. chain handles that +for you.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :have_errors_on do |key|
+  chain :with do |message|
+    @message = message
+  end
+
+  match do |actual|
+    actual.errors[key] == @message
+  end
+end
+
+expect(minor).to have_errors_on(:age).with("Not old enough to participate")
+ +
+ + +
+ + + + +
+
+
+
+178
+179
+180
+181
+182
+183
+
+
# File 'lib/rspec/matchers/dsl.rb', line 178
+
+def chain(name, &definition)
+  define_user_override(name, definition) do |*args, &block|
+    super(*args, &block)
+    self
+  end
+end
+
+
+ +
+

+ + - (Object) description {|Object| ... } + + + + + +

+
+

Customize the description to use for one-liners. Only use this when +the description generated by default doesn't suit your needs.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :qualify_for do |expected|
+  match { your_match_logic }
+
+  description do
+    "qualify for #{expected}"
+  end
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+142
+143
+144
+
+
# File 'lib/rspec/matchers/dsl.rb', line 142
+
+def description(&definition)
+  define_user_override(__method__, definition)
+end
+
+
+ +
+

+ + - (Object) diffable + + + + + +

+
+

Tells the matcher to diff the actual and expected values in the failure +message.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+148
+149
+150
+
+
# File 'lib/rspec/matchers/dsl.rb', line 148
+
+def diffable
+  define_method(:diffable?) { true }
+end
+
+
+ +
+

+ + - (Object) failure_message {|Object| ... } + + + + + +

+
+

Customizes the failure messsage to use when this matcher is +asked to positively match. Only use this when the message +generated by default doesn't suit your needs.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :have_strength do |expected|
+  match { your_match_logic }
+
+  failure_message do |actual|
+    "Expected strength of #{expected}, but had #{actual.strength}"
+  end
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+105
+106
+107
+
+
# File 'lib/rspec/matchers/dsl.rb', line 105
+
+def failure_message(&definition)
+  define_user_override(__method__, definition)
+end
+
+
+ +
+

+ + - (Object) failure_message_when_negated {|Object| ... } + + + + + +

+
+

Customize the failure messsage to use when this matcher is asked +to negatively match. Only use this when the message generated by +default doesn't suit your needs.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :have_strength do |expected|
+  match { your_match_logic }
+
+  failure_message_when_negated do |actual|
+    "Expected not to have strength of #{expected}, but did"
+  end
+end
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+124
+125
+126
+
+
# File 'lib/rspec/matchers/dsl.rb', line 124
+
+def failure_message_when_negated(&definition)
+  define_user_override(__method__, definition)
+end
+
+
+ +
+

+ + - (Object) match {|Object| ... } + + + + + +

+
+

Stores the block that is used to determine whether this matcher passes +or fails. The block should return a boolean value. When the matcher is +passed to expect(...).to and the block returns true, then the expectation +passes. Similarly, when the matcher is passed to expect(...).not_to and the +block returns false, then the expectation passes.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :be_even do
+  match do |actual|
+    actual.even?
+  end
+end
+
+expect(4).to be_even     # passes
+expect(3).not_to be_even # passes
+expect(3).to be_even     # fails
+expect(4).not_to be_even # fails
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual value (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+
+
# File 'lib/rspec/matchers/dsl.rb', line 39
+
+def match(&match_block)
+  define_user_override(:matches?, match_block) do |actual|
+    begin
+      @actual = actual
+      super(*actual_arg_for(match_block))
+    rescue RSpec::Expectations::ExpectationNotMetError
+      false
+    end
+  end
+end
+
+
+ +
+

+ + - (Object) match_unless_raises(expected_exception = Exception) {|Object| ... } + + + + + +

+
+

Use this instead of match when the block will raise an exception +rather than returning false to indicate a failure.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec::Matchers.define :accept_as_valid do |candidate_address|
+  match_unless_raises ValidationException do |validator|
+    validator.validate(candidate_address)
+  end
+end
+
+expect(email_validator).to accept_as_valid("person@company.com")
+ +
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual object (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+
+
# File 'lib/rspec/matchers/dsl.rb', line 77
+
+def match_unless_raises(expected_exception=Exception, &match_block)
+  define_user_override(:matches?, match_block) do |actual|
+    @actual = actual
+    begin
+      super(*actual_arg_for(match_block))
+    rescue expected_exception => @rescued_exception
+      false
+    else
+      true
+    end
+  end
+end
+
+
+ +
+

+ + - (Object) match_when_negated {|Object| ... } + + + + + +

+
+

Use this to define the block for a negative expectation (expect(...).not_to) +when the positive and negative forms require different handling. This +is rarely necessary, but can be helpful, for example, when specifying +asynchronous processes that require different timeouts.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + (Object) + + + + — +

    actual the actual value (i.e. the value wrapped by expect)

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+56
+57
+58
+59
+60
+61
+
+
# File 'lib/rspec/matchers/dsl.rb', line 56
+
+def match_when_negated(&match_block)
+  define_user_override(:does_not_match?, match_block) do |actual|
+    @actual = actual
+    super(*actual_arg_for(match_block))
+  end
+end
+
+
+ +
+

+ + - (Object) supports_block_expectations + + + + + +

+
+

Declares that the matcher can be used in a block expectation. +Users will not be able to use your matcher in a block +expectation without declaring this. +(e.g. expect { do_something }.to matcher).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+156
+157
+158
+
+
# File 'lib/rspec/matchers/dsl.rb', line 156
+
+def supports_block_expectations
+  define_method(:supports_block_expectations?) { true }
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html new file mode 100644 index 000000000..1a0b385e4 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Macros/Deprecated.html @@ -0,0 +1,402 @@ + + + + + + Module: RSpec::Matchers::DSL::Macros::Deprecated + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::DSL::Macros::Deprecated + + Deprecated + +

+ +
+ + + + + + + +
Included in:
+
RSpec::Matchers::DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+
Deprecated.

Use the methods from RSpec::Matchers::DSL::Macros instead.

+
+

Defines deprecated macro methods from RSpec 2 for backwards compatibility.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) failure_message_for_should(&definition) + + + + + +

+
+ + + +
+
+
+ + +
+ + + + +
+
+
+
+226
+227
+228
+229
+
+
# File 'lib/rspec/matchers/dsl.rb', line 226
+
+def failure_message_for_should(&definition)
+  RSpec.deprecate("`failure_message_for_should`", :replacement => "`failure_message`")
+  failure_message(&definition)
+end
+
+
+ +
+

+ + - (Object) failure_message_for_should_not(&definition) + + + + + +

+ +
+
+ + +
+ + + + +
+
+
+
+232
+233
+234
+235
+
+
# File 'lib/rspec/matchers/dsl.rb', line 232
+
+def failure_message_for_should_not(&definition)
+  RSpec.deprecate("`failure_message_for_should_not`", :replacement => "`failure_message_when_negated`")
+  failure_message_when_negated(&definition)
+end
+
+
+ +
+

+ + - (Object) match_for_should(&definition) + + + + + +

+
+
Deprecated.
+ + +
+
+
+ + +
+ + + + +
+
+
+
+214
+215
+216
+217
+
+
# File 'lib/rspec/matchers/dsl.rb', line 214
+
+def match_for_should(&definition)
+  RSpec.deprecate("`match_for_should`", :replacement => "`match`")
+  match(&definition)
+end
+
+
+ +
+

+ + - (Object) match_for_should_not(&definition) + + + + + +

+
+ + + +
+
+
+ + +
+ + + + +
+
+
+
+220
+221
+222
+223
+
+
# File 'lib/rspec/matchers/dsl.rb', line 220
+
+def match_for_should_not(&definition)
+  RSpec.deprecate("`match_for_should_not`", :replacement => "`match_when_negated`")
+  match_when_negated(&definition)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Matcher.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Matcher.html new file mode 100644 index 000000000..43d0cfa3a --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/DSL/Matcher.html @@ -0,0 +1,910 @@ + + + + + + Class: RSpec::Matchers::DSL::Matcher + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Matchers::DSL::Matcher + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + +
Extended by:
+
Macros, RSpec::Matchers::DSL::Macros::Deprecated
+ + + + +
Includes:
+
RSpec::Matchers, Composable, DefaultImplementations, Pretty
+ + + + + +
Defined in:
+
lib/rspec/matchers/dsl.rb
+ +
+
+ +

Overview

+
+

The class used for custom matchers. The block passed to +RSpec::Matchers.define will be evaluated in the context +of the singleton class of an instance, and will have the +Macros methods available.

+ + +
+
+
+ + +
+

Constant Summary

+ + + + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Object) actual + + + + + + + + + readonly + + + + + + + + + +

    Exposes the value being matched against -- generally the object object wrapped by expect.

    +
    + +
  • + + +
  • + + + - (Object) expected_as_array + + + + + + + + + readonly + + + + + + + + + +

    Returns the expected value as an an array.

    +
    + +
  • + + +
  • + + + - (Object) rescued_exception + + + + + + + + + readonly + + + + + + + + + +

    Exposes the exception raised during the matching by match_unless_raises.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from RSpec::Matchers::DSL::Macros::Deprecated

+

failure_message_for_should, failure_message_for_should_not, match_for_should, match_for_should_not

+ + + + + + + + + +

Methods included from Macros

+

chain, description, diffable, failure_message, failure_message_when_negated, match, match_unless_raises, match_when_negated, supports_block_expectations

+ + + + + + + + + +

Methods included from Composable

+

#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?

+ + + + + + + + + +

Methods included from Pretty

+

#name, split_words, #to_sentence, #to_word

+ + + + + + + + + +

Methods included from RSpec::Matchers

+

alias_matcher, #all, #be, #be_a, #be_a_kind_of, #be_an_instance_of, #be_between, #be_falsey, #be_nil, #be_truthy, #be_within, #change, clear_generated_description, configuration, #contain_exactly, #cover, #end_with, #eq, #eql, #equal, #exist, #expect, generated_description, #include, #match, #match_array, #output, #raise_error, #respond_to, #satisfy, #start_with, #throw_symbol, #yield_control, #yield_successive_args, #yield_with_args, #yield_with_no_args

+ + + + + + + + + +

Methods included from DefaultImplementations

+

#description, #diffable?, #failure_message, #failure_message_when_negated, #supports_block_expectations?

+
+

Constructor Details

+ +
+

+ + - (Matcher) initialize(name, declarations, matcher_execution_context, *expected) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Returns a new instance of Matcher

+ + +
+
+
+ + +
+ + + + +
+
+
+
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+
+
# File 'lib/rspec/matchers/dsl.rb', line 302
+
+def initialize(name, declarations, matcher_execution_context, *expected)
+  @name     = name
+  @actual   = nil
+  @expected_as_array = expected
+  @matcher_execution_context = matcher_execution_context
+
+  class << self
+    # See `Macros#define_user_override` above, for an explanation.
+    include(@user_method_defs = Module.new)
+    self
+  end.class_exec(*expected, &declarations)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing(method, *args, &block) (private) + + + + + +

+
+

Takes care of forwarding unhandled messages to the +@matcher_execution_context (typically the current +running RSpec::Core::Example). This is needed by +rspec-rails so that it can define matchers that wrap +Rails' test helper methods, but it's also a useful +feature in its own right.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+367
+368
+369
+370
+371
+372
+373
+
+
# File 'lib/rspec/matchers/dsl.rb', line 367
+
+def method_missing(method, *args, &block)
+  if @matcher_execution_context.respond_to?(method)
+    @matcher_execution_context.__send__ method, *args, &block
+  else
+    super(method, *args, &block)
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) actual (readonly) + + + + + +

+
+

Exposes the value being matched against -- generally the object +object wrapped by expect.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+295
+296
+297
+
+
# File 'lib/rspec/matchers/dsl.rb', line 295
+
+def actual
+  @actual
+end
+
+
+ + + +
+

+ + - (Object) expected_as_array (readonly) + + + + + +

+
+

Returns the expected value as an an array. This exists primarily +to aid in upgrading from RSpec 2.x, since in RSpec 2, expected +always returned an array.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+331
+332
+333
+
+
# File 'lib/rspec/matchers/dsl.rb', line 331
+
+def expected_as_array
+  @expected_as_array
+end
+
+
+ + + +
+

+ + - (Object) rescued_exception (readonly) + + + + + +

+
+

Exposes the exception raised during the matching by match_unless_raises. +Could be useful to extract details for a failure message.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+299
+300
+301
+
+
# File 'lib/rspec/matchers/dsl.rb', line 299
+
+def rescued_exception
+  @rescued_exception
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) expected + + + + + +

+
+

Provides the expected value. This will return an array if +multiple arguments were passed to the matcher; otherwise it +will return a single value.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+319
+320
+321
+322
+323
+324
+325
+
+
# File 'lib/rspec/matchers/dsl.rb', line 319
+
+def expected
+  if expected_as_array.size == 1
+    expected_as_array[0]
+  else
+    expected_as_array
+  end
+end
+
+
+ +
+

+ + - (Object) inspect + + + + + +

+
+

Adds the name (rather than a cryptic hex number) +so we can identify an instance of +the matcher in error messages (e.g. for NoMethodError)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+336
+337
+338
+
+
# File 'lib/rspec/matchers/dsl.rb', line 336
+
+def inspect
+  "#<#{self.class.name} #{name}>"
+end
+
+
+ +
+

+ + - (Boolean) respond_to?(method, include_private = false) + + + + + +

+
+

Indicates that this matcher responds to messages +from the @matcher_execution_context as well.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+350
+351
+352
+
+
# File 'lib/rspec/matchers/dsl.rb', line 350
+
+def respond_to?(method, include_private=false)
+  super || @matcher_execution_context.respond_to?(method, include_private)
+end
+
+
+ +
+

+ + - (Boolean) respond_to_missing?(method, include_private = false) + + + + + +

+
+

Indicates that this matcher responds to messages +from the @matcher_execution_context as well. +Also, supports getting a method object for such methods.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+344
+345
+346
+
+
# File 'lib/rspec/matchers/dsl.rb', line 344
+
+def respond_to_missing?(method, include_private=false)
+  super || @matcher_execution_context.respond_to?(method, include_private)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Pretty.html b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Pretty.html new file mode 100644 index 000000000..3cb030951 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/RSpec/Matchers/Pretty.html @@ -0,0 +1,446 @@ + + + + + + Module: RSpec::Matchers::Pretty + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Matchers::Pretty + + + Private +

+ +
+ + + + + + + +
Included in:
+
BuiltIn::BaseMatcher, DSL::Matcher
+ + + +
Defined in:
+
lib/rspec/matchers/pretty.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+

Contains logic to facilitate converting ruby symbols and +objects to english phrases.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (Object) name + + + + + + + + + + + private + + +

    Provides a name for the matcher.

    +
    + +
  • + + +
  • + + + - (Object) to_sentence(words) + + + + + + + + + + + private + + +

    Converts a collection of objects into an english expression.

    +
    + +
  • + + +
  • + + + - (Object) to_word(item) + + + + + + + + + + + private + + +

    Converts the given item to string suitable for use in a list expression.

    +
    + +
  • + + +
+ + + + +
+

Class Method Details

+ + +
+

+ + + (Object) split_words(sym) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Converts a symbol into an english expression.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lib/rspec/matchers/pretty.rb', line 9
+
+def split_words(sym)
+  sym.to_s.gsub(/_/, ' ')
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Object) name + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Provides a name for the matcher.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lib/rspec/matchers/pretty.rb', line 45
+
+def name
+  defined?(@name) ? @name : underscore(self.class.name.split("::").last)
+end
+
+
+ +
+

+ + - (Object) to_sentence(words) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Converts a collection of objects into an english expression.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'lib/rspec/matchers/pretty.rb', line 16
+
+def to_sentence(words)
+  return " #{words.inspect}" if !words || Struct === words
+  words = Array(words).map { |w| to_word(w) }
+  case words.length
+  when 0
+    ""
+  when 1
+    " #{words[0]}"
+  when 2
+    " #{words[0]} and #{words[1]}"
+  else
+    " #{words[0...-1].join(', ')}, and #{words[-1]}"
+  end
+end
+
+
+ +
+

+ + - (Object) to_word(item) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+

Converts the given item to string suitable for use in a list expression.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/rspec/matchers/pretty.rb', line 33
+
+def to_word(item)
+  is_matcher_with_description?(item) ? item.description : item.inspect
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/_index.html b/source/documentation/3.0/rspec-expectations/_index.html new file mode 100644 index 000000000..479bcc3bd --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/_index.html @@ -0,0 +1,634 @@ + + + + + + Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Documentation by YARD 0.8.7.4

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + +
    +
  • A
  • +
      + +
    • + AliasedMatcher + + (RSpec::Matchers) + +
    • + +
    • + All + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + And + + (RSpec::Matchers::BuiltIn::Compound) + +
    • + +
    +
+ + +
    +
  • B
  • +
      + +
    • + BaseMatcher + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BasicObject + +
    • + +
    • + Be + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeAKindOf + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeAnInstanceOf + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeBetween + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeComparedTo + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeFalsey + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeNil + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BePredicate + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeTruthy + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BeWithin + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + BuiltIn + + (RSpec::Matchers) + +
    • + +
    +
+ + + + + + + + +
    +
  • E
  • +
      + +
    • + EndWith + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Eq + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Eql + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Equal + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Exist + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + ExistenceTest + + (RSpec::Matchers::BuiltIn::Exist) + +
    • + +
    • + ExpectationTarget + + (RSpec::Expectations) + +
    • + +
    • + Expectations + + (RSpec) + +
    • + +
    +
+ + +
    +
  • H
  • +
      + +
    • + Has + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + +
    +
  • I
  • +
      + +
    • + Include + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + +
+ + +
    +
  • M
  • +
      + +
    • + Macros + + (RSpec::Matchers::DSL) + +
    • + +
    • + Match + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Matcher + + (RSpec::Matchers::DSL) + +
    • + +
    • + Matchers + + (RSpec) + +
    • + +
    +
+ + +
    +
  • O
  • +
      + +
    • + OperatorMatcher + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + Or + + (RSpec::Matchers::BuiltIn::Compound) + +
    • + +
    • + Output + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + +
    +
  • P
  • +
      + +
    • + Pretty + + (RSpec::Matchers) + +
    • + +
    +
+ + +
    +
  • R
  • +
      + +
    • + RSpec + +
    • + +
    • + RaiseError + + (RSpec::Matchers::BuiltIn) + +
    • + +
    • + RespondTo + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + + + + +
    +
  • T
  • +
      + +
    • + ThrowSymbol + + (RSpec::Matchers::BuiltIn) + +
    • + +
    +
+ + + + +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/class_list.html b/source/documentation/3.0/rspec-expectations/class_list.html new file mode 100644 index 000000000..c99055ac7 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/class_list.html @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + Class List + + + + +
+

Class List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-expectations/file.Changelog.html b/source/documentation/3.0/rspec-expectations/file.Changelog.html new file mode 100644 index 000000000..b0b3e65ca --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/file.Changelog.html @@ -0,0 +1,1030 @@ + + + + + + File: Changelog + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

3.0.4 / 2014-08-14

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix start_with and end_with so that they work properly with +structs. (Myron Marston, #620)
  • +
  • Fix failure message generation so that structs are printed properly +in failures. Previously failure messages would represent them as +an array. (Myron Marston, #620)
  • +
  • Fix composable matcher support so that it does not wrongly treat +structs as arrays. (Myron Marston, #620)
  • +
+ +

3.0.3 / 2014-07-21

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix issue with detection of generic operator matchers so they work +correctly when undefined. (Myron Marston, #597)
  • +
  • Don't inadvertently define BasicObject in 1.8.7. (Chris Griego, #603)
  • +
  • Fix include matcher so that it fails gracefully when matched against +an object that does not respond to include?. (Myron Marston, #607)
  • +
+ +

3.0.2 / 2014-06-19

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix regression in contain_exactly (AKA match_array) that caused it +to wrongly pass when the expected array was empty. (Myron Marston, #581)
  • +
  • Provide a better error message when you use the change(obj, :msg) +form of the change matcher but forget the message argument. (Alex +Sunderland, #585)
  • +
  • Make the contain_exactly matcher work with arrays that contain hashes in +arbitrary ordering. (Sam Phippen, #578)
  • +
+ +

3.0.1 / 2014-06-12

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Add a missing require that would cause the respond_to matcher to +fail when used in a project where the rest of RSpec (e.g. core and +expecatations) weren't being used. (Myron Marston, #566)
  • +
  • Structs are no longer treated as arrays when diffed. (Jon Rowe, #576)
  • +
+ +

3.0.0 / 2014-06-01

+ +

Full Changelog

+ +

No code changes. Just taking it out of pre-release.

+ +

3.0.0.rc1 / 2014-05-18

+ +

Full Changelog

+ +

Breaking Changes for 3.0.0:

+ +
    +
  • Remove matcher_execution_context attribute from DSL-defined +custom matchers. (Myron Marston)
  • +
  • Remove RSpec::Matchers::Pretty#_pretty_print. (Myron Marston)
  • +
  • Remove RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston)
  • +
  • Rename RSpec::Matchers::Configuration constant to +RSpec::Expectations::Configuration. (Myron Marston)
  • +
  • Prevent have_xyz predicate matchers using private methods. +(Adrian Gonzalez)
  • +
  • Block matchers must now implement supports_block_expectations?. +(Myron Marston)
  • +
  • Stop supporting require 'rspec-expectations'. +Use require 'rspec/expectations' instead. (Myron Marston)
  • +
+ +

Bug Fixes:

+ +
    +
  • Fix NoMethodError triggered by beta2 when YARD was loaded in +the test environment. (Myron Marston)
  • +
  • Fix be_xyz matcher to accept a do...end block. (Myron Marston)
  • +
  • Fix composable matcher failure message generation logic +so that it does not blow up when given $stdout or $stderr. +(Myron Marston)
  • +
  • Fix change matcher to work properly with IO objects. +(Myron Marston)
  • +
  • Fix exist matcher so that it can be used in composed matcher +expressions involving objects that do not implement exist? or +exists?. (Daniel Fone)
  • +
  • Fix composable matcher match logic so that it clones matchers +before using them in order to work properly with matchers +that use internal memoization based on a given actual value. +(Myron Marston)
  • +
  • Fix be_xyz and has_xyz predicate matchers so that they can +be used in composed matcher expressions involving objects that +do not implement the predicate method. (Daniel Fone)
  • +
+ +

Enhancements:

+ +
    +
  • Document the remaining public APIs. rspec-expectations now has 100% of +the public API documented and will remain that way (as new undocumented +methods will fail the build). (Myron Marston)
  • +
  • Improve the formatting of BigDecimal objects in eq matcher failure +messages. (Daniel Fone)
  • +
  • Improve the failure message for be_xyz predicate matchers so +that it includes the inspect output of the receiver. +(Erik Michaels-Ober, Sam Phippen)
  • +
  • Add all matcher, to allow you to specify that a given matcher +matches all elements in a collection: +expect([1, 3, 5]).to all( be_odd ). (Adam Farhi)
  • +
  • Add boolean aliases (&/|) for compound operators (and/or). (Adam Farhi)
  • +
  • Give users a clear error when they wrongly use a value matcher +in a block expectation expression (e.g. expect { 3 }.to eq(3)) +or vice versa. (Myron Marston)
  • +
+ +

3.0.0.beta2 / 2014-02-17

+ +

Full Changelog

+ +

Breaking Changes for 3.0.0:

+ +
    +
  • Remove deprecated support for accessing the RSpec constant using +Rspec or Spec. (Myron Marston)
  • +
  • Remove deprecated RSpec::Expectations.differ=. (Myron Marston)
  • +
  • Remove support for deprecated expect(...).should. (Myron Marston)
  • +
  • Explicitly disallow expect { }.not_to change { } with by, +by_at_least, by_at_most or to. These have never been supported +but did not raise explicit errors. (Myron Marston)
  • +
  • Provide === rather than == as an alias of matches? for +all matchers. The semantics of === are closer to an RSpec +matcher than ==. (Myron Marston)
  • +
  • Remove deprecated RSpec::Matchers::OperatorMatcher constant. +(Myron Marston)
  • +
  • Make RSpec::Expectations::ExpectationNotMetError subclass +Exception rather than StandardError so they can bypass +a bare rescue in end-user code (e.g. when an expectation is +set from within a rspec-mocks stub implementation). (Myron Marston)
  • +
  • Remove Test::Unit and Minitest 4.x integration. (Myron Marston)
  • +
+ +

Enhancements:

+ +
    +
  • Simplify the failure message of the be matcher when matching against: +true, false and nil. (Sam Phippen)
  • +
  • Update matcher protocol and custom matcher DSL to better align +with the newer expect syntax. If you want your matchers to +maintain compatibility with multiple versions of RSpec, you can +alias the new names to the old. (Myron Marston) + +
      +
    • failure_message_for_should => failure_message
    • +
    • failure_message_for_should_not => failure_message_when_negated
    • +
    • match_for_should => match
    • +
    • match_for_should_not => match_when_negated
    • +
  • +
  • Improve generated descriptions from change matcher. (Myron Marston)
  • +
  • Add support for compound matcher expressions using and and or. +Simply chain them off of any existing matcher to create an expression +like expect(alphabet).to start_with("a").and end_with("z"). +(Eloy Espinaco)
  • +
  • Add contain_exactly as a less ambiguous version of match_array. +Note that it expects the expected array to be splatted as +individual args: expect(array).to contain_exactly(1, 2) is +the same as expect(array).to match_array([1, 2]). (Myron Marston)
  • +
  • Update contain_exactly/match_array so that it can match against +other non-array collections (such as a Set). (Myron Marston)
  • +
  • Update built-in matchers so that they can accept matchers as arguments +to allow you to compose matchers in arbitrary ways. (Myron Marston)
  • +
  • Add RSpec::Matchers::Composable mixin that can be used to make +a custom matcher composable as well. Note that custom matchers +defined via RSpec::Matchers.define already have this. (Myron +Marston)
  • +
  • Define noun-phrase aliases for built-in matchers, which can be +used when creating composed matcher expressions that read better +and provide better failure messages. (Myron Marston)
  • +
  • Add RSpec::Machers.alias_matcher so users can define their own +matcher aliases. The description of the matcher will reflect the +alternate matcher name. (Myron Marston)
  • +
  • Add explicit be_between matcher. be_between has worked for a +long time as a dynamic predicate matcher, but the failure message +was suboptimal. The new matcher provides a much better failure +message. (Erik Michaels-Ober)
  • +
  • Enhance the be_between matcher to allow for inclusive or exclusive +comparison (e.g. inclusive of min/max or exclusive of min/max). +(Pedro Gimenez)
  • +
  • Make failure message for not_to be #{operator} less confusing by +only saying it's confusing when comparison operators are used. +(Prathamesh Sonpatki)
  • +
  • Improve failure message of eq matcher when Time or DateTime +objects are used so that the full sub-second precision is included. +(Thomas Holmes, Jeff Wallace)
  • +
  • Add output matcher for expecting that a block outputs to_stdout +or to_stderr. (Luca Pette, Matthias Günther)
  • +
  • Forward a provided block on to the has_xyz? method call when +the have_xyz matcher is used. (Damian Galarza)
  • +
  • Provide integration with Minitest 5.x. Require +rspec/expectations/minitest_integration after loading minitest +to use rspec-expectations with minitest. (Myron Marston)
  • +
+ +

Bug Fixes:

+ +
    +
  • Fix wrong matcher descriptions with falsey expected value (yujinakayama)
  • +
  • Fix expect { }.not_to change { }.from(x) so that the matcher only +passes if the starting value is x. (Tyler Rick, Myron Marston)
  • +
  • Fix hash diffing, so that it colorizes properly and doesn't consider trailing +commas when performing the diff. (Jared Norman)
  • +
  • Fix built-in matchers to fail normally rather than raising +ArgumentError when given an object of the wrong type to match +against, so that they work well in composite matcher expressions like +expect([1.51, "foo"]).to include(a_string_matching(/foo/), a_value_within(0.1).of(1.5)). +(Myron Marston)
  • +
+ +

Deprecations:

+ +
    +
  • Retain support for RSpec 2 matcher protocol (e.g. for matchers +in 3rd party extension gems like shoulda), but it will print +a deprecation warning. (Myron Marston)
  • +
+ +

3.0.0.beta1 / 2013-11-07

+ +

Full Changelog

+ +

Breaking Changes for 3.0.0:

+ +
    +
  • Remove explicit support for 1.8.6. (Jon Rowe)
  • +
  • Remove the deprecated be_close matcher, preferring be_within instead. +(Sam Phippen)
  • +
  • Remove the deprecated have, have_at_least and have_at_most matchers. +You can continue using those matchers through https://github.com/rspec/rspec-collection_matchers, +or you can rewrite your expectations with something like +expect(your_object.size).to eq(num). (Hugo Baraúna)
  • +
  • Rename be_true and be_false to be_truthy and be_falsey. (Sam Phippen)
  • +
  • Make expect { }.to_not raise_error(SomeSpecificClass, message), + expect { }.to_not raise_error(SomeSpecificClass) and + expect { }.to_not raise_error(message) invalid, since they are prone +to hiding failures. Instead, use expect { }.to_not raise_error (with no +args). (Sam Phippen)
  • +
  • Within RSpec::Matchers.define blocks, helper methods made available +either via def self.helper or extend HelperModule are no longer +available to the match block (or any of the others). Instead +include your helper module and define the helper method as an +instance method. (Myron Marston)
  • +
  • Force upgrading Diff::LCS for encoding compatability with diffs. (Jon Rowe)
  • +
+ +

Enhancements:

+ +
    +
  • Support do..end style block with raise_error matcher. (Yuji Nakayama)
  • +
  • Rewrote custom matcher DSL to simplify its implementation and solve a +few issues. (Myron Marston)
  • +
  • Allow early return from within custom matcher DSL blocks. (Myron +Marston)
  • +
  • The custom matcher DSL's chain can now accept a block. (Myron +Marston)
  • +
  • Support setting an expectation on a raise_error matcher via a chained +with_message method call. (Sam Phippen)
  • +
+ +

Bug Fixes:

+ +
    +
  • Allow include and match matchers to be used from within a +DSL-defined custom matcher's match block. (Myron Marston)
  • +
  • Correct encoding error message on diff failure (Jon Rowe)
  • +
+ +

Deprecations:

+ +
    +
  • Using the old :should syntax without explicitly configuring it is deprecated. +It will continue to work but will emit a deprecation warning in RSpec 3 if +you do not explicitly enable it. (Sam Phippen)
  • +
+ +

2.99.2 / 2014-07-21

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix regression in Expectations#method_handle_for where proxy objects +with method delegated would wrongly not return a method handle. +(Jon Rowe, #594)
  • +
  • Fix issue with detection of generic operator matchers so they work +correctly when undefined. (Myron Marston, #597)
  • +
+ +

2.99.1 / 2014-06-19

+ +

Full Changelog

+ +

Bug Fixes:

+ +
    +
  • Fix typo in custom matcher expected deprecation warning -- it's +expected_as_array, not expected_array. (Frederick Cheung, #562)
  • +
+ +

2.99.0 / 2014-06-01

+ +

Full Changelog

+ +

Enhancements:

+ +
    +
  • Special case deprecation message for errors_on with rspec-rails to be more useful. +(Aaron Kromer)
  • +
+ +

2.99.0.rc1 / 2014-05-18

+ +

Full Changelog

+ +

Deprecations:

+ +
    +
  • Deprecate matcher_execution_context attribute on DSL-defined +custom matchers. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::Pretty#_pretty_print. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::Pretty#expected_to_sentence. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::Configuration in favor of +RSpec::Expectations::Configuration. (Myron Marston)
  • +
  • Deprecate be_xyz predicate matcher on an object that doesn't respond to +xyz? or xyzs?. (Daniel Fone)
  • +
  • Deprecate have_xyz matcher on an object that doesn't respond to has_xyz?. +(Daniel Fone)
  • +
  • Deprecate have_xyz matcher on an object that has a private method has_xyz?. +(Jon Rowe)
  • +
  • Issue a deprecation warning when a block expectation expression is +used with a matcher that doesn't explicitly support block expectations +via supports_block_expectations?. (Myron Marston)
  • +
  • Deprecate require 'rspec-expectations'. Use +require 'rspec/expectations' instead. (Myron Marston)
  • +
+ +

2.99.0.beta2 / 2014-02-17

+ +

Full Changelog

+ +

Deprecations:

+ +
    +
  • Deprecate chaining by, by_at_least, by_at_most or to off of +expect { }.not_to change { }. The docs have always said these are +not supported for the negative form but now they explicitly raise +errors in RSpec 3. (Myron Marston)
  • +
  • Change the semantics of expect { }.not_to change { x }.from(y). +In RSpec 2.x, this expectation would only fail if x started with +the value of y and changed. If it started with a different value +and changed, it would pass. In RSpec 3, it will pass only if the +value starts at y and it does not change. (Myron Marston)
  • +
  • Deprecate matcher == value as an alias for matcher.matches?(value), +in favor of matcher === value. (Myron Marston)
  • +
  • Deprecate RSpec::Matchers::OperatorMatcher in favor of +RSpec::Matchers::BuiltIn::OperatorMatcher. (Myron Marston)
  • +
  • Deprecate auto-integration with Test::Unit and minitest. +Instead, include RSpec::Matchers in the appropriate test case +base class yourself. (Myron Marston)
  • +
  • Deprecate treating #expected on a DSL-generated custom matcher +as an array when only 1 argument is passed to the matcher method. +In RSpec 3 it will be the single value in order to make diffs +work properly. (Jon Rowe)
  • +
+ +

2.99.0.beta1 / 2013-11-07

+ +

Full Changelog

+ +

Deprecations

+ +
    +
  • Deprecate have, have_at_least and have_at_most. You can continue using those +matchers through https://github.com/rspec/rspec-collection_matchers, or +you can rewrite your expectations with something like +expect(your_object.size).to eq(num). (Hugo Baraúna)
  • +
  • Deprecate be_xyz predicate matcher when xyz? is a private method. +(Jon Rowe)
  • +
  • Deprecate be_true/be_false in favour of be_truthy/be_falsey +(for Ruby's conditional semantics) or be true/be false +(for exact equality). (Sam Phippen)
  • +
  • Deprecate calling helper methods from a custom matcher with the wrong +scope. (Myron Marston) + +
      +
    • def self.foo / extend Helper can be used to add macro methods +(e.g. methods that call the custom matcher DSL methods), but should +not be used to define helper methods called from within the DSL +blocks.
    • +
    • def foo / include Helper is the opposite: it's for helper methods +callable from within a DSL block, but not for defining macros.
    • +
    • RSpec 2.x allowed helper methods defined either way to be used for +either purpose, but RSpec 3.0 will not.
    • +
  • +
+ +

2.14.5 / 2014-02-01

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix wrong matcher descriptions with falsey expected value +(yujinakayama)
  • +
+ +

2.14.4 / 2013-11-06

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Make the match matcher produce a diff output. (Jon Rowe, Ben Moss)
  • +
  • Choose encoding for diff's more intelligently, and when all else fails fall +back to default internal encoding with replacing characters. (Jon Rowe)
  • +
+ +

2.14.3 / 2013-09-22

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix operator matchers (should syntax) when method is redefined on target. +(Brandon Turner)
  • +
  • Fix diffing of hashes with object based keys. (Jon Rowe)
  • +
  • Fix operator matchers (should syntax) when operator is defined via +method_missing (Jon Rowe)
  • +
+ +

2.14.2 / 2013-08-14

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix be_<predicate> matcher to not support operator chaining like the +be matcher does (e.g. be == 5). This led to some odd behaviors +since be_<predicate> == anything returned a BeComparedTo matcher +and was thus always truthy. This was a consequence of the implementation +(e.g. subclassing the basic Be matcher) and was not intended behavior. +(Myron Marston).
  • +
  • Fix change matcher to compare using == in addition to ===. This +is important for an expression like: +expect {}.to change { a.class }.from(ClassA).to(ClassB) because +SomeClass === SomeClass returns false. (Myron Marston)
  • +
+ +

2.14.1 / 2013-08-08

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Ensure diff output uses the same encoding as the encoding of +the string being diff'd to prevent Encoding::UndefinedConversionError +errors (Jon Rowe).
  • +
+ +

2.14.0 / 2013-07-06

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Values that are not matchers use #inspect, rather than #description for +documentation output (Andy Lindeman, Sam Phippen).
  • +
  • Make expect(a).to be_within(x).percent_of(y) work with negative y +(Katsuhiko Nishimra).
  • +
  • Make the be_predicate matcher work as expected used with expect{...}.to +change... (Sam Phippen).
  • +
+ +

2.14.0.rc1 / 2013-05-27

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Enhance yield_control so that you can specify an exact or relative +number of times: expect { }.to yield_control.exactly(3).times, +expect { }.to yield_control.at_least(2).times, etc (Bartek +Borkowski).
  • +
  • Make the differ that is used when an expectation fails better handle arrays +by splitting each element of the array onto its own line. (Sam Phippen)
  • +
  • Accept duck-typed strings that respond to :to_str as expectation messages. +(Toby Ovod-Everett)
  • +
+ +

Bug fixes

+ +
    +
  • Fix differ to not raise errors when dealing with differently-encoded +strings (Jon Rowe).
  • +
  • Fix expect(something).to be_within(x).percent_of(y) where x and y are both +integers (Sam Phippen).
  • +
  • Fix have matcher to handle the fact that on ruby 2.0, +Enumerator#size may return nil (Kenta Murata).
  • +
  • Fix expect { raise s }.to raise_error(s) where s is an error instance +on ruby 2.0 (Sam Phippen).
  • +
  • Fix expect(object).to raise_error passing. This now warns the user and +fails the spec (tomykaira).
  • +
+ +

Deprecations

+ +
    +
  • Deprecate expect { }.not_to raise_error(SpecificErrorClass) or +expect { }.not_to raise_error("some specific message"). Using +these was prone to hiding failures as they would allow any other +error to pass. (Sam Phippen and David Chelimsky)
  • +
+ +

2.13.0 / 2013-02-23

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Add support for percent deltas to be_within matcher: +expect(value).to be_within(10).percent_of(expected) +(Myron Marston).
  • +
  • Add support to include matcher to allow it to be given a list +of matchers as the expecteds to match against (Luke Redpath).
  • +
+ +

Bug fixes

+ +
    +
  • Fix change matcher so that it dups strings in order to handle +mutated strings (Myron Marston).
  • +
  • Fix should be =~ /some regex/ / expect(...).to be =~ /some regex/. +Previously, these either failed with a confusing undefined method +matches?' for false:FalseClass error or were no-ops that didn't +actually verify anything (Myron Marston).
  • +
  • Add compatibility for diff-lcs 1.2 and relax the version +constraint (Peter Goldstein).
  • +
  • Fix DSL-generated matchers to allow multiple instances of the +same matcher in the same example to have different description +and failure messages based on the expected value (Myron Marston).
  • +
  • Prevent undefined method #split for Array error when dumping +the diff of an array of multiline strings (Myron Marston).
  • +
  • Don't blow up when comparing strings that are in an encoding +that is not ASCII compatible (Myron Marston).
  • +
  • Remove confusing "Check the implementation of #==" message +printed for empty diffs (Myron Marston).
  • +
+ +

2.12.1 / 2012-12-15

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Improve the failure message for an expression like +{}.should =~ {}. (Myron Marston and Andy Lindeman)
  • +
  • Provide a match_regex alias so that custom matchers +built using the matcher DSL can use it (since match +is a different method in that context). +(Steven Harman)
  • +
+ +

2.12.0 / 2012-11-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Colorize diffs if the --color option is configured. (Alex Coplan)
  • +
  • Include backtraces in unexpected errors handled by raise_error +matcher (Myron Marston)
  • +
  • Print a warning when users accidentally pass a non-string argument +as an expectation message (Sam Phippen)
  • +
  • =~ and match_array matchers output a more useful error message when +the actual value is not an array (or an object that responds to #to_ary) +(Sam Phippen)
  • +
+ +

Bug fixes

+ +
    +
  • Fix include matcher so that expect({}).to include(:a => nil) +fails as it should (Sam Phippen).
  • +
  • Fix be_an_instance_of matcher so that Class#to_s is used in the +description rather than Class#inspect, since some classes (like +ActiveRecord::Base) define a long, verbose #inspect. +(Tom Stuart)
  • +
+ +

2.11.3 / 2012-09-04

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Fix (and deprecate) expect { }.should syntax so that it works even +though it was never a documented or intended syntax. It worked as a +consequence of the implementation of expect in RSpec 2.10 and +earlier. (Myron Marston)
  • +
  • Ensure #== is defined on built in matchers so that they can be composed. +For example:

    + +

    expect { + user.emailed! +}.to change { user.last_emailed_at }.to be_within(1.second).of(Time.zone.now)

  • +
+ +

2.11.2 / 2012-07-25

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Define should and should_not on Object rather than BasicObject +on MacRuby. On MacRuby, BasicObject is defined but is not the root +of the object hierarchy. (Gabriel Gilder)
  • +
+ +

2.11.1 / 2012-07-08

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Constrain actual in be_within matcher to values that respond to - instead +of requiring a specific type. + +
      +
    • Time, for example, is a legit alternative.
    • +
  • +
+ +

2.11.0 / 2012-07-07

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Expand expect syntax so that it supports expections on bare values +in addition to blocks (Myron Marston).
  • +
  • Add configuration options to control available expectation syntaxes +(Myron Marston): + +
      +
    • RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :expect }
    • +
    • RSpec.configuration.expect_with(:rspec) { |c| c.syntax = :should }
    • +
    • RSpec.configuration.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
    • +
    • RSpec.configuration.add_should_and_should_not_to Delegator
    • +
  • +
+ +

Bug fixes

+ +
    +
  • Allow only Numeric values to be the "actual" in the be_within matcher. +This prevents confusing error messages. (Su Zhang @zhangsu)
  • +
  • Define should and should_not on BasicObject rather than Kernel +on 1.9. This makes should and should_not work properly with +BasicObject-subclassed proxy objects like Delegator. (Myron +Marston)
  • +
+ +

2.10.0 / 2012-05-03

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Add new start_with and end_with matchers (Jeremy Wadsack)
  • +
  • Add new matchers for specifying yields (Myron Marston): + +
      +
    • expect {...}.to yield_control
    • +
    • expect {...}.to yield_with_args(1, 2, 3)
    • +
    • expect {...}.to yield_with_no_args
    • +
    • expect {...}.to yield_successive_args(1, 2, 3)
    • +
  • +
  • match_unless_raises takes multiple exception args
  • +
+ +

Bug fixes

+ +
    +
  • Fix be_within matcher to be inclusive of delta.
  • +
  • Fix message-specific specs to pass on Rubinius (John Firebaugh)
  • +
+ +

2.9.1 / 2012-04-03

+ +

Full Changelog

+ +

Bug fixes

+ +
    +
  • Provide a helpful message if the diff between two objects is empty.
  • +
  • Fix bug diffing single strings with multiline strings.
  • +
  • Fix for error with using custom matchers inside other custom matchers +(mirasrael)
  • +
  • Fix using execution context methods in nested DSL matchers (mirasrael)
  • +
+ +

2.9.0 / 2012-03-17

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Move built-in matcher classes to RSpec::Matchers::BuiltIn to reduce pollution +of RSpec::Matchers (which is included in every example).
  • +
  • Autoload files with matcher classes to improve load time.
  • +
+ +

Bug fixes

+ +
    +
  • Align respond_to? and method_missing in DSL-defined matchers.
  • +
  • Clear out user-defined instance variables between invocations of DSL-defined +matchers.
  • +
  • Dup the instance of a DSL generated matcher so its state is not changed by +subsequent invocations.
  • +
  • Treat expected args consistently across positive and negative expectations +(thanks to Ralf Kistner for the heads up)
  • +
+ +

2.8.0 / 2012-01-04

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Better diff output for Hash (Philippe Creux)
  • +
  • Eliminate Ruby warnings (Olek Janiszewski)
  • +
+ +

2.8.0.rc2 / 2011-12-19

+ +

Full Changelog

+ +

No changes for this release. Just releasing with the other rspec gems.

+ +

2.8.0.rc1 / 2011-11-06

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Use classes for the built-in matchers (they're faster).
  • +
  • Eliminate Ruby warnings (Matijs van Zuijlen)
  • +
+ +

2.7.0 / 2011-10-16

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • HaveMatcher converts argument using to_i (Alex Bepple & Pat Maddox)
  • +
  • Improved failure message for the have_xxx matcher (Myron Marston)
  • +
  • HaveMatcher supports count (Matthew Bellantoni)
  • +
  • Change matcher dups Enumerable before the action, supporting custom +Enumerable types like CollectionProxy in Rails (David Chelimsky)
  • +
+ +

Bug fixes

+ +
    +
  • Fix typo in have(n).xyz documentation (Jean Boussier)
  • +
  • fix safe_sort for ruby 1.9.2 (Kernel now defines <=> for Object) (Peter +van Hardenberg)
  • +
+ +

2.6.0 / 2011-05-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • change matcher accepts regexps (Robert Davis)
  • +
  • better descriptions for have_xxx matchers (Magnus Bergmark)
  • +
  • range.should cover(*values) (Anders Furseth)
  • +
+ +

Bug fixes

+ +
    +
  • Removed non-ascii characters that were choking rcov (Geoffrey Byers)
  • +
  • change matcher dups arrays and hashes so their before/after states can be +compared correctly.
  • +
  • Fix the order of inclusion of RSpec::Matchers in Test::Unit::TestCase and +MiniTest::Unit::TestCase to prevent a SystemStackError (Myron Marston)
  • +
+ +

2.5.0 / 2011-02-05

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • should exist works with exist? or exists? (Myron Marston)
  • +
  • expect { ... }.not_to do_something (in addition to to_not)
  • +
+ +

Documentation

+ +
    +
  • improved docs for raise_error matcher (James Almond)
  • +
+ +

2.4.0 / 2011-01-02

+ +

Full Changelog

+ +

No functional changes in this release, which was made to align with the +rspec-core-2.4.0 release.

+ +

Enhancements

+ +
    +
  • improved RDoc for change matcher (Jo Liss)
  • +
+ +

2.3.0 / 2010-12-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • diff strings when include matcher fails (Mike Sassak)
  • +
+ +

2.2.0 / 2010-11-28

+ +

Full Changelog

+ +

2.1.0 / 2010-11-07

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • be_within(delta).of(expected) matcher (Myron Marston)
  • +
  • Lots of new Cucumber features (Myron Marston)
  • +
  • Raise error if you try should != expected on Ruby-1.9 (Myron Marston)
  • +
  • Improved failure messages from throw_symbol (Myron Marston)
  • +
+ +

Bug fixes

+ +
    +
  • Eliminate hard dependency on RSpec::Core (Myron Marston)
  • +
  • have_matcher - use pluralize only when ActiveSupport inflections are indeed +defined (Josep M Bach)
  • +
  • throw_symbol matcher no longer swallows exceptions (Myron Marston)
  • +
  • fix matcher chaining to avoid name collisions (Myron Marston)
  • +
+ +

2.0.0 / 2010-10-10

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • Add match_for_should_not method to matcher DSL (Myron Marston)
  • +
+ +

Bug fixes

+ +
    +
  • respond_to matcher works correctly with should_not with multiple methods +(Myron Marston)
  • +
  • include matcher works correctly with should_not with multiple values +(Myron Marston)
  • +
+ +

2.0.0.rc / 2010-10-05

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • require 'rspec/expectations' in a T::U or MiniUnit suite (Josep M. Bach)
  • +
+ +

Bug fixes

+ +
    +
  • change by 0 passes/fails correctly (Len Smith)
  • +
  • Add description to satisfy matcher
  • +
+ +

2.0.0.beta.22 / 2010-09-12

+ +

Full Changelog

+ +

Enhancements

+ +
    +
  • diffing improvements + +
      +
    • diff multiline strings
    • +
    • don't diff single line strings
    • +
    • don't diff numbers (silly)
    • +
    • diff regexp + multiline string
    • +
  • +
+ +

Bug fixes + * should[_not] change now handles boolean values correctly

+
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/file.License.html b/source/documentation/3.0/rspec-expectations/file.License.html new file mode 100644 index 000000000..9fa7c14a6 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/file.License.html @@ -0,0 +1,73 @@ + + + + + + File: License + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +
(The MIT License)

Copyright (c) 2012 David Chelimsky, Myron Marston
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
Copyright (c) 2005 Steven Baker

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/file.README.html b/source/documentation/3.0/rspec-expectations/file.README.html new file mode 100644 index 000000000..f42ae98fb --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/file.README.html @@ -0,0 +1,338 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

RSpec Expectations Build Status Code Climate

+ +

RSpec::Expectations lets you express expected outcomes on an object in an +example.

+ +
expect(.balance).to eq(Money.new(37.42, :USD))
+
+ +

Install

+ +

If you want to use rspec-expectations with rspec, just install the rspec gem +and RubyGems will also install rspec-expectations for you (along with +rspec-core and rspec-mocks):

+ +
gem install rspec
+
+ +

If you want to use rspec-expectations with another tool, like Test::Unit, +Minitest, or Cucumber, you can install it directly:

+ +
gem install rspec-expectations
+
+ +

Basic usage

+ +

Here's an example using rspec-core:

+ +
RSpec.describe Order do
+  it "sums the prices of the items in its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe and it methods come from rspec-core. The Order, LineItem, Item and Money classes would be from your code. The last line of the example +expresses an expected outcome. If order.total == Money.new(5.55, :USD), then +the example passes. If not, it fails with a message like:

+ +
expected: #<Money @value=5.55 @currency=:USD>
+     got: #<Money @value=1.11 @currency=:USD>
+
+ +

Built-in matchers

+ +

Equivalence

+ +
expect(actual).to eq(expected)  # passes if actual == expected
+expect(actual).to eql(expected) # passes if actual.eql?(expected)
+
+ +

Note: The new expect syntax no longer supports the == matcher.

+ +

Identity

+ +
expect(actual).to be(expected)    # passes if actual.equal?(expected)
+expect(actual).to equal(expected) # passes if actual.equal?(expected)
+
+ +

Comparisons

+ +
expect(actual).to be >  expected
+expect(actual).to be >= expected
+expect(actual).to be <= expected
+expect(actual).to be <  expected
+expect(actual).to be_within(delta).of(expected)
+
+ +

Regular expressions

+ +
expect(actual).to match(/expression/)
+
+ +

Note: The new expect syntax no longer supports the =~ matcher.

+ +

Types/classes

+ +
expect(actual).to be_an_instance_of(expected) # passes if actual.class == expected
+expect(actual).to be_a(expected)              # passes if actual.is_a?(expected)
+expect(actual).to be_an(expected)             # an alias for be_a
+expect(actual).to be_a_kind_of(expected)      # another alias
+
+ +

Truthiness

+ +
expect(actual).to be_truthy # passes if actual is truthy (not nil or false)
+expect(actual).to be true   # passes if actual == true
+expect(actual).to be_falsy  # passes if actual is falsy (nil or false)
+expect(actual).to be false  # passes if actual == false
+expect(actual).to be_nil    # passes if actual is nil
+
+ +

Expecting errors

+ +
expect { ... }.to raise_error
+expect { ... }.to raise_error(ErrorClass)
+expect { ... }.to raise_error("message")
+expect { ... }.to raise_error(ErrorClass, "message")
+
+ +

Expecting throws

+ +
expect { ... }.to throw_symbol
+expect { ... }.to throw_symbol(:symbol)
+expect { ... }.to throw_symbol(:symbol, 'value')
+
+ +

Yielding

+ +
expect { |b| 5.tap(&b) }.to yield_control # passes regardless of yielded args
+
+expect { |b| yield_if_true(true, &b) }.to yield_with_no_args # passes only if no args are yielded
+
+expect { |b| 5.tap(&b) }.to yield_with_args(5)
+expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum)
+expect { |b| "a string".tap(&b) }.to yield_with_args(/str/)
+
+expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
+expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2])
+
+ +

Predicate matchers

+ +
expect(actual).to be_xxx         # passes if actual.xxx?
+expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
+
+ +

Ranges (Ruby >= 1.9 only)

+ +
expect(1..10).to cover(3)
+
+ +

Collection membership

+ +
expect(actual).to include(expected)
+expect(actual).to start_with(expected)
+expect(actual).to end_with(expected)
+
+expect(actual).to contain_exactly(individual, items)
+# ...which is the same as:
+expect(actual).to match_array(expected_array)
+
+ +

Examples

+ +
expect([1, 2, 3]).to include(1)
+expect([1, 2, 3]).to include(1, 2)
+expect([1, 2, 3]).to start_with(1)
+expect([1, 2, 3]).to start_with(1, 2)
+expect([1, 2, 3]).to end_with(3)
+expect([1, 2, 3]).to end_with(2, 3)
+expect({:a => 'b'}).to include(:a => 'b')
+expect("this string").to include("is str")
+expect("this string").to start_with("this")
+expect("this string").to end_with("ring")
+expect([1, 2, 3]).to contain_exactly(2, 3, 1)
+expect([1, 2, 3]).to match_array([3, 2, 1])
+
+ +

should syntax

+ +

In addition to the expect syntax, rspec-expectations continues to support the +should syntax:

+ +
actual.should eq expected
+actual.should be > 3
+[1, 2, 3].should_not include 4
+
+ +

See detailed information on the should syntax and its usage.

+ +

Compound Matcher Expressions

+ +

You can also create compound matcher expressions using and or or:

+ +
expect(alphabet).to start_with("a").and end_with("z")
+expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
+
+ +

Composing Matchers

+ +

Many of the built-in matchers are designed to take matchers as +arguments, to allow you to flexibly specify only the essential +aspects of an object or data structure. In addition, all of the +built-in matchers have one or more aliases that provide better +phrasing for when they are used as arguments to another matcher.

+ +

Examples

+ +
expect { k += 1.05 }.to change { k }.by( a_value_within(0.1).of(1.0) )
+
+expect { s = "barn" }.to change { s }
+  .from( a_string_matching(/foo/) )
+  .to( a_string_matching(/bar/) )
+
+expect(["barn", 2.45]).to contain_exactly(
+  a_value_within(0.1).of(2.5),
+  a_string_starting_with("bar")
+)
+
+expect(["barn", "food", 2.45]).to end_with(
+  a_string_matching("foo"),
+  a_value > 2
+)
+
+expect(["barn", 2.45]).to include( a_string_starting_with("bar") )
+
+expect(:a => "food", :b => "good").to include(:a => a_string_matching(/foo/))
+
+hash = {
+  :a => {
+    :b => ["foo", 5],
+    :c => { :d => 2.05 }
+  }
+}
+
+expect(hash).to match(
+  :a => {
+    :b => a_collection_containing_exactly(
+      a_string_starting_with("f"),
+      an_instance_of(Fixnum)
+    ),
+    :c => { :d => (a_value < 3) }
+  }
+)
+
+expect { |probe|
+  [1, 2, 3].each(&probe)
+}.to yield_successive_args( a_value < 2, 2, a_value > 2 )
+
+ +

Usage outside rspec-core

+ +

You always need to load rspec/expectations even if you only want to use one part of the library:

+ +
require 'rspec/expectations'
+
+ +

Then simply include RSpec::Matchers in any class:

+ +
class MyClass
+  include RSpec::Matchers
+
+  def do_something(arg)
+    expect(arg).to be > 0
+    # do other stuff
+  end
+end
+
+ +

Also see

+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/file_list.html b/source/documentation/3.0/rspec-expectations/file_list.html new file mode 100644 index 000000000..ac9df6c7e --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/file_list.html @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + File List + + + + +
+

File List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-expectations/frames.html b/source/documentation/3.0/rspec-expectations/frames.html new file mode 100644 index 000000000..43d89f7b9 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/frames.html @@ -0,0 +1,26 @@ + + + + + + Documentation by YARD 0.8.7.4 + + + + diff --git a/source/documentation/3.0/rspec-expectations/index.html b/source/documentation/3.0/rspec-expectations/index.html new file mode 100644 index 000000000..f42ae98fb --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/index.html @@ -0,0 +1,338 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

RSpec Expectations Build Status Code Climate

+ +

RSpec::Expectations lets you express expected outcomes on an object in an +example.

+ +
expect(.balance).to eq(Money.new(37.42, :USD))
+
+ +

Install

+ +

If you want to use rspec-expectations with rspec, just install the rspec gem +and RubyGems will also install rspec-expectations for you (along with +rspec-core and rspec-mocks):

+ +
gem install rspec
+
+ +

If you want to use rspec-expectations with another tool, like Test::Unit, +Minitest, or Cucumber, you can install it directly:

+ +
gem install rspec-expectations
+
+ +

Basic usage

+ +

Here's an example using rspec-core:

+ +
RSpec.describe Order do
+  it "sums the prices of the items in its line items" do
+    order = Order.new
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(1.11, :USD)
+    )))
+    order.add_entry(LineItem.new(:item => Item.new(
+      :price => Money.new(2.22, :USD),
+      :quantity => 2
+    )))
+    expect(order.total).to eq(Money.new(5.55, :USD))
+  end
+end
+
+ +

The describe and it methods come from rspec-core. The Order, LineItem, Item and Money classes would be from your code. The last line of the example +expresses an expected outcome. If order.total == Money.new(5.55, :USD), then +the example passes. If not, it fails with a message like:

+ +
expected: #<Money @value=5.55 @currency=:USD>
+     got: #<Money @value=1.11 @currency=:USD>
+
+ +

Built-in matchers

+ +

Equivalence

+ +
expect(actual).to eq(expected)  # passes if actual == expected
+expect(actual).to eql(expected) # passes if actual.eql?(expected)
+
+ +

Note: The new expect syntax no longer supports the == matcher.

+ +

Identity

+ +
expect(actual).to be(expected)    # passes if actual.equal?(expected)
+expect(actual).to equal(expected) # passes if actual.equal?(expected)
+
+ +

Comparisons

+ +
expect(actual).to be >  expected
+expect(actual).to be >= expected
+expect(actual).to be <= expected
+expect(actual).to be <  expected
+expect(actual).to be_within(delta).of(expected)
+
+ +

Regular expressions

+ +
expect(actual).to match(/expression/)
+
+ +

Note: The new expect syntax no longer supports the =~ matcher.

+ +

Types/classes

+ +
expect(actual).to be_an_instance_of(expected) # passes if actual.class == expected
+expect(actual).to be_a(expected)              # passes if actual.is_a?(expected)
+expect(actual).to be_an(expected)             # an alias for be_a
+expect(actual).to be_a_kind_of(expected)      # another alias
+
+ +

Truthiness

+ +
expect(actual).to be_truthy # passes if actual is truthy (not nil or false)
+expect(actual).to be true   # passes if actual == true
+expect(actual).to be_falsy  # passes if actual is falsy (nil or false)
+expect(actual).to be false  # passes if actual == false
+expect(actual).to be_nil    # passes if actual is nil
+
+ +

Expecting errors

+ +
expect { ... }.to raise_error
+expect { ... }.to raise_error(ErrorClass)
+expect { ... }.to raise_error("message")
+expect { ... }.to raise_error(ErrorClass, "message")
+
+ +

Expecting throws

+ +
expect { ... }.to throw_symbol
+expect { ... }.to throw_symbol(:symbol)
+expect { ... }.to throw_symbol(:symbol, 'value')
+
+ +

Yielding

+ +
expect { |b| 5.tap(&b) }.to yield_control # passes regardless of yielded args
+
+expect { |b| yield_if_true(true, &b) }.to yield_with_no_args # passes only if no args are yielded
+
+expect { |b| 5.tap(&b) }.to yield_with_args(5)
+expect { |b| 5.tap(&b) }.to yield_with_args(Fixnum)
+expect { |b| "a string".tap(&b) }.to yield_with_args(/str/)
+
+expect { |b| [1, 2, 3].each(&b) }.to yield_successive_args(1, 2, 3)
+expect { |b| { :a => 1, :b => 2 }.each(&b) }.to yield_successive_args([:a, 1], [:b, 2])
+
+ +

Predicate matchers

+ +
expect(actual).to be_xxx         # passes if actual.xxx?
+expect(actual).to have_xxx(:arg) # passes if actual.has_xxx?(:arg)
+
+ +

Ranges (Ruby >= 1.9 only)

+ +
expect(1..10).to cover(3)
+
+ +

Collection membership

+ +
expect(actual).to include(expected)
+expect(actual).to start_with(expected)
+expect(actual).to end_with(expected)
+
+expect(actual).to contain_exactly(individual, items)
+# ...which is the same as:
+expect(actual).to match_array(expected_array)
+
+ +

Examples

+ +
expect([1, 2, 3]).to include(1)
+expect([1, 2, 3]).to include(1, 2)
+expect([1, 2, 3]).to start_with(1)
+expect([1, 2, 3]).to start_with(1, 2)
+expect([1, 2, 3]).to end_with(3)
+expect([1, 2, 3]).to end_with(2, 3)
+expect({:a => 'b'}).to include(:a => 'b')
+expect("this string").to include("is str")
+expect("this string").to start_with("this")
+expect("this string").to end_with("ring")
+expect([1, 2, 3]).to contain_exactly(2, 3, 1)
+expect([1, 2, 3]).to match_array([3, 2, 1])
+
+ +

should syntax

+ +

In addition to the expect syntax, rspec-expectations continues to support the +should syntax:

+ +
actual.should eq expected
+actual.should be > 3
+[1, 2, 3].should_not include 4
+
+ +

See detailed information on the should syntax and its usage.

+ +

Compound Matcher Expressions

+ +

You can also create compound matcher expressions using and or or:

+ +
expect(alphabet).to start_with("a").and end_with("z")
+expect(stoplight.color).to eq("red").or eq("green").or eq("yellow")
+
+ +

Composing Matchers

+ +

Many of the built-in matchers are designed to take matchers as +arguments, to allow you to flexibly specify only the essential +aspects of an object or data structure. In addition, all of the +built-in matchers have one or more aliases that provide better +phrasing for when they are used as arguments to another matcher.

+ +

Examples

+ +
expect { k += 1.05 }.to change { k }.by( a_value_within(0.1).of(1.0) )
+
+expect { s = "barn" }.to change { s }
+  .from( a_string_matching(/foo/) )
+  .to( a_string_matching(/bar/) )
+
+expect(["barn", 2.45]).to contain_exactly(
+  a_value_within(0.1).of(2.5),
+  a_string_starting_with("bar")
+)
+
+expect(["barn", "food", 2.45]).to end_with(
+  a_string_matching("foo"),
+  a_value > 2
+)
+
+expect(["barn", 2.45]).to include( a_string_starting_with("bar") )
+
+expect(:a => "food", :b => "good").to include(:a => a_string_matching(/foo/))
+
+hash = {
+  :a => {
+    :b => ["foo", 5],
+    :c => { :d => 2.05 }
+  }
+}
+
+expect(hash).to match(
+  :a => {
+    :b => a_collection_containing_exactly(
+      a_string_starting_with("f"),
+      an_instance_of(Fixnum)
+    ),
+    :c => { :d => (a_value < 3) }
+  }
+)
+
+expect { |probe|
+  [1, 2, 3].each(&probe)
+}.to yield_successive_args( a_value < 2, 2, a_value > 2 )
+
+ +

Usage outside rspec-core

+ +

You always need to load rspec/expectations even if you only want to use one part of the library:

+ +
require 'rspec/expectations'
+
+ +

Then simply include RSpec::Matchers in any class:

+ +
class MyClass
+  include RSpec::Matchers
+
+  def do_something(arg)
+    expect(arg).to be > 0
+    # do other stuff
+  end
+end
+
+ +

Also see

+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-expectations/method_list.html b/source/documentation/3.0/rspec-expectations/method_list.html new file mode 100644 index 000000000..c1e91a6f0 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/method_list.html @@ -0,0 +1,1565 @@ + + + + + + + + + + + + + + + + + Method List + + + + +
+

Method List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-expectations/top-level-namespace.html b/source/documentation/3.0/rspec-expectations/top-level-namespace.html new file mode 100644 index 000000000..b91e2a512 --- /dev/null +++ b/source/documentation/3.0/rspec-expectations/top-level-namespace.html @@ -0,0 +1,129 @@ + + + + + + Top Level Namespace + + — Documentation by YARD 0.8.7.4 + + + + + + + + + + + + + + + + + + + + + +

Top Level Namespace + + + +

+ +
+ + + +
Extended by:
+
RSpec::Matchers::DSL
+ + + + + + + +
+
+ +

Defined Under Namespace

+

+ + + Modules: RSpec + + + + Classes: BasicObject + + +

+ + + + + + + + + + + + + + +

Method Summary

+ +

Methods included from RSpec::Matchers::DSL

+

define

+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/BasicObject.html b/source/documentation/3.0/rspec-mocks/BasicObject.html new file mode 100644 index 000000000..d8bcf2adc --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/BasicObject.html @@ -0,0 +1,720 @@ + + + + + + Class: BasicObject + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: BasicObject + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/syntax.rb
+ +
+
+ +

Overview

+
+ +

The legacy :should syntax adds the following methods directly +to BasicObject so that they are available off of any object. +Note, however, that this syntax does not always play nice with +delegate/proxy objects. We recommend you use the non-monkeypatching +:expect syntax instead.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (Object) as_null_object + + + + + + + + + + + + + +
    +

    Tells the object to respond to all messages.

    +
    + +
  • + + +
  • + + + - (Object) null_object? + + + + + + + + + + + + + +
    +

    Returns true if this object has received as_null_object.

    +
    + +
  • + + +
  • + + + - (Object) should_not_receive + + + + + + + + + + + + + +
    +

    Sets and expectation that this object should not receive a message +during this example.

    +
    + +
  • + + +
  • + + + - (Object) should_receive + + + + + + + + + + + + + +
    +

    Sets an expectation that this object should receive a message before the +end of the example.

    +
    + +
  • + + +
  • + + + - (Object) stub + + + + + + + + + + + + + +
    +

    Tells the object to respond to the message with the specified value.

    +
    + +
  • + + +
  • + + + - (Object) stub_chain + + + + + + + + + + + + + +
    +

    Stubs a chain of methods.

    +
    + +
  • + + +
  • + + + - (Object) unstub + + + + + + + + + + + + + +
    +

    Removes a stub.

    +
    + +
  • + + +
+ + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) as_null_object + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Tells the object to respond to all messages. If specific stub values are +declared, they'll work as expected. If not, the receiver is returned.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 286
+
+
+
+
+ +
+

+ + - (Object) null_object? + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Returns true if this object has received as_null_object

+ + +
+
+
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 297
+
+
+
+
+ +
+

+ + - (Object) should_not_receive + + + + + +

+
+ +

Sets and expectation that this object should not receive a message +during this example.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 226
+
+
+
+
+ +
+

+ + - (Object) should_receive + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Sets an expectation that this object should receive a message before the +end of the example.

+ + +
+
+
+ +
+

Examples:

+ + +

+logger = double('logger')
+thing_that_logs = ThingThatLogs.new(logger)
+logger.should_receive(:log)
+thing_that_logs.do_something_that_logs_a_message
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 212
+
+
+
+
+ +
+

+ + - (Object) stub + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Tells the object to respond to the message with the specified value.

+ + +
+
+
+ +
+

Examples:

+ + +

+counter.stub(:count).and_return(37)
+counter.stub(:count => 37)
+counter.stub(:count) { 37 }
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 231
+
+
+
+
+ +
+

+ + + - (Object) stub_chain(method1, method2) + + - (Object) stub_chain("method1.method2") + + - (Object) stub_chain(method1, method_to_value_hash) + + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Stubs a chain of methods.

+ +

Warning:

+ +

Chains can be arbitrarily long, which makes it quite painless to violate +the Law of Demeter in violent ways, so you should consider any use of +stub_chain a code smell. Even though not all code smells +indicate real problems (think fluent interfaces), stub_chain +still results in brittle examples. For example, if you write +foo.stub_chain(:bar, :baz => 37) in a spec and then the +implementation calls foo.baz.bar, the stub will not work.

+ + +
+
+
+ +
+

Examples:

+ + +

+double.stub_chain("foo.bar") { :baz }
+double.stub_chain(:foo, :bar => :baz)
+double.stub_chain(:foo, :bar) { :baz }
+
+# Given any of ^^ these three forms ^^:
+double.foo.bar # => :baz
+
+# Common use in Rails/ActiveRecord:
+Article.stub_chain("recent.published") { [Article.new] }
+ +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 254
+
+
+
+
+ +
+

+ + - (Object) unstub + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Removes a stub. On a double, the object will no longer respond to +message. On a real object, the original method (if it exists) +is restored.

+ +

This is rarely used, but can be useful when a stub is set up during a +shared before hook for the common case, but you want to +replace it for a special case.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 243
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/Class.html b/source/documentation/3.0/rspec-mocks/Class.html new file mode 100644 index 000000000..27381f6b3 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/Class.html @@ -0,0 +1,271 @@ + + + + + + Class: Class + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: Class + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/syntax.rb
+ +
+
+ +

Overview

+
+ +

The legacy :should syntax adds the any_instance +to Class. We generally recommend you use the newer +:expect syntax instead, which allows you to stub any instance +of a class using allow_any_instance_of(klass) or mock any +instance using expect_any_instance_of(klass).

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (Recorder) any_instance + + + + + + + + + + + + + +
    +

    Used to set stubs and message expectations on any instance of a given +class.

    +
    + +
  • + + +
+ + + + +
+

Instance Method Details

+ + +
+

+ + - (Recorder) any_instance + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the should +syntax.

+
+
+ + +

Used to set stubs and message expectations on any instance of a given +class. Returns a Recorder, which records messages +like stub and should_receive for later playback +on instances of the class.

+ + +
+
+
+ +
+

Examples:

+ + +

+Car.any_instance.should_receive(:go)
+race = Race.new
+race.cars << Car.new
+race.go # assuming this delegates to all of its cars
+        # this example would pass
+
+Account.any_instance.stub(:balance) { Money.new(:USD, 25) }
+Account.new.balance # => Money.new(:USD, 25))
+ +
+ +

Returns:

+
    + +
  • + + + (Recorder) + + + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/syntax.rb', line 329
+
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec.html b/source/documentation/3.0/rspec-mocks/RSpec.html new file mode 100644 index 000000000..fd8cbdc6e --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec.html @@ -0,0 +1,129 @@ + + + + + + Module: RSpec + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks.rb,
+ lib/rspec/mocks/proxy.rb,
lib/rspec/mocks/space.rb,
lib/rspec/mocks/syntax.rb,
lib/rspec/mocks/version.rb,
lib/rspec/mocks/targets.rb,
lib/rspec/mocks/test_double.rb,
lib/rspec/mocks/order_group.rb,
lib/rspec/mocks/mutate_const.rb,
lib/rspec/mocks/configuration.rb,
lib/rspec/mocks/message_chain.rb,
lib/rspec/mocks/method_double.rb,
lib/rspec/mocks/example_methods.rb,
lib/rspec/mocks/verifying_proxy.rb,
lib/rspec/mocks/error_generator.rb,
lib/rspec/mocks/method_reference.rb,
lib/rspec/mocks/matchers/receive.rb,
lib/rspec/mocks/verifying_double.rb,
lib/rspec/mocks/object_reference.rb,
lib/rspec/mocks/argument_matchers.rb,
lib/rspec/mocks/marshal_extension.rb,
lib/rspec/mocks/any_instance/proxy.rb,
lib/rspec/mocks/any_instance/chain.rb,
lib/rspec/mocks/message_expectation.rb,
lib/rspec/mocks/any_instance/recorder.rb,
lib/rspec/mocks/argument_list_matcher.rb,
lib/rspec/mocks/matchers/have_received.rb,
lib/rspec/mocks/instance_method_stasher.rb,
lib/rspec/mocks/any_instance/stub_chain.rb,
lib/rspec/mocks/matchers/receive_messages.rb,
lib/rspec/mocks/any_instance/message_chains.rb,
lib/rspec/mocks/verifying_message_expecation.rb,
lib/rspec/mocks/any_instance/stub_chain_chain.rb,
lib/rspec/mocks/matchers/receive_message_chain.rb,
lib/rspec/mocks/any_instance/expectation_chain.rb,
lib/rspec/mocks/any_instance/expect_chain_chain.rb,
lib/rspec/mocks/matchers/expectation_customization.rb
+
+ +
+
+ +

Overview

+
+ +

Share the top-level RSpec namespace, because we are a core supported +extension.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Mocks + + + + +

+ + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks.html new file mode 100644 index 000000000..403c5099e --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks.html @@ -0,0 +1,860 @@ + + + + + + Module: RSpec::Mocks + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks.rb,
+ lib/rspec/mocks/proxy.rb,
lib/rspec/mocks/space.rb,
lib/rspec/mocks/syntax.rb,
lib/rspec/mocks/version.rb,
lib/rspec/mocks/targets.rb,
lib/rspec/mocks/test_double.rb,
lib/rspec/mocks/order_group.rb,
lib/rspec/mocks/mutate_const.rb,
lib/rspec/mocks/configuration.rb,
lib/rspec/mocks/message_chain.rb,
lib/rspec/mocks/method_double.rb,
lib/rspec/mocks/example_methods.rb,
lib/rspec/mocks/verifying_proxy.rb,
lib/rspec/mocks/error_generator.rb,
lib/rspec/mocks/method_reference.rb,
lib/rspec/mocks/matchers/receive.rb,
lib/rspec/mocks/verifying_double.rb,
lib/rspec/mocks/object_reference.rb,
lib/rspec/mocks/argument_matchers.rb,
lib/rspec/mocks/marshal_extension.rb,
lib/rspec/mocks/any_instance/proxy.rb,
lib/rspec/mocks/any_instance/chain.rb,
lib/rspec/mocks/message_expectation.rb,
lib/rspec/mocks/any_instance/recorder.rb,
lib/rspec/mocks/argument_list_matcher.rb,
lib/rspec/mocks/matchers/have_received.rb,
lib/rspec/mocks/instance_method_stasher.rb,
lib/rspec/mocks/any_instance/stub_chain.rb,
lib/rspec/mocks/matchers/receive_messages.rb,
lib/rspec/mocks/any_instance/message_chains.rb,
lib/rspec/mocks/verifying_message_expecation.rb,
lib/rspec/mocks/any_instance/stub_chain_chain.rb,
lib/rspec/mocks/matchers/receive_message_chain.rb,
lib/rspec/mocks/any_instance/expectation_chain.rb,
lib/rspec/mocks/any_instance/expect_chain_chain.rb,
lib/rspec/mocks/matchers/expectation_customization.rb
+
+ +
+
+ +

Overview

+
+ +

Contains top-level utility methods. While this contains a few public +methods, these are not generally meant to be called from a test or example. +They exist primarily for integration with test frameworks (such as +rspec-core).

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: ArgumentMatchers, ExampleMethods, Matchers, Syntax, TestDouble, Version + + + + Classes: ArgumentListMatcher, Configuration, Constant, ConstantMutator, Double, VerifyingMessageExpectation + + +

+ +

Constant Summary

+ +
+ +
MockExpectationError = +
+
+ +

Raised when a message expectation is not satisfied.

+ + +
+
+
+ + +
+
+
Class.new(Exception)
+ +
ExpiredTestDoubleError = +
+
+ +

Raised when a test double is used after it has been torn down (typically at +the end of an rspec-core example).

+ + +
+
+
+ + +
+
+
Class.new(MockExpectationError)
+ +
OutsideOfExampleError = +
+
+ +

Raised when doubles or partial doubles are used outside of the per-test +lifecycle.

+ + +
+
+
+ + +
+
+
Class.new(StandardError)
+ +
+ + + + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) allow_message(subject, message, opts = {}) { ... } + + + + + +

+
+ +

Adds an allowance (stub) on subject

+ + +
+
+
+ +
+

Examples:

+ + +

+

Defines the implementation of foo on bar, using +the passed block

+

+ +
x = 0
+RSpec::Mocks.allow_message(bar, :foo) { x += 1 }
+ +
+

Parameters:

+
    + +
  • + + subject + + + + + + + — +
    +

    the subject to which the message will be added

    +
    + +
  • + +
  • + + message + + + + + + + — +
    +

    a symbol, representing the message that will be added.

    +
    + +
  • + +
  • + + opts + + + + + + (defaults to: {}) + + + — +
    +

    a hash of options, :expected_from is used to set the original call site

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    an optional implementation for the allowance

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+69
+70
+71
+
+
# File 'lib/rspec/mocks.rb', line 69
+
+def self.allow_message(subject, message, opts={}, &block)
+  space.proxy_for(subject).add_stub(message, opts, &block)
+end
+
+
+ +
+

+ + + (Object) configuration + + + + + +

+
+ +

Mocks specific configuration, as distinct from +RSpec.configuration which is core RSpec configuration.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+158
+159
+160
+
+
# File 'lib/rspec/mocks/configuration.rb', line 158
+
+def self.configuration
+  @configuration ||= Configuration.new
+end
+
+
+ +
+

+ + + (Object) expect_message(subject, message, opts = {}) { ... } + + + + + +

+
+ +

Sets a message expectation on subject.

+ + +
+
+
+ +
+

Examples:

+ + +

+

Expect the message foo to receive bar, then call +it

+

+ +
RSpec::Mocks.expect_message(bar, :foo)
+bar.foo
+ +
+

Parameters:

+
    + +
  • + + subject + + + + + + + — +
    +

    the subject on which the message will be expected

    +
    + +
  • + +
  • + + message + + + + + + + — +
    +

    a symbol, representing the message that will be expected.

    +
    + +
  • + +
  • + + opts + + + + + + (defaults to: {}) + + + — +
    +

    a hash of options, :expected_from is used to set the original call site

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +
    +

    an optional implementation for the expectation

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+84
+85
+86
+
+
# File 'lib/rspec/mocks.rb', line 84
+
+def self.expect_message(subject, message, opts={}, &block)
+  space.proxy_for(subject).add_message_expectation(message, opts, &block)
+end
+
+
+ +
+

+ + + (Object) setup + + + + + +

+
+ +

Performs per-test/example setup. This should be called before an test or +example begins.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+38
+39
+40
+
+
# File 'lib/rspec/mocks.rb', line 38
+
+def self.setup
+  @space_stack << (@space = space.new_scope)
+end
+
+
+ +
+

+ + + (Object) teardown + + + + + +

+
+ +

Cleans up all test double state (including any methods that were redefined +on partial doubles). This must be called after each example, even +if an error was raised during the example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+51
+52
+53
+54
+55
+
+
# File 'lib/rspec/mocks.rb', line 51
+
+def self.teardown
+  space.reset_all
+  @space_stack.pop
+  @space = @space_stack.last || @root_space
+end
+
+
+ +
+

+ + + (Object) verify + + + + + +

+
+ +

Verifies any message expectations that were set during the test or example. +This should be called at the end of an example.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+44
+45
+46
+
+
# File 'lib/rspec/mocks.rb', line 44
+
+def self.verify
+  space.verify_all
+end
+
+
+ +
+

+ + + (Object) with_temporary_scope + + + + + +

+
+ +

Call the passed block and verify mocks after it has executed. This allows +mock usage in arbitrary places, such as a before(:all) hook.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+
+
# File 'lib/rspec/mocks.rb', line 90
+
+def self.with_temporary_scope
+  setup
+
+  begin
+    yield
+    verify
+  ensure
+    teardown
+  end
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html new file mode 100644 index 000000000..752ec66d7 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentListMatcher.html @@ -0,0 +1,397 @@ + + + + + + Class: RSpec::Mocks::ArgumentListMatcher + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::ArgumentListMatcher + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/argument_list_matcher.rb
+ +
+
+ +

Overview

+
+ +

Wrapper for matching arguments against a list of expected values. Used by +the with method on a MessageExpectation:

+ +
expect(object).to receive(:message).with(:a, 'b', 3)
+object.message(:a, 'b', 3)
+ +

Values passed to with can be literal values or argument +matchers that match against the real objects .e.g.

+ +
expect(object).to receive(:message).with(hash_including(:a => 'b'))
+
+ +

Can also be used directly to match the contents of any Array. +This enables 3rd party mocking libs to take advantage of rspec's +argument matching without using the rest of rspec-mocks.

+ +
require 'rspec/mocks/argument_list_matcher'
+include RSpec::Mocks::ArgumentMatchers
+
+arg_list_matcher = RSpec::Mocks::ArgumentListMatcher.new(123, hash_including(:a => 'b'))
+arg_list_matcher.args_match?(123, :a => 'b')
+
+ +

This class is immutable.

+ + +
+
+
+ + +

See Also:

+ + +
+

Constant Summary

+ + + + + + + + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (Boolean) args_match?(*args) + + + + + + + + + + + + + +
    +

    Matches each element in the expected_args against the element +in the same position of the arguments passed to new.

    +
    + +
  • + + +
  • + + + - (ArgumentListMatcher) initialize(*expected_args) + + + + + + + constructor + + + + + + + + +
    +

    Initializes an ArgumentListMatcher with a collection of +literal values and/or argument matchers.

    +
    + +
  • + + +
+ + +
+

Constructor Details

+ +
+

+ + - (ArgumentListMatcher) initialize(*expected_args) + + + + + +

+
+ +

Initializes an ArgumentListMatcher with a collection of +literal values and/or argument matchers.

+ + +
+
+
+

Parameters:

+
    + +
  • + + expected_args + + + (Array) + + + + — +
    +

    a list of expected literals and/or argument matchers

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/rspec/mocks/argument_list_matcher.rb', line 45
+
+def initialize(*expected_args)
+  @expected_args = expected_args
+
+  @matchers = case expected_args.first
+    when ArgumentMatchers::AnyArgsMatcher then Array
+    when ArgumentMatchers::NoArgsMatcher  then []
+    else expected_args
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Boolean) args_match?(*args) + + + + + +

+
+ +

Matches each element in the expected_args against the element +in the same position of the arguments passed to new.

+ + +
+
+
+

Parameters:

+
    + +
  • + + args + + + (Array) + + + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lib/rspec/mocks/argument_list_matcher.rb', line 62
+
+def args_match?(*args)
+  Support::FuzzyMatcher.values_match?(@matchers, args)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html new file mode 100644 index 000000000..e0a2ea697 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ArgumentMatchers.html @@ -0,0 +1,918 @@ + + + + + + Module: RSpec::Mocks::ArgumentMatchers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::ArgumentMatchers + + + +

+ +
+ + + + + + + +
Included in:
+
ExampleMethods
+ + + +
Defined in:
+
lib/rspec/mocks/argument_matchers.rb
+ +
+
+ +

Overview

+
+ +

ArgumentMatchers are placeholders that you can include in message +expectations to match arguments against a broader check than simple +equality.

+ +

With the exception of any_args and no_args, they +all match against the arg in same position in the argument list.

+ + +
+
+
+ + +

See Also:

+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) any_args + + + + + +

+
+ +

Matches any args at all. Supports a more explicit variation of +expect(object).to receive(:message)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(any_args)
+ +
+ + +
+ + + + +
+
+
+
+19
+20
+21
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 19
+
+def any_args
+  AnyArgsMatcher.new
+end
+
+
+ +
+

+ + - (Object) anything + + + + + +

+
+ +

Matches any argument at all.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(anything)
+ +
+ + +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 28
+
+def anything
+  AnyArgMatcher.new
+end
+
+
+ +
+

+ + - (Object) array_including(*args) + + + + + +

+
+ +

Matches an array that includes the specified items at least once. Ignores +duplicates and additional values

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(array_including(1,2,3))
+expect(object).to receive(:message).with(array_including([1,2,3]))
+ +
+ + +
+ + + + +
+
+
+
+79
+80
+81
+82
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 79
+
+def array_including(*args)
+  actually_an_array = Array === args.first && args.count == 1 ? args.first : args
+  ArrayIncludingMatcher.new(actually_an_array)
+end
+
+
+ +
+

+ + - (Object) boolean + + + + + +

+
+ +

Matches a boolean value.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(boolean())
+ +
+ + +
+ + + + +
+
+
+
+56
+57
+58
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 56
+
+def boolean
+  BooleanMatcher.new
+end
+
+
+ +
+

+ + - (Object) duck_type(*args) + + + + + +

+
+ +

Matches if the actual argument responds to the specified messages.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(duck_type(:hello))
+expect(object).to receive(:message).with(duck_type(:hello, :goodbye))
+ +
+ + +
+ + + + +
+
+
+
+47
+48
+49
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 47
+
+def duck_type(*args)
+  DuckTypeMatcher.new(*args)
+end
+
+
+ +
+

+ + - (Object) hash_excluding(*args) + + + + Also known as: + hash_not_including + + + + +

+
+ +

Matches a hash that doesn't include the specified key(s) or key/value.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(hash_excluding(:key => val))
+expect(object).to receive(:message).with(hash_excluding(:key))
+expect(object).to receive(:message).with(hash_excluding(:key, :key2 => :val2))
+ +
+ + +
+ + + + +
+
+
+
+91
+92
+93
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 91
+
+def hash_excluding(*args)
+  HashExcludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
+end
+
+
+ +
+

+ + - (Object) hash_including(*args) + + + + + +

+
+ +

Matches a hash that includes the specified key(s) or key/value pairs. +Ignores any additional keys.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(hash_including(:key => val))
+expect(object).to receive(:message).with(hash_including(:key))
+expect(object).to receive(:message).with(hash_including(:key, :key2 => val2))
+ +
+ + +
+ + + + +
+
+
+
+68
+69
+70
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 68
+
+def hash_including(*args)
+  HashIncludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args))
+end
+
+
+ +
+

+ + - (Object) instance_of(klass) + + + + Also known as: + an_instance_of + + + + +

+
+ +

Matches if arg.instance_of?(klass)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(instance_of(Thing))
+ +
+ + +
+ + + + +
+
+
+
+102
+103
+104
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 102
+
+def instance_of(klass)
+  InstanceOf.new(klass)
+end
+
+
+ +
+

+ + - (Object) kind_of(klass) + + + + Also known as: + a_kind_of + + + + +

+
+ +

Matches if arg.kind_of?(klass)

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(kind_of(Thing))
+ +
+ + +
+ + + + +
+
+
+
+112
+113
+114
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 112
+
+def kind_of(klass)
+  KindOf.new(klass)
+end
+
+
+ +
+

+ + - (Object) no_args + + + + + +

+
+ +

Matches no arguments.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(object).to receive(:message).with(no_args)
+ +
+ + +
+ + + + +
+
+
+
+37
+38
+39
+
+
# File 'lib/rspec/mocks/argument_matchers.rb', line 37
+
+def no_args
+  NoArgsMatcher.new
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Configuration.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Configuration.html new file mode 100644 index 000000000..03acb6ed8 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Configuration.html @@ -0,0 +1,1234 @@ + + + + + + Class: RSpec::Mocks::Configuration + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::Configuration + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/configuration.rb
+ +
+
+ +

Overview

+
+ +

Provides configuration options for rspec-mocks.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + +
+

Constructor Details

+ +
+

+ + - (Configuration) initialize + + + + + +

+
+ +

Returns a new instance of Configuration

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+9
+10
+11
+
+
# File 'lib/rspec/mocks/configuration.rb', line 6
+
+def initialize
+  @yield_receiver_to_any_instance_implementation_blocks = true
+  @verify_doubled_constant_names = false
+  @transfer_nested_constants = false
+  @verify_partial_doubles = false
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) add_stub_and_should_receive_to(*modules) + + + + + +

+
+ +

Adds stub and should_receive to the given modules +or classes. This is usually only necessary if you application uses some +proxy classes that “strip themselves down” to a bare minimum set of methods +and remove stub and should_receive in the +process.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.mock_with :rspec do |mocks|
+    mocks.add_stub_and_should_receive_to Delegator
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+48
+49
+50
+51
+52
+
+
# File 'lib/rspec/mocks/configuration.rb', line 48
+
+def add_stub_and_should_receive_to(*modules)
+  modules.each do |mod|
+    Syntax.enable_should(mod)
+  end
+end
+
+
+ +
+

+ + - (Object) patch_marshal_to_support_partial_doubles=(val) + + + + + +

+
+ +

Monkey-patch Marshal.dump to enable dumping of mocked or +stubbed objects. By default this will not work since RSpec mocks works by +adding singleton methods that cannot be serialized. This patch removes +these singleton methods before serialization. Setting to falsey removes the +patch.

+ +

This method is idempotent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+140
+141
+142
+143
+144
+145
+146
+
+
# File 'lib/rspec/mocks/configuration.rb', line 140
+
+def patch_marshal_to_support_partial_doubles=(val)
+  if val
+    RSpec::Mocks::MarshalExtension.patch!
+  else
+    RSpec::Mocks::MarshalExtension.unpatch!
+  end
+end
+
+
+ +
+

+ + - (Object) reset_syntaxes_to_default + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Resets the configured syntax to the default.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+150
+151
+152
+153
+
+
# File 'lib/rspec/mocks/configuration.rb', line 150
+
+def reset_syntaxes_to_default
+  self.syntax = [:should, :expect]
+  RSpec::Mocks::Syntax.warn_about_should!
+end
+
+
+ +
+

+ + - (Object) syntax + + + + + +

+
+ +

Returns an array with a list of syntaxes that are enabled.

+ + +
+
+
+ +
+

Examples:

+ + +

+unless RSpec::Mocks.configuration.syntax.include?(:expect)
+  raise "this RSpec extension gem requires the rspec-mocks `:expect` syntax"
+end
+ +
+ + +
+ + + + +
+
+
+
+92
+93
+94
+95
+96
+97
+
+
# File 'lib/rspec/mocks/configuration.rb', line 92
+
+def syntax
+  syntaxes = []
+  syntaxes << :should  if Syntax.should_enabled?
+  syntaxes << :expect if Syntax.expect_enabled?
+  syntaxes
+end
+
+
+ +
+

+ + - (Object) syntax=(*values) + + + + + +

+
+ +

Provides the ability to set either expect, should +or both syntaxes. RSpec uses expect syntax by default. This is +needed if you want to explicitly enable should syntax and/or +explicitly disable expect syntax.

+ +

end

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.mock_with :rspec do |mocks|
+    mocks.syntax = [:expect, :should]
+  end
+ +
+ + +
+ + + + +
+
+
+
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+
+
# File 'lib/rspec/mocks/configuration.rb', line 68
+
+def syntax=(*values)
+  syntaxes = values.flatten
+  if syntaxes.include?(:expect)
+    Syntax.enable_expect
+  else
+    Syntax.disable_expect
+  end
+
+  if syntaxes.include?(:should)
+    Syntax.enable_should
+  else
+    Syntax.disable_should
+  end
+end
+
+
+ +
+

+ + - (Object) transfer_nested_constants=(val) + + + + + +

+
+ +

Sets the default for the transfer_nested_constants option when +stubbing constants.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+118
+119
+120
+
+
# File 'lib/rspec/mocks/configuration.rb', line 118
+
+def transfer_nested_constants=(val)
+  @transfer_nested_constants = val
+end
+
+
+ +
+

+ + - (Boolean) transfer_nested_constants? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+112
+113
+114
+
+
# File 'lib/rspec/mocks/configuration.rb', line 112
+
+def transfer_nested_constants?
+  !!@transfer_nested_constants
+end
+
+
+ +
+

+ + - (Object) verify_doubled_constant_names=(val) + + + + + +

+
+ +

When this is set to true, an error will be raised when +instance_double or class_double is given the name +of an undefined constant. You probably only want to set this when running +your entire test suite, with all production code loaded. Setting this for +an isolated unit test will prevent you from being able to isolate it!

+ + +
+
+
+ + +
+ + + + +
+
+
+
+108
+109
+110
+
+
# File 'lib/rspec/mocks/configuration.rb', line 108
+
+def verify_doubled_constant_names=(val)
+  @verify_doubled_constant_names = val
+end
+
+
+ +
+

+ + - (Boolean) verify_doubled_constant_names? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+99
+100
+101
+
+
# File 'lib/rspec/mocks/configuration.rb', line 99
+
+def verify_doubled_constant_names?
+  !!@verify_doubled_constant_names
+end
+
+
+ +
+

+ + - (Object) verify_partial_doubles=(val) + + + + + +

+
+ +

When set to true, partial mocks will be verified the same as object +doubles. Any stubs will have their arguments checked against the original +method, and methods that do not exist cannot be stubbed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+125
+126
+127
+
+
# File 'lib/rspec/mocks/configuration.rb', line 125
+
+def verify_partial_doubles=(val)
+  @verify_partial_doubles = !!val
+end
+
+
+ +
+

+ + - (Boolean) verify_partial_doubles? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+129
+130
+131
+
+
# File 'lib/rspec/mocks/configuration.rb', line 129
+
+def verify_partial_doubles?
+  @verify_partial_doubles
+end
+
+
+ +
+

+ + - (Object) yield_receiver_to_any_instance_implementation_blocks=(arg) + + + + + +

+
+ +

Sets whether or not RSpec will yield the receiving instance of a message to +blocks that are used for any_instance stub implementations. When set, the +first yielded argument will be the receiving instance. Defaults to +true.

+ + +
+
+
+ +
+

Examples:

+ + +

+RSpec.configure do |rspec|
+  rspec.mock_with :rspec do |mocks|
+    mocks.yield_receiver_to_any_instance_implementation_blocks = false
+  end
+end
+ +
+ + +
+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'lib/rspec/mocks/configuration.rb', line 29
+
+def yield_receiver_to_any_instance_implementation_blocks=(arg)
+  @yield_receiver_to_any_instance_implementation_blocks = arg
+end
+
+
+ +
+

+ + - (Boolean) yield_receiver_to_any_instance_implementation_blocks? + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+13
+14
+15
+
+
# File 'lib/rspec/mocks/configuration.rb', line 13
+
+def yield_receiver_to_any_instance_implementation_blocks?
+  @yield_receiver_to_any_instance_implementation_blocks
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Constant.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Constant.html new file mode 100644 index 000000000..a0674b007 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Constant.html @@ -0,0 +1,953 @@ + + + + + + Class: RSpec::Mocks::Constant + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::Constant + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/mutate_const.rb
+ +
+
+ +

Overview

+
+ +

Provides information about constants that may (or may not) have been +mutated by rspec-mocks.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (String) name + + + + + + + + + readonly + + + + + + + + + +
    +

    The fully qualified name of the constant.

    +
    + +
  • + + +
  • + + + - (Object?) original_value + + + + + + + + + + + + + + + + +
    +

    The original value (e.g. before it was mutated by rspec-mocks) of the +constant, or nil if the constant was not previously defined.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + (collapse) +

+ +
    + +
  • + + + + (Constant) original(name) + + + + + + + + + + + + + +
    +

    Queries rspec-mocks to find out information about the named constant.

    +
    + +
  • + + +
+ +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (Boolean) hidden? + + + + + + + + + + + + + +
    +

    Whether or not rspec-mocks has hidden this constant.

    +
    + +
  • + + +
  • + + + - (Constant) initialize(name) + + + + + + + constructor + + + + + + private + + +
    +

    A new instance of Constant.

    +
    + +
  • + + +
  • + + + - (Boolean) mutated? + + + + + + + + + + + + + +
    +

    Whether or not rspec-mocks has mutated (stubbed or hidden) this constant.

    +
    + +
  • + + +
  • + + + - (Boolean) previously_defined? + + + + + + + + + + + + + +
    +

    Whether or not the constant was defined before the current example.

    +
    + +
  • + + +
  • + + + - (Boolean) stubbed? + + + + + + + + + + + + + +
    +

    Whether or not rspec-mocks has stubbed this constant.

    +
    + +
  • + + +
  • + + + - (Object) to_s + + + + (also: #inspect) + + + + + + + + + + + +
    +

    The default to_s isn't very useful, so a custom version is +provided.

    +
    + +
  • + + +
+ + + + + + + + +
+

Constructor Details

+ +
+

+ + - (Constant) initialize(name) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of Constant

+ + +
+
+
+ + +
+ + + + +
+
+
+
+85
+86
+87
+88
+89
+90
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 85
+
+def initialize(name)
+  @name = name
+  @previously_defined = false
+  @stubbed = false
+  @hidden = false
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (String) name (readonly) + + + + + +

+
+ +

Returns The fully qualified name of the constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +
    +

    The fully qualified name of the constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+93
+94
+95
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 93
+
+def name
+  @name
+end
+
+
+ + + +
+

+ + - (Object?) original_value + + + + + +

+
+ +

Returns The original value (e.g. before it was mutated by rspec-mocks) of +the constant, or nil if the constant was not previously defined.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Object, nil) + + + + — +
    +

    The original value (e.g. before it was mutated by rspec-mocks) of the +constant, or nil if the constant was not previously defined.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+98
+99
+100
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 98
+
+def original_value
+  @original_value
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + + (Constant) original(name) + + + + + +

+
+ +

Queries rspec-mocks to find out information about the named constant.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +
    +

    the name of the constant

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Constant) + + + + — +
    +

    an object contaning information about the named constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+149
+150
+151
+152
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 149
+
+def self.original(name)
+  mutator = ::RSpec::Mocks.space.constant_mutator_for(name)
+  mutator ? mutator.to_constant : unmutated(name)
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + - (Boolean) hidden? + + + + + +

+
+ +

Returns Whether or not rspec-mocks has hidden this constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not rspec-mocks has hidden this constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+123
+124
+125
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 123
+
+def hidden?
+  @hidden
+end
+
+
+ +
+

+ + - (Boolean) mutated? + + + + + +

+
+ +

Returns Whether or not rspec-mocks has mutated (stubbed or hidden) this +constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not rspec-mocks has mutated (stubbed or hidden) this constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+111
+112
+113
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 111
+
+def mutated?
+  @stubbed || @hidden
+end
+
+
+ +
+

+ + - (Boolean) previously_defined? + + + + + +

+
+ +

Returns Whether or not the constant was defined before the current example.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not the constant was defined before the current example.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+105
+106
+107
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 105
+
+def previously_defined?
+  @previously_defined
+end
+
+
+ +
+

+ + - (Boolean) stubbed? + + + + + +

+
+ +

Returns Whether or not rspec-mocks has stubbed this constant.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +
    +

    Whether or not rspec-mocks has stubbed this constant.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+117
+118
+119
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 117
+
+def stubbed?
+  @stubbed
+end
+
+
+ +
+

+ + - (Object) to_s + + + + Also known as: + inspect + + + + +

+
+ +

The default to_s isn't very useful, so a custom version is +provided.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+128
+129
+130
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 128
+
+def to_s
+  "#<#{self.class.name} #{name}>"
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ConstantMutator.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ConstantMutator.html new file mode 100644 index 000000000..3044ed6f5 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ConstantMutator.html @@ -0,0 +1,538 @@ + + + + + + Class: RSpec::Mocks::ConstantMutator + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::ConstantMutator + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/mutate_const.rb
+ +
+
+ +

Overview

+
+ +

Provides a means to stub constants.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + + + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) hide(constant_name) + + + + + +

+
+ +
+ Note: +
+

It's recommended that you use hide_const in your examples. +This is an alternate public API that is provided so you can hide constants +in other contexts (e.g. helper classes).

+
+
+ + +

Hides a constant.

+ + +
+
+
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+190
+191
+192
+193
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 190
+
+def self.hide(constant_name)
+  mutate(ConstantHider.new(constant_name, nil, { }))
+  nil
+end
+
+
+ +
+

+ + + (Object) raise_on_invalid_const + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Used internally by the constant stubbing to raise a helpful error when a +constant like “A::B::C” is stubbed and A::B is not a module (and thus, +it's impossible to define “A::B::C” since only modules can have nested +constants).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+390
+391
+392
+393
+394
+395
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 390
+
+def self.raise_on_invalid_const
+  lambda do |const_name, failed_name|
+    raise "Cannot stub constant #{failed_name} on #{const_name} " +
+          "since #{const_name} is not a module."
+  end
+end
+
+
+ +
+

+ + + (Object) stub(constant_name, value, options = {}) + + + + + +

+
+ +
+ Note: +
+

It's recommended that you use stub_const in your examples. +This is an alternate public API that is provided so you can stub constants +in other contexts (e.g. helper classes).

+
+
+ + +

Stubs a constant.

+ + +
+
+
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
  • + + value + + + (Object) + + + + — +
    +

    The value to make the constant refer to. When the example completes, the +constant will be restored to its prior state.

    +
    + +
  • + +
  • + + options + + + (Hash) + + + (defaults to: {}) + + + — +
    +

    Stubbing options.

    +
    + +
  • + +
+ + + + + + + + +

Options Hash (options):

+
    + +
  • + :transfer_nested_constants + (Boolean, Array<Symbol>) + + + + + —
    +

    Determines what nested constants, if any, will be transferred from the +original value of the constant to the new value of the constant. This only +works if both the original and new values are modules (or classes).

    +
    + +
  • + +
+ + +

Returns:

+
    + +
  • + + + (Object) + + + + — +
    +

    the stubbed value of the constant

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+
+
# File 'lib/rspec/mocks/mutate_const.rb', line 170
+
+def self.stub(constant_name, value, options = {})
+  mutator = if recursive_const_defined?(constant_name, &raise_on_invalid_const)
+    DefinedConstantReplacer
+  else
+    UndefinedConstantSetter
+  end
+
+  mutate(mutator.new(constant_name, value, options[:transfer_nested_constants]))
+  value
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Double.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Double.html new file mode 100644 index 000000000..dce17aa2b --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Double.html @@ -0,0 +1,157 @@ + + + + + + Class: RSpec::Mocks::Double + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::Double + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + +
Includes:
+
TestDouble
+ + + + + +
Defined in:
+
lib/rspec/mocks/test_double.rb
+ +
+
+ +

Overview

+
+ +

A generic test double object. double, +instance_double and friends return an instance of this.

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods included from TestDouble

+

#==, #as_null_object, #freeze, #initialize, #null_object?

+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + + in the class RSpec::Mocks::TestDouble + +

+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods.html new file mode 100644 index 000000000..97d892033 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods.html @@ -0,0 +1,1973 @@ + + + + + + Module: RSpec::Mocks::ExampleMethods + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::ExampleMethods + + + +

+ +
+ + + + + +
Includes:
+
ArgumentMatchers
+ + + + + +
Defined in:
+
lib/rspec/mocks/example_methods.rb
+ +
+
+ +

Overview

+
+ +

Contains methods intended to be used from within code examples. Mix this in +to your test context (such as a test framework base class) to use +rspec-mocks with your test framework. If you're using rspec-core, +it'll take care of doing this for you.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: ExpectHost + + + + +

+ + + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + + + + +

Methods included from ArgumentMatchers

+

#any_args, #anything, #array_including, #boolean, #duck_type, #hash_excluding, #hash_including, #instance_of, #kind_of, #no_args

+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) allow + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Used to wrap an object in preparation for stubbing a method on it.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow(dbl).to receive(:foo).with(5).and_return(:return_value)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 188
+
+
+
+
+ +
+

+ + - (Object) allow_any_instance_of + + + + + +

+
+ +
+ Note: +
+

This is only available when you have enabled the expect +syntax.

+
+
+ + +

Used to wrap a class in preparation for stubbing a method on instances of +it.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow_any_instance_of(MyClass).to receive(:foo)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 208
+
+
+
+
+ +
+

+ + - (Object) allow_message_expectations_on_nil + + + + + +

+
+ +

Disables warning messages about expectations being set on nil.

+ +

By default warning messages are issued when expectations are set on nil. +This is to prevent false-positives and to catch potential bugs early on.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+92
+93
+94
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 92
+
+def allow_message_expectations_on_nil
+  RSpec::Mocks.space.proxy_for(nil).warn_about_expectations = false
+end
+
+
+ +
+

+ + + - (Object) class_double(doubled_class) + + - (Object) class_double(doubled_class, stubs) + + + + + + +

+
+ +

Constructs a test double against a specific class. If the given class name +has been loaded, only class methods defined on the class are allowed to be +stubbed. In all other ways it behaves like a double.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) class_double(doubled_class) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Module) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) class_double(doubled_class, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Module) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    ClassVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+69
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 66
+
+def class_double(doubled_class, *args)
+  ref = ObjectReference.for(doubled_class)
+  ExampleMethods.declare_verifying_double(ClassVerifyingDouble, ref, *args)
+end
+
+
+ +
+

+ + + - (Double) double + + - (Double) double(name) + + - (Double) double(stubs) + + - (Double) double(name, stubs) + + + + + + +

+
+ +

Constructs an instance of :Mocks::Double +configured with an optional name, used for reporting in failure messages, +and an optional hash of message/return-value pairs.

+ + +
+
+
+ +
+

Examples:

+ + +

+book = double("book", :title => "The RSpec Book")
+book.title #=> "The RSpec Book"
+
+card = double("card", :suit => "Spades", :rank => "A")
+card.suit  #=> "Spades"
+card.rank  #=> "A"
+ +
+ +

Overloads:

+
    + + + +
  • + - (Double) double(name) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String/Symbol) + + + + — +
      +

      used to clarify intent

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (Double) double(stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + + +
  • + - (Double) double(name, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + name + + + (String/Symbol) + + + + — +
      +

      used to clarify intent

      +
      + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + (Double) + + + +
  • + +
+ +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 35
+
+def double(*args)
+  ExampleMethods.declare_double(Double, *args)
+end
+
+
+ +
+

+ + - (Object) expect + + + + + +

+
+ +
+ Note: +
+

This method is usually provided by rspec-expectations. However, if you use +rspec-mocks without rspec-expectations, there's a definition of it that +is made available here. If you disable the :expect syntax this +method will be undefined.

+
+
+ + +

Used to wrap an object in preparation for setting a mock expectation on it.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(obj).to receive(:foo).with(5).and_return(:return_value)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 175
+
+
+
+
+ +
+

+ + - (Object) expect_any_instance_of + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Used to wrap a class in preparation for setting a mock expectation on +instances of it.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect_any_instance_of(MyClass).to receive(:foo)
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 198
+
+
+
+
+ +
+

+ + - (Object) have_received(method_name, &block) + + + + + +

+
+ +

Verifies that the given object received the expected message during the +course of the test. The method must have previously been stubbed in order +for messages to be verified.

+ +

Stubbing and verifying messages received in this way implements the Test +Spy pattern.

+ + +
+
+
+ +
+

Examples:

+ + +

+invitation = double('invitation', accept: true)
+user.accept_invitation(invitation)
+expect(invitation).to have_received(:accept)
+
+# You can also use most message expectations:
+expect(invitation).to have_received(:accept).with(mailer).once
+ +
+

Parameters:

+
    + +
  • + + method_name + + + (Symbol) + + + + — +
    +

    name of the method expected to have been called.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+171
+172
+173
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 171
+
+def have_received(method_name, &block)
+  Matchers::HaveReceived.new(method_name, &block)
+end
+
+
+ +
+

+ + - (Object) hide_const(constant_name) + + + + + +

+
+ +

Hides the named constant with the given value. The constant will be +undefined for the duration of the test.

+ +

Like method stubs, the constant will be restored to its original value when +the example completes.

+ + +
+
+
+ +
+

Examples:

+ + +

+hide_const("MyClass") # => MyClass is now an undefined constant
+ +
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+149
+150
+151
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 149
+
+def hide_const(constant_name)
+  ConstantMutator.hide(constant_name)
+end
+
+
+ +
+

+ + + - (Object) instance_double(doubled_class) + + - (Object) instance_double(doubled_class, stubs) + + + + + + +

+
+ +

Constructs a test double against a specific class. If the given class name +has been loaded, only instance methods defined on the class are allowed to +be stubbed. In all other ways it behaves like a double.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) instance_double(doubled_class) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Class) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) instance_double(doubled_class, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + doubled_class + + + (String, Class) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    InstanceVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+50
+51
+52
+53
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 50
+
+def instance_double(doubled_class, *args)
+  ref = ObjectReference.for(doubled_class)
+  ExampleMethods.declare_verifying_double(InstanceVerifyingDouble, ref, *args)
+end
+
+
+ +
+

+ + + - (Object) object_double(object_or_name) + + - (Object) object_double(object_or_name, stubs) + + + + + + +

+
+ +

Constructs a test double against a specific object. Only the methods the +object responds to are allowed to be stubbed. If a String argument is +provided, it is assumed to reference a constant object which is used for +verification. In all other ways it behaves like a double.

+ + +
+
+
+ +

Overloads:

+
    + + +
  • + - (Object) object_double(object_or_name) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + object_or_name + + + (String, Object) + + + +
    • + +
    + + +
    +
  • + + +
  • + - (Object) object_double(object_or_name, stubs) +
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + object_or_name + + + (String, Object) + + + +
    • + +
    • + + stubs + + + (Hash) + + + + — +
      +

      hash of message/return-value pairs

      +
      + +
    • + +
    + + +
    +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +
    +

    ObjectVerifyingDouble

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+82
+83
+84
+85
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 82
+
+def object_double(object_or_name, *args)
+  ref = ObjectReference.for(object_or_name, :allow_direct_object_refs)
+  ExampleMethods.declare_verifying_double(ObjectVerifyingDouble, ref, *args)
+end
+
+
+ +
+

+ + - (Object) receive + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Used to specify a message that you expect or allow an object to receive. +The object returned by receive supports the same fluent +interface that should_receive and stub have +always supported, allowing you to constrain the arguments or number of +times, and configure how the object should respond to the message.

+ + +
+
+
+ +
+

Examples:

+ + +

+expect(obj).to receive(:hello).with("world").exactly(3).times
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 218
+
+
+
+
+ +
+

+ + + - (Object) receive_message_chain(method1, method2) + + - (Object) receive_message_chain("method1.method2") + + - (Object) receive_message_chain(method1, method_to_value_hash) + + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

stubs/mocks a chain of messages on an object or test double.

+ +

Warning:

+ +

Chains can be arbitrarily long, which makes it quite painless to violate +the Law of Demeter in violent ways, so you should consider any use of +receive_message_chain a code smell. Even though not all code +smells indicate real problems (think fluent interfaces), +receive_message_chain still results in brittle examples. For +example, if you write allow(foo).to receive_message_chain(:bar, :baz +=> 37) in a spec and then the implementation calls +foo.baz.bar, the stub will not work.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow(double).to receive_message_chain("foo.bar") { :baz }
+allow(double).to receive_message_chain(:foo, :bar => :baz)
+allow(double).to receive_message_chain(:foo, :bar) { :baz }
+
+# Given any of ^^ these three forms ^^:
+double.foo.bar # => :baz
+
+# Common use in Rails/ActiveRecord:
+allow(Article).to receive_message_chain("recent.published") { [Article.new] }
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 245
+
+
+
+
+ +
+

+ + - (Object) receive_messages + + + + + +

+
+ +
+ Note: +
+

If you disable the :expect syntax this method will be +undefined.

+
+
+ + +

Shorthand syntax used to setup message(s), and their return value(s), that +you expect or allow an object to receive. The method takes a hash of +messages and their respective return values. Unlike with +receive, you cannot apply further customizations using a block +or the fluent interface.

+ + +
+
+
+ +
+

Examples:

+ + +

+allow(obj).to receive_messages(:speak => "Hello World")
+allow(obj).to receive_messages(:speak => "Hello", :meow => "Meow")
+ +
+ + +
+ + + + +
+
+
+
+
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 231
+
+
+
+
+ +
+

+ + - (Object) stub_const(constant_name, value, options = {}) + + + + + +

+
+ +

Stubs the named constant with the given value. Like method stubs, the +constant will be restored to its original value (or lack of one, if it was +undefined) when the example completes.

+ + +
+
+
+ +
+

Examples:

+ + +

+stub_const("MyClass", Class.new) # => Replaces (or defines) MyClass with a new class object.
+stub_const("SomeModel::PER_PAGE", 5) # => Sets SomeModel::PER_PAGE to 5.
+
+class CardDeck
+  SUITS = [:Spades, :Diamonds, :Clubs, :Hearts]
+  NUM_CARDS = 52
+end
+
+stub_const("CardDeck", Class.new)
+CardDeck::SUITS # => uninitialized constant error
+CardDeck::NUM_CARDS # => uninitialized constant error
+
+stub_const("CardDeck", Class.new, :transfer_nested_constants => true)
+CardDeck::SUITS # => our suits array
+CardDeck::NUM_CARDS # => 52
+
+stub_const("CardDeck", Class.new, :transfer_nested_constants => [:SUITS])
+CardDeck::SUITS # => our suits array
+CardDeck::NUM_CARDS # => uninitialized constant error
+ +
+

Parameters:

+
    + +
  • + + constant_name + + + (String) + + + + — +
    +

    The fully qualified name of the constant. The current constant scoping at +the point of call is not considered.

    +
    + +
  • + +
  • + + value + + + (Object) + + + + — +
    +

    The value to make the constant refer to. When the example completes, the +constant will be restored to its prior state.

    +
    + +
  • + +
  • + + options + + + (Hash) + + + (defaults to: {}) + + + — +
    +

    Stubbing options.

    +
    + +
  • + +
+ + + + + + + + +

Options Hash (options):

+
    + +
  • + :transfer_nested_constants + (Boolean, Array<Symbol>) + + + + + —
    +

    Determines what nested constants, if any, will be transferred from the +original value of the constant to the new value of the constant. This only +works if both the original and new values are modules (or classes).

    +
    + +
  • + +
+ + +

Returns:

+
    + +
  • + + + (Object) + + + + — +
    +

    the stubbed value of the constant

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+133
+134
+135
+
+
# File 'lib/rspec/mocks/example_methods.rb', line 133
+
+def stub_const(constant_name, value, options = {})
+  ConstantMutator.stub(constant_name, value, options)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html new file mode 100644 index 000000000..e94e4d649 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/ExampleMethods/ExpectHost.html @@ -0,0 +1,117 @@ + + + + + + Module: RSpec::Mocks::ExampleMethods::ExpectHost + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::ExampleMethods::ExpectHost + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/example_methods.rb
+ +
+
+ +

Overview

+
+ +

This module exists to host the expect method for cases where +rspec-mocks is used w/o rspec-expectations.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Matchers.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Matchers.html new file mode 100644 index 000000000..0cde118a6 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Matchers.html @@ -0,0 +1,118 @@ + + + + + + Module: RSpec::Mocks::Matchers + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::Matchers + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks.rb,
+ lib/rspec/mocks/matchers/receive.rb,
lib/rspec/mocks/matchers/have_received.rb,
lib/rspec/mocks/matchers/receive_messages.rb,
lib/rspec/mocks/matchers/receive_message_chain.rb,
lib/rspec/mocks/matchers/expectation_customization.rb
+
+ +
+
+ +

Overview

+
+ +

Namespace for mock-related matchers.

+ + +
+
+
+ + +
+ + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Syntax.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Syntax.html new file mode 100644 index 000000000..7846ff38d --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Syntax.html @@ -0,0 +1,929 @@ + + + + + + Module: RSpec::Mocks::Syntax + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::Syntax + + + Private +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/syntax.rb
+ +
+
+ +

Overview

+
+

+ This module is part of a private API. + You should avoid using this module if possible, as it may be removed or be changed in the future. +

+ +

Provides methods for enabling and disabling the available syntaxes provided +by rspec-mocks.

+ + +
+
+
+ + +
+ + + + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Object) default_should_syntax_host + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Determines where the methods like should_receive, and +stub are added.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+
+
# File 'lib/rspec/mocks/syntax.rb', line 181
+
+def self.default_should_syntax_host
+  # JRuby 1.7.4 introduces a regression whereby `defined?(::BasicObject) => nil`
+  # yet `BasicObject` still exists and patching onto ::Object breaks things
+  # e.g. SimpleDelegator expectations won't work
+  #
+  # See: https://github.com/jruby/jruby/issues/814
+  if defined?(JRUBY_VERSION) && JRUBY_VERSION == '1.7.4' && RUBY_VERSION.to_f > 1.8
+    return ::BasicObject
+  end
+
+  # On 1.8.7, Object.ancestors.last == Kernel but
+  # things blow up if we include `RSpec::Mocks::Methods`
+  # into Kernel...not sure why.
+  return Object unless defined?(::BasicObject)
+
+  # MacRuby has BasicObject but it's not the root class.
+  return Object unless Object.ancestors.last == ::BasicObject
+
+  ::BasicObject
+end
+
+
+ +
+

+ + + (Object) disable_expect(syntax_host = ::RSpec::Mocks::ExampleMethods) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Disables the expect syntax (expect(dbl).to receive, +allow(dbl).to receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+
+
# File 'lib/rspec/mocks/syntax.rb', line 150
+
+def self.disable_expect(syntax_host = ::RSpec::Mocks::ExampleMethods)
+  return unless expect_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    undef receive
+    undef receive_messages
+    undef receive_message_chain
+    undef allow
+    undef expect_any_instance_of
+    undef allow_any_instance_of
+  end
+
+  RSpec::Mocks::ExampleMethods::ExpectHost.class_exec do
+    undef expect
+  end
+end
+
+
+ +
+

+ + + (Object) disable_should(syntax_host = default_should_syntax_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Disables the should syntax (dbl.stub, +dbl.should_receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+
+
# File 'lib/rspec/mocks/syntax.rb', line 89
+
+def self.disable_should(syntax_host = default_should_syntax_host)
+  return unless should_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    undef should_receive
+    undef should_not_receive
+    undef stub
+    undef unstub
+    undef stub_chain
+    undef as_null_object
+    undef null_object?
+    undef received_message?
+  end
+
+  Class.class_exec do
+    undef any_instance
+  end
+end
+
+
+ +
+

+ + + (Object) enable_expect(syntax_host = ::RSpec::Mocks::ExampleMethods) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Enables the expect syntax (expect(dbl).to receive, +allow(dbl).to receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+
+
# File 'lib/rspec/mocks/syntax.rb', line 110
+
+def self.enable_expect(syntax_host = ::RSpec::Mocks::ExampleMethods)
+  return if expect_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    def receive(method_name, &block)
+      Matchers::Receive.new(method_name, block)
+    end
+
+    def receive_messages(message_return_value_hash)
+      matcher = Matchers::ReceiveMessages.new(message_return_value_hash)
+      matcher.warn_about_block if block_given?
+      matcher
+    end
+
+    def receive_message_chain(*messages, &block)
+      Matchers::ReceiveMessageChain.new(messages, &block)
+    end
+
+    def allow(target)
+      AllowanceTarget.new(target)
+    end
+
+    def expect_any_instance_of(klass)
+      AnyInstanceExpectationTarget.new(klass)
+    end
+
+    def allow_any_instance_of(klass)
+      AnyInstanceAllowanceTarget.new(klass)
+    end
+  end
+
+  RSpec::Mocks::ExampleMethods::ExpectHost.class_exec do
+    def expect(target)
+      ExpectationTarget.new(target)
+    end
+  end
+end
+
+
+ +
+

+ + + (Object) enable_should(syntax_host = default_should_syntax_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Enables the should syntax (dbl.stub, +dbl.should_receive, etc).

+ + +
+
+
+ + +
+ + + + +
+
+
+
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+
+
# File 'lib/rspec/mocks/syntax.rb', line 26
+
+def self.enable_should(syntax_host = default_should_syntax_host)
+  @warn_about_should = false if syntax_host == default_should_syntax_host
+  return if should_enabled?(syntax_host)
+
+  syntax_host.class_exec do
+    def should_receive(message, opts={}, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks.expect_message(self, message, opts, &block)
+    end
+
+    def should_not_receive(message, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks.expect_message(self, message, {}, &block).never
+    end
+
+    def stub(message_or_hash, opts={}, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      if ::Hash === message_or_hash
+        message_or_hash.each {|message, value| stub(message).and_return value }
+      else
+        ::RSpec::Mocks.allow_message(self, message_or_hash, opts, &block)
+      end
+    end
+
+    def unstub(message)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__, "`allow(...).to_receive(...).and_call_original` or explicitly enable `:should`")
+      ::RSpec::Mocks.space.proxy_for(self).remove_stub(message)
+    end
+
+    def stub_chain(*chain, &blk)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks::StubChain.stub_chain_on(self, *chain, &blk)
+    end
+
+    def as_null_object
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      @_null_object = true
+      ::RSpec::Mocks.space.proxy_for(self).as_null_object
+    end
+
+    def null_object?
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      defined?(@_null_object)
+    end
+
+    def received_message?(message, *args, &block)
+      ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+      ::RSpec::Mocks.space.proxy_for(self).received_message?(message, *args, &block)
+    end
+
+    unless Class.respond_to? :any_instance
+      Class.class_exec do
+        def any_instance
+          ::RSpec::Mocks::Syntax.warn_unless_should_configured(__method__)
+          ::RSpec::Mocks.space.any_instance_proxy_for(self)
+        end
+      end
+    end
+  end
+end
+
+
+ +
+

+ + + (Boolean) expect_enabled?(syntax_host = ::RSpec::Mocks::ExampleMethods) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Indicates whether or not the expect syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+175
+176
+177
+
+
# File 'lib/rspec/mocks/syntax.rb', line 175
+
+def self.expect_enabled?(syntax_host = ::RSpec::Mocks::ExampleMethods)
+  syntax_host.method_defined?(:allow)
+end
+
+
+ +
+

+ + + (Boolean) should_enabled?(syntax_host = default_should_syntax_host) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Indicates whether or not the should syntax is enabled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+169
+170
+171
+
+
# File 'lib/rspec/mocks/syntax.rb', line 169
+
+def self.should_enabled?(syntax_host = default_should_syntax_host)
+  syntax_host.method_defined?(:should_receive)
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/TestDouble.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/TestDouble.html new file mode 100644 index 000000000..b2f8bac58 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/TestDouble.html @@ -0,0 +1,613 @@ + + + + + + Module: RSpec::Mocks::TestDouble + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::TestDouble + + + +

+ +
+ + + + + + + +
Included in:
+
Double
+ + + +
Defined in:
+
lib/rspec/mocks/test_double.rb
+ +
+
+ +

Overview

+
+ +

Implements the methods needed for a pure test double. RSpec::Mocks::Double +includes this module, and it is provided for cases where you want a pure +test double without subclassing RSpec::Mocks::Double.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ +
    + +
  • + + + - (Object) ==(other) + + + + + + + + + + + + + +
    +

    This allows for comparing the mock to other objects that proxy such as +ActiveRecords belongs_to proxy objects.

    +
    + +
  • + + +
  • + + + - (Object) as_null_object + + + + + + + + + + + + + +
    +

    Tells the object to respond to all messages.

    +
    + +
  • + + +
  • + + + - (Object) freeze + + + + + + + + + + + + + +
    +

    Override for default freeze implementation to prevent freezing of test +doubles.

    +
    + +
  • + + +
  • + + + - (Object) initialize(name = nil, stubs = {}) + + + + + + + + + + + + + +
    +

    Creates a new test double with a name (that will be used in +error messages only).

    +
    + +
  • + + +
  • + + + - (Boolean) null_object? + + + + + + + + + + + + + +
    +

    Returns true if this object has received as_null_object.

    +
    + +
  • + + +
+ + +
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + - (Object) method_missing(message, *args, &block) (private) + + + + + +

+
+ + +
+
+
+ +

Raises:

+
    + +
  • + + + (NoMethodError) + + + +
  • + +
+ +
+ + + + +
+
+
+
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+
+
# File 'lib/rspec/mocks/test_double.rb', line 73
+
+def method_missing(message, *args, &block)
+  proxy = __mock_proxy
+  proxy.record_message_received(message, *args, &block)
+
+  if proxy.null_object?
+    case message
+    when :to_int        then return 0
+    when :to_a, :to_ary then return nil
+    when :to_str        then return to_s
+    else return self
+    end
+  end
+
+  # Defined private and protected methods will still trigger `method_missing`
+  # when called publicly. We want ruby's method visibility error to get raised,
+  # so we simply delegate to `super` in that case.
+  # ...well, we would delegate to `super`, but there's a JRuby
+  # bug, so we raise our own visibility error instead:
+  # https://github.com/jruby/jruby/issues/1398
+  visibility = proxy.visibility_for(message)
+  if visibility == :private || visibility == :protected
+    ErrorGenerator.new(self, @name).raise_non_public_error(
+      message, visibility
+    )
+  end
+
+  # Required wrapping doubles in an Array on Ruby 1.9.2
+  raise NoMethodError if [:to_a, :to_ary].include? message
+  proxy.raise_unexpected_message_error(message, *args)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + - (Object) ==(other) + + + + + +

+
+ +

This allows for comparing the mock to other objects that proxy such as +ActiveRecords belongs_to proxy objects. By making the other object run the +comparison, we're sure the call gets delegated to the proxy target.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lib/rspec/mocks/test_double.rb', line 36
+
+def ==(other)
+  other == __mock_proxy
+end
+
+
+ +
+

+ + - (Object) as_null_object + + + + + +

+
+ +

Tells the object to respond to all messages. If specific stub values are +declared, they'll work as expected. If not, the receiver is returned.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/rspec/mocks/test_double.rb', line 23
+
+def as_null_object
+  __mock_proxy.as_null_object
+end
+
+
+ +
+

+ + - (Object) freeze + + + + + +

+
+ +

Override for default freeze implementation to prevent freezing of test +doubles.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+67
+68
+69
+
+
# File 'lib/rspec/mocks/test_double.rb', line 67
+
+def freeze
+  RSpec.warn_with("WARNING: you attempted to freeze a test double. This is explicitly a no-op as freezing doubles can lead to undesired behaviour when resetting tests.")
+end
+
+
+ +
+

+ + - (Object) initialize(name = nil, stubs = {}) + + + + + +

+
+ +

Creates a new test double with a name (that will be used in +error messages only)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'lib/rspec/mocks/test_double.rb', line 9
+
+def initialize(name=nil, stubs={})
+  @__expired = false
+  if Hash === name && stubs.empty?
+    stubs = name
+    @name = nil
+  else
+    @name = name
+  end
+  assign_stubs(stubs)
+end
+
+
+ +
+

+ + - (Boolean) null_object? + + + + + +

+
+ +

Returns true if this object has received as_null_object

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lib/rspec/mocks/test_double.rb', line 28
+
+def null_object?
+  __mock_proxy.null_object?
+end
+
+
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html new file mode 100644 index 000000000..0e1f658cf --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/VerifyingMessageExpectation.html @@ -0,0 +1,324 @@ + + + + + + Class: RSpec::Mocks::VerifyingMessageExpectation + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Class: RSpec::Mocks::VerifyingMessageExpectation + + + Private +

+ +
+ +
Inherits:
+
+ MessageExpectation + +
    +
  • Object
  • + + + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/rspec/mocks/verifying_message_expecation.rb
+ +
+
+ +

Overview

+
+

+ This class is part of a private API. + You should avoid using this class if possible, as it may be removed or be changed in the future. +

+ +

A message expectation that knows about the real implementation of the +message being expected, so that it can verify that any expectations have +the valid arguments.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary (collapse)

+
    + +
  • + + + - (Object) method_reference + + + + + + + + + + + + + + private + + +
    +

    A level of indirection is used here rather than just passing in the method +itself, since method look up is expensive and we only want to do it if +actually needed.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + + + + + +
+

Constructor Details

+ +
+

+ + - (VerifyingMessageExpectation) initialize(*args) + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

Returns a new instance of VerifyingMessageExpectation

+ + +
+
+
+ + +
+ + + + +
+
+
+
+22
+23
+24
+
+
# File 'lib/rspec/mocks/verifying_message_expecation.rb', line 22
+
+def initialize(*args)
+  super
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + - (Object) method_reference + + + + + +

+
+

+ This method is part of a private API. + You should avoid using this method if possible, as it may be removed or be changed in the future. +

+ +

A level of indirection is used here rather than just passing in the method +itself, since method look up is expensive and we only want to do it if +actually needed.

+ +

Conceptually the method reference makes more sense as a constructor +argument since it should be immutable, but it is significantly more +straight forward to build the object in pieces so for now it stays as an +accessor.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+20
+21
+22
+
+
# File 'lib/rspec/mocks/verifying_message_expecation.rb', line 20
+
+def method_reference
+  @method_reference
+end
+
+
+ +
+ + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Version.html b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Version.html new file mode 100644 index 000000000..e1547e84e --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/RSpec/Mocks/Version.html @@ -0,0 +1,139 @@ + + + + + + Module: RSpec::Mocks::Version + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Module: RSpec::Mocks::Version + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/rspec/mocks/version.rb
+ +
+
+ +

Overview

+
+ +

Version information for RSpec mocks.

+ + +
+
+
+ + +
+

Constant Summary

+ +
+ +
STRING = +
+
+ +

Version of RSpec mocks currently in use in SemVer format.

+ + +
+
+
+ + +
+
+
'3.0.4'
+ +
+ + + + + + + + + + +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/_index.html b/source/documentation/3.0/rspec-mocks/_index.html new file mode 100644 index 000000000..e7e976446 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/_index.html @@ -0,0 +1,299 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Documentation by YARD 0.8.7.6

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + + + + + + + + + + +
    +
  • D
  • +
      + +
    • + Double + + (RSpec::Mocks) + +
    • + +
    +
+ + + + + +
    +
  • M
  • +
      + +
    • + Matchers + + (RSpec::Mocks) + +
    • + +
    • + Mocks + + (RSpec) + +
    • + +
    +
+ + +
    +
  • R
  • + +
+ + +
+ + +
    +
  • S
  • +
      + +
    • + Syntax + + (RSpec::Mocks) + +
    • + +
    +
+ + +
    +
  • T
  • + +
+ + + + +
+ +
+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/class_list.html b/source/documentation/3.0/rspec-mocks/class_list.html new file mode 100644 index 000000000..0dcaf4e45 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/class_list.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + Class List + + + + +
+

Class List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-mocks/file.Changelog.html b/source/documentation/3.0/rspec-mocks/file.Changelog.html new file mode 100644 index 000000000..21cc982c3 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/file.Changelog.html @@ -0,0 +1,1217 @@ + + + + + + File: Changelog + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

3.0.5 Development

+ +

Full +Changelog

+ +

Bugfixes:

+
  • +

    Remove any_number_of_times from any_instance +recorders that were erroneously causing mention of the method in +documentation. (Jon Rowe, #760)

    +
  • +

    Prevent included modules being detected as prepended modules on Ruby 2.0. +(Eugene Kenny, #771)

    +
+ +

3.0.4 / 2014-08-14

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Restore kind_of(x) to match using arg.kind_of?(x) +(like RSpec 2) rather than x === arg. (Jon Rowe, #750)

    +
+ +

3.0.3 / 2014-07-21

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    have_received matcher will raise “does not implement” errors +correctly when used with verifying doubles and partial doubles. (Xavier +Shay, #722)

    +
  • +

    Make double.as_null_object.dup and +double.as_null_object.clone make the copies be null objects. +(Myron Marston, #732)

    +
  • +

    Don't inadvertently define BasicObject in 1.8.7. (Chris +Griego, #739)

    +
+ +

3.0.2 / 2014-06-19

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix edge case that triggered “can't add a new key into hash during +iteration” during mock verification. (Sam Phippen, Myron Marston, #711)

    +
  • +

    Fix verifying doubles so that when they accidentally leak into another +example, they provide the same clear error message that normal doubles do. +(Myron Marston, #718)

    +
  • +

    Make ordered work with exact receive counts. (Sam Phippen, +#713)

    +
+ +

3.0.1 / 2014-06-07

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix receive_message_chain(...) so that it supports +with just like stub_chain did. (Jon Rowe, #697)

    +
  • +

    Fix regression in expect_any_instance_of so that it expects +the message on any instance rather than on every +instance. (Myron Marston, #699)

    +
+ +

3.0.0 / 2014-06-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix module prepend detection to work properly on ruby 2.0 for a case where +a module is extended onto itself. (Myron Marston)

    +
  • +

    Fix transfer_nested_constants option so that transferred +constants get properly reset at the end of the example. (Myron Marston)

    +
  • +

    Fix config.transfer_nested_constants = true so that you +don't erroneously get errors when stubbing a constant that is not a +module or a class. (Myron Marston)

    +
  • +

    Fix regression that caused double(:class => SomeClass) to +later trigger infinite recursion. (Myron Marston)

    +
  • +

    Fix bug in have_received(...).with(...).ordered where it was +not taking the args into account when checking the order. (Myron Marston)

    +
  • +

    Fix bug in have_received(...).ordered where it was wrongly +considering stubs when checking the order. (Myron Marston)

    +
  • +

    Message expectation matchers now show descriptions from argument matchers +when their expectations aren't met. (Jon Rowe)

    +
  • +

    Display warning when encountering TypeError during instance +method staging on 2.0.0-p195, suffers from bugs.ruby-lang.org/issues/8686 +too. (Cezar Halmagean).

    +
+ +

3.0.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Remove RSpec::Mocks::TestDouble.extend_onto. (Myron Marston)

    +
  • +

    Remove RSpec::Mocks::ConstantStubber. (Jon Rowe)

    +
  • +

    Make monkey-patch of Marshal to support dumping of stubbed objects opt-in. +(Xavier Shay)

    +
+ +

Enhancements:

+
  • +

    Instead of crashing when cleaning up stub methods on a frozen object, it +now issues a warning explaining that it's impossible to clean up the +stubs. (Justin Coyne and Sam Phippen)

    +
  • +

    Add meaningful descriptions to anything, +duck_type and instance_of argument matchers. +(Jon Rowe)

    +
+ +

Bug Fixes:

+
  • +

    Fix regression introduced in 3.0.0.beta2 that caused +double.as_null_object.to_str to return the double rather than +a string. (Myron Marston)

    +
  • +

    Fix bug in expect(dbl).to receive_message_chain(:foo, :bar) +where it was not setting an expectation for the last message in the chain. +(Jonathan del Strother)

    +
  • +

    Allow verifying partial doubles to have private methods stubbed. (Xavier +Shay)

    +
  • +

    Fix bug with allowing/expecting messages on Class objects which have had +their singleton class prepended to. (Jon Rowe)

    +
  • +

    Fix an issue with 1.8.7 not running implementation blocks on partial +doubles. (Maurício Linhares)

    +
  • +

    Prevent StackLevelTooDeep errors when stubbing an +any_instance method that's accessed in +inspect by providing our own inspect output. (Jon Rowe)

    +
  • +

    Fix bug in any_instance logic that did not allow you to mock +or stub private methods if verify_partial_doubles was +configured. (Oren Dobzinski)

    +
  • +

    Include useful error message when trying to observe an unimplemented method +on an any instance. (Xavier Shay)

    +
  • +

    Fix and_call_original to work properly when multiple classes +in an inheritance hierarchy have been stubbed with the same method. (Myron +Marston)

    +
  • +

    Fix any_instance so that it updates existing instances that +have already been stubbed. (Myron Marston)

    +
  • +

    Fix verified doubles so that their class name is included in failure +messages. (Myron Marston)

    +
  • +

    Fix expect_any_instance_of so that when the message is +received on an individual instance that has been directly stubbed, it +still satisfies the expectation. (Sam Phippen, Myron Marston)

    +
  • +

    Explicitly disallow using any_instance to mock or stub a +method that is defined on a module prepended onto the class. This +triggered SystemStackError before and is very hard to support +so we are not supporting it at this time. (Myron Marston)

    +
+ +

3.0.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Rename RSpec::Mocks::Mock to +RSpec::Mocks::Double. (Myron Marston)

    +
  • +

    Change how to integrate rspec-mocks in other test frameworks. You now need +to include RSpec::Mocks::ExampleMethods in your test context. +(Myron Marston)

    +
  • +

    Prevent RSpec mocks' doubles and partial doubles from being used +outside of the per-test lifecycle (e.g. from a before(:all) +hook). (Sam Phippen)

    +
  • +

    Remove the host argument of RSpec::Mocks.setup. +Instead RSpec::Mocks::ExampleMethods should be included +directly in the scope where RSpec's mocking capabilities are used. +(Sam Phippen)

    +
  • +

    Make test doubles raise errors if you attempt to use them after they get +reset, to help surface issues when you accidentally retain references to +test doubles and attempt to reuse them in another example. (Myron Marston)

    +
  • +

    Remove support for and_return { value } and +and_return without arguments. (Yuji Nakayama)

    +
+ +

Enhancements:

+
  • +

    Add receive_message_chain which provides the functionality of +the old stub_chain for the new allow/expect syntax. Use it +like so: allow(...).to receive_message_chain(:foo, :bar, +:bazz). (Sam Phippen).

    +
  • +

    Change argument matchers to use === as their primary matching +protocol, since their semantics mirror that of a case or rescue statement +(which uses === for matching). (Myron Marston)

    +
  • +

    Add RSpec::Mocks.with_temporary_scope, which allows you to +create temporary rspec-mocks scopes in arbitrary places (such as a +before(:all) hook). (Myron Marston)

    +
  • +

    Support keyword arguments when checking arity with verifying doubles. +(Xavier Shay)

    +
+ +

Bug Fixes:

+
  • +

    Fix regression in 3.0.0.beta1 that caused +double("string_name" => :value) to stop working. +(Xavier Shay)

    +
  • +

    Fix the way rspec-mocks and rspec-core interact so that if users define a +let with the same name as one of the methods from +RSpec::Mocks::ArgumentMatchers, the user's +let takes precedence. (Michi Huber, Myron Marston)

    +
  • +

    Fix verified doubles so that their methods match the visibility (public, +protected or private) of the interface they verify against. (Myron +Marston)

    +
  • +

    Fix verified null object doubles so that they do not wrongly report that +they respond to anything. They only respond to methods available on the +interface they verify against. (Myron Marston)

    +
  • +

    Fix deprecation warning for use of old :should syntax w/o +explicit config so that it no longer is silenced by an extension gem such +as rspec-rails when it calls +config.add_stub_and_should_receive_to. (Sam Phippen)

    +
  • +

    Fix expect syntax so that it does not wrongly emit a +“You're overriding a previous implementation for this stub” warning +when you are not actually doing that. (Myron Marston)

    +
  • +

    Fix any_instance.unstub when used on sub classes for whom the +super class has had any_instance.stub invoked on. (Jon Rowe)

    +
  • +

    Fix regression in +stub_chain/receive_message_chain that caused it +to raise an ArgumentError when passing args to the stubbed +methods. (Sam Phippen)

    +
  • +

    Correct stub of undefined parent modules all the way down when stubbing a +nested constant. (Xavier Shay)

    +
  • +

    Raise VerifyingDoubleNotDefinedError when a constant is not +defined for a verifying class double. (Maurício Linhares)

    +
  • +

    Remove Double#to_str, which caused confusing raise +some_double behavior. (Maurício Linhares)

    +
+ +

3.0.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Breaking Changes for 3.0.0:

+
  • +

    Raise an explicit error if should_not_receive(...).and_return +is used. (Sam Phippen)

    +
  • +

    Remove 1.8.6 workarounds. (Jon Rowe)

    +
  • +

    Remove stub! and unstub!. (Sam Phippen)

    +
  • +

    Remove mock(name, methods) and stub(name, +methods), leaving double(name, methods) for creating +test doubles. (Sam Phippen, Michi Huber)

    +
  • +

    Remove any_number_of_times since +should_receive(:msg).any_number_of_times is really a stub in +a mock's clothing. (Sam Phippen)

    +
  • +

    Remove support for re-using the same null-object test double in multiple +examples. Test doubles are designed to only live for one example. (Myron +Marston)

    +
  • +

    Make at_least(0) raise an error. (Sam Phippen)

    +
  • +

    Remove support for require 'spec/mocks' which had been +kept in place for backwards compatibility with RSpec 1. (Myron Marston)

    +
  • +

    Blocks provided to with are always used as implementation. +(Xavier Shay)

    +
  • +

    The config option (added in 2.99) to yield the receiver to +any_instance implementation blocks now defaults to “on”. (Sam +Phippen)

    +
+ +

Enhancements:

+
  • +

    Allow the have_received matcher to use a block to set further +expectations on arguments. (Tim Cowlishaw)

    +
  • +

    Provide instance_double and class_double to +create verifying doubles, ported from rspec-fire. (Xavier +Shay)

    +
  • +

    as_null_object on a verifying double only responds to defined +methods. (Xavier Shay)

    +
  • +

    Provide object_double to create verified doubles of specific +object instances. (Xavier Shay)

    +
  • +

    Provide verify_partial_doubles configuration that provides +object_double like verification behaviour on partial doubles. +(Xavier Shay)

    +
  • +

    Improved performance of double creation, particularly those with many +attributes. (Xavier Shay)

    +
  • +

    Default value of transfer_nested_constants option for constant +stubbing can be configured. (Xavier Shay)

    +
  • +

    Messages can be allowed or expected on in bulk via +receive_messages(:message => :value). (Jon Rowe)

    +
  • +

    allow(Klass.any_instance) and +expect(Klass.any_instance) now print a warning. This is +usually a mistake, and users usually want +allow_any_instance_of or expect_any_instance_of +instead. (Sam Phippen)

    +
  • +

    instance_double and class_double raise +ArgumentError if the underlying module is loaded and the +arity of the method being invoked does not match the arity of the method +as it is actually implemented. (Andy Lindeman)

    +
  • +

    Spies can now check their invocation ordering is correct. (Jon Rowe)

    +
+ +

Deprecations:

+
  • +

    Using the old :should syntax without explicitly configuring it +is deprecated. It will continue to work but will emit a deprecation +warning in RSpec 3 if you do not explicitly enable it. (Sam Phippen)

    +
+ +

Bug Fixes:

+
  • +

    Fix and_call_original to handle a complex edge case involving +singleton class ancestors. (Marc-André Lafortune, Myron Marston)

    +
  • +

    When generating an error message for unexpected arguments, use +#inspect rather than #description if +#description returns nil or +'' so that you still get a useful message. (Nick +DeLuca)

    +
+ +

2.99.2 / 2014-07-21

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Warn about upcoming change to #=== matching and +DateTime#=== behaviour. (Jon Rowe, #735)

    +
+ +

2.99.1 / 2014-06-12

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix bug that caused errors at the end of each example when a +double.as_null_object had been frozen. (Yuji Nakayama, #698)

    +
+ +

Deprecations:

+
  • +

    Deprecate freezing a test double. (Yuji Nakayama, #698)

    +
+ +

2.99.0 / 2014-06-01

+ +

Full +Changelog

+ +

No changes. Just taking it out of pre-release.

+ +

2.99.0.rc1 / 2014-05-18

+ +

Full +Changelog

+ +

Deprecations:

+
  • +

    Deprecate RSpec::Mocks::TestDouble.extend_onto. (Myron +Marston)

    +
  • +

    Deprecate RSpec::Mocks::ConstantStubber. (Jon Rowe)

    +
  • +

    Deprecate Marshal.dump monkey-patch without opt-in. (Xavier +Shay)

    +
+ +

2.99.0.beta2 / 2014-02-17

+ +

Full +Changelog

+ +

Deprecations:

+
  • +

    Deprecate RSpec::Mocks::Mock in favor of +RSpec::Mocks::Double. (Myron Marston)

    +
  • +

    Deprecate the host argument of +RSpec::Mocks.setup. Instead +RSpec::Mocks::ExampleMethods should be included directly in +the scope where RSpec's mocking capabilities are used. (Sam Phippen)

    +
  • +

    Deprecate using any of rspec-mocks' features outside the per-test +lifecycle (e.g. from a before(:all) hook). (Myron Marston)

    +
  • +

    Deprecate re-using a test double in another example. (Myron Marston)

    +
  • +

    Deprecate and_return { value } and and_return +without arguments. (Yuji Nakayama)

    +
+ +

2.99.0.beta1 / 2013-11-07

+ +

Full +Changelog

+ +

Deprecations

+
  • +

    Expecting to use lambdas or other strong arity implementations for stub +methods with mis-matched arity is deprecated and support for them will be +removed in 3.0. Either provide the right amount of arguments or use a weak +arity implementation (methods with splats or procs). (Jon Rowe)

    +
  • +

    Using the same test double instance in multiple examples is deprecated. +Test doubles are only meant to live for one example. The mocks and stubs +have always been reset between examples; however, in 2.x the +as_null_object state was not reset and some users relied on +this to have a null object double that is used for many examples. This +behavior will be removed in 3.0. (Myron Marston)

    +
  • +

    Print a detailed warning when an any_instance implementation +block is used when the new +yield_receiver_to_any_instance_implementation_blocks config +option is not explicitly set, as RSpec 3.0 will default to enabling this +new feature. (Sam Phippen)

    +
+ +

Enhancements:

+
  • +

    Add a config option to yield the receiver to any_instance +implementation blocks. (Sam Phippen)

    +
+ +

2.14.6 / 2014-02-20

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Ensure any_instance method stubs and expectations are torn +down regardless of expectation failures. (Sam Phippen)

    +
+ +

2.14.5 / 2014-02-01

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix regression that caused block implementations to not receive all args +on 1.8.7 if the block also receives a block, due to Proc#arity reporting +1 no matter how many args the block receives if it receives a +block, too. (Myron Marston)

    +
+ +

2.14.4 / 2013-10-15

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix issue where unstubing methods on “any instances” would not remove +stubs on existing instances (Jon Rowe)

    +
  • +

    Fix issue with receive(:message) do … end precedence preventing the usage +of modifications (and_return etc) (Jon Rowe)

    +
+ +

2.14.3 / 2013-08-08

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix stubbing some instance methods for classes whose hierarchy includes a +prepended Module (Bradley Schaefer)

    +
+ +

2.14.2 / 2013-07-30

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Fix as_null_object doubles so that they return +nil from to_ary (Jon Rowe).

    +
  • +

    Fix regression in 2.14 that made stub! (with an implicit +receiver) return a test double rather than stub a method (Myron Marston).

    +
+ +

2.14.1 / 2013-07-07

+ +

Full +Changelog

+ +

Bug Fixes:

+
  • +

    Restore double.as_null_object behavior from 2.13 and earlier: +a double's nullness persisted between examples in earlier examples. +While this is not an intended use case (test doubles are meant to live for +only one example), we don't want to break behavior users rely on in a +minor relase. This will be deprecated in 2.99 and removed in 3.0. (Myron +Marston)

    +
+ +

2.14.0 / 2013-07-06

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Document test spies in the readme. (Adarsh Pandit)

    +
  • +

    Add an array_including matcher. (Sam Phippen)

    +
  • +

    Add a syntax-agnostic API for mocking or stubbing a method. This is +intended for use by libraries such as rspec-rails that need to mock or +stub a method, and work regardless of the syntax the user has configured +(Paul Annesley, Myron Marston and Sam Phippen).

    +
+ +

Bug Fixes:

+
  • +

    Fix double so that it sets up passed stubs correctly +regardless of the configured syntax (Paul Annesley).

    +
  • +

    Allow a block implementation to be used in combination with +and_yield, and_raise, and_return or +and_throw. This got fixed in 2.13.1 but failed to get merged +into master for the 2.14.0.rc1 release (Myron Marston).

    +
  • +

    Marshal.dump does not unnecessarily duplicate objects when +rspec-mocks has not been fully initialized. This could cause errors when +using spork or similar preloading gems (Andy Lindeman).

    +
+ +

2.14.0.rc1 / 2013-05-27

+ +

Full +Changelog

+ +

Enhancements:

+
  • +

    Refactor internals so that the mock proxy methods and state are held +outside of the mocked object rather than inside it. This paves the way for +future syntax enhancements and removes the need for some hacky work +arounds for any_instance dup'ing and YAML +serialization, among other things. Note that the code now relies upon +__id__ returning a unique, consistent value for any object +you want to mock or stub (Myron Marston).

    +
  • +

    Add support for test spies. This allows you to verify a message was +received afterwards using the have_received matcher. Note +that you must first stub the method or use a null double. (Joe Ferris and +Joël Quenneville)

    +
  • +

    Make at_least and at_most style receive +expectations print that they were expecting at least or at most some +number of calls, rather than just the number of calls given in the +expectation (Sam Phippen)

    +
  • +

    Make with style receive expectations print the args they were +expecting, and the args that they got (Sam Phippen)

    +
  • +

    Fix some warnings seen under ruby 2.0.0p0 (Sam Phippen).

    +
  • +

    Add a new :expect syntax for message expectations (Myron +Marston and Sam Phippen).

    +
+ +

Bug fixes

+
  • +

    Fix any_instance so that a frozen object can be +dup'd when methods have been stubbed on that type using +any_instance (Jon Rowe).

    +
  • +

    Fix and_call_original so that it properly raises an +ArgumentError when the wrong number of args are passed (Jon +Rowe).

    +
  • +

    Fix double on 1.9.2 so you can wrap them in an Array using +Array(my_double) (Jon Rowe).

    +
  • +

    Fix stub_const and hide_const to handle constants +that redefine send (Sam Phippen).

    +
  • +

    Fix Marshal.dump extension so that it correctly handles nil. +(Luke Imhoff, Jon Rowe)

    +
  • +

    Fix isolation of allow_message_expectations_on_nil (Jon Rowe)

    +
  • +

    Use inspect to format actual arguments on expectations in failure messages +(#280, Ben Langfeld)

    +
  • +

    Protect against improperly initialised test doubles (#293) (Joseph +Shraibman and Jon Rowe)

    +
+ +

Deprecations

+
  • +

    Deprecate stub and mock as aliases for +double. double is the best term for creating a +test double, and it reduces confusion to have only one term (Michi Huber).

    +
  • +

    Deprecate stub! and unstub! in favor of +stub and unstub (Jon Rowe).

    +
  • +

    Deprecate at_least(0).times and +any_number_of_times (Michi Huber).

    +
+ +

2.13.1 / 2013-04-06

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Allow a block implementation to be used in combination with +and_yield, and_raise, and_return or +and_throw (Myron Marston).

    +
+ +

2.13.0 / 2013-02-23

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix bug that caused weird behavior when a method that had previously been +stubbed with multiple return values (e.g. +obj.stub(:foo).and_return(1, 2)) was later mocked with a +single return value (e.g. +obj.should_receive(:foo).once.and_return(1)). (Myron Marston)

    +
  • +

    Fix bug related to a mock expectation for a method that already had +multiple stubs with different with constraints. Previously, +the first stub was used, even though it may not have matched the passed +args. The fix defers this decision until the message is received so that +the proper stub response can be chosen based on the passed arguments +(Myron Marston).

    +
  • +

    Do not call nil? extra times on a mocked object, in case +nil? itself is expected a set number of times (Myron +Marston).

    +
  • +

    Fix missing_default_stub_error message so array args are +handled properly (Myron Marston).

    +
  • +

    Explicitly disallow any_instance.unstub! (Ryan Jones).

    +
  • +

    Fix any_instance stubbing so that it works with +Delegator subclasses (Myron Marston).

    +
  • +

    Fix and_call_original so that it works with +Delegator subclasses (Myron Marston).

    +
  • +

    Fix any_instance.should_not_receive when +any_instance.should_receive is used on the same class in the +same example. Previously it would wrongly report a failure even when the +message was not received (Myron Marston).

    +
+ +

2.12.2 / 2013-01-27

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix and_call_original to work properly for methods defined on +a module extended onto an object instance (Myron Marston).

    +
  • +

    Fix stub_const with an undefined constnat name to work +properly with constant strings that are prefixed with :: – +and edge case I missed in the bug fix in the 2.12.1 release (Myron +Marston).

    +
  • +

    Ensure method visibility on a partial mock is restored after reseting +method stubs, even on a singleton module (created via extend +self) when the method visibility differs between the instance and +singleton versions (Andy Lindeman).

    +
+ +

2.12.1 / 2012-12-21

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix any_instance to support and_call_original. +(Myron Marston)

    +
  • +

    Properly restore stubbed aliased methods on rubies that report the +incorrect owner (Myron Marston and Andy Lindeman).

    +
  • +

    Fix hide_const and stub_const with a defined +constnat name to work properly with constant strings that are prefixed +with :: (Myron Marston).

    +
+ +

2.12.0 / 2012-11-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    and_raise can accept an exception class and message, more +closely matching Kernel#raise (e.g., +foo.stub(:bar).and_raise(RuntimeError, "message")) +(Bas Vodde)

    +
  • +

    Add and_call_original, which will delegate the message to the +original method (Myron Marston).

    +
+ +

Deprecations:

+
  • +

    Add deprecation warning when using and_return with +should_not_receive (Neha Kumari)

    +
+ +

2.11.3 / 2012-09-19

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix :transfer_nested_constants option of +stub_const so that it doesn't blow up when there are +inherited constants. (Myron Marston)

    +
  • +

    any_instance stubs can be used on classes that override +Object#method. (Andy Lindeman)

    +
  • +

    Methods stubbed with any_instance are unstubbed after the test +finishes. (Andy Lindeman)

    +
  • +

    Fix confusing error message when calling a mocked class method an extra +time with the wrong arguments (Myron Marston).

    +
+ +

2.11.2 / 2012-08-11

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Don't modify dup on classes that don't support +dup (David Chelimsky)

    +
  • +

    Fix any_instance so that it works properly with methods +defined on a superclass. (Daniel Eguzkiza)

    +
  • +

    Fix stub_const so that it works properly for nested constants +that share a name with a top-level constant (e.g. “MyGem::Hash”). (Myron +Marston)

    +
+ +

2.11.1 / 2012-07-09

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix should_receive so that when it is called on an +as_null_object double with no implementation, and there is a +previous explicit stub for the same method, the explicit stub remains +(rather than being overriden with the null object +implementation–return self). (Myron Marston)

    +
+ +

2.11.0 / 2012-07-07

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Expose ArgumentListMatcher as a formal API

    +
    • +

      supports use by 3rd party mock frameworks like Surrogate

      +
    +
  • +

    Add stub_const API to stub constants for the duration of an +example (Myron Marston).

    +
+ +

Bug fixes

+
  • +

    Fix regression of edge case behavior. double.should_receive(:foo) { a +} was causing a NoMethodError when +double.stub(:foo).and_return(a, b) had been setup before +(Myron Marston).

    +
  • +

    Infinite loop generated by using any_instance and +dup. (Sidu Ponnappa @kaiwren)

    +
  • +

    double.should_receive(:foo).at_least(:once).and_return(a) +always returns a even if :foo is already stubbed.

    +
  • +

    Prevent infinite loop when interpolating a null double into a string as an +integer ("%i" % double.as_null_object). (Myron +Marston)

    +
  • +

    Fix should_receive so that null object behavior (e.g. +returning self) is preserved if no implementation is given (Myron +Marston).

    +
  • +

    Fix and_raise so that it raises RuntimeError +rather than Exception by default, just like ruby does. +(Andrew Marshall)

    +
+ +

2.10.1 / 2012-05-05

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    fix regression of edge case behavior (github.com/rspec/rspec-mocks/issues/132)

    +
    • +

      fixed failure of +object.should_receive(:message).at_least(0).times.and_return +value

      +
    • +

      fixed failure of object.should_not_receive(:message).and_return +value

      +
    +
+ +

2.10.0 / 2012-05-03

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    fail fast when an exactly or at_most expectation +is exceeded

    +
+ +

2.9.0 / 2012-03-17

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Support order constraints across objects (preethiramdev)

    +
+ +

Bug fixes

+
  • +

    Allow a as_null_object to be passed to with

    +
  • +

    Pass proc to block passed to stub (Aubrey Rhodes)

    +
  • +

    Initialize child message expectation args to match any args (#109 - +preethiramdev)

    +
+ +

2.8.0 / 2012-01-04

+ +

Full +Changelog

+ +

No changes for this release. Just releasing with the other rspec gems.

+ +

2.8.0.rc2 / 2011-12-19

+ +

Full +Changelog

+ +

No changes for this release. Just releasing with the other rspec gems.

+ +

2.8.0.rc1 / 2011-11-06

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Eliminate Ruby warnings (Matijs van Zuijlen)

    +
+ +

2.7.0 / 2011-10-16

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Use __send__ rather than send (alextk)

    +
  • +

    Add support for any_instance.stub_chain (Sidu Ponnappa)

    +
  • +

    Add support for any_instance argument matching based on +with (Sidu Ponnappa and Andy Lindeman)

    +
+ +

Changes

+
  • +

    Check for failure_message_for_should or +failure_message instead of description to detect +a matcher (Tibor Claassen)

    +
+ +

Bug fixes

+
  • +

    pass a hash to any_instance.stub. (Justin Ko)

    +
  • +

    allow to_ary to be called without raising +NoMethodError (Mikhail Dieterle)

    +
  • +

    any_instance properly restores private methods (Sidu Ponnappa)

    +
+ +

2.6.0 / 2011-05-12

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Add support for any_instance.stub and +any_instance.should_receive (Sidu Ponnappa and Andy Lindeman)

    +
+ +

Bug fixes

+
  • +

    fix bug in which multiple chains with shared messages ending in hashes +failed to return the correct value

    +
+ +

2.5.0 / 2011-02-05

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    message expectation counts now work in combination with a stub (Damian +Nurzynski)

    +
  • +

    fix failure message when message received with incorrect args (Josep M. +Bach)

    +
+ +

2.4.0 / 2011-01-02

+ +

Full +Changelog

+ +

No functional changes in this release, which was made to align with the +rspec-core-2.4.0 release.

+ +

2.3.0 / 2010-12-12

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix our Marshal extension so that it does not interfere with objects that +have their own @mock_proxy instance variable. (Myron Marston)

    +
+ +

2.2.0 / 2010-11-28

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    Added “rspec/mocks/standalone” for exploring the rspec-mocks in irb.

    +
+ +

Bug fix

+
  • +

    Eliminate warning on splat args without parens (Gioele Barabucci)

    +
  • +

    Fix bug where +obj.should_receive(:foo).with(stub.as_null_object) would pass +with a false positive.

    +
+ +

2.1.0 / 2010-11-07

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    Fix serialization of stubbed object (Josep M Bach)

    +
+ +

2.0.0 / 2010-10-10

+ +

Full +Changelog

+ +

2.0.0.rc / 2010-10-05

+ +

Full +Changelog

+ +

Enhancements

+
  • +

    support passing a block to an expectation block (Nicolas Braem)

    +
    • +

      obj.should_receive(:msg) {|&block| ... }

      +
    +
+ +

Bug fixes

+
  • +

    Fix YAML serialization of stub (Myron Marston)

    +
  • +

    Fix rdoc rake task (Hans de Graaff)

    +
+ +

2.0.0.beta.22 / 2010-09-12

+ +

Full +Changelog

+ +

Bug fixes

+
  • +

    fixed regression that broke obj.stub_chain(:a, :b => :c)

    +
  • +

    fixed regression that broke obj.stub_chain(:a, :b) { :c }

    +
  • +

    respond_to? always returns true when using +as_null_object

    +
+
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/file.License.html b/source/documentation/3.0/rspec-mocks/file.License.html new file mode 100644 index 000000000..296ac3d38 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/file.License.html @@ -0,0 +1,73 @@ + + + + + + File: License + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
(The MIT License)

Copyright (c) 2012 David Chelimsky, Myron Marston
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
Copyright (c) 2005 Steven Baker

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/file.README.html b/source/documentation/3.0/rspec-mocks/file.README.html new file mode 100644 index 000000000..85033dba9 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/file.README.html @@ -0,0 +1,453 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

RSpec Mocks

+ +

rspec-mocks is a test-double framework for rspec with support for method +stubs, fakes, and message expectations on generated test-doubles and real +objects alike.

+ +

Install

+ +
gem install rspec       # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-mocks # for rspec-mocks only
+ +

Test Doubles

+ +

A test double is an object that stands in for another object in your system +during a code example. Use the double method, passing in an +optional identifier, to create one:

+ +
book = double("book")
+
+ +

Most of the time you will want some confidence that your doubles resemble +an existing object in your system. Verifying doubles are provided for this +purpose. If the existing object is available, they will prevent you from +adding stubs and expectations for methods that do not exist or that have an +invalid number of parameters.

+ +
book = instance_double("Book", :pages => 250)
+
+ +

Verifying doubles have some clever tricks to enable you to both test in +isolation without your dependencies loaded while still being able to +validate them against real objects. More detail is available in their +documentation.

+ +

Method Stubs

+ +

A method stub is an implementation that returns a pre-determined value. +Method stubs can be declared on test doubles or real objects using the same +syntax. rspec-mocks supports 3 forms for declaring method stubs:

+ +
allow(book).to receive(:title) { "The RSpec Book" }
+allow(book).to receive(:title).and_return("The RSpec Book")
+
+ +

You can also use this shortcut, which creates a test double and declares a +method stub in one statement:

+ +
book = double("book", :title => "The RSpec Book")
+
+ +

The first argument is a name, which is used for documentation and appears +in failure messages. If you don't care about the name, you can leave it +out, making the combined instantiation/stub declaration very terse:

+ +
double(:foo => 'bar')
+
+ +

This is particularly nice when providing a list of test doubles to a method +that iterates through them:

+ +
order.calculate_total_price(double(:price => 1.99), double(:price => 2.99))
+
+ +

Consecutive return values

+ +

When a stub might be invoked more than once, you can provide additional +arguments to and_return. The invocations cycle through the +list. The last value is returned for any subsequent invocations:

+ +
allow(die).to receive(:roll).and_return(1, 2, 3)
+die.roll # => 1
+die.roll # => 2
+die.roll # => 3
+die.roll # => 3
+die.roll # => 3
+
+ +

To return an array in a single invocation, declare an array:

+ +
allow(team).to receive(:players).and_return([double(:name => "David")])
+
+ +

Message Expectations

+ +

A message expectation is an expectation that the test double will receive a +message some time before the example ends. If the message is received, the +expectation is satisfied. If not, the example fails.

+ +
validator = double("validator")
+expect(validator).to receive(:validate) { "02134" }
+zipcode = Zipcode.new("02134", validator)
+zipcode.valid?
+
+ +

Test Spies

+ +

Verifies the given object received the expected message during the course +of the test. The method must have previously been stubbed in order for +messages to be verified.

+ +

Stubbing and verifying messages received in this way implements the Test +Spy pattern.

+ +
invitation = double('invitation', :accept => true)
+
+  user.accept_invitation(invitation)
+
+  expect(invitation).to have_received(:accept)
+
+  # You can also use other common message expectations. For example:
+  expect(invitation).to have_received(:accept).with(mailer)
+  expect(invitation).to have_received(:accept).twice
+  expect(invitation).to_not have_received(:accept).with(mailer)
+
+ +

Nomenclature

+ +

Mock Objects and Test Stubs

+ +

The names Mock Object and Test Stub suggest specialized Test Doubles. i.e. +a Test Stub is a Test Double that only supports method stubs, and a Mock +Object is a Test Double that supports message expectations and method +stubs.

+ +

There is a lot of overlapping nomenclature here, and there are many +variations of these patterns (fakes, spies, etc). Keep in mind that most of +the time we're talking about method-level concepts that are variations +of method stubs and message expectations, and we're applying to them to +one generic kind of object: a Test Double.

+ +

Test-Specific Extension

+ +

a.k.a. Partial Double, a Test-Specific Extension is an extension of a real +object in a system that is instrumented with test-double like behaviour in +the context of a test. This technique is very common in Ruby because we +often see class objects acting as global namespaces for methods. For +example, in Rails:

+ +
person = double("person")
+allow(Person).to receive(:find) { person }
+
+ +

In this case we're instrumenting Person to return the person object +we've defined whenever it receives the find message. We +can also set a message expectation so that the example fails if +find is not called:

+ +
person = double("person")
+expect(Person).to receive(:find) { person }
+
+ +

RSpec replaces the method we're stubbing or mocking with its own +test-double-like method. At the end of the example, RSpec verifies any +message expectations, and then restores the original methods.

+ +

Expecting Arguments

+ +
expect(double).to receive(:msg).with(*args)
+expect(double).to_not receive(:msg).with(*args)
+
+ +

You can set multiple expectations for the same message if you need to:

+ +
expect(double).to receive(:msg).with("A", 1, 3)
+expect(double).to receive(:msg).with("B", 2, 4)
+
+ +

Argument Matchers

+ +

Arguments that are passed to with are compared with actual +arguments received using ==. In cases in which you want to specify things +about the arguments rather than the arguments themselves, you can use any +of the matchers that ship with rspec-expectations. They don't all make +syntactic sense (they were primarily designed for use with +RSpec::Expectations), but you are free to create your own custom +RSpec::Matchers.

+ +

rspec-mocks also adds some keyword Symbols that you can use to specify +certain kinds of arguments:

+ +
expect(double).to receive(:msg).with(no_args())
+expect(double).to receive(:msg).with(any_args())
+expect(double).to receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can be any kind of Numeric
+expect(double).to receive(:msg).with(1, boolean(), "b") #2nd argument can be true or false
+expect(double).to receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp
+expect(double).to receive(:msg).with(1, anything(), "b") #2nd argument can be anything at all
+expect(double).to receive(:msg).with(1, duck_type(:abs, :div), "b")
+                    #2nd argument can be object that responds to #abs and #div
+
+ +

Receive Counts

+ +
expect(double).to receive(:msg).once
+expect(double).to receive(:msg).twice
+expect(double).to receive(:msg).exactly(n).times
+expect(double).to receive(:msg).at_least(:once)
+expect(double).to receive(:msg).at_least(:twice)
+expect(double).to receive(:msg).at_least(n).times
+expect(double).to receive(:msg).at_most(:once)
+expect(double).to receive(:msg).at_most(:twice)
+expect(double).to receive(:msg).at_most(n).times
+
+ +

Ordering

+ +
expect(double).to receive(:msg).ordered
+expect(double).to receive(:other_msg).ordered
+  # This will fail if the messages are received out of order
+
+ +

This can include the same message with different arguments:

+ +
expect(double).to receive(:msg).with("A", 1, 3).ordered
+expect(double).to receive(:msg).with("B", 2, 4).ordered
+
+ +

Setting Responses

+ +

Whether you are setting a message expectation or a method stub, you can +tell the object precisely how to respond. The most generic way is to pass a +block to receive:

+ +
expect(double).to receive(:msg) { value }
+
+ +

When the double receives the msg message, it evaluates the +block and returns the result.

+ +
expect(double).to receive(:msg).and_return(value)
+expect(double).to receive(:msg).exactly(3).times.and_return(value1, value2, value3)
+  # returns value1 the first time, value2 the second, etc
+expect(double).to receive(:msg).and_raise(error)
+  # error can be an instantiated object or a class
+  # if it is a class, it must be instantiable with no args
+expect(double).to receive(:msg).and_throw(:msg)
+expect(double).to receive(:msg).and_yield(values, to, yield)
+expect(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+  # for methods that yield to a block multiple times
+
+ +

Any of these responses can be applied to a stub as well

+ +
allow(double).to receive(:msg).and_return(value)
+allow(double).to receive(:msg).and_return(value1, value2, value3)
+allow(double).to receive(:msg).and_raise(error)
+allow(double).to receive(:msg).and_throw(:msg)
+allow(double).to receive(:msg).and_yield(values, to, yield)
+allow(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+
+ +

Arbitrary Handling

+ +

Once in a while you'll find that the available expectations don't +solve the particular problem you are trying to solve. Imagine that you +expect the message to come with an Array argument that has a specific +length, but you don't care what is in it. You could do this:

+ +
expect(double).to receive(:msg) do |arg|
+  expect(arg.size).to eq 7
+end
+
+ +

If the method being stubbed itself takes a block, and you need to yield to +it in some special way, you can use this:

+ +
expect(double).to receive(:msg) do |&arg|
+  begin
+    arg.call
+  ensure
+    # cleanup
+  end
+end
+
+ +

Delegating to the Original Implementation

+ +

When working with a partial mock object, you may occasionally want to set a +message expecation without interfering with how the object responds to the +message. You can use and_call_original to achieve this:

+ +
expect(Person).to receive(:find).and_call_original
+Person.find # => executes the original find method and returns the result
+
+ +

Combining Expectation Details

+ +

Combining the message name with specific arguments, receive counts and +responses you can get quite a bit of detail in your expectations:

+ +
expect(double).to receive(:<<).with("illegal value").once.and_raise(ArgumentError)
+
+ +

While this is a good thing when you really need it, you probably don't +really need it! Take care to specify only the things that matter to the +behavior of your code.

+ +

Stubbing and Hiding Constants

+ +

See the mutating +constants README for info on this feature.

+ +

Use before(:example), not before(:context)

+ +

Stubs in before(:context) are not supported. The reason is +that all stubs and mocks get cleared out after each example, so any stub +that is set in before(:context) would work in the first +example that happens to run in that group, but not for any others.

+ +

Instead of before(:context), use +before(:example).

+ +

Settings mocks or stubs on any instance of a class

+ +

rspec-mocks provides two methods, allow_any_instance_of and +expect_any_instance_of, that will allow you to stub or mock +any instance of a class. They are used in place of allow or +expect:

+ +
allow_any_instance_of(Widget).to receive(:name).and_return("Wibble")
+expect_any_instance_of(Widget).to receive(:name).and_return("Wobble")
+
+ +

These methods add the appropriate stub or expectation to all instances of +Widget.

+ +

This feature is sometimes useful when working with legacy code, though in +general we discourage its use for a number of reasons:

+
  • +

    The rspec-mocks API is designed for individual object +instances, but this feature operates on entire classes of objects. As a +result there are some sematically confusing edge cases. For example in +expect_any_instance_of(Widget).to receive(:name).twice it +isn't clear whether each specific instance is expected to receive +name twice, or if two receives total are expected. (It's +the former.)

    +
  • +

    Using this feature is often a design smell. It may be that your test is +trying to do too much or that the object under test is too complex.

    +
  • +

    It is the most complicated feature of rspec-mocks, and has +historically received the most bug reports. (None of the core team +actively use it, which doesn't help.)

    +
+ +

Further Reading

+ +

There are many different viewpoints about the meaning of mocks and stubs. +If you are interested in learning more, here is some recommended reading:

+ + +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/file_list.html b/source/documentation/3.0/rspec-mocks/file_list.html new file mode 100644 index 000000000..4fbe39987 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/file_list.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + File List + + + + +
+

File List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-mocks/frames.html b/source/documentation/3.0/rspec-mocks/frames.html new file mode 100644 index 000000000..87a4a6df1 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/frames.html @@ -0,0 +1,26 @@ + + + + + + Documentation by YARD 0.8.7.6 + + + + diff --git a/source/documentation/3.0/rspec-mocks/index.html b/source/documentation/3.0/rspec-mocks/index.html new file mode 100644 index 000000000..85033dba9 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/index.html @@ -0,0 +1,453 @@ + + + + + + File: README + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +
+

RSpec Mocks

+ +

rspec-mocks is a test-double framework for rspec with support for method +stubs, fakes, and message expectations on generated test-doubles and real +objects alike.

+ +

Install

+ +
gem install rspec       # for rspec-core, rspec-expectations, rspec-mocks
+gem install rspec-mocks # for rspec-mocks only
+ +

Test Doubles

+ +

A test double is an object that stands in for another object in your system +during a code example. Use the double method, passing in an +optional identifier, to create one:

+ +
book = double("book")
+
+ +

Most of the time you will want some confidence that your doubles resemble +an existing object in your system. Verifying doubles are provided for this +purpose. If the existing object is available, they will prevent you from +adding stubs and expectations for methods that do not exist or that have an +invalid number of parameters.

+ +
book = instance_double("Book", :pages => 250)
+
+ +

Verifying doubles have some clever tricks to enable you to both test in +isolation without your dependencies loaded while still being able to +validate them against real objects. More detail is available in their +documentation.

+ +

Method Stubs

+ +

A method stub is an implementation that returns a pre-determined value. +Method stubs can be declared on test doubles or real objects using the same +syntax. rspec-mocks supports 3 forms for declaring method stubs:

+ +
allow(book).to receive(:title) { "The RSpec Book" }
+allow(book).to receive(:title).and_return("The RSpec Book")
+
+ +

You can also use this shortcut, which creates a test double and declares a +method stub in one statement:

+ +
book = double("book", :title => "The RSpec Book")
+
+ +

The first argument is a name, which is used for documentation and appears +in failure messages. If you don't care about the name, you can leave it +out, making the combined instantiation/stub declaration very terse:

+ +
double(:foo => 'bar')
+
+ +

This is particularly nice when providing a list of test doubles to a method +that iterates through them:

+ +
order.calculate_total_price(double(:price => 1.99), double(:price => 2.99))
+
+ +

Consecutive return values

+ +

When a stub might be invoked more than once, you can provide additional +arguments to and_return. The invocations cycle through the +list. The last value is returned for any subsequent invocations:

+ +
allow(die).to receive(:roll).and_return(1, 2, 3)
+die.roll # => 1
+die.roll # => 2
+die.roll # => 3
+die.roll # => 3
+die.roll # => 3
+
+ +

To return an array in a single invocation, declare an array:

+ +
allow(team).to receive(:players).and_return([double(:name => "David")])
+
+ +

Message Expectations

+ +

A message expectation is an expectation that the test double will receive a +message some time before the example ends. If the message is received, the +expectation is satisfied. If not, the example fails.

+ +
validator = double("validator")
+expect(validator).to receive(:validate) { "02134" }
+zipcode = Zipcode.new("02134", validator)
+zipcode.valid?
+
+ +

Test Spies

+ +

Verifies the given object received the expected message during the course +of the test. The method must have previously been stubbed in order for +messages to be verified.

+ +

Stubbing and verifying messages received in this way implements the Test +Spy pattern.

+ +
invitation = double('invitation', :accept => true)
+
+  user.accept_invitation(invitation)
+
+  expect(invitation).to have_received(:accept)
+
+  # You can also use other common message expectations. For example:
+  expect(invitation).to have_received(:accept).with(mailer)
+  expect(invitation).to have_received(:accept).twice
+  expect(invitation).to_not have_received(:accept).with(mailer)
+
+ +

Nomenclature

+ +

Mock Objects and Test Stubs

+ +

The names Mock Object and Test Stub suggest specialized Test Doubles. i.e. +a Test Stub is a Test Double that only supports method stubs, and a Mock +Object is a Test Double that supports message expectations and method +stubs.

+ +

There is a lot of overlapping nomenclature here, and there are many +variations of these patterns (fakes, spies, etc). Keep in mind that most of +the time we're talking about method-level concepts that are variations +of method stubs and message expectations, and we're applying to them to +one generic kind of object: a Test Double.

+ +

Test-Specific Extension

+ +

a.k.a. Partial Double, a Test-Specific Extension is an extension of a real +object in a system that is instrumented with test-double like behaviour in +the context of a test. This technique is very common in Ruby because we +often see class objects acting as global namespaces for methods. For +example, in Rails:

+ +
person = double("person")
+allow(Person).to receive(:find) { person }
+
+ +

In this case we're instrumenting Person to return the person object +we've defined whenever it receives the find message. We +can also set a message expectation so that the example fails if +find is not called:

+ +
person = double("person")
+expect(Person).to receive(:find) { person }
+
+ +

RSpec replaces the method we're stubbing or mocking with its own +test-double-like method. At the end of the example, RSpec verifies any +message expectations, and then restores the original methods.

+ +

Expecting Arguments

+ +
expect(double).to receive(:msg).with(*args)
+expect(double).to_not receive(:msg).with(*args)
+
+ +

You can set multiple expectations for the same message if you need to:

+ +
expect(double).to receive(:msg).with("A", 1, 3)
+expect(double).to receive(:msg).with("B", 2, 4)
+
+ +

Argument Matchers

+ +

Arguments that are passed to with are compared with actual +arguments received using ==. In cases in which you want to specify things +about the arguments rather than the arguments themselves, you can use any +of the matchers that ship with rspec-expectations. They don't all make +syntactic sense (they were primarily designed for use with +RSpec::Expectations), but you are free to create your own custom +RSpec::Matchers.

+ +

rspec-mocks also adds some keyword Symbols that you can use to specify +certain kinds of arguments:

+ +
expect(double).to receive(:msg).with(no_args())
+expect(double).to receive(:msg).with(any_args())
+expect(double).to receive(:msg).with(1, kind_of(Numeric), "b") #2nd argument can be any kind of Numeric
+expect(double).to receive(:msg).with(1, boolean(), "b") #2nd argument can be true or false
+expect(double).to receive(:msg).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp
+expect(double).to receive(:msg).with(1, anything(), "b") #2nd argument can be anything at all
+expect(double).to receive(:msg).with(1, duck_type(:abs, :div), "b")
+                    #2nd argument can be object that responds to #abs and #div
+
+ +

Receive Counts

+ +
expect(double).to receive(:msg).once
+expect(double).to receive(:msg).twice
+expect(double).to receive(:msg).exactly(n).times
+expect(double).to receive(:msg).at_least(:once)
+expect(double).to receive(:msg).at_least(:twice)
+expect(double).to receive(:msg).at_least(n).times
+expect(double).to receive(:msg).at_most(:once)
+expect(double).to receive(:msg).at_most(:twice)
+expect(double).to receive(:msg).at_most(n).times
+
+ +

Ordering

+ +
expect(double).to receive(:msg).ordered
+expect(double).to receive(:other_msg).ordered
+  # This will fail if the messages are received out of order
+
+ +

This can include the same message with different arguments:

+ +
expect(double).to receive(:msg).with("A", 1, 3).ordered
+expect(double).to receive(:msg).with("B", 2, 4).ordered
+
+ +

Setting Responses

+ +

Whether you are setting a message expectation or a method stub, you can +tell the object precisely how to respond. The most generic way is to pass a +block to receive:

+ +
expect(double).to receive(:msg) { value }
+
+ +

When the double receives the msg message, it evaluates the +block and returns the result.

+ +
expect(double).to receive(:msg).and_return(value)
+expect(double).to receive(:msg).exactly(3).times.and_return(value1, value2, value3)
+  # returns value1 the first time, value2 the second, etc
+expect(double).to receive(:msg).and_raise(error)
+  # error can be an instantiated object or a class
+  # if it is a class, it must be instantiable with no args
+expect(double).to receive(:msg).and_throw(:msg)
+expect(double).to receive(:msg).and_yield(values, to, yield)
+expect(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+  # for methods that yield to a block multiple times
+
+ +

Any of these responses can be applied to a stub as well

+ +
allow(double).to receive(:msg).and_return(value)
+allow(double).to receive(:msg).and_return(value1, value2, value3)
+allow(double).to receive(:msg).and_raise(error)
+allow(double).to receive(:msg).and_throw(:msg)
+allow(double).to receive(:msg).and_yield(values, to, yield)
+allow(double).to receive(:msg).and_yield(values, to, yield).and_yield(some, other, values, this, time)
+
+ +

Arbitrary Handling

+ +

Once in a while you'll find that the available expectations don't +solve the particular problem you are trying to solve. Imagine that you +expect the message to come with an Array argument that has a specific +length, but you don't care what is in it. You could do this:

+ +
expect(double).to receive(:msg) do |arg|
+  expect(arg.size).to eq 7
+end
+
+ +

If the method being stubbed itself takes a block, and you need to yield to +it in some special way, you can use this:

+ +
expect(double).to receive(:msg) do |&arg|
+  begin
+    arg.call
+  ensure
+    # cleanup
+  end
+end
+
+ +

Delegating to the Original Implementation

+ +

When working with a partial mock object, you may occasionally want to set a +message expecation without interfering with how the object responds to the +message. You can use and_call_original to achieve this:

+ +
expect(Person).to receive(:find).and_call_original
+Person.find # => executes the original find method and returns the result
+
+ +

Combining Expectation Details

+ +

Combining the message name with specific arguments, receive counts and +responses you can get quite a bit of detail in your expectations:

+ +
expect(double).to receive(:<<).with("illegal value").once.and_raise(ArgumentError)
+
+ +

While this is a good thing when you really need it, you probably don't +really need it! Take care to specify only the things that matter to the +behavior of your code.

+ +

Stubbing and Hiding Constants

+ +

See the mutating +constants README for info on this feature.

+ +

Use before(:example), not before(:context)

+ +

Stubs in before(:context) are not supported. The reason is +that all stubs and mocks get cleared out after each example, so any stub +that is set in before(:context) would work in the first +example that happens to run in that group, but not for any others.

+ +

Instead of before(:context), use +before(:example).

+ +

Settings mocks or stubs on any instance of a class

+ +

rspec-mocks provides two methods, allow_any_instance_of and +expect_any_instance_of, that will allow you to stub or mock +any instance of a class. They are used in place of allow or +expect:

+ +
allow_any_instance_of(Widget).to receive(:name).and_return("Wibble")
+expect_any_instance_of(Widget).to receive(:name).and_return("Wobble")
+
+ +

These methods add the appropriate stub or expectation to all instances of +Widget.

+ +

This feature is sometimes useful when working with legacy code, though in +general we discourage its use for a number of reasons:

+
  • +

    The rspec-mocks API is designed for individual object +instances, but this feature operates on entire classes of objects. As a +result there are some sematically confusing edge cases. For example in +expect_any_instance_of(Widget).to receive(:name).twice it +isn't clear whether each specific instance is expected to receive +name twice, or if two receives total are expected. (It's +the former.)

    +
  • +

    Using this feature is often a design smell. It may be that your test is +trying to do too much or that the object under test is too complex.

    +
  • +

    It is the most complicated feature of rspec-mocks, and has +historically received the most bug reports. (None of the core team +actively use it, which doesn't help.)

    +
+ +

Further Reading

+ +

There are many different viewpoints about the meaning of mocks and stubs. +If you are interested in learning more, here is some recommended reading:

+ + +

Also see

+ +
+ + + + + \ No newline at end of file diff --git a/source/documentation/3.0/rspec-mocks/method_list.html b/source/documentation/3.0/rspec-mocks/method_list.html new file mode 100644 index 000000000..788becca2 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/method_list.html @@ -0,0 +1,609 @@ + + + + + + + + + + + + + + + + + Method List + + + + +
+

Method List

+ + + + +
+ + diff --git a/source/documentation/3.0/rspec-mocks/top-level-namespace.html b/source/documentation/3.0/rspec-mocks/top-level-namespace.html new file mode 100644 index 000000000..6c7b24ca4 --- /dev/null +++ b/source/documentation/3.0/rspec-mocks/top-level-namespace.html @@ -0,0 +1,140 @@ + + + + + + Top Level Namespace + + — Documentation by YARD 0.8.7.6 + + + + + + + + + + + + + + + + + + + + + +

Top Level Namespace + + + +

+ +
+ + + + + +
Includes:
+
RSpec::Mocks::ExampleMethods
+ + + + + +
+
+ +

Defined Under Namespace

+

+ + + Modules: RSpec + + + + Classes: BasicObject, Class + + +

+ + + + + + + + + + + + + + +

Method Summary

+ +

Methods included from RSpec::Mocks::ExampleMethods

+

#allow, #allow_any_instance_of, #allow_message_expectations_on_nil, #class_double, #double, #expect, #expect_any_instance_of, #have_received, #hide_const, #instance_double, #object_double, #receive, #receive_message_chain, #receive_messages, #stub_const

+ + + + + + + + + +

Methods included from RSpec::Mocks::ArgumentMatchers

+

#any_args, #anything, #array_including, #boolean, #duck_type, #hash_excluding, #hash_including, #instance_of, #kind_of, #no_args

+ + +
+ + + + + \ No newline at end of file