Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
require:
- rubocop-rspec

inherit_mode:
merge:
- Exclude
inherit_gem:
rubocop-mhenrixon:
- config/default.yml

AllCops:
TargetRubyVersion: 2.5
Include:
- "Rakefile"
- "lib/**/*"
- "bin/**/*"
- "spec/**/*"
- ".simplecov"
Exclude:
- "lib/stub_requests/core_ext/**/*"
- "Gemfile.lock"
- "bin/setup"
- "gemfiles/**/*"

Layout/IndentArray:
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Metrics/AbcSize:
Max: 38

Metrics/CyclomaticComplexity:
Max: 7

Metrics/LineLength:
Max: 120

Metrics/MethodLength:
Max: 13

Metrics/BlockLength:
Exclude:
- '**/spec/**/*.rb'
Expand All @@ -46,14 +28,11 @@ Naming/FileName:
Exclude:
- '**/Gemfile'

Naming/UncommunicativeMethodParamName:
Naming/MethodParameterName:
AllowedNames:
- ex
- id

AlignLeftLetBrace:
Enabled: true

RSpec/ContextWording:
Prefixes:
- when
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.5.3
ruby-2.6.5
7 changes: 4 additions & 3 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

require "simplecov-json"
require "simplecov-oj"
require "simplecov-material"

SimpleCov.formatters =
SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter,
SimpleCov::Formatter::MaterialFormatter,
SimpleCov::Formatter::OjFormatter,
])

SimpleCov.configure do
Expand Down
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ source "https://rubygems.org"
# Specify your gem's dependencies in stub_requests.gemspec
gemspec

gem "rb-readline"
platform :mri do
gem "redcarpet"
gem "rb-readline"
gem "rubocop-mhenrixon", path: '../rubocop-mhenrixon'
end
66 changes: 52 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,68 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "reek/rake/task"
require "rspec/core/rake_task"
require "rubocop/rake_task"

Dir.glob("#{File.expand_path(__dir__)}/lib/tasks/**/*.rake").each { |f| import f }

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
Reek::Rake::Task.new(:reek) do |t|
t.name = "reek"
t.config_file = ".reek.yml"
t.source_files = "."
t.reek_opts = %w[
--line-numbers
--color
--documentation
--progress
--single-line
--sort-by smelliness
].join(" ")
t.fail_on_error = true
t.verbose = true
end

def changed_files(pedantry)
`git diff-tree --no-commit-id --name-only -r HEAD~#{pedantry} HEAD`
.split("\n").select { |f| f.match(/(\.rb\z)|Rakefile/) && File.exist?(f) && !f.match(/db/) }
end

RuboCop::RakeTask.new(:rubocop) do |task|
# task.patterns = changed_files(5)
task.options = %w[-DEP --require fuubar --format fuubar]
end

desc "Runs validation of ruby styles"
task style: [:reek, :rubocop]

RSpec::Core::RakeTask.new(:rspec) do |t|
t.rspec_opts = "--require fuubar --format Fuubar --format Nc"
end

