Skip to content

Commit

Permalink
Enforce code coverage minimums
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Nov 10, 2014
1 parent b75db89 commit cdec8fc
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Metrics/BlockNesting:

Metrics/LineLength:
AllowURI: true
Max: 90 # TODO: Lower to 80
Max: 93 # TODO: Lower to 80

Metrics/MethodLength:
CountComments: false
Expand Down
2 changes: 1 addition & 1 deletion lib/naught/null_class_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def null_equivalents
@null_equivalents ||= [nil]
end

def generate_class
def generate_class # rubocop:disable AbcSize
respond_to_any_message unless interface_defined?
generation_mod = Module.new
customization_mod = customization_module # get a local binding
Expand Down
31 changes: 9 additions & 22 deletions spec/mimic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,20 @@

describe 'null object mimicking a class' do
class User
def login
'bob'
end
attr_reader :login
end

module Authorizable
def authorized_for?(_)
true
end
def authorized_for?(_); end
end

class LibraryPatron < User
include Authorizable
attr_reader :name

def member?
true
end
def member?; end

def name
'Bob'
end

def notify_of_overdue_books(_)
puts 'Notifying...'
end
def notify_of_overdue_books(_); end
end

subject(:null) { mimic_class.new }
Expand Down Expand Up @@ -82,9 +71,7 @@ def notify_of_overdue_books(_)
describe 'with an instance as example' do
let(:mimic_class) do
milton = LibraryPatron.new
def milton.stapler
'red swingline'
end
def milton.stapler; end
Naught.build do |b|
b.mimic :example => milton
end
Expand All @@ -110,7 +97,7 @@ def milton.stapler
end
end

def self.it_behaves_like_a_black_hole_mimic
shared_examples_for 'a black hole mimic' do
it 'returns self from mimicked methods' do
expect(null.info).to equal(null)
expect(null.error).to equal(null)
Expand All @@ -122,7 +109,7 @@ def self.it_behaves_like_a_black_hole_mimic
end
end

it_behaves_like_a_black_hole_mimic
it_should_behave_like 'a black hole mimic'

describe '(reverse order)' do
let(:mimic_class) do
Expand All @@ -132,7 +119,7 @@ def self.it_behaves_like_a_black_hole_mimic
end
end

it_behaves_like_a_black_hole_mimic
it_should_behave_like 'a black hole mimic'
end

end
8 changes: 1 addition & 7 deletions spec/naught_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

describe 'null object impersonating another type' do
class Point
def x
23
end

def y
42
end
attr_reader :x, :y
end

subject(:null) { impersonation_class.new }
Expand Down
9 changes: 2 additions & 7 deletions spec/predicate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,8 @@
end

class Coffee
def black?
true
end

def origin
'Ethiopia'
end
attr_reader :origin
def black?; end
end

describe '(mimic)' do
Expand Down
14 changes: 8 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
GEM_ROOT = File.expand_path('../../', __FILE__)
$LOAD_PATH.unshift File.join(GEM_ROOT, 'lib')

if ENV['TRAVIS']
require 'coveralls'
Coveralls.wear!
else
require 'simplecov'
SimpleCov.start
require 'simplecov'
require 'coveralls'

SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]

SimpleCov.start do
add_filter '/spec/'
minimum_coverage(97.7)
end

require 'naught'
Expand Down

0 comments on commit cdec8fc

Please sign in to comment.