-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# This is a combination of 2 commits.
# This is the 1st commit message: # This is the commit message #2: Added rspec tests with code coverage reporting.
- Loading branch information
1 parent
05325d9
commit 18c9211
Showing
10 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,20 @@ jobs: | |
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: RuboCop Linter | ||
uses: andrewmcodes/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
spec: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
# runs 'bundle install' and caches installed gems automatically | ||
bundler-cache: true | ||
- name: Run tests | ||
run: bundle exec rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ vendor | |
# Ignore import and export files. | ||
./*.csv | ||
./*.json | ||
|
||
# Ignore test outputs | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--require spec_helper.rb | ||
--color | ||
--format RSpec::Github::Formatter | ||
--format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
require: | ||
- rubocop-rake | ||
- rubocop-rspec | ||
|
||
AllCops: | ||
NewCops: enable | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rspec/core/rake_task' | ||
require 'rubocop/rake_task' | ||
|
||
task default: [:rubocop] | ||
task default: %i[spec rubocop] | ||
|
||
RuboCop::RakeTask.new do |task| | ||
RuboCop::RakeTask.new(:rubocop) do |task| | ||
task.requires << 'rubocop' | ||
end | ||
|
||
RSpec::Core::RakeTask.new(:spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
if ENV['COVERAGE'] | ||
require 'simplecov' | ||
|
||
SimpleCov.start do | ||
add_filter '/spec/' | ||
|
||
track_files 'lib/**/*.rb' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../lib/config' | ||
|
||
RSpec.describe Config do | ||
describe '#initialize' do | ||
it 'can be initialized without a block' do | ||
expect(described_class.new).to be_a(described_class) | ||
end | ||
|
||
it 'can be initialized with a block' do | ||
expect { |probe| described_class.new(&probe) }.to yield_with_args(described_class) | ||
end | ||
end | ||
|
||
describe '.from_file' do | ||
subject(:from_file) { described_class.from_file(path) } | ||
|
||
let(:path) { File.join(__dir__, '../../config/config.sample.yml') } | ||
|
||
it 'can be loaded from a file' do | ||
expect(from_file).to be_a(described_class) | ||
end | ||
|
||
it 'loads expected options' do | ||
expect(from_file.sources.first[:type]).to eq('CSV') | ||
end | ||
end | ||
end |