Skip to content

Commit

Permalink
Convert MiniTest tests to Rspec (#10)
Browse files Browse the repository at this point in the history
* Converted tests to Rspec

* Updated CircleCI config

* Updated CircleCI config

* Locked style guide gem
  • Loading branch information
schinery authored Sep 25, 2020
1 parent d0b5231 commit bf193b8
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 111 deletions.
7 changes: 5 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
parallelism: 1
docker:
- image: circleci/ruby:2.7.0
- image: circleci/ruby:2.7.1
environment:
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3
Expand All @@ -29,8 +29,11 @@ jobs:
key: logga-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Run rubocop
command: bundle exec rubocop
- run:
name: Run tests
command: bundle exec rake | circleci tests split --split-by=timings
command: bundle exec rake test
- store_test_results:
path: test_results
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--require spec_helper
--format=progress
--format=Nc
13 changes: 13 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
inherit_gem:
boxt_ruby_style_guide:
- default.yml
- pending.yml
- rspec.yml

require:
- rubocop-rspec

inherit_mode:
merge:
- Exclude
- TargetRubyVersion

AllCops:
TargetRubyVersion: 2.5 # Although all Boxt apps are using 2.7, this gem is public so setting to a lower version
105 changes: 54 additions & 51 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,96 +8,99 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activemodel (6.0.3.1)
activesupport (= 6.0.3.1)
activerecord (6.0.3.1)
activemodel (= 6.0.3.1)
activesupport (= 6.0.3.1)
activesupport (6.0.3.1)
activemodel (6.0.3.3)
activesupport (= 6.0.3.3)
activerecord (6.0.3.3)
activemodel (= 6.0.3.3)
activesupport (= 6.0.3.3)
activesupport (6.0.3.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
ansi (1.5.0)
ast (2.4.1)
boxt_ruby_style_guide (5.0.0)
rubocop (~> 0.83)
rubocop-faker (~> 1.0)
builder (3.2.4)
boxt_ruby_style_guide (7.2.0)
rubocop (= 0.91.1)
rubocop-faker (= 1.1.0)
rubocop-rails (= 2.8.1)
rubocop-rspec (= 1.43.2)
byebug (11.1.3)
concurrent-ruby (1.1.6)
concurrent-ruby (1.1.7)
diff-lcs (1.4.4)
docile (1.3.2)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
faker (2.12.0)
faker (2.14.0)
i18n (>= 1.6, < 2)
i18n (1.8.3)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
minitest (5.14.1)
minitest-bang (1.0.4)
minitest (>= 4.7.5)
minitest-fail-fast (0.1.0)
minitest (~> 5)
minitest-macos-notification (0.3.3)
minitest (~> 5.14)
minitest-reporters (~> 1.4)
os (~> 1.0)
terminal-notifier (~> 2.0)
minitest-reporters (1.4.2)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
os (1.1.0)
parallel (1.19.1)
parser (2.7.1.3)
ast (~> 2.4.0)
minitest (5.14.2)
parallel (1.19.2)
parser (2.7.1.5)
ast (~> 2.4.1)
rack (2.2.3)
rainbow (3.0.0)
rake (13.0.1)
regexp_parser (1.7.1)
regexp_parser (1.8.0)
rexml (3.2.4)
rubocop (0.85.1)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-nc (0.3.0)
rspec (>= 3)
terminal-notifier (>= 1.4)
rspec-support (3.9.3)
rubocop (0.91.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.0.3)
rubocop-ast (>= 0.4.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.0.3)
parser (>= 2.7.0.1)
rubocop-ast (0.5.0)
parser (>= 2.7.1.5)
rubocop-faker (1.1.0)
faker (>= 2.12.0)
rubocop (>= 0.82.0)
rubocop-rails (2.8.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.87.0)
rubocop-rspec (1.43.2)
rubocop (~> 0.87)
ruby-progressbar (1.10.1)
simplecov (0.18.5)
simplecov (0.19.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
simplecov-html (0.12.3)
terminal-notifier (2.0.0)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
zeitwerk (2.3.0)
zeitwerk (2.4.0)

PLATFORMS
ruby

DEPENDENCIES
boxt_ruby_style_guide (~> 5.0)
boxt_ruby_style_guide (= 7.2.0)
bundler (~> 2.1)
byebug (~> 11.0)
factory_bot (~> 4.8)
logga!
minitest (~> 5.13)
minitest-bang (~> 1.0)
minitest-fail-fast (~> 0.1)
minitest-macos-notification (~> 0.3)
minitest-reporters (~> 1.4)
rake (~> 13.0)
rspec (~> 3.9)
rspec-nc (~> 0.3)
simplecov (~> 0.17)

BUNDLED WITH
Expand Down
9 changes: 4 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

require "bundler/gem_tasks"
require "rake/testtask"
require "rspec/core/rake_task"

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = Dir.glob("spec/**/*_spec.rb")
end

task default: :test
task test: :spec
12 changes: 5 additions & 7 deletions logga.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "logga/version"

Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 2.5"
spec.name = "logga"
spec.version = Logga::VERSION
spec.authors = ["Boxt"]
Expand All @@ -26,15 +27,12 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency "activerecord", ">= 5.2", "~> 6.0"
spec.add_runtime_dependency "activesupport", ">= 5.2", "~> 6.0"
spec.add_development_dependency "boxt_ruby_style_guide", "~> 5.0"
# Lock style guide to specific version incase a new version is published with new breaking cops
spec.add_development_dependency "boxt_ruby_style_guide", "7.2.0"
spec.add_development_dependency "bundler", "~> 2.1"
spec.add_development_dependency "byebug", "~> 11.0"
spec.add_development_dependency "factory_bot", "~> 4.8"
spec.add_development_dependency "minitest", "~> 5.13"
spec.add_development_dependency "minitest-bang", "~> 1.0"
spec.add_development_dependency "minitest-fail-fast", "~> 0.1"
spec.add_development_dependency "minitest-macos-notification", "~> 0.3"
spec.add_development_dependency "minitest-reporters", "~> 1.4"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.9"
spec.add_development_dependency "rspec-nc", "~> 0.3"
spec.add_development_dependency "simplecov", "~> 0.17"
end
13 changes: 13 additions & 0 deletions spec/logga_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "spec_helper"

describe Logga do
describe "VERSION" do
let(:current_version) { File.read("VERSION").split("\n").first }

it "is set from the VERSION file" do
expect(::Logga::VERSION).to eq(current_version)
end
end
end
105 changes: 105 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# frozen_string_literal: true

require "simplecov"

SimpleCov.start do
minimum_coverage 44.44 # Tis what it is, should try and bump this up!
end

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "logga"

# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
# a separate helper file that requires the additional dependencies and performs
# the additional setup, and require it from the spec files that actually need
# it.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end

# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
# have no way to turn it off -- the option exists only for backwards
# compatibility in RSpec 3). It causes shared context metadata to be
# inherited by the metadata hash of host groups and examples, rather than
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
# # This allows you to limit a spec run to individual examples or groups
# # you care about by tagging them with `:focus` metadata. When nothing
# # is tagged with `:focus`, all examples get run. RSpec also provides
# # aliases for `it`, `describe`, and `context` that include `:focus`
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
# config.filter_run_when_matching :focus
#
# # Allows RSpec to persist some state between runs in order to support
# # the `--only-failures` and `--next-failure` CLI options. We recommend
# # you configure your source control system to ignore this file.
# config.example_status_persistence_file_path = "spec/examples.txt"
#
# # Limits the available syntax to the non-monkey patched syntax that is
# # recommended. For more details, see:
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
# config.disable_monkey_patching!
#
# # Many RSpec users commonly either run the entire suite or an individual
# # file, and it's useful to allow more verbose output when running an
# # individual spec file.
# if config.files_to_run.one?
# # Use the documentation formatter for detailed output,
# # unless a formatter has already been configured
# # (e.g. via a command-line flag).
# config.default_formatter = "doc"
# end
#
# # Print the 10 slowest examples and example groups at the
# # end of the spec run, to help surface which specs are running
# # particularly slow.
# config.profile_examples = 10
#
# # Run specs in random order to surface order dependencies. If you find an
# # order dependency and want to debug it, you can fix the order by providing
# # the seed, which is printed after each run.
# # --seed 1234
# config.order = :random
#
# # Seed global randomization in this process using the `--seed` CLI option.
# # Setting this allows you to use `--seed` to deterministically reproduce
# # test failures related to randomization by passing the same `--seed` value
# # as the one that triggered the failure.
# Kernel.srand config.seed
end
15 changes: 0 additions & 15 deletions test/logga_test.rb

This file was deleted.

Loading

0 comments on commit bf193b8

Please sign in to comment.