Skip to content

Commit a8d9c04

Browse files
committed
Gem internals modernized
1 parent 8379482 commit a8d9c04

File tree

8 files changed

+40
-16
lines changed

8 files changed

+40
-16
lines changed

.rspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
---
2+
sudo: false
13
language: ruby
4+
cache: bundler
25

36
env:
47
global:

Rakefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
# frozen_string_literal: true
22

3-
$LOAD_PATH.unshift File.expand_path('lib', File.dirname(__FILE__))
4-
53
require 'bundler/gem_tasks'
64
require 'rspec/core/rake_task'
75

8-
task default: :spec
6+
RSpec::Core::RakeTask.new(:spec)
97

10-
RSpec::Core::RakeTask.new do |task|
11-
task.pattern = 'spec/**/*_spec.rb'
12-
task.verbose = false
13-
end
8+
task default: :spec

bin/console

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'bundler/setup'
5+
require 'http_wrapper'
6+
7+
# You can add fixtures and/or initialization code here to make experimenting
8+
# with your gem easier. You can also use a different console, if you like.
9+
10+
# (If you use this, don't forget to add pry to your Gemfile!)
11+
# require "pry"
12+
# Pry.start
13+
14+
require 'irb'
15+
IRB.start(__FILE__)

http_wrapper.gemspec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

3-
require File.expand_path('lib/http_wrapper/version', __dir__)
3+
lib = File.expand_path('lib', __dir__)
4+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5+
require 'http_wrapper/version'
46

57
Gem::Specification.new do |spec|
68
spec.name = 'http_wrapper'
@@ -12,7 +14,7 @@ Gem::Specification.new do |spec|
1214
spec.homepage = 'http://github.com/svyatov/http_wrapper'
1315
spec.license = 'MIT'
1416

15-
spec.files = Dir['Gemfile', 'LICENSE', 'README.md', 'CHANGELOG.md', 'Rakefile', 'lib/**/*', 'spec/*']
17+
spec.files = Dir['Gemfile', 'LICENSE', 'README.md', 'CHANGELOG.md', 'Rakefile', 'lib/**/*']
1618
spec.test_files = Dir['spec/*']
1719
spec.require_paths = %w[lib]
1820

@@ -23,5 +25,6 @@ Gem::Specification.new do |spec|
2325
spec.add_development_dependency 'rspec', '~> 3.7'
2426
spec.add_development_dependency 'rubocop', '~> 0.63.1'
2527
spec.add_development_dependency 'rubocop-rspec', '~> 1.32'
28+
spec.add_development_dependency 'simplecov', '~> 0.16.1'
2629
spec.add_development_dependency 'webmock', '~> 3.5'
2730
end

lib/http_wrapper/errors.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
class HTTPWrapper
4-
HTTPWrapperError = Class.new StandardError
5-
TooManyRedirectsError = Class.new HTTPWrapperError
6-
UnknownKeyError = Class.new HTTPWrapperError
4+
Error = Class.new StandardError
5+
TooManyRedirectsError = Class.new Error
6+
UnknownKeyError = Class.new Error
77
end

spec/http_wrapper_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
require 'http_wrapper'
66

7-
describe HTTPWrapper do
7+
RSpec.describe HTTPWrapper do
88
subject(:http) { described_class.new }
99

1010
let(:basic_auth_login) { 'balogin' }

spec/spec_helper.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# frozen_string_literal: true
22

3-
require 'rspec'
3+
require 'bundler/setup'
44
require 'webmock/rspec'
55

66
if ENV['TRAVIS'] == 'true'
77
require 'simplecov'
88
SimpleCov.start
99
end
1010

11-
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
12-
1311
module HTTPWrapperSpecHelpers
1412
%i[get post put delete].each do |type|
1513
define_method("stub_#{type}") do |url, params = nil|
@@ -31,4 +29,11 @@ def stub_redirects(url, amount_of_redirects)
3129

3230
RSpec.configure do |config|
3331
config.include HTTPWrapperSpecHelpers
32+
33+
# Disable RSpec exposing methods globally on `Module` and `main`
34+
config.disable_monkey_patching!
35+
36+
config.expect_with :rspec do |c|
37+
c.syntax = :expect
38+
end
3439
end

0 commit comments

Comments
 (0)