Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose files to support testing Cops using RSpec #3179

Merged
merged 1 commit into from Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@
* [#3173](https://github.com/bbatsov/rubocop/pull/3173): Make `Style/ModuleFunction` configurable with `module_function` and `extend_self` styles. ([@tjwp][])
* [#3105](https://github.com/bbatsov/rubocop/issues/3105): Add new `Style/RequestReferer` cop. ([@giannileggio][])
* [#3200](https://github.com/bbatsov/rubocop/pull/3200): Add autocorrect for `Style/EachForSimpleLoop` cop. ([@tejasbubane][])
* [#3179](https://github.com/bbatsov/rubocop/pull/3179): Expose files to support testings Cops using RSpec. ([@tjwp][])

### Bug fixes

Expand Down
Expand Up @@ -3,6 +3,7 @@

require 'tempfile'

# This module provides methods that make it easier to test Cops.
module CopHelper
extend RSpec::SharedContext

Expand Down Expand Up @@ -64,6 +65,8 @@ def _investigate(cop, processed_source)

module RuboCop
module Cop
# Monkey-patch Cop for tests to provide easy access to messages and
# highlights.
class Cop
def messages
offenses.sort.map(&:message)
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions lib/rubocop/rspec/support.rb
@@ -0,0 +1,9 @@
# encoding: utf-8
# frozen_string_literal: true

# Require this file to load code that supports testing using RSpec.

require 'rubocop/rspec/cop_helper'
require 'rubocop/rspec/host_environment_simulation_helper'
require 'rubocop/rspec/shared_contexts'
require 'rubocop/rspec/shared_examples'
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -12,6 +12,9 @@

require 'webmock/rspec'

# Require supporting files exposed for testing.
require 'rubocop/rspec/support'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
Expand Down