Skip to content

Commit

Permalink
Improving coverage Part I: where we are
Browse files Browse the repository at this point in the history
Adding support to Coveralls, Adjusting README

Adjusting Gemfile

Improving gemspec dependencies definition

Adjusting ruby target > 2.5
  • Loading branch information
g3ortega committed Sep 7, 2021
1 parent de3d0c7 commit ca7b80b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sudo: false
language: ruby
cache: bundler
rvm:
- 2.4
- 2.5
- 2.6
- 2.7
Expand Down
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

group :test do
gem 'coveralls', '>= 0.7'
gem 'rspec', '>= 3.10'
gem 'rubocop', '>= 0.79'
gem 'simplecov', '>= 0.18.2'
end

# Specify your gem's dependencies in price_calculator.gemspec
gemspec
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[![Build Status](https://app.travis-ci.com/g3ortega/price_calculator.svg?branch=main)](https://app.travis-ci.com/g3ortega/price_calculator)
[![Build Status](https://app.travis-ci.com/g3ortega/price_calculator.svg?branch=main)][travis]
[![Coverage Status](https://img.shields.io/coveralls/g3ortega/price_calculator.svg)][coveralls]

[travis]: https://app.travis-ci.com/g3ortega/price_calculator
[coveralls]: https://coveralls.io/r/g3ortega/price_calculator

# PriceCalculator

Expand Down
9 changes: 4 additions & 5 deletions price_calculator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'text-table'
spec.add_dependency 'thor'
spec.add_dependency 'dry-types'
spec.add_dependency 'dry-struct'
spec.add_dependency 'text-table', '~> 1.2.4'
spec.add_dependency 'thor', '~> 1.1'
spec.add_dependency 'dry-types', '~> 1.5'
spec.add_dependency 'dry-struct', '~> 1.4'

spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'pry'
end
20 changes: 19 additions & 1 deletion spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@
Some items are not available at this moment: ["nope", "etc"]
ORDERPRICING
end

it 'renders order pricing without discounted items' do
expect(Thor::LineEditor).to receive(:readline)
.with('Please enter all the items purchased separated by a comma: ', {})
.and_return('bread,bread,milk,apple')

@shell.order

expect($stdout.string).to eq <<~ORDERPRICING
+-------+----------+-------+
| Item | Quantity | Price |
+-------+----------+-------+
| Bread | 2 | $4.34 |
| Milk | 1 | $3.97 |
| Apple | 1 | $0.89 |
+-------+----------+-------+
Total price: $9.2
ORDERPRICING
end
end

context 'wrong input' do
Expand Down Expand Up @@ -98,4 +117,3 @@
end
end
end

9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
require 'price_calculator'
require 'bigdecimal'
require 'pry'
require 'simplecov'
require 'coveralls'

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

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

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down

0 comments on commit ca7b80b

Please sign in to comment.