require "yard"
YARD::Rake::YardocTask.new do |t|
t.files = %w[lib/stub_requests/**/*.rb"]
YARD::Rake::YardocTask.new(:yard) do |t|
t.files = %w[lib/stub_requests/**/*.rb]
t.options = %w[
--no-private
--embed-mixins
--markup=markdown
--markup-provider=redcarpet
--readme README.md
--files CHANGELOG.md
]
t.stats_options = %w[
--no-private
--compact
--list-undoc
]
end

task default: :spec

namespace :stub_requests do
task :release do
sh("./update_docs.sh")
sh("gem release --tag --push")
Rake::Task["changelog"].invoke
sh("gem bump")
end
desc "Releases a new gem, updates changelog and documentation"
task :release do
sh("./update_docs.sh")
sh("gem release --tag --push")
Rake::Task["changelog"].invoke
sh("gem bump --file lib/stub_requests/version.rb")
end

task default: [:style, :rspec, :yard]
4 changes: 2 additions & 2 deletions lib/rspec/subject_as_lambda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module SubjectAsLambda
# its(:age) { should eq(25) }
# end
#
def it!(*options, &block)
def it!(*options, &block) # rubocop:disable Metrics/MethodLength
it_lambda_caller = caller.reject { |file_line| file_line =~ %r{/rspec/subject_as_lambda} }
describe(nil, caller: it_lambda_caller) do
let(:__it_lambda_subject) do
Expand Down Expand Up @@ -134,4 +134,4 @@ def is_expected # rubocop:disable Lint/NestedMethodDefinition, Naming/PredicateN
rspec.backtrace_exclusion_patterns << %r{/lib/rspec/subject_as_lambda}
end

RSpec::SharedContext.send(:include, RSpec::SubjectAsLambda)
RSpec::SharedContext.include RSpec::SubjectAsLambda
12 changes: 6 additions & 6 deletions lib/stub_requests/concerns/register_verb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module RegisterVerb
#
# @return [Endpoint] the registered endpoint
#
def any(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
def any(path, as:) # rubocop:disable Naming/MethodParameterName
register(as, __method__, path)
end

Expand All @@ -38,7 +38,7 @@ def any(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
#
# @return [Endpoint] the registered endpoint
#
def get(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
def get(path, as:) # rubocop:disable Naming/MethodParameterName
register(as, __method__, path)
end

Expand All @@ -54,7 +54,7 @@ def get(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
#
# @return [Endpoint] the registered endpoint
#
def post(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
def post(path, as:) # rubocop:disable Naming/MethodParameterName
register(as, __method__, path)
end

Expand All @@ -70,7 +70,7 @@ def post(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
#
# @return [Endpoint] the registered endpoint
#
def patch(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
def patch(path, as:) # rubocop:disable Naming/MethodParameterName
register(as, __method__, path)
end

Expand All @@ -86,7 +86,7 @@ def patch(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
#
# @return [Endpoint] the registered endpoint
#
def put(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
def put(path, as:) # rubocop:disable Naming/MethodParameterName
register(as, __method__, path)
end

Expand All @@ -102,7 +102,7 @@ def put(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
#
# @return [Endpoint] the registered endpoint
#
def delete(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
def delete(path, as:) # rubocop:disable Naming/MethodParameterName
register(as, __method__, path)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/stub_requests/webmock/stub_registry_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def request_stub_for_ext(request_signature)
end
end

::WebMock::StubRegistry.send(:include, StubRequests::WebMock::StubRegistryExtension)
::WebMock::StubRegistry.include StubRequests::WebMock::StubRegistryExtension
11 changes: 6 additions & 5 deletions lib/tasks/changelog.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ task :changelog do
# rubocop:disable Style/MutableConstant
CHANGELOG_CMD ||= %w[
github_changelog_generator
-u
--no-verbose
--no-http-cache
--user
mhenrixon
-p
--project
stub_requests
--no-verbose
--token
]
ADD_CHANGELOG_CMD ||= "git add --all"
COMMIT_CHANGELOG_CMD ||= "git commit -a -m 'Update changelog'"
ADD_CHANGELOG_CMD ||= "git add --all"
COMMIT_CHANGELOG_CMD ||= "git commit -a -m 'Update changelog'"
# rubocop:enable Style/MutableConstant

sh("git checkout master")
Expand Down
15 changes: 0 additions & 15 deletions lib/tasks/gem.rake

This file was deleted.

40 changes: 0 additions & 40 deletions lib/tasks/git.rake

This file was deleted.

20 changes: 12 additions & 8 deletions spec/rspec/subject_as_lambda_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
require "spec_helper"

RSpec.describe RSpec::SubjectAsLambda do
class NullFormatter
private

def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
# ignore
end
end

let(:stub) { double }
let(:error) { ArgumentError }
let(:message) { "nice message" }

before do
null_formatter_class = Class.new do
private

def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
# ignore
end
end

stub_const("NullFormatter", null_formatter_class)
end

describe "#it!" do
before { allow(stub).to receive(:message).and_raise(error, message) }

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require "rspec/its"
require "rspec/subject_as_lambda"

Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].each { |f| require f }
Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].sort.each { |f| require f }

RSpec.configure do |config|
config.after do
Expand Down
Loading