Skip to content

Commit

Permalink
test cleanup and enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
rubysolo committed Oct 22, 2017
1 parent bc0b4d7 commit 66eb9a2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
5 changes: 0 additions & 5 deletions Gemfile
Expand Up @@ -2,8 +2,3 @@ source "http://rubygems.org"

# Specify your gem's dependencies in dentaku.gemspec
gemspec

if RUBY_VERSION.to_f >= 2.0 && RUBY_ENGINE == 'ruby'
gem 'pry-byebug'
gem 'pry-stack_explorer'
end
5 changes: 4 additions & 1 deletion Rakefile
@@ -1,5 +1,8 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

RuboCop::RakeTask.new

desc "Run specs"
task :spec do
Expand All @@ -10,7 +13,7 @@ task :spec do
end

desc "Default: run specs."
task default: :spec
task(:default).clear.enhance [:spec, :rubocop]

task :console do
begin
Expand Down
8 changes: 6 additions & 2 deletions dentaku.gemspec
Expand Up @@ -16,10 +16,14 @@ Gem::Specification.new do |s|

s.rubyforge_project = "dentaku"

s.add_development_dependency('coveralls')
s.add_development_dependency('pry')
s.add_development_dependency('pry-byebug')
s.add_development_dependency('pry-stack_explorer')
s.add_development_dependency('rake')
s.add_development_dependency('rspec')
s.add_development_dependency('pry')
s.add_development_dependency('coveralls')
s.add_development_dependency('rubocop')
s.add_development_dependency('simplecov')

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
6 changes: 3 additions & 3 deletions lib/dentaku/flat_hash.rb
@@ -1,8 +1,8 @@
module Dentaku
class FlatHash
def self.from_hash(h, key=[], acc={})
return acc.update({ key => h }) unless h.is_a? Hash
h.each { |k, v| from_hash(v, key+[k], acc) }
def self.from_hash(h, key = [], acc = {})
return acc.update(key => h) unless h.is_a? Hash
h.each { |k, v| from_hash(v, key + [k], acc) }
flatten_keys(acc)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/calculator_spec.rb
Expand Up @@ -79,7 +79,7 @@
end

it 'evalutates arrays' do
expect(calculator.evaluate([1,2,3])).to eq([1,2,3])
expect(calculator.evaluate([1, 2, 3])).to eq([1, 2, 3])
end
end

Expand All @@ -99,7 +99,7 @@
end

it "finds no dependencies in array literals" do
expect(calculator.dependencies([1,2,3])).to eq([])
expect(calculator.dependencies([1, 2, 3])).to eq([])
end
end

Expand Down
14 changes: 13 additions & 1 deletion spec/spec_helper.rb
@@ -1,9 +1,21 @@
require 'pry'
require 'simplecov'
require 'coveralls'

# Check the amount of testcoverage
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
])

Coveralls.wear!

SimpleCov.minimum_coverage 90
SimpleCov.minimum_coverage_by_file 80

SimpleCov.start do
add_filter "spec/"
end

# automatically create a token stream from bare values
def token_stream(*args)
args.map do |value|
Expand Down

0 comments on commit 66eb9a2

Please sign in to comment.