From 800853a28d079d77a0c51b7c0ba39337cb8e4814 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 14 Oct 2018 12:11:53 -0700 Subject: [PATCH 01/61] Vendor rubocop-rspec We aren't going to vendor its dependencies because we already require a systemwide installation of `rubocop` to work in your editor. This avoids requiring users to manually do another `gem install rubocop-rspec` to have their editor integration behave as expected. --- .gitignore | 13 + Library/.rubocop.yml | 4 +- Library/Homebrew/rubocops.rb | 1 + Library/Homebrew/test/Gemfile | 1 - Library/Homebrew/vendor/Gemfile | 5 + Library/Homebrew/vendor/Gemfile.lock | 23 +- .../vendor/bundle-standalone/bundler/setup.rb | 11 + .../rubocop-rspec-1.30.0/config/default.yml | 451 ++++++++++++++++++ .../rubocop-rspec-1.30.0/lib/rubocop-rspec.rb | 43 ++ .../rubocop/cop/rspec/align_left_let_brace.rb | 53 ++ .../cop/rspec/align_right_let_brace.rb | 53 ++ .../lib/rubocop/cop/rspec/any_instance.rb | 42 ++ .../lib/rubocop/cop/rspec/around_block.rb | 71 +++ .../lib/rubocop/cop/rspec/be.rb | 35 ++ .../lib/rubocop/cop/rspec/be_eql.rb | 55 +++ .../lib/rubocop/cop/rspec/before_after_all.rb | 48 ++ .../capybara/current_path_expectation.rb | 42 ++ .../cop/rspec/capybara/feature_methods.rb | 118 +++++ .../lib/rubocop/cop/rspec/context_wording.rb | 66 +++ .../lib/rubocop/cop/rspec/cop.rb | 94 ++++ .../lib/rubocop/cop/rspec/describe_class.rb | 60 +++ .../lib/rubocop/cop/rspec/describe_method.rb | 35 ++ .../lib/rubocop/cop/rspec/describe_symbol.rb | 35 ++ .../lib/rubocop/cop/rspec/described_class.rb | 124 +++++ .../rubocop/cop/rspec/empty_example_group.rb | 90 ++++ .../rspec/empty_line_after_example_group.rb | 46 ++ .../cop/rspec/empty_line_after_final_let.rb | 39 ++ .../cop/rspec/empty_line_after_hook.rb | 56 +++ .../cop/rspec/empty_line_after_subject.rb | 41 ++ .../lib/rubocop/cop/rspec/example_length.rb | 55 +++ .../cop/rspec/example_without_description.rb | 87 ++++ .../lib/rubocop/cop/rspec/example_wording.rb | 97 ++++ .../lib/rubocop/cop/rspec/expect_actual.rb | 71 +++ .../lib/rubocop/cop/rspec/expect_change.rb | 102 ++++ .../lib/rubocop/cop/rspec/expect_in_hook.rb | 46 ++ .../lib/rubocop/cop/rspec/expect_output.rb | 50 ++ .../attribute_defined_statically.rb | 147 ++++++ .../cop/rspec/factory_bot/create_list.rb | 149 ++++++ .../lib/rubocop/cop/rspec/file_path.rb | 116 +++++ .../lib/rubocop/cop/rspec/focus.rb | 64 +++ .../lib/rubocop/cop/rspec/hook_argument.rb | 136 ++++++ .../cop/rspec/hooks_before_examples.rb | 99 ++++ .../lib/rubocop/cop/rspec/implicit_expect.rb | 107 +++++ .../lib/rubocop/cop/rspec/implicit_subject.rb | 77 +++ .../lib/rubocop/cop/rspec/instance_spy.rb | 66 +++ .../rubocop/cop/rspec/instance_variable.rb | 87 ++++ .../cop/rspec/invalid_predicate_matcher.rb | 42 ++ .../lib/rubocop/cop/rspec/it_behaves_like.rb | 47 ++ .../rubocop/cop/rspec/iterated_expectation.rb | 52 ++ .../lib/rubocop/cop/rspec/leading_subject.rb | 92 ++++ .../rubocop/cop/rspec/let_before_examples.rb | 102 ++++ .../lib/rubocop/cop/rspec/let_setup.rb | 57 +++ .../lib/rubocop/cop/rspec/message_chain.rb | 31 ++ .../rubocop/cop/rspec/message_expectation.rb | 59 +++ .../lib/rubocop/cop/rspec/message_spies.rb | 82 ++++ .../rspec/missing_example_group_argument.rb | 35 ++ .../rubocop/cop/rspec/multiple_describes.rb | 40 ++ .../cop/rspec/multiple_expectations.rb | 120 +++++ .../rubocop/cop/rspec/multiple_subjects.rb | 79 +++ .../lib/rubocop/cop/rspec/named_subject.rb | 63 +++ .../lib/rubocop/cop/rspec/nested_groups.rb | 145 ++++++ .../lib/rubocop/cop/rspec/not_to_not.rb | 41 ++ .../rubocop/cop/rspec/overwriting_setup.rb | 69 +++ .../lib/rubocop/cop/rspec/pending.rb | 72 +++ .../rubocop/cop/rspec/predicate_matcher.rb | 350 ++++++++++++++ .../rubocop/cop/rspec/rails/http_status.rb | 147 ++++++ .../lib/rubocop/cop/rspec/receive_counts.rb | 86 ++++ .../lib/rubocop/cop/rspec/receive_never.rb | 43 ++ .../rubocop/cop/rspec/repeated_description.rb | 59 +++ .../lib/rubocop/cop/rspec/repeated_example.rb | 51 ++ .../lib/rubocop/cop/rspec/return_from_stub.rb | 173 +++++++ .../lib/rubocop/cop/rspec/scattered_let.rb | 53 ++ .../lib/rubocop/cop/rspec/scattered_setup.rb | 49 ++ .../lib/rubocop/cop/rspec/shared_context.rb | 111 +++++ .../lib/rubocop/cop/rspec/shared_examples.rb | 76 +++ .../rspec/single_argument_message_chain.rb | 73 +++ .../lib/rubocop/cop/rspec/subject_stub.rb | 147 ++++++ .../cop/rspec/unspecified_exception.rb | 64 +++ .../lib/rubocop/cop/rspec/verified_doubles.rb | 49 ++ .../lib/rubocop/cop/rspec/void_expect.rb | 55 +++ .../lib/rubocop/cop/rspec_cops.rb | 77 +++ .../rubocop-rspec-1.30.0/lib/rubocop/rspec.rb | 10 + .../lib/rubocop/rspec/align_let_brace.rb | 62 +++ .../rubocop/rspec/blank_line_separation.rb | 43 ++ .../lib/rubocop/rspec/concept.rb | 34 ++ .../lib/rubocop/rspec/config_formatter.rb | 36 ++ .../rubocop/rspec/description_extractor.rb | 84 ++++ .../lib/rubocop/rspec/example.rb | 32 ++ .../lib/rubocop/rspec/example_group.rb | 87 ++++ .../lib/rubocop/rspec/final_end_location.rb | 15 + .../lib/rubocop/rspec/hook.rb | 49 ++ .../lib/rubocop/rspec/inject.rb | 16 + .../lib/rubocop/rspec/language.rb | 119 +++++ .../rubocop/rspec/language/node_pattern.rb | 26 + .../lib/rubocop/rspec/node.rb | 19 + .../lib/rubocop/rspec/top_level_describe.rb | 54 +++ .../lib/rubocop/rspec/util.rb | 19 + .../lib/rubocop/rspec/version.rb | 10 + .../lib/rubocop/rspec/wording.rb | 81 ++++ 99 files changed, 6993 insertions(+), 5 deletions(-) create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/config/default.yml create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop-rspec.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_left_let_brace.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_right_let_brace.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/any_instance.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/around_block.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be_eql.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/before_after_all.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/feature_methods.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/context_wording.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/cop.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_class.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_method.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_symbol.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/described_class.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_example_group.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_example_group.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_final_let.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_hook.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_subject.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_length.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_without_description.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_wording.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_actual.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_change.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_in_hook.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_output.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/create_list.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/file_path.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/focus.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hook_argument.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hooks_before_examples.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_expect.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_subject.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_spy.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_variable.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/it_behaves_like.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/iterated_expectation.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/leading_subject.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_before_examples.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_setup.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_chain.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_expectation.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_spies.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/missing_example_group_argument.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/multiple_describes.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/multiple_expectations.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/multiple_subjects.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/named_subject.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/nested_groups.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/not_to_not.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/overwriting_setup.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/pending.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/predicate_matcher.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/rails/http_status.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/receive_counts.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/receive_never.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/repeated_description.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/repeated_example.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/return_from_stub.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/scattered_let.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/scattered_setup.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/shared_context.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/shared_examples.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/single_argument_message_chain.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/subject_stub.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/unspecified_exception.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/verified_doubles.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/void_expect.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec_cops.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/align_let_brace.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/blank_line_separation.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/concept.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/config_formatter.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/description_extractor.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/example.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/example_group.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/final_end_location.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/hook.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/inject.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/language.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/language/node_pattern.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/node.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/top_level_describe.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/util.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/version.rb create mode 100644 Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/rspec/wording.rb diff --git a/.gitignore b/.gitignore index a4cd169ec1..7d9ad4550c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,9 @@ **/.bundle/cache **/vendor/bundle **/vendor/ruby +**/vendor/bundle-standalone/ruby/*/bin **/vendor/bundle-standalone/ruby/*/cache +**/vendor/bundle-standalone/ruby/*/extensions **/vendor/bundle-standalone/ruby/*/gems/*/* **/vendor/bundle-standalone/ruby/*/specifications @@ -39,6 +41,17 @@ **/vendor/bundle-standalone/ruby/*/gems/thread_safe-*/lib **/vendor/bundle-standalone/ruby/*/gems/tzinfo-*/lib +# Ignore rubocop dependencies we don't wish to vendor +**/vendor/bundle-standalone/ruby/*/gems/ast-*/ +**/vendor/bundle-standalone/ruby/*/gems/jaro_winkler-*/ +**/vendor/bundle-standalone/ruby/*/gems/parallel-*/ +**/vendor/bundle-standalone/ruby/*/gems/parser-*/ +**/vendor/bundle-standalone/ruby/*/gems/powerpack-*/ +**/vendor/bundle-standalone/ruby/*/gems/rainbow-*/ +**/vendor/bundle-standalone/ruby/*/gems/rubocop-*/ +**/vendor/bundle-standalone/ruby/*/gems/ruby-progressbar-*/ +**/vendor/bundle-standalone/ruby/*/gems/unicode-display_width-*/ + # Ignore `bin` contents (again). /bin diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 36281a4d62..d6cfcb03bc 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -5,9 +5,7 @@ AllCops: - '**/vendor/**/*' DisplayCopNames: false -require: - - ./Homebrew/rubocops.rb - - rubocop-rspec +require: ./Homebrew/rubocops.rb # enable all formulae audits FormulaAudit: diff --git a/Library/Homebrew/rubocops.rb b/Library/Homebrew/rubocops.rb index b5dd08187b..aed555d72a 100644 --- a/Library/Homebrew/rubocops.rb +++ b/Library/Homebrew/rubocops.rb @@ -1,5 +1,6 @@ require_relative "load_path" +require "rubocop-rspec" require "rubocops/formula_desc_cop" require "rubocops/components_order_cop" require "rubocops/components_redundancy_cop" diff --git a/Library/Homebrew/test/Gemfile b/Library/Homebrew/test/Gemfile index 6ff11dc88d..74f7fe4225 100644 --- a/Library/Homebrew/test/Gemfile +++ b/Library/Homebrew/test/Gemfile @@ -8,7 +8,6 @@ gem "rspec-its", require: false gem "rspec-retry", require: false gem "rspec-wait", require: false gem "rubocop", HOMEBREW_RUBOCOP_VERSION -gem "rubocop-rspec", require: false group :development do gem "ronn", require: false diff --git a/Library/Homebrew/vendor/Gemfile b/Library/Homebrew/vendor/Gemfile index 0ea1675a5a..93cfca2cd7 100644 --- a/Library/Homebrew/vendor/Gemfile +++ b/Library/Homebrew/vendor/Gemfile @@ -5,3 +5,8 @@ gem "concurrent-ruby" gem "backports" gem "plist" gem "ruby-macho" +gem "rubocop-rspec" + +# not actually vendored but used to ensure the version matches here. +require_relative "../constants" +gem "rubocop", HOMEBREW_RUBOCOP_VERSION diff --git a/Library/Homebrew/vendor/Gemfile.lock b/Library/Homebrew/vendor/Gemfile.lock index 7839681024..910bf2da62 100644 --- a/Library/Homebrew/vendor/Gemfile.lock +++ b/Library/Homebrew/vendor/Gemfile.lock @@ -6,16 +6,35 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + ast (2.4.0) backports (3.11.4) concurrent-ruby (1.0.5) i18n (1.1.0) concurrent-ruby (~> 1.0) + jaro_winkler (1.5.1) minitest (5.11.3) + parallel (1.12.1) + parser (2.5.1.2) + ast (~> 2.4.0) plist (3.4.0) + powerpack (0.1.2) + rainbow (3.0.0) + rubocop (0.59.1) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-rspec (1.30.0) + rubocop (>= 0.58.0) ruby-macho (2.1.0) + ruby-progressbar (1.10.0) thread_safe (0.3.6) tzinfo (1.2.5) thread_safe (~> 0.1) + unicode-display_width (1.4.0) PLATFORMS ruby @@ -25,7 +44,9 @@ DEPENDENCIES backports concurrent-ruby plist + rubocop (= 0.59.1) + rubocop-rspec ruby-macho BUNDLED WITH - 1.16.4 + 1.16.6 diff --git a/Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb b/Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb index 76c3cfbf1f..e5b194b9c4 100644 --- a/Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle-standalone/bundler/setup.rb @@ -9,7 +9,18 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.11.3/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thread_safe-0.3.6/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tzinfo-1.2.5/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/activesupport-5.2.1/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ast-2.4.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/backports-3.11.4/lib" $:.unshift "#{path}/" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-18/2.3.0/jaro_winkler-1.5.1" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/jaro_winkler-1.5.1/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.12.1/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.5.1.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.4.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/powerpack-0.1.2/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.4.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.59.1/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.30.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.1.0/lib" diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/config/default.yml b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/config/default.yml new file mode 100644 index 0000000000..7fc26d8589 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/config/default.yml @@ -0,0 +1,451 @@ +--- +AllCops: + RSpec: + Patterns: + - _spec.rb + - "(?:^|/)spec/" + RSpec/FactoryBot: + Patterns: + - spec/factories.rb + - spec/factories/**/*.rb + - features/support/factories/**/*.rb + +RSpec/AlignLeftLetBrace: + Description: Checks that left braces for adjacent single line lets are aligned. + Enabled: false + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignLeftLetBrace + +RSpec/AlignRightLetBrace: + Description: Checks that right braces for adjacent single line lets are aligned. + Enabled: false + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignRightLetBrace + +RSpec/AnyInstance: + Description: Check that instances are not being stubbed globally. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AnyInstance + +RSpec/AroundBlock: + Description: Checks that around blocks actually run the test. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AroundBlock + +RSpec/Be: + Description: Check for expectations where `be` is used without argument. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Be + +RSpec/BeEql: + Description: Check for expectations where `be(...)` can replace `eql(...)`. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEql + +RSpec/BeforeAfterAll: + Description: Check that before/after(:all) isn't being used. + Enabled: true + Exclude: + - spec/spec_helper.rb + - spec/rails_helper.rb + - spec/support/**/*.rb + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeforeAfterAll + +RSpec/ContextWording: + Description: "`context` block descriptions should start with 'when', or 'with'." + Enabled: true + Prefixes: + - when + - with + - without + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ContextWording + +RSpec/DescribeClass: + Description: Check that the first argument to the top level describe is a constant. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass + +RSpec/DescribeMethod: + Description: Checks that the second argument to `describe` specifies a method. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeMethod + +RSpec/DescribeSymbol: + Description: Avoid describing symbols. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeSymbol + +RSpec/DescribedClass: + Description: Checks that tests use `described_class`. + SkipBlocks: false + Enabled: true + EnforcedStyle: described_class + SupportedStyles: + - described_class + - explicit + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClass + +RSpec/EmptyExampleGroup: + Description: Checks if an example group does not include any tests. + Enabled: true + CustomIncludeMethods: [] + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup + +RSpec/EmptyLineAfterExampleGroup: + Description: Checks if there is an empty line after example group blocks. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterExampleGroup + +RSpec/EmptyLineAfterFinalLet: + Description: Checks if there is an empty line after the last let block. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterFinalLet + +RSpec/EmptyLineAfterHook: + Description: Checks if there is an empty line after hook blocks. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterHook + +RSpec/EmptyLineAfterSubject: + Description: Checks if there is an empty line after subject block. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterSubject + +RSpec/ExampleLength: + Description: Checks for long examples. + Enabled: true + Max: 5 + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength + +RSpec/ExampleWithoutDescription: + Description: Checks for examples without a description. + Enabled: true + EnforcedStyle: always_allow + SupportedStyles: + - always_allow + - single_line_only + - disallow + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWithoutDescription + +RSpec/ExampleWording: + Description: Checks for common mistakes in example descriptions. + Enabled: true + CustomTransform: + be: is + BE: IS + have: has + HAVE: HAS + IgnoredWords: [] + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording + +RSpec/ExpectActual: + Description: Checks for `expect(...)` calls containing literal values. + Enabled: true + Exclude: + - spec/routing/**/* + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual + +RSpec/ExpectChange: + Description: Checks for consistent style of change matcher. + Enabled: true + EnforcedStyle: method_call + SupportedStyles: + - method_call + - block + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectChange + +RSpec/ExpectInHook: + Enabled: true + Description: Do not use `expect` in hooks such as `before`. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInHook + +RSpec/ExpectOutput: + Description: Checks for opportunities to use `expect { ... }.to output`. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectOutput + +RSpec/FilePath: + Description: Checks that spec file paths are consistent with the test subject. + Enabled: true + CustomTransform: + RuboCop: rubocop + RSpec: rspec + IgnoreMethods: false + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath + +RSpec/Focus: + Description: Checks if examples are focused. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Focus + +RSpec/HookArgument: + Description: Checks the arguments passed to `before`, `around`, and `after`. + Enabled: true + EnforcedStyle: implicit + SupportedStyles: + - implicit + - each + - example + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HookArgument + +RSpec/HooksBeforeExamples: + Enabled: true + Description: Checks for before/around/after hooks that come after an example. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples + +RSpec/ImplicitExpect: + Description: Check that a consistent implicit expectation style is used. + Enabled: true + EnforcedStyle: is_expected + SupportedStyles: + - is_expected + - should + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitExpect + +RSpec/ImplicitSubject: + Enabled: true + Description: Checks for usage of implicit subject (`is_expected` / `should`). + EnforcedStyle: single_line_only + SupportedStyles: + - single_line_only + - single_statement_only + - disallow + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitSubject + +RSpec/InstanceSpy: + Description: Checks for `instance_double` used with `have_received`. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceSpy + +RSpec/InstanceVariable: + Description: Checks for instance variable usage in specs. + AssignmentOnly: false + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceVariable + +RSpec/InvalidPredicateMatcher: + Description: Checks invalid usage for predicate matcher. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InvalidPredicateMatcher + +RSpec/ItBehavesLike: + Description: Checks that only one `it_behaves_like` style is used. + Enabled: true + EnforcedStyle: it_behaves_like + SupportedStyles: + - it_behaves_like + - it_should_behave_like + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ItBehavesLike + +RSpec/IteratedExpectation: + Description: Check that `all` matcher is used instead of iterating over an array. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IteratedExpectation + +RSpec/LeadingSubject: + Description: Enforce that subject is the first definition in the test. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LeadingSubject + +RSpec/LetBeforeExamples: + Description: Checks for `let` definitions that come after an example. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples + +RSpec/LetSetup: + Description: Checks unreferenced `let!` calls being used for test setup. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup + +RSpec/MessageChain: + Description: Check that chains of messages are not being stubbed. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageChain + +RSpec/MessageExpectation: + Description: Checks for consistent message expectation style. + Enabled: false + EnforcedStyle: allow + SupportedStyles: + - allow + - expect + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageExpectation + +RSpec/MessageSpies: + Description: Checks that message expectations are set using spies. + Enabled: true + EnforcedStyle: have_received + SupportedStyles: + - have_received + - receive + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageSpies + +RSpec/MissingExampleGroupArgument: + Description: Checks that the first argument to an example group is not empty. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MissingExampleGroupArgument + +RSpec/MultipleDescribes: + Description: Checks for multiple top level describes. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleDescribes + +RSpec/MultipleExpectations: + Description: Checks if examples contain too many `expect` calls. + Enabled: true + Max: 1 + AggregateFailuresByDefault: false + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleExpectations + +RSpec/MultipleSubjects: + Description: Checks if an example group defines `subject` multiple times. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleSubjects + +RSpec/NamedSubject: + Description: Checks for explicitly referenced test subjects. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject + +RSpec/NestedGroups: + Description: Checks for nested example groups. + Enabled: true + Max: 3 + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups + +RSpec/NotToNot: + Description: Checks for consistent method usage for negating expectations. + EnforcedStyle: not_to + SupportedStyles: + - not_to + - to_not + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot + +RSpec/OverwritingSetup: + Enabled: true + Description: Checks if there is a let/subject that overwrites an existing one. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/OverwritingSetup + +RSpec/Pending: + Enabled: false + Description: Checks for any pending or skipped examples. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Pending + +RSpec/PredicateMatcher: + Description: Prefer using predicate matcher over using predicate method directly. + Enabled: true + Strict: true + EnforcedStyle: inflected + SupportedStyles: + - inflected + - explicit + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/PredicateMatcher + +RSpec/ReceiveCounts: + Enabled: true + Description: Check for `once` and `twice` receive counts matchers usage. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveCounts + +RSpec/ReceiveNever: + Enabled: true + Description: Prefer `not_to receive(...)` over `receive(...).never`. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveNever + +RSpec/RepeatedDescription: + Enabled: true + Description: Check for repeated description strings in example groups. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedDescription + +RSpec/RepeatedExample: + Enabled: true + Description: Check for repeated examples within example groups. + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample + +RSpec/ReturnFromStub: + Enabled: true + Description: Checks for consistent style of stub's return setting. + EnforcedStyle: and_return + SupportedStyles: + - and_return + - block + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReturnFromStub + +RSpec/ScatteredLet: + Description: Checks for let scattered across the example group. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet + +RSpec/ScatteredSetup: + Description: Checks for setup scattered across multiple hooks in an example group. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup + +RSpec/SharedContext: + Description: Checks for proper shared_context and shared_examples usage. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedContext + +RSpec/SharedExamples: + Description: Enforces use of string to titleize shared examples. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedExamples + +RSpec/SingleArgumentMessageChain: + Description: Checks that chains of messages contain more than one element. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SingleArgumentMessageChain + +RSpec/SubjectStub: + Description: Checks for stubbed test subjects. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectStub + +RSpec/UnspecifiedException: + Description: Checks for a specified error in checking raised errors. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/UnspecifiedException + +RSpec/VerifiedDoubles: + Description: Prefer using verifying doubles over normal doubles. + Enabled: true + IgnoreNameless: true + IgnoreSymbolicNames: false + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubles + +RSpec/VoidExpect: + Description: This cop checks void `expect()`. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VoidExpect + +Capybara/CurrentPathExpectation: + Description: Checks that no expectations are set on Capybara's `current_path`. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/CurrentPathExpectation + +Capybara/FeatureMethods: + Description: Checks for consistent method usage in feature specs. + Enabled: true + EnabledMethods: [] + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/FeatureMethods + +FactoryBot/AttributeDefinedStatically: + Description: Always declare attribute values as blocks. + Enabled: true + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/AttributeDefinedStatically + +FactoryBot/CreateList: + Description: Checks for create_list usage. + Enabled: true + EnforcedStyle: create_list + SupportedStyles: + - create_list + - n_times + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/CreateList + +Rails/HttpStatus: + Description: Enforces use of symbolic or numeric value to describe HTTP status. + Enabled: true + EnforcedStyle: symbolic + SupportedStyles: + - numeric + - symbolic + StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/HttpStatus diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop-rspec.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop-rspec.rb new file mode 100644 index 0000000000..0c1719cea9 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop-rspec.rb @@ -0,0 +1,43 @@ +require 'pathname' +require 'yaml' + +require 'rubocop' + +require_relative 'rubocop/rspec' +require_relative 'rubocop/rspec/version' +require_relative 'rubocop/rspec/inject' +require_relative 'rubocop/rspec/node' +require_relative 'rubocop/rspec/top_level_describe' +require_relative 'rubocop/rspec/wording' +require_relative 'rubocop/rspec/util' +require_relative 'rubocop/rspec/language' +require_relative 'rubocop/rspec/language/node_pattern' +require_relative 'rubocop/rspec/concept' +require_relative 'rubocop/rspec/example_group' +require_relative 'rubocop/rspec/example' +require_relative 'rubocop/rspec/hook' +require_relative 'rubocop/cop/rspec/cop' +require_relative 'rubocop/rspec/align_let_brace' +require_relative 'rubocop/rspec/final_end_location' +require_relative 'rubocop/rspec/blank_line_separation' + +RuboCop::RSpec::Inject.defaults! + +require_relative 'rubocop/cop/rspec_cops' + +# We have to register our autocorrect incompatibilies in RuboCop's cops as well +# so we do not hit infinite loops + +module RuboCop + module Cop + module Layout + class ExtraSpacing # rubocop:disable Style/Documentation + def self.autocorrect_incompatible_with + [RSpec::AlignLeftLetBrace, RSpec::AlignRightLetBrace] + end + end + end + end +end + +RuboCop::AST::Node.include(RuboCop::RSpec::Node) diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_left_let_brace.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_left_let_brace.rb new file mode 100644 index 0000000000..8bbc9658ed --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_left_let_brace.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks that left braces for adjacent single line lets are aligned. + # + # @example + # + # # bad + # let(:foobar) { blahblah } + # let(:baz) { bar } + # let(:a) { b } + # + # # good + # let(:foobar) { blahblah } + # let(:baz) { bar } + # let(:a) { b } + # + class AlignLeftLetBrace < Cop + MSG = 'Align left let brace'.freeze + + def self.autocorrect_incompatible_with + [Layout::ExtraSpacing] + end + + def investigate(_processed_source) + return if processed_source.blank? + + token_aligner.offending_tokens.each do |let| + add_offense(let, location: :begin) + end + end + + def autocorrect(let) + lambda do |corrector| + corrector.insert_before( + let.loc.begin, + token_aligner.indent_for(let) + ) + end + end + + private + + def token_aligner + @token_aligner ||= + RuboCop::RSpec::AlignLetBrace.new(processed_source.ast, :begin) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_right_let_brace.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_right_let_brace.rb new file mode 100644 index 0000000000..7eea9b9bdd --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/align_right_let_brace.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks that right braces for adjacent single line lets are aligned. + # + # @example + # + # # bad + # let(:foobar) { blahblah } + # let(:baz) { bar } + # let(:a) { b } + # + # # good + # let(:foobar) { blahblah } + # let(:baz) { bar } + # let(:a) { b } + # + class AlignRightLetBrace < Cop + MSG = 'Align right let brace'.freeze + + def self.autocorrect_incompatible_with + [Layout::ExtraSpacing] + end + + def investigate(_processed_source) + return if processed_source.blank? + + token_aligner.offending_tokens.each do |let| + add_offense(let, location: :end) + end + end + + def autocorrect(let) + lambda do |corrector| + corrector.insert_before( + let.loc.end, + token_aligner.indent_for(let) + ) + end + end + + private + + def token_aligner + @token_aligner ||= + RuboCop::RSpec::AlignLetBrace.new(processed_source.ast, :end) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/any_instance.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/any_instance.rb new file mode 100644 index 0000000000..a3890a0914 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/any_instance.rb @@ -0,0 +1,42 @@ +module RuboCop + module Cop + module RSpec + # Check that instances are not being stubbed globally. + # + # Prefer instance doubles over stubbing any instance of a class + # + # @example + # # bad + # describe MyClass do + # before { allow_any_instance_of(MyClass).to receive(:foo) } + # end + # + # # good + # describe MyClass do + # let(:my_instance) { instance_double(MyClass) } + # + # before do + # allow(MyClass).to receive(:new).and_return(my_instance) + # allow(my_instance).to receive(:foo) + # end + # end + class AnyInstance < Cop + MSG = 'Avoid stubbing using `%s`.'.freeze + + def_node_matcher :disallowed_stub, <<-PATTERN + (send _ ${:any_instance :allow_any_instance_of :expect_any_instance_of} ...) + PATTERN + + def on_send(node) + disallowed_stub(node) do |method| + add_offense( + node, + location: :expression, + message: format(MSG, method: method) + ) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/around_block.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/around_block.rb new file mode 100644 index 0000000000..42761e79ea --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/around_block.rb @@ -0,0 +1,71 @@ +module RuboCop + module Cop + module RSpec + # Checks that around blocks actually run the test. + # + # @example + # # bad + # around do + # some_method + # end + # + # around do |test| + # some_method + # end + # + # # good + # around do |test| + # some_method + # test.call + # end + # + # around do |test| + # some_method + # test.run + # end + class AroundBlock < Cop + MSG_NO_ARG = 'Test object should be passed to around block.'.freeze + MSG_UNUSED_ARG = 'You should call `%s.call` '\ + 'or `%s.run`.'.freeze + + def_node_matcher :hook, <<-PATTERN + (block {(send nil? :around) (send nil? :around sym)} (args $...) ...) + PATTERN + + def_node_search :find_arg_usage, <<-PATTERN + {(send $... {:call :run}) (send _ _ $...) (yield $...) (block-pass $...)} + PATTERN + + def on_block(node) + hook(node) do |(example_proxy)| + if example_proxy.nil? + add_no_arg_offense(node) + else + check_for_unused_proxy(node, example_proxy) + end + end + end + + private + + def add_no_arg_offense(node) + add_offense(node, location: :expression, message: MSG_NO_ARG) + end + + def check_for_unused_proxy(block, proxy) + name, = *proxy + + find_arg_usage(block) do |usage| + return if usage.include?(s(:lvar, name)) + end + + add_offense( + proxy, + location: :expression, + message: format(MSG_UNUSED_ARG, arg: name) + ) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be.rb new file mode 100644 index 0000000000..1347811b10 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be.rb @@ -0,0 +1,35 @@ +module RuboCop + module Cop + module RSpec + # Check for expectations where `be` is used without argument. + # + # The `be` matcher is too generic, as it pass on everything that is not + # nil or false. If that is the exact intend, use `be_truthy`. In all other + # cases it's better to specify what exactly is the expected value. + # + # @example + # + # # bad + # expect(foo).to be + # + # # good + # expect(foo).to be_truthy + # expect(foo).to be 1.0 + # expect(foo).to be(true) + # + class Be < Cop + MSG = 'Don\'t use `be` without an argument.'.freeze + + def_node_matcher :be_without_args, <<-PATTERN + (send _ {:to :not_to :to_not} $(send nil? :be)) + PATTERN + + def on_send(node) + be_without_args(node) do |matcher| + add_offense(matcher, location: :selector) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be_eql.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be_eql.rb new file mode 100644 index 0000000000..be0ca2858d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/be_eql.rb @@ -0,0 +1,55 @@ +module RuboCop + module Cop + module RSpec + # Check for expectations where `be(...)` can replace `eql(...)`. + # + # The `be` matcher compares by identity while the `eql` matcher + # compares using `eql?`. Integers, floats, booleans, symbols, and nil + # can be compared by identity and therefore the `be` matcher is + # preferable as it is a more strict test. + # + # @example + # + # # bad + # expect(foo).to eql(1) + # expect(foo).to eql(1.0) + # expect(foo).to eql(true) + # expect(foo).to eql(false) + # expect(foo).to eql(:bar) + # expect(foo).to eql(nil) + # + # # good + # expect(foo).to be(1) + # expect(foo).to be(1.0) + # expect(foo).to be(true) + # expect(foo).to be(false) + # expect(foo).to be(:bar) + # expect(foo).to be(nil) + # + # This cop only looks for instances of `expect(...).to eql(...)`. We + # do not check `to_not` or `not_to` since `!eql?` is more strict + # than `!equal?`. We also do not try to flag `eq` because if + # `a == b`, and `b` is comparable by identity, `a` is still not + # necessarily the same type as `b` since the `#==` operator can + # coerce objects for comparison. + # + class BeEql < Cop + MSG = 'Prefer `be` over `eql`.'.freeze + + def_node_matcher :eql_type_with_identity, <<-PATTERN + (send _ :to $(send nil? :eql {true false int float sym nil_type?})) + PATTERN + + def on_send(node) + eql_type_with_identity(node) do |eql| + add_offense(eql, location: :selector) + end + end + + def autocorrect(node) + ->(corrector) { corrector.replace(node.loc.selector, 'be') } + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/before_after_all.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/before_after_all.rb new file mode 100644 index 0000000000..bf9f93df8d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/before_after_all.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Check that before/after(:all) isn't being used. + # + # @example + # # bad + # # + # # Faster but risk of state leaking between examples + # # + # describe MyClass do + # before(:all) { Widget.create } + # after(:all) { Widget.delete_all } + # end + # + # # good + # # + # # Slower but examples are properly isolated + # # + # describe MyClass do + # before(:each) { Widget.create } + # after(:each) { Widget.delete_all } + # end + class BeforeAfterAll < Cop + MSG = 'Beware of using `%s` as it may cause state to leak '\ + 'between tests. If you are using `rspec-rails`, and '\ + '`use_transactional_fixtures` is enabled, then records created '\ + 'in `%s` are not automatically rolled back.'.freeze + + def_node_matcher :before_or_after_all, <<-PATTERN + $(send _ {:before :after} (sym {:all :context})) + PATTERN + + def on_send(node) + before_or_after_all(node) do |hook| + add_offense( + node, + location: :expression, + message: format(MSG, hook: hook.source) + ) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb new file mode 100644 index 0000000000..53d2cd638b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb @@ -0,0 +1,42 @@ +module RuboCop + module Cop + module RSpec + module Capybara + # Checks that no expectations are set on Capybara's `current_path`. + # + # The `have_current_path` matcher (http://www.rubydoc.info/github/ + # teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path- + # instance_method) should be used on `page` to set expectations on + # Capybara's current path, since it uses Capybara's waiting + # functionality (https://github.com/teamcapybara/capybara/blob/master/ + # README.md#asynchronous-javascript-ajax-and-friends) which ensures that + # preceding actions (like `click_link`) have completed. + # + # @example + # # bad + # expect(current_path).to eq('/callback') + # expect(page.current_path).to match(/widgets/) + # + # # good + # expect(page).to have_current_path("/callback") + # expect(page).to have_current_path(/widgets/) + # + class CurrentPathExpectation < Cop + MSG = 'Do not set an RSpec expectation on `current_path` in ' \ + 'Capybara feature specs - instead, use the ' \ + '`have_current_path` matcher on `page`'.freeze + + def_node_matcher :expectation_set_on_current_path, <<-PATTERN + (send nil? :expect (send {(send nil? :page) nil?} :current_path)) + PATTERN + + def on_send(node) + expectation_set_on_current_path(node) do + add_offense(node, location: :selector) + end + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/feature_methods.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/feature_methods.rb new file mode 100644 index 0000000000..8d60d3a771 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/capybara/feature_methods.rb @@ -0,0 +1,118 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + module Capybara + # Checks for consistent method usage in feature specs. + # + # By default, the cop disables all Capybara-specific methods that have + # the same native RSpec method (e.g. are just aliases). Some teams + # however may prefer using some of the Capybara methods (like `feature`) + # to make it obvious that the test uses Capybara, while still disable + # the rest of the methods, like `given` (alias for `let`), `background` + # (alias for `before`), etc. You can configure which of the methods to + # be enabled by using the EnabledMethods configuration option. + # + # @example + # # bad + # feature 'User logs in' do + # given(:user) { User.new } + # + # background do + # visit new_session_path + # end + # + # scenario 'with OAuth' do + # # ... + # end + # end + # + # # good + # describe 'User logs in' do + # let(:user) { User.new } + # + # before do + # visit new_session_path + # end + # + # it 'with OAuth' do + # # ... + # end + # end + class FeatureMethods < Cop + MSG = 'Use `%s` instead of `%s`.'.freeze + + # https://git.io/v7Kwr + MAP = { + background: :before, + scenario: :it, + xscenario: :xit, + given: :let, + given!: :let!, + feature: :describe + }.freeze + + def_node_matcher :spec?, <<-PATTERN + (block + (send {(const nil? :RSpec) nil?} {:describe :feature} ...) + ...) + PATTERN + + def_node_matcher :feature_method, <<-PATTERN + (block + $(send {(const nil? :RSpec) nil?} ${#{MAP.keys.map(&:inspect).join(' ')}} ...) + ...) + PATTERN + + def on_block(node) + return unless inside_spec?(node) + + feature_method(node) do |send_node, match| + next if enabled?(match) + + add_offense( + send_node, + location: :selector, + message: format(MSG, method: match, replacement: MAP[match]) + ) + end + end + + def autocorrect(node) + lambda do |corrector| + corrector.replace(node.loc.selector, MAP[node.method_name].to_s) + end + end + + private + + def inside_spec?(node) + return spec?(node) if root_node?(node) + + root = node.ancestors.find { |parent| root_node?(parent) } + spec?(root) + end + + def root_node?(node) + node.parent.nil? || root_with_siblings?(node.parent) + end + + def root_with_siblings?(node) + node.begin_type? && node.parent.nil? + end + + def enabled?(method_name) + enabled_methods.include?(method_name) + end + + def enabled_methods + cop_config + .fetch('EnabledMethods', []) + .map(&:to_sym) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/context_wording.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/context_wording.rb new file mode 100644 index 0000000000..1cfed8767c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/context_wording.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # `context` block descriptions should start with 'when', or 'with'. + # + # @see https://github.com/reachlocal/rspec-style-guide#context-descriptions + # @see http://www.betterspecs.org/#contexts + # + # @example `Prefixes` configuration option, defaults: 'when', 'with', and + # 'without' + # Prefixes: + # - when + # - with + # - without + # - if + # + # @example + # # bad + # context 'the display name not present' do + # # ... + # end + # + # # good + # context 'when the display name is not present' do + # # ... + # end + class ContextWording < Cop + MSG = 'Start context description with %s.'.freeze + + def_node_matcher :context_wording, <<-PATTERN + (block (send _ { :context :shared_context } $(str #bad_prefix?)) ...) + PATTERN + + def on_block(node) + context_wording(node) do |context| + add_offense(context, message: message) + end + end + + private + + def bad_prefix?(description) + !prefixes.include?(description.split.first) + end + + def prefixes + cop_config['Prefixes'] || [] + end + + def message + format(MSG, prefixes: joined_prefixes) + end + + def joined_prefixes + quoted = prefixes.map { |prefix| "'#{prefix}'" } + return quoted.first if quoted.size == 1 + + quoted << "or #{quoted.pop}" + quoted.join(', ') + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/cop.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/cop.rb new file mode 100644 index 0000000000..636333212b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/cop.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true + +module RuboCop + module Cop # rubocop:disable Style/Documentation + WorkaroundCop = Cop.dup + + # Clone of the the normal RuboCop::Cop::Cop class so we can rewrite + # the inherited method without breaking functionality + class WorkaroundCop + # Remove the Cop.inherited method to be a noop. Our RSpec::Cop + # class will invoke the inherited hook instead + class << self + undef inherited + def inherited(*) end + end + + # Special case `Module#<` so that the rspec support rubocop exports + # is compatible with our subclass + def self.<(other) + other.equal?(RuboCop::Cop::Cop) || super + end + end + private_constant(:WorkaroundCop) + + module RSpec + # @abstract parent class to rspec cops + # + # The criteria for whether rubocop-rspec analyzes a certain ruby file + # is configured via `AllCops/RSpec`. For example, if you want to + # customize your project to scan all files within a `test/` directory + # then you could add this to your configuration: + # + # @example configuring analyzed paths + # + # AllCops: + # RSpec: + # Patterns: + # - '_test.rb$' + # - '(?:^|/)test/' + class Cop < WorkaroundCop + include RuboCop::RSpec::Language + include RuboCop::RSpec::Language::NodePattern + + DEFAULT_CONFIGURATION = + RuboCop::RSpec::CONFIG.fetch('AllCops').fetch('RSpec') + + DEFAULT_PATTERN_RE = Regexp.union( + DEFAULT_CONFIGURATION.fetch('Patterns') + .map(&Regexp.public_method(:new)) + ) + + # Invoke the original inherited hook so our cops are recognized + def self.inherited(subclass) + RuboCop::Cop::Cop.inherited(subclass) + end + + def relevant_file?(file) + relevant_rubocop_rspec_file?(file) && super + end + + private + + def relevant_rubocop_rspec_file?(file) + rspec_pattern =~ file + end + + def rspec_pattern + if rspec_pattern_config? + Regexp.union(rspec_pattern_config.map(&Regexp.public_method(:new))) + else + DEFAULT_PATTERN_RE + end + end + + def all_cops_config + config + .for_all_cops + end + + def rspec_pattern_config? + return unless all_cops_config.key?('RSpec') + + all_cops_config.fetch('RSpec').key?('Patterns') + end + + def rspec_pattern_config + all_cops_config + .fetch('RSpec', DEFAULT_CONFIGURATION) + .fetch('Patterns') + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_class.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_class.rb new file mode 100644 index 0000000000..ff2211dcf8 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_class.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Check that the first argument to the top level describe is a constant. + # + # @example + # # bad + # describe 'Do something' do + # end + # + # # good + # describe TestedClass do + # end + # + # describe "A feature example", type: :feature do + # end + class DescribeClass < Cop + include RuboCop::RSpec::TopLevelDescribe + + MSG = 'The first argument to describe should be '\ + 'the class or module being tested.'.freeze + + def_node_matcher :valid_describe?, <<-PATTERN + { + (send {(const nil? :RSpec) nil?} :describe const ...) + (send {(const nil? :RSpec) nil?} :describe) + } + PATTERN + + def_node_matcher :describe_with_metadata, <<-PATTERN + (send {(const nil? :RSpec) nil?} :describe + !const + ... + (hash $...)) + PATTERN + + def_node_matcher :rails_metadata?, <<-PATTERN + (pair + (sym :type) + (sym {:request :feature :system :routing :view})) + PATTERN + + def_node_matcher :shared_group?, SharedGroups::ALL.block_pattern + + def on_top_level_describe(node, args) + return if shared_group?(root_node) + return if valid_describe?(node) + + describe_with_metadata(node) do |pairs| + return if pairs.any?(&method(:rails_metadata?)) + end + + add_offense(args.first, location: :expression) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_method.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_method.rb new file mode 100644 index 0000000000..109c556529 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_method.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks that the second argument to `describe` specifies a method. + # + # @example + # # bad + # describe MyClass, 'do something' do + # end + # + # # good + # describe MyClass, '#my_instance_method' do + # end + # + # describe MyClass, '.my_class_method' do + # end + class DescribeMethod < Cop + include RuboCop::RSpec::TopLevelDescribe + include RuboCop::RSpec::Util + + MSG = 'The second argument to describe should be the method '\ + "being tested. '#instance' or '.class'.".freeze + + def on_top_level_describe(_node, (_, second_arg)) + return unless second_arg && second_arg.str_type? + return if second_arg.str_content.start_with?('#', '.') + + add_offense(second_arg, location: :expression) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_symbol.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_symbol.rb new file mode 100644 index 0000000000..95bb0b4c77 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/describe_symbol.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Avoid describing symbols. + # + # @example + # # bad + # describe :my_method do + # # ... + # end + # + # # good + # describe '#my_method' do + # # ... + # end + # + # @see https://github.com/rspec/rspec-core/issues/1610 + class DescribeSymbol < Cop + MSG = 'Avoid describing symbols.'.freeze + + def_node_matcher :describe_symbol?, <<-PATTERN + (send {(const nil? :RSpec) nil?} :describe $sym ...) + PATTERN + + def on_send(node) + describe_symbol?(node) do |match| + add_offense(match, location: :expression) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/described_class.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/described_class.rb new file mode 100644 index 0000000000..cabc766653 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/described_class.rb @@ -0,0 +1,124 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks that tests use `described_class`. + # + # If the first argument of describe is a class, the class is exposed to + # each example via described_class. + # + # This cop can be configured using the `EnforcedStyle` option + # + # @example `EnforcedStyle: described_class` + # # bad + # describe MyClass do + # subject { MyClass.do_something } + # end + # + # # good + # describe MyClass do + # subject { described_class.do_something } + # end + # + # @example `EnforcedStyle: explicit` + # # bad + # describe MyClass do + # subject { described_class.do_something } + # end + # + # # good + # describe MyClass do + # subject { MyClass.do_something } + # end + # + class DescribedClass < Cop + include RuboCop::RSpec::TopLevelDescribe + include ConfigurableEnforcedStyle + + DESCRIBED_CLASS = 'described_class'.freeze + MSG = 'Use `%s` instead of `%s`.'.freeze + + def_node_matcher :common_instance_exec_closure?, <<-PATTERN + (block (send (const nil? {:Class :Module}) :new ...) ...) + PATTERN + + def_node_matcher :rspec_block?, + RuboCop::RSpec::Language::ALL.block_pattern + + def_node_matcher :scope_changing_syntax?, '{def class module}' + + def on_block(node) + # In case the explicit style is used, we needs to remember what's + # being described. Thus, we use an ivar for @described_class. + describe, @described_class, body = described_constant(node) + + return if body.nil? + return unless top_level_describe?(describe) + + find_usage(body) do |match| + add_offense( + match, + location: :expression, + message: message(match.const_name) + ) + end + end + + def autocorrect(node) + replacement = if style == :described_class + DESCRIBED_CLASS + else + @described_class.const_name + end + lambda do |corrector| + corrector.replace(node.loc.expression, replacement) + end + end + + private + + def find_usage(node, &block) + yield(node) if offensive?(node) + + return if scope_change?(node) || node.const_type? + + node.each_child_node do |child| + find_usage(child, &block) + end + end + + def message(offense) + if style == :described_class + format(MSG, replacement: DESCRIBED_CLASS, src: offense) + else + format(MSG, replacement: @described_class.const_name, + src: DESCRIBED_CLASS) + end + end + + def scope_change?(node) + scope_changing_syntax?(node) || + common_instance_exec_closure?(node) || + skippable_block?(node) + end + + def skippable_block?(node) + node.block_type? && !rspec_block?(node) && skip_blocks? + end + + def skip_blocks? + cop_config['SkipBlocks'].equal?(true) + end + + def offensive?(node) + if style == :described_class + node.eql?(@described_class) + else + node.send_type? && node.method_name == :described_class + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_example_group.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_example_group.rb new file mode 100644 index 0000000000..3ee001dd64 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_example_group.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks if an example group does not include any tests. + # + # This cop is configurable using the `CustomIncludeMethods` option + # + # @example usage + # + # # bad + # describe Bacon do + # let(:bacon) { Bacon.new(chunkiness) } + # let(:chunkiness) { false } + # + # context 'extra chunky' do # flagged by rubocop + # let(:chunkiness) { true } + # end + # + # it 'is chunky' do + # expect(bacon.chunky?).to be_truthy + # end + # end + # + # # good + # describe Bacon do + # let(:bacon) { Bacon.new(chunkiness) } + # let(:chunkiness) { false } + # + # it 'is chunky' do + # expect(bacon.chunky?).to be_truthy + # end + # end + # + # @example configuration + # + # # .rubocop.yml + # # RSpec/EmptyExampleGroup: + # # CustomIncludeMethods: + # # - include_tests + # + # # spec_helper.rb + # RSpec.configure do |config| + # config.alias_it_behaves_like_to(:include_tests) + # end + # + # # bacon_spec.rb + # describe Bacon do + # let(:bacon) { Bacon.new(chunkiness) } + # let(:chunkiness) { false } + # + # context 'extra chunky' do # not flagged by rubocop + # let(:chunkiness) { true } + # + # include_tests 'shared tests' + # end + # end + # + class EmptyExampleGroup < Cop + MSG = 'Empty example group detected.'.freeze + + def_node_search :contains_example?, <<-PATTERN + { + #{(Examples::ALL + Includes::ALL).send_pattern} + (send _ #custom_include? ...) + } + PATTERN + + def on_block(node) + return unless example_group?(node) && !contains_example?(node) + + add_offense(node.send_node, location: :expression) + end + + private + + def custom_include?(method_name) + custom_include_methods.include?(method_name) + end + + def custom_include_methods + cop_config + .fetch('CustomIncludeMethods', []) + .map(&:to_sym) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_example_group.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_example_group.rb new file mode 100644 index 0000000000..4279e68eb0 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_example_group.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks if there is an empty line after example group blocks. + # + # @example + # # bad + # RSpec.describe Foo do + # describe '#bar' do + # end + # describe '#baz' do + # end + # end + # + # # good + # RSpec.describe Foo do + # describe '#bar' do + # end + # + # describe '#baz' do + # end + # end + # + class EmptyLineAfterExampleGroup < Cop + include RuboCop::RSpec::BlankLineSeparation + + MSG = 'Add an empty line after `%s`.'.freeze + + def on_block(node) + return unless example_group?(node) + return if last_child?(node) + + missing_separating_line(node) do |location| + add_offense( + node, + location: location, + message: format(MSG, example_group: node.method_name) + ) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_final_let.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_final_let.rb new file mode 100644 index 0000000000..f5f1ba77fa --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_final_let.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks if there is an empty line after the last let block. + # + # @example + # # bad + # let(:foo) { bar } + # let(:something) { other } + # it { does_something } + # + # # good + # let(:foo) { bar } + # let(:something) { other } + # + # it { does_something } + class EmptyLineAfterFinalLet < Cop + include RuboCop::RSpec::BlankLineSeparation + + MSG = 'Add an empty line after the last `let` block.'.freeze + + def on_block(node) + return unless example_group_with_body?(node) + + latest_let = node.body.child_nodes.select { |child| let?(child) }.last + + return if latest_let.nil? + return if last_child?(latest_let) + + missing_separating_line(latest_let) do |location| + add_offense(latest_let, location: location) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_hook.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_hook.rb new file mode 100644 index 0000000000..8ce719f5d1 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_hook.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks if there is an empty line after hook blocks. + # + # @example + # # bad + # before { do_something } + # it { does_something } + # + # # bad + # after { do_something } + # it { does_something } + # + # # bad + # around { |test| test.run } + # it { does_something } + # + # # good + # before { do_something } + # + # it { does_something } + # + # # good + # after { do_something } + # + # it { does_something } + # + # # good + # around { |test| test.run } + # + # it { does_something } + # + class EmptyLineAfterHook < Cop + include RuboCop::RSpec::BlankLineSeparation + + MSG = 'Add an empty line after `%s`.'.freeze + + def on_block(node) + return unless hook?(node) + return if last_child?(node) + + missing_separating_line(node) do |location| + add_offense( + node, + location: location, + message: format(MSG, hook: node.method_name) + ) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_subject.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_subject.rb new file mode 100644 index 0000000000..e41824b2b5 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/empty_line_after_subject.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks if there is an empty line after subject block. + # + # @example + # # bad + # subject(:obj) { described_class } + # let(:foo) { bar } + # + # # good + # subject(:obj) { described_class } + # + # let(:foo) { bar } + class EmptyLineAfterSubject < Cop + include RuboCop::RSpec::BlankLineSeparation + + MSG = 'Add empty line after `subject`.'.freeze + + def on_block(node) + return unless subject?(node) && !in_spec_block?(node) + return if last_child?(node) + + missing_separating_line(node) do |location| + add_offense(node, location: location, message: MSG) + end + end + + private + + def in_spec_block?(node) + node.each_ancestor(:block).any? do |ancestor| + Examples::ALL.include?(ancestor.method_name) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_length.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_length.rb new file mode 100644 index 0000000000..a867bf530d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_length.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for long examples. + # + # A long example is usually more difficult to understand. Consider + # extracting out some behaviour, e.g. with a `let` block, or a helper + # method. + # + # @example + # # bad + # it do + # service = described_class.new + # more_setup + # more_setup + # result = service.call + # expect(result).to be(true) + # end + # + # # good + # it do + # service = described_class.new + # result = service.call + # expect(result).to be(true) + # end + class ExampleLength < Cop + include CodeLength + + MSG = 'Example has too many lines [%d/%d].'.freeze + + def on_block(node) + return unless example?(node) + + length = code_length(node) + + return unless length > max_length + + add_offense(node, location: :expression, message: message(length)) + end + + private + + def code_length(node) + node.source.lines[1..-2].count { |line| !irrelevant_line(line) } + end + + def message(length) + format(MSG, total: length, max: max_length) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_without_description.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_without_description.rb new file mode 100644 index 0000000000..fdb7316c08 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_without_description.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for examples without a description. + # + # RSpec allows for auto-generated example descriptions when there is no + # description provided or the description is an empty one. + # + # This cop removes empty descriptions. + # It also defines whether auto-generated description is allowed, based + # on the configured style. + # + # This cop can be configured using the `EnforcedStyle` option + # + # @example `EnforcedStyle: always_allow` + # # bad + # it('') { is_expected.to be_good } + # it '' do + # result = service.call + # expect(result).to be(true) + # end + # + # # good + # it { is_expected.to be_good } + # it do + # result = service.call + # expect(result).to be(true) + # end + # + # @example `EnforcedStyle: single_line_only` + # # bad + # it('') { is_expected.to be_good } + # it do + # result = service.call + # expect(result).to be(true) + # end + # + # # good + # it { is_expected.to be_good } + # + # @example `EnforcedStyle: disallow` + # # bad + # it { is_expected.to be_good } + # it do + # result = service.call + # expect(result).to be(true) + # end + class ExampleWithoutDescription < Cop + include ConfigurableEnforcedStyle + + MSG_DEFAULT_ARGUMENT = 'Omit the argument when you want to ' \ + 'have auto-generated description.'.freeze + MSG_ADD_DESCRIPTION = 'Add a description.'.freeze + + def_node_matcher :example_description, '(send nil? _ $(str $_))' + + def on_block(node) + return unless example?(node) + + check_example_without_description(node.send_node) + + example_description(node.send_node) do |message_node, message| + return unless message.to_s.empty? + + add_offense(message_node, message: MSG_DEFAULT_ARGUMENT) + end + end + + private + + def check_example_without_description(node) + return if node.arguments? + return unless disallow_empty_description?(node) + + add_offense(node, message: MSG_ADD_DESCRIPTION) + end + + def disallow_empty_description?(node) + style == :disallow || + (style == :single_line_only && node.parent.multiline?) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_wording.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_wording.rb new file mode 100644 index 0000000000..ba8ae11758 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/example_wording.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for common mistakes in example descriptions. + # + # This cop will correct docstrings that begin with 'should' and 'it'. + # + # @see http://betterspecs.org/#should + # + # The autocorrect is experimental - use with care! It can be configured + # with CustomTransform (e.g. have => has) and IgnoredWords (e.g. only). + # + # @example + # # bad + # it 'should find nothing' do + # end + # + # # good + # it 'finds nothing' do + # end + # + # @example + # # bad + # it 'it does things' do + # end + # + # # good + # it 'does things' do + # end + class ExampleWording < Cop + MSG_SHOULD = 'Do not use should when describing your tests.'.freeze + MSG_IT = "Do not repeat 'it' when describing your tests.".freeze + + SHOULD_PREFIX = /\Ashould(?:n't)?\b/i + IT_PREFIX = /\Ait /i + + def_node_matcher( + :it_description, + '(block (send _ :it $(str $_) ...) ...)' + ) + + def on_block(node) + it_description(node) do |description_node, message| + if message =~ SHOULD_PREFIX + add_wording_offense(description_node, MSG_SHOULD) + elsif message =~ IT_PREFIX + add_wording_offense(description_node, MSG_IT) + end + end + end + + def autocorrect(range) + ->(corrector) { corrector.replace(range, replacement_text(range)) } + end + + private + + def add_wording_offense(node, message) + expr = node.loc.expression + + docstring = + Parser::Source::Range.new( + expr.source_buffer, + expr.begin_pos + 1, + expr.end_pos - 1 + ) + + add_offense(docstring, location: docstring, message: message) + end + + def replacement_text(range) + text = range.source + + if text =~ SHOULD_PREFIX + RuboCop::RSpec::Wording.new( + text, + ignore: ignored_words, + replace: custom_transform + ).rewrite + else + text.sub(IT_PREFIX, '') + end + end + + def custom_transform + cop_config.fetch('CustomTransform', {}) + end + + def ignored_words + cop_config.fetch('IgnoredWords', []) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_actual.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_actual.rb new file mode 100644 index 0000000000..9da8b7cc83 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_actual.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for `expect(...)` calls containing literal values. + # + # @example + # # bad + # expect(5).to eq(price) + # expect(/foo/).to eq(pattern) + # expect("John").to eq(name) + # + # # good + # expect(price).to eq(5) + # expect(pattern).to eq(/foo/) + # expect(name).to eq("John") + # + class ExpectActual < Cop + MSG = 'Provide the actual you are testing to `expect(...)`.'.freeze + + SIMPLE_LITERALS = %i[ + true + false + nil + int + float + str + sym + complex + rational + regopt + ].freeze + + COMPLEX_LITERALS = %i[ + array + hash + pair + irange + erange + regexp + ].freeze + + def_node_matcher :expect_literal, '(send _ :expect $#literal?)' + + def on_send(node) + expect_literal(node) do |argument| + add_offense(argument, location: :expression) + end + end + + private + + # This is not implement using a NodePattern because it seems + # to not be able to match against an explicit (nil) sexp + def literal?(node) + node && (simple_literal?(node) || complex_literal?(node)) + end + + def simple_literal?(node) + SIMPLE_LITERALS.include?(node.type) + end + + def complex_literal?(node) + COMPLEX_LITERALS.include?(node.type) && + node.each_child_node.all?(&method(:literal?)) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_change.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_change.rb new file mode 100644 index 0000000000..552b2d763a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_change.rb @@ -0,0 +1,102 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for consistent style of change matcher. + # + # Enforces either passing object and attribute as arguments to the matcher + # or passing a block that reads the attribute value. + # + # This cop can be configured using the `EnforcedStyle` option. + # + # @example `EnforcedStyle: block` + # # bad + # expect(run).to change(Foo, :bar) + # + # # good + # expect(run).to change { Foo.bar } + # + # @example `EnforcedStyle: method_call` + # # bad + # expect(run).to change { Foo.bar } + # expect(run).to change { foo.baz } + # + # # good + # expect(run).to change(Foo, :bar) + # expect(run).to change(foo, :baz) + # # also good when there are arguments or chained method calls + # expect(run).to change { Foo.bar(:count) } + # expect(run).to change { user.reload.name } + # + class ExpectChange < Cop + include ConfigurableEnforcedStyle + + MSG_BLOCK = 'Prefer `change(%s, :%s)`.'.freeze + MSG_CALL = 'Prefer `change { %s.%s }`.'.freeze + + def_node_matcher :expect_change_with_arguments, <<-PATTERN + (send nil? :change ({const send} nil? $_) (sym $_)) + PATTERN + + def_node_matcher :expect_change_with_block, <<-PATTERN + (block + (send nil? :change) + (args) + (send ({const send} nil? $_) $_) + ) + PATTERN + + def on_send(node) + return unless style == :block + + expect_change_with_arguments(node) do |receiver, message| + add_offense( + node, + message: format(MSG_CALL, obj: receiver, attr: message) + ) + end + end + + def on_block(node) + return unless style == :method_call + + expect_change_with_block(node) do |receiver, message| + add_offense( + node, + message: format(MSG_BLOCK, obj: receiver, attr: message) + ) + end + end + + def autocorrect(node) + if style == :block + autocorrect_method_call_to_block(node) + else + autocorrect_block_to_method_call(node) + end + end + + private + + def autocorrect_method_call_to_block(node) + lambda do |corrector| + expect_change_with_arguments(node) do |receiver, message| + replacement = "change { #{receiver}.#{message} }" + corrector.replace(node.loc.expression, replacement) + end + end + end + + def autocorrect_block_to_method_call(node) + lambda do |corrector| + expect_change_with_block(node) do |receiver, message| + replacement = "change(#{receiver}, :#{message})" + corrector.replace(node.loc.expression, replacement) + end + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_in_hook.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_in_hook.rb new file mode 100644 index 0000000000..22232f60f8 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_in_hook.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Do not use `expect` in hooks such as `before`. + # + # @example + # # bad + # before do + # expect(something).to eq 'foo' + # end + # + # # bad + # after do + # expect_any_instance_of(Something).to receive(:foo) + # end + # + # # good + # it do + # expect(something).to eq 'foo' + # end + class ExpectInHook < Cop + MSG = 'Do not use `%s` in `%s` hook'.freeze + + def_node_search :expectation, Expectations::ALL.send_pattern + + def on_block(node) + return unless hook?(node) + return if node.body.nil? + + expectation(node.body) do |expect| + add_offense(expect, location: :selector, + message: message(expect, node)) + end + end + + private + + def message(expect, hook) + format(MSG, expect: expect.method_name, hook: hook.method_name) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_output.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_output.rb new file mode 100644 index 0000000000..d23e7159da --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/expect_output.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for opportunities to use `expect { ... }.to output`. + # + # @example + # # bad + # $stdout = StringIO.new + # my_app.print_report + # $stdout = STDOUT + # expect($stdout.string).to eq('Hello World') + # + # # good + # expect { my_app.print_report }.to output('Hello World').to_stdout + class ExpectOutput < Cop + MSG = 'Use `expect { ... }.to output(...).to_%s` '\ + 'instead of mutating $%s.'.freeze + + def on_gvasgn(node) + return unless inside_example_scope?(node) + + variable_name, _rhs = *node + name = variable_name[1..-1] + return unless name.eql?('stdout') || name.eql?('stderr') + + add_offense(node, location: :name, message: format(MSG, name: name)) + end + + private + + # Detect if we are inside the scope of a single example + # + # We want to encourage using `expect { ... }.to output` so + # we only care about situations where you would replace with + # an expectation. Therefore, assignments to stderr or stdout + # within a `before(:all)` or otherwise outside of an example + # don't matter. + def inside_example_scope?(node) + return false if node.nil? || example_group?(node) + return true if example?(node) + return RuboCop::RSpec::Hook.new(node).example? if hook?(node) + + inside_example_scope?(node.parent) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb new file mode 100644 index 0000000000..21b522b79f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb @@ -0,0 +1,147 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + module FactoryBot + # Always declare attribute values as blocks. + # + # @example + # # bad + # kind [:active, :rejected].sample + # + # # good + # kind { [:active, :rejected].sample } + # + # # bad + # closed_at 1.day.from_now + # + # # good + # closed_at { 1.day.from_now } + # + # # bad + # count 1 + # + # # good + # count { 1 } + class AttributeDefinedStatically < Cop + MSG = 'Use a block to declare attribute values.'.freeze + + ATTRIBUTE_DEFINING_METHODS = %i[factory trait transient ignore].freeze + + UNPROXIED_METHODS = %i[ + __send__ + __id__ + nil? + send + object_id + extend + instance_eval + initialize + block_given? + raise + caller + method + ].freeze + + DEFINITION_PROXY_METHODS = %i[ + add_attribute + after + association + before + callback + ignore + initialize_with + sequence + skip_create + to_create + ].freeze + + RESERVED_METHODS = + DEFINITION_PROXY_METHODS + + UNPROXIED_METHODS + + ATTRIBUTE_DEFINING_METHODS + + def_node_matcher :value_matcher, <<-PATTERN + (send {self nil?} !#reserved_method? $...) + PATTERN + + def_node_search :factory_attributes, <<-PATTERN + (block (send nil? #attribute_defining_method? ...) _ { (begin $...) $(send ...) } ) + PATTERN + + def on_block(node) + factory_attributes(node).to_a.flatten.each do |attribute| + next if proc?(attribute) || association?(attribute) + + add_offense(attribute, location: :expression) + end + end + + def autocorrect(node) + if node.parenthesized? + autocorrect_replacing_parens(node) + else + autocorrect_without_parens(node) + end + end + + private + + def proc?(attribute) + value_matcher(attribute).to_a.all?(&:block_pass_type?) + end + + def association?(attribute) + argument = attribute.first_argument + argument.hash_type? && factory_key?(argument) + end + + def factory_key?(hash_node) + hash_node.keys.any? { |key| key.sym_type? && key.value == :factory } + end + + def autocorrect_replacing_parens(node) + left_braces, right_braces = braces(node) + + lambda do |corrector| + corrector.replace(node.location.begin, ' ' + left_braces) + corrector.replace(node.location.end, right_braces) + end + end + + def autocorrect_without_parens(node) + left_braces, right_braces = braces(node) + + lambda do |corrector| + argument = node.first_argument + expression = argument.location.expression + corrector.insert_before(expression, left_braces) + corrector.insert_after(expression, right_braces) + end + end + + def braces(node) + if value_hash_without_braces?(node.first_argument) + ['{ { ', ' } }'] + else + ['{ ', ' }'] + end + end + + def value_hash_without_braces?(node) + node.hash_type? && !node.braces? + end + + def reserved_method?(method_name) + RESERVED_METHODS.include?(method_name) + end + + def attribute_defining_method?(method_name) + ATTRIBUTE_DEFINING_METHODS.include?(method_name) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/create_list.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/create_list.rb new file mode 100644 index 0000000000..8eb690609a --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/factory_bot/create_list.rb @@ -0,0 +1,149 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + module FactoryBot + # Checks for create_list usage. + # + # This cop can be configured using the `EnforcedStyle` option + # + # @example `EnforcedStyle: create_list` + # # bad + # 3.times { create :user } + # + # # good + # create_list :user, 3 + # + # # good + # 3.times { |n| create :user, created_at: n.months.ago } + # + # @example `EnforcedStyle: n_times` + # # bad + # create_list :user, 3 + # + # # good + # 3.times { create :user } + class CreateList < Cop + include ConfigurableEnforcedStyle + + MSG_CREATE_LIST = 'Prefer create_list.'.freeze + MSG_N_TIMES = 'Prefer %s.times.'.freeze + + def_node_matcher :n_times_block?, <<-PATTERN + (block + (send (int _) :times) + ... + ) + PATTERN + + def_node_matcher :factory_call, <<-PATTERN + (send ${(const nil? {:FactoryGirl :FactoryBot}) nil?} :create (sym $_) $...) + PATTERN + + def_node_matcher :factory_list_call, <<-PATTERN + (send ${(const nil? {:FactoryGirl :FactoryBot}) nil?} :create_list (sym $_) (int $_) $...) + PATTERN + + def on_block(node) + return unless style == :create_list + return unless n_times_block?(node) + return unless contains_only_factory?(node.body) + + add_offense(node.send_node, + location: :expression, message: MSG_CREATE_LIST) + end + + def on_send(node) + return unless style == :n_times + + factory_list_call(node) do |_receiver, _factory, count, _| + add_offense( + node, + location: :selector, + message: format(MSG_N_TIMES, number: count) + ) + end + end + + def autocorrect(node) + if style == :create_list + autocorrect_n_times_to_create_list(node) + else + autocorrect_create_list_to_n_times(node) + end + end + + private + + def contains_only_factory?(node) + if node.block_type? + factory_call(node.send_node) + else + factory_call(node) + end + end + + def autocorrect_n_times_to_create_list(node) + block = node.parent + count = block.receiver.source + replacement = factory_call_replacement(block.body, count) + + lambda do |corrector| + corrector.replace(block.loc.expression, replacement) + end + end + + def autocorrect_create_list_to_n_times(node) + replacement = generate_n_times_block(node) + lambda do |corrector| + corrector.replace(node.loc.expression, replacement) + end + end + + def generate_n_times_block(node) + receiver, factory, count, options = *factory_list_call(node) + + arguments = ":#{factory}" + options = build_options_string(options) + arguments += ", #{options}" unless options.empty? + + replacement = format_receiver(receiver) + replacement += format_method_call(node, 'create', arguments) + "#{count}.times { #{replacement} }" + end + + def factory_call_replacement(body, count) + receiver, factory, options = *factory_call(body) + + arguments = ":#{factory}, #{count}" + options = build_options_string(options) + arguments += ", #{options}" unless options.empty? + + replacement = format_receiver(receiver) + replacement += format_method_call(body, 'create_list', arguments) + replacement + end + + def build_options_string(options) + options.map(&:source).join(', ') + end + + def format_method_call(node, method, arguments) + if node.parenthesized? + "#{method}(#{arguments})" + else + "#{method} #{arguments}" + end + end + + def format_receiver(receiver) + return '' unless receiver + + "#{receiver.source}." + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/file_path.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/file_path.rb new file mode 100644 index 0000000000..44df621366 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/file_path.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks that spec file paths are consistent with the test subject. + # + # Checks the path of the spec file and enforces that it reflects the + # described class/module and its optionally called out method. + # + # With the configuration option `IgnoreMethods` the called out method will + # be ignored when determining the enforced path. + # + # With the configuration option `CustomTransform` modules or classes can + # be specified that should not as usual be transformed from CamelCase to + # snake_case (e.g. 'RuboCop' => 'rubocop' ). + # + # @example + # # bad + # whatever_spec.rb # describe MyClass + # + # # bad + # my_class_spec.rb # describe MyClass, '#method' + # + # # good + # my_class_spec.rb # describe MyClass + # + # # good + # my_class_method_spec.rb # describe MyClass, '#method' + # + # # good + # my_class/method_spec.rb # describe MyClass, '#method' + # + # @example when configuration is `IgnoreMethods: true` + # # bad + # whatever_spec.rb # describe MyClass + # + # # good + # my_class_spec.rb # describe MyClass + # + # # good + # my_class_spec.rb # describe MyClass, '#method' + # + class FilePath < Cop + include RuboCop::RSpec::TopLevelDescribe + + MSG = 'Spec path should end with `%s`.'.freeze + + def_node_search :const_described?, '(send _ :describe (const ...) ...)' + def_node_search :routing_metadata?, '(pair (sym :type) (sym :routing))' + + def on_top_level_describe(node, args) + return unless const_described?(node) && single_top_level_describe? + return if routing_spec?(args) + + glob = glob_for(args) + + return if filename_ends_with?(glob) + + add_offense( + node, + location: :expression, + message: format(MSG, suffix: glob) + ) + end + + private + + def routing_spec?(args) + args.any?(&method(:routing_metadata?)) + end + + def glob_for((described_class, method_name)) + "#{expected_path(described_class)}#{name_glob(method_name)}*_spec.rb" + end + + def name_glob(name) + return unless name && name.str_type? + + "*#{name.str_content.gsub(/\W/, '')}" unless ignore_methods? + end + + def expected_path(constant) + File.join( + constant.const_name.split('::').map do |name| + custom_transform.fetch(name) { camel_to_snake_case(name) } + end + ) + end + + def camel_to_snake_case(string) + string + .gsub(/([^A-Z])([A-Z]+)/, '\1_\2') + .gsub(/([A-Z])([A-Z][^A-Z\d]+)/, '\1_\2') + .downcase + end + + def custom_transform + cop_config.fetch('CustomTransform', {}) + end + + def ignore_methods? + cop_config['IgnoreMethods'] + end + + def filename_ends_with?(glob) + File.fnmatch?("*#{glob}", processed_source.buffer.name) + end + + def relevant_rubocop_rspec_file?(_file) + true + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/focus.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/focus.rb new file mode 100644 index 0000000000..0322aae8d2 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/focus.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks if examples are focused. + # + # @example + # # bad + # describe MyClass, focus: true do + # end + # + # describe MyClass, :focus do + # end + # + # fdescribe MyClass do + # end + # + # # good + # describe MyClass do + # end + class Focus < Cop + MSG = 'Focused spec found.'.freeze + + focusable = + ExampleGroups::GROUPS + + ExampleGroups::SKIPPED + + Examples::EXAMPLES + + Examples::SKIPPED + + focused = ExampleGroups::FOCUSED + Examples::FOCUSED + + FOCUSABLE_SELECTORS = focusable.node_pattern_union + + FOCUS_SYMBOL = s(:sym, :focus) + FOCUS_TRUE = s(:pair, FOCUS_SYMBOL, s(:true)) + + def_node_matcher :metadata, <<-PATTERN + {(send nil? #{FOCUSABLE_SELECTORS} ... (hash $...)) + (send nil? #{FOCUSABLE_SELECTORS} $...)} + PATTERN + + def_node_matcher :focused_block?, focused.send_pattern + + def on_send(node) + focus_metadata(node) do |focus| + add_offense(focus, location: :expression) + end + end + + private + + def focus_metadata(node, &block) + yield(node) if focused_block?(node) + + metadata(node) do |matches| + matches.grep(FOCUS_SYMBOL, &block) + matches.grep(FOCUS_TRUE, &block) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hook_argument.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hook_argument.rb new file mode 100644 index 0000000000..2f83353c15 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hook_argument.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks the arguments passed to `before`, `around`, and `after`. + # + # This cop checks for consistent style when specifying RSpec + # hooks which run for each example. There are three supported + # styles: "implicit", "each", and "example." All styles have + # the same behavior. + # + # @example when configuration is `EnforcedStyle: implicit` + # # bad + # before(:each) do + # # ... + # end + # + # # bad + # before(:example) do + # # ... + # end + # + # # good + # before do + # # ... + # end + # + # @example when configuration is `EnforcedStyle: each` + # # bad + # before(:example) do + # # ... + # end + # + # # good + # before do + # # ... + # end + # + # # good + # before(:each) do + # # ... + # end + # + # @example when configuration is `EnforcedStyle: example` + # # bad + # before(:each) do + # # ... + # end + # + # # bad + # before do + # # ... + # end + # + # # good + # before(:example) do + # # ... + # end + class HookArgument < Cop + include ConfigurableEnforcedStyle + include RangeHelp + + IMPLICIT_MSG = 'Omit the default `%p` ' \ + 'argument for RSpec hooks.'.freeze + EXPLICIT_MSG = 'Use `%p` for RSpec hooks.'.freeze + + HOOKS = Hooks::ALL.node_pattern_union.freeze + + def_node_matcher :scoped_hook, <<-PATTERN + (block $(send _ #{HOOKS} (sym ${:each :example})) ...) + PATTERN + + def_node_matcher :unscoped_hook, "(block $(send _ #{HOOKS}) ...)" + + def on_block(node) + hook(node) do |method_send, scope_name| + return correct_style_detected if scope_name.equal?(style) + return check_implicit(method_send) unless scope_name + + style_detected(scope_name) + add_offense( + method_send, + location: :expression, + message: explicit_message(scope_name) + ) + end + end + + def autocorrect(node) + scope = implicit_style? ? '' : "(#{style.inspect})" + + lambda do |corrector| + corrector.replace(argument_range(node), scope) + end + end + + private + + def check_implicit(method_send) + style_detected(:implicit) + return if implicit_style? + + add_offense( + method_send, + location: :selector, + message: format(EXPLICIT_MSG, scope: style) + ) + end + + def explicit_message(scope) + if implicit_style? + format(IMPLICIT_MSG, scope: scope) + else + format(EXPLICIT_MSG, scope: style) + end + end + + def implicit_style? + style.equal?(:implicit) + end + + def hook(node, &block) + scoped_hook(node, &block) || unscoped_hook(node, &block) + end + + def argument_range(send_node) + range_between( + send_node.loc.selector.end_pos, + send_node.loc.expression.end_pos + ) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hooks_before_examples.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hooks_before_examples.rb new file mode 100644 index 0000000000..d81f6860a3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/hooks_before_examples.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for before/around/after hooks that come after an example. + # + # @example + # # Bad + # + # it 'checks what foo does' do + # expect(foo).to be + # end + # + # before { prepare } + # after { clean_up } + # + # # Good + # before { prepare } + # after { clean_up } + # + # it 'checks what foo does' do + # expect(foo).to be + # end + # + class HooksBeforeExamples < Cop + include RangeHelp + include RuboCop::RSpec::FinalEndLocation + + MSG = 'Move `%s` above the examples in the group.'.freeze + + def_node_matcher :example_or_group?, <<-PATTERN + { + #{(Examples::ALL + ExampleGroups::ALL).block_pattern} + #{Includes::EXAMPLES.send_pattern} + } + PATTERN + + def on_block(node) + return unless example_group_with_body?(node) + + check_hooks(node.body) if multiline_block?(node.body) + end + + def autocorrect(node) + lambda do |corrector| + first_example = find_first_example(node.parent) + first_example_pos = first_example.loc.expression + indent = "\n" + ' ' * first_example.loc.column + + corrector.insert_before(first_example_pos, source(node) + indent) + corrector.remove(node_range_with_surrounding_space(node)) + end + end + + private + + def multiline_block?(block) + block.begin_type? + end + + def check_hooks(node) + first_example = find_first_example(node) + return unless first_example + + node.each_child_node do |child| + next if child.sibling_index < first_example.sibling_index + next unless hook?(child) + + add_offense( + child, + message: format(MSG, hook: child.method_name) + ) + end + end + + def find_first_example(node) + node.children.find { |sibling| example_or_group?(sibling) } + end + + def node_range_with_surrounding_space(node) + range = node_range(node) + range_by_whole_lines(range, include_final_newline: true) + end + + def source(node) + node_range(node).source + end + + def node_range(node) + range_between( + node.loc.expression.begin_pos, + final_end_location(node).end_pos + ) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_expect.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_expect.rb new file mode 100644 index 0000000000..eb3272588b --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_expect.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Check that a consistent implicit expectation style is used. + # + # This cop can be configured using the `EnforcedStyle` option + # and supports the `--auto-gen-config` flag. + # + # @example `EnforcedStyle: is_expected` + # + # # bad + # it { should be_truthy } + # + # # good + # it { is_expected.to be_truthy } + # + # @example `EnforcedStyle: should` + # + # # bad + # it { is_expected.to be_truthy } + # + # # good + # it { should be_truthy } + # + class ImplicitExpect < Cop + include ConfigurableEnforcedStyle + + MSG = 'Prefer `%s` over `%s`.'.freeze + + def_node_matcher :implicit_expect, <<-PATTERN + { + (send nil? ${:should :should_not} ...) + (send (send nil? $:is_expected) {:to :to_not :not_to} ...) + } + PATTERN + + alternatives = { + 'is_expected.to' => 'should', + 'is_expected.not_to' => 'should_not', + 'is_expected.to_not' => 'should_not' + } + + ENFORCED_REPLACEMENTS = alternatives.merge(alternatives.invert).freeze + + def on_send(node) # rubocop:disable Metrics/MethodLength + return unless (source_range = offending_expect(node)) + + expectation_source = source_range.source + + if expectation_source.start_with?(style.to_s) + correct_style_detected + else + opposite_style_detected + + add_offense( + node, + location: source_range, + message: offense_message(expectation_source) + ) + end + end + + def autocorrect(node) + lambda do |corrector| + offense = offending_expect(node) + replacement = replacement_source(offense.source) + + corrector.replace(offense, replacement) + end + end + + private + + def offending_expect(node) + case implicit_expect(node) + when :is_expected + is_expected_range(node.loc) + when :should, :should_not + node.loc.selector + end + end + + def is_expected_range(source_map) # rubocop:disable PredicateName + Parser::Source::Range.new( + source_map.expression.source_buffer, + source_map.expression.begin_pos, + source_map.selector.end_pos + ) + end + + def offense_message(offending_source) + format( + MSG, + good: replacement_source(offending_source), + bad: offending_source + ) + end + + def replacement_source(offending_source) + ENFORCED_REPLACEMENTS.fetch(offending_source) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_subject.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_subject.rb new file mode 100644 index 0000000000..85877475f4 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/implicit_subject.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for usage of implicit subject (`is_expected` / `should`). + # + # This cop can be configured using the `EnforcedStyle` option + # + # @example `EnforcedStyle: single_line_only` + # # bad + # it do + # is_expected.to be_truthy + # end + # + # # good + # it { is_expected.to be_truthy } + # it do + # expect(subject).to be_truthy + # end + # + # @example `EnforcedStyle: disallow` + # # bad + # it { is_expected.to be_truthy } + # + # # good + # it { expect(subject).to be_truthy } + # + class ImplicitSubject < Cop + include ConfigurableEnforcedStyle + + MSG = "Don't use implicit subject.".freeze + + def_node_matcher :implicit_subject?, <<-PATTERN + (send nil? {:should :should_not :is_expected} ...) + PATTERN + + def on_send(node) + return unless implicit_subject?(node) + return if valid_usage?(node) + + add_offense(node) + end + + def autocorrect(node) + replacement = 'expect(subject)' + if node.method_name == :should + replacement += '.to' + elsif node.method_name == :should_not + replacement += '.not_to' + end + + ->(corrector) { corrector.replace(node.loc.selector, replacement) } + end + + private + + def valid_usage?(node) + example = node.ancestors.find { |parent| example?(parent) } + return false if example.nil? + + example.method_name == :its || allowed_by_style?(example) + end + + def allowed_by_style?(example) + if style == :single_line_only + example.single_line? + elsif style == :single_statement_only + !example.body.begin_type? + else + false + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_spy.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_spy.rb new file mode 100644 index 0000000000..9f40ac7173 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_spy.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for `instance_double` used with `have_received`. + # + # @example + # # bad + # it do + # foo = instance_double(Foo).as_null_object + # expect(foo).to have_received(:bar) + # end + # + # # good + # it do + # foo = instance_spy(Foo) + # expect(foo).to have_received(:bar) + # end + # + class InstanceSpy < Cop + MSG = 'Use `instance_spy` when you check your double '\ + 'with `have_received`.'.freeze + + def_node_search :null_double, <<-PATTERN + (lvasgn $_ + (send + $(send nil? :instance_double + ...) :as_null_object)) + PATTERN + + def_node_search :have_received_usage, <<-PATTERN + (send + (send nil? :expect + (lvar $_)) :to + (send nil? :have_received + ...) + ...) + PATTERN + + def on_block(node) + return unless example?(node) + + null_double(node) do |var, receiver| + have_received_usage(node) do |expected| + add_offense(receiver, location: :expression) if expected == var + end + end + end + + def autocorrect(node) + lambda do |corrector| + replacement = 'instance_spy' + corrector.replace(node.loc.selector, replacement) + + double_source_map = node.parent.loc + as_null_object_range = double_source_map + .dot + .join(double_source_map.selector) + corrector.remove(as_null_object_range) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_variable.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_variable.rb new file mode 100644 index 0000000000..fab437d9d7 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/instance_variable.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for instance variable usage in specs. + # + # This cop can be configured with the option `AssignmentOnly` which + # will configure the cop to only register offenses on instance + # variable usage if the instance variable is also assigned within + # the spec + # + # @example + # # bad + # describe MyClass do + # before { @foo = [] } + # it { expect(@foo).to be_empty } + # end + # + # # good + # describe MyClass do + # let(:foo) { [] } + # it { expect(foo).to be_empty } + # end + # + # @example with AssignmentOnly configuration + # + # # rubocop.yml + # # RSpec/InstanceVariable: + # # AssignmentOnly: false + # + # # bad + # describe MyClass do + # before { @foo = [] } + # it { expect(@foo).to be_empty } + # end + # + # # allowed + # describe MyClass do + # it { expect(@foo).to be_empty } + # end + # + # # good + # describe MyClass do + # let(:foo) { [] } + # it { expect(foo).to be_empty } + # end + # + class InstanceVariable < Cop + MSG = 'Replace instance variable with local variable or `let`.'.freeze + + EXAMPLE_GROUP_METHODS = ExampleGroups::ALL + SharedGroups::ALL + + def_node_matcher :spec_group?, EXAMPLE_GROUP_METHODS.block_pattern + + def_node_matcher :dynamic_class?, <<-PATTERN + (block (send (const nil? :Class) :new ...) ...) + PATTERN + + def_node_search :ivar_usage, '$(ivar $_)' + + def_node_search :ivar_assigned?, '(ivasgn % ...)' + + def on_block(node) + return unless spec_group?(node) + + ivar_usage(node) do |ivar, name| + return if inside_dynamic_class?(ivar) + return if assignment_only? && !ivar_assigned?(node, name) + + add_offense(ivar, location: :expression) + end + end + + private + + def inside_dynamic_class?(node) + node.each_ancestor(:block).any? { |block| dynamic_class?(block) } + end + + def assignment_only? + cop_config['AssignmentOnly'] + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb new file mode 100644 index 0000000000..828588171f --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb @@ -0,0 +1,42 @@ +module RuboCop + module Cop + module RSpec + # Checks invalid usage for predicate matcher. + # + # Predicate matcher does not need a question. + # This cop checks an unnecessary question in predicate matcher. + # + # @example + # + # # bad + # expect(foo).to be_something? + # + # # good + # expect(foo).to be_something + class InvalidPredicateMatcher < Cop + MSG = 'Omit `?` from `%s`.'.freeze + + def_node_matcher :invalid_predicate_matcher?, <<-PATTERN + (send (send nil? :expect ...) {:to :not_to :to_not} $(send nil? #predicate?)) + PATTERN + + def on_send(node) + invalid_predicate_matcher?(node) do |predicate| + add_offense(predicate, location: :expression) + end + end + + private + + def predicate?(name) + name = name.to_s + name.start_with?('be_', 'have_') && name.end_with?('?') + end + + def message(predicate) + format(MSG, matcher: predicate.method_name) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/it_behaves_like.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/it_behaves_like.rb new file mode 100644 index 0000000000..b7ede3c09c --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/it_behaves_like.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks that only one `it_behaves_like` style is used. + # + # @example when configuration is `EnforcedStyle: it_behaves_like` + # # bad + # it_should_behave_like 'a foo' + # + # # good + # it_behaves_like 'a foo' + # + # @example when configuration is `EnforcedStyle: it_should_behave_like` + # # bad + # it_behaves_like 'a foo' + # + # # good + # it_should_behave_like 'a foo' + class ItBehavesLike < Cop + include ConfigurableEnforcedStyle + + MSG = 'Prefer `%s` over `%s` when including '\ + 'examples in a nested context.'.freeze + + def_node_matcher :example_inclusion_offense, '(send _ % ...)' + + def on_send(node) + example_inclusion_offense(node, alternative_style) do + add_offense(node, location: :expression) + end + end + + def autocorrect(node) + ->(corrector) { corrector.replace(node.loc.selector, style.to_s) } + end + + private + + def message(_node) + format(MSG, replacement: style, original: alternative_style) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/iterated_expectation.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/iterated_expectation.rb new file mode 100644 index 0000000000..3fa5f6b4c6 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/iterated_expectation.rb @@ -0,0 +1,52 @@ +module RuboCop + module Cop + module RSpec + # Check that `all` matcher is used instead of iterating over an array. + # + # @example + # # bad + # it 'validates users' do + # [user1, user2, user3].each { |user| expect(user).to be_valid } + # end + # + # # good + # it 'validates users' do + # expect([user1, user2, user3]).to all(be_valid) + # end + class IteratedExpectation < Cop + MSG = 'Prefer using the `all` matcher instead ' \ + 'of iterating over an array.'.freeze + + def_node_matcher :each?, <<-PATTERN + (block + (send ... :each) + (args (arg $_)) + $(...) + ) + PATTERN + + def_node_matcher :expectation?, <<-PATTERN + (send (send nil? :expect (lvar %)) :to ...) + PATTERN + + def on_block(node) + each?(node) do |arg, body| + if single_expectation?(body, arg) || only_expectations?(body, arg) + add_offense(node.send_node, location: :expression) + end + end + end + + private + + def single_expectation?(body, arg) + expectation?(body, arg) + end + + def only_expectations?(body, arg) + body.each_child_node.all? { |child| expectation?(child, arg) } + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/leading_subject.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/leading_subject.rb new file mode 100644 index 0000000000..bc21c2929d --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/leading_subject.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Enforce that subject is the first definition in the test. + # + # @example + # # bad + # let(:params) { blah } + # subject { described_class.new(params) } + # + # before { do_something } + # subject { described_class.new(params) } + # + # it { expect_something } + # subject { described_class.new(params) } + # it { expect_something_else } + # + # + # # good + # subject { described_class.new(params) } + # let(:params) { blah } + # + # # good + # subject { described_class.new(params) } + # before { do_something } + # + # # good + # subject { described_class.new(params) } + # it { expect_something } + # it { expect_something_else } + # + class LeadingSubject < Cop + include RangeHelp + + MSG = 'Declare `subject` above any other `%s` ' \ + 'declarations.'.freeze + + def on_block(node) + return unless subject?(node) && !in_spec_block?(node) + + check_previous_nodes(node) + end + + def check_previous_nodes(node) + node.parent.each_child_node do |sibling| + if offending?(sibling) + add_offense( + node, + location: :expression, + message: format(MSG, offending: sibling.method_name) + ) + end + + break if offending?(sibling) || sibling.equal?(node) + end + end + + def autocorrect(node) + lambda do |corrector| + first_node = find_first_offending_node(node) + first_node_position = first_node.loc.expression + indent = "\n" + ' ' * first_node.loc.column + corrector.insert_before(first_node_position, node.source + indent) + corrector.remove(node_range(node)) + end + end + + private + + def offending?(node) + let?(node) || hook?(node) || example?(node) + end + + def find_first_offending_node(node) + node.parent.children.find { |sibling| offending?(sibling) } + end + + def node_range(node) + range_by_whole_lines(node.source_range, include_final_newline: true) + end + + def in_spec_block?(node) + node.each_ancestor(:block).any? do |ancestor| + example?(ancestor) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_before_examples.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_before_examples.rb new file mode 100644 index 0000000000..f8d9f533e3 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_before_examples.rb @@ -0,0 +1,102 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for `let` definitions that come after an example. + # + # @example + # # Bad + # let(:foo) { bar } + # + # it 'checks what foo does' do + # expect(foo).to be + # end + # + # let(:some) { other } + # + # it 'checks what some does' do + # expect(some).to be + # end + # + # # Good + # let(:foo) { bar } + # let(:some) { other } + # + # it 'checks what foo does' do + # expect(foo).to be + # end + # + # it 'checks what some does' do + # expect(some).to be + # end + class LetBeforeExamples < Cop + include RangeHelp + include RuboCop::RSpec::FinalEndLocation + + MSG = 'Move `let` before the examples in the group.'.freeze + + def_node_matcher :example_or_group?, <<-PATTERN + { + #{(Examples::ALL + ExampleGroups::ALL).block_pattern} + #{Includes::EXAMPLES.send_pattern} + } + PATTERN + + def on_block(node) + return unless example_group_with_body?(node) + + check_let_declarations(node.body) if multiline_block?(node.body) + end + + def autocorrect(node) + lambda do |corrector| + first_example = find_first_example(node.parent) + first_example_pos = first_example.loc.expression + indent = "\n" + ' ' * first_example.loc.column + + corrector.insert_before(first_example_pos, source(node) + indent) + corrector.remove(node_range_with_surrounding_space(node)) + end + end + + private + + def multiline_block?(block) + block.begin_type? + end + + def check_let_declarations(node) + first_example = find_first_example(node) + return unless first_example + + node.each_child_node do |child| + next if child.sibling_index < first_example.sibling_index + + add_offense(child, location: :expression) if let?(child) + end + end + + def find_first_example(node) + node.children.find { |sibling| example_or_group?(sibling) } + end + + def node_range_with_surrounding_space(node) + range = node_range(node) + range_by_whole_lines(range, include_final_newline: true) + end + + def source(node) + node_range(node).source + end + + def node_range(node) + range_between( + node.loc.expression.begin_pos, + final_end_location(node).end_pos + ) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_setup.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_setup.rb new file mode 100644 index 0000000000..f271f3d0d6 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/let_setup.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks unreferenced `let!` calls being used for test setup. + # + # @example + # # Bad + # let!(:my_widget) { create(:widget) } + # + # it 'counts widgets' do + # expect(Widget.count).to eq(1) + # end + # + # # Good + # it 'counts widgets' do + # create(:widget) + # expect(Widget.count).to eq(1) + # end + # + # # Good + # before { create(:widget) } + # + # it 'counts widgets' do + # expect(Widget.count).to eq(1) + # end + class LetSetup < Cop + include RuboCop::RSpec::TopLevelDescribe + + MSG = 'Do not use `let!` for test setup.'.freeze + + def_node_search :let_bang, <<-PATTERN + (block $(send nil? :let! (sym $_)) args ...) + PATTERN + + def_node_search :method_called?, '(send nil? %)' + + def on_block(node) + return unless example_group?(node) + + unused_let_bang(node) do |let| + add_offense(let, location: :expression) + end + end + + private + + def unused_let_bang(node) + let_bang(node) do |method_send, method_name| + yield(method_send) unless method_called?(node, method_name) + end + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_chain.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_chain.rb new file mode 100644 index 0000000000..88b4b221b5 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_chain.rb @@ -0,0 +1,31 @@ +module RuboCop + module Cop + module RSpec + # Check that chains of messages are not being stubbed. + # + # @example + # # bad + # allow(foo).to receive_message_chain(:bar, :baz).and_return(42) + # + # # better + # thing = Thing.new(baz: 42) + # allow(foo).to receive(bar: thing) + # + class MessageChain < Cop + MSG = 'Avoid stubbing using `%s`.'.freeze + + def_node_matcher :message_chain, <<-PATTERN + (send _ {:receive_message_chain :stub_chain} ...) + PATTERN + + def on_send(node) + message_chain(node) { add_offense(node, location: :selector) } + end + + def message(node) + format(MSG, method: node.method_name) + end + end + end + end +end diff --git a/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_expectation.rb b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_expectation.rb new file mode 100644 index 0000000000..cd1972dcd5 --- /dev/null +++ b/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/rubocop-rspec-1.30.0/lib/rubocop/cop/rspec/message_expectation.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module RSpec + # Checks for consistent message expectation style. + # + # This cop can be configured in your configuration using the + # `EnforcedStyle` option and supports `--auto-gen-config`. + # + # @example `EnforcedStyle: allow` + # + # # bad + # expect(foo).to receive(:bar) + # + # # good + # allow(foo).to receive(:bar) + # + # @example `EnforcedStyle: expect` + # + # # bad + # allow(foo).to receive(:bar) + # + # # good + # expect(foo).to receive(:bar) + # + class MessageExpectation < Cop + include ConfigurableEnforcedStyle + + MSG = 'Prefer `%