Skip to content

Commit

Permalink
refactor(test): separate awesome_print and amazing_print specs
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed May 12, 2024
1 parent 38bac8f commit cb6805e
Show file tree
Hide file tree
Showing 27 changed files with 103 additions and 25 deletions.
14 changes: 13 additions & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,17 @@ appraise "dry" do
gem "dry-core", "~> 0.8.0"
end

appraise "amazing_print" do
gem "amazing_print", "~> 1.5.0"
end

appraise "awesome_print" do
gem "awesome_print", "~> 1.9.2"
end

##
# NOTE: A combination of all the highest versions of gems. Just for quick hacking in `APPRAISAL=all task console`.
# IMPORTANT: Should not be enforced in CI, since integrity checks between external gems are not the goal of this library (a least for now).
# IMPORTANT: Should not be enforced in CI, since integrity checks between external gems are not the goal of this library (at least for now).
#
appraise "all" do
gem "activemodel", "~> 7.0.0"
Expand Down Expand Up @@ -152,4 +160,8 @@ appraise "all" do
# NOTE: Waits for `should-matchers` full support.
#
# gem "shoulda-matchers", "~> 5.0.0"

gem "amazing_print", "~> 1.5.0"

gem "awesome_print", "~> 1.9.2"
end
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ tasks:
APPRAISAL_PREFIX:
sh: ruby -e 'puts "appraisal" + " " + RUBY_ENGINE + "_" + RUBY_VERSION + "_" + ENV["APPRAISAL"] unless ENV["APPRAISAL"].to_s.empty?'
REQUIRE_SUFFIX:
sh: ruby -e 'puts case ENV["APPRAISAL"] when /rails/ then "--require rails_helper" when /dry/ then "--require dry_helper" else "--require standard_helper" end'
sh: ruby -e 'puts case ENV["APPRAISAL"] when /rails/ then "--require rails_helper" when /dry/ then "--require dry_helper" when /amazing_print/ then "--require amazing_print_helper" when /awesome_print/ then "--require awesome_print_helper" else "--require standard_helper" end'
GIT_STAGED_RSPEC_FILES:
sh: ruby -e 'puts `task git:staged:rspec --silent` if ENV["STAGED"] == "true"'

Expand Down
4 changes: 2 additions & 2 deletions convenient_service.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Gem::Specification.new do |spec|
# Used for pretty printing when debugging Ruby code. `amazing_print` is `awesome_print` successor.
# - https://github.com/amazing-print/amazing_print
#
spec.add_development_dependency "amazing_print"
spec.add_development_dependency "amazing_print", "~> 1.5.0"

##
# Used to run specs with multiple versions of gems.
Expand All @@ -75,7 +75,7 @@ Gem::Specification.new do |spec|
# Used for pretty printing when debugging Ruby code. `awesome_print` is NOT maintained anymore.
# - https://github.com/awesome-print/awesome_print
#
spec.add_development_dependency "awesome_print"
spec.add_development_dependency "awesome_print", "~> 1.9.2"

##
# Used for benchmarking (iteration per second). See `benchmark` directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Factorial
module Services
class Calculate
include ConvenientService::Standard::Config
include ConvenientService::AwesomePrintInspect::Config

attr_reader :number, :timeout_seconds

Expand Down
13 changes: 13 additions & 0 deletions spec/amazing_print_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require_relative "spec_helper"

require_relative "support/convenient_service/amazing_print"

##
# NOTE: Runs only spec with specific tag.
# - https://github.com/rspec/rspec-core/blob/main/Filtering.md#rspecconfigure
#
RSpec.configure do |config|
config.filter_run_including type: :amazing_print
end
13 changes: 13 additions & 0 deletions spec/awesome_print_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require_relative "spec_helper"

require_relative "support/convenient_service/awesome_print"

##
# NOTE: Runs only spec with specific tag.
# - https://github.com/rspec/rspec-core/blob/main/Filtering.md#rspecconfigure
#
RSpec.configure do |config|
config.filter_run_including type: :awesome_print
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
subject { described_class }

it { is_expected.to include_module(ConvenientService::Standard::Config) }
it { is_expected.to include_module(ConvenientService::AwesomePrintInspect::Config) }
end

example_group "class methods" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Configs::AmazingPrintInspect, type: :standard do
RSpec.describe ConvenientService::Service::Configs::AmazingPrintInspect, type: :amazing_print do
example_group "modules" do
include ConvenientService::RSpec::Matchers::IncludeModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/DescribeClass
RSpec.describe "convenient_service/service/configs/awesome_print_inspect/aliases", type: :standard do
RSpec.describe "convenient_service/service/configs/awesome_print_inspect/aliases", type: :awesome_print do
specify { expect(ConvenientService::AwesomePrintInspect::Config).to eq(ConvenientService::Service::Configs::AwesomePrintInspect) }
end
# rubocop:enable RSpec/DescribeClass
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Configs::AwesomePrintInspect, type: :standard do
RSpec.describe ConvenientService::Service::Configs::AwesomePrintInspect, type: :awesome_print do
example_group "modules" do
include ConvenientService::RSpec::Matchers::IncludeModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::HasAmazingPrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::HasAmazingPrintInspect::Concern, type: :amazing_print do
example_group "modules" do
include ConvenientService::RSpec::Matchers::IncludeModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::HasAwesomePrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins::HasAwesomePrintInspect::Concern, type: :awesome_print do
example_group "modules" do
include ConvenientService::RSpec::Matchers::IncludeModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasAmazingPrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasAmazingPrintInspect::Concern, type: :amazing_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasAwesomePrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasAwesomePrintInspect::Concern, type: :awesome_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasAmazingPrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasAmazingPrintInspect::Concern, type: :amazing_print do
example_group "modules" do
include ConvenientService::RSpec::Matchers::IncludeModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasAwesomePrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasAwesomePrintInspect::Concern, type: :awesome_print do
example_group "modules" do
include ConvenientService::RSpec::Matchers::IncludeModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code::Plugins::HasAmazingPrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code::Plugins::HasAmazingPrintInspect::Concern, type: :amazing_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code::Plugins::HasAwesomePrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code::Plugins::HasAwesomePrintInspect::Concern, type: :awesome_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::Plugins::HasAmazingPrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::Plugins::HasAmazingPrintInspect::Concern, type: :amazing_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::Plugins::HasAwesomePrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::Plugins::HasAwesomePrintInspect::Concern, type: :awesome_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins::HasAmazingPrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins::HasAmazingPrintInspect::Concern, type: :amazing_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins::HasAwesomePrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message::Plugins::HasAwesomePrintInspect::Concern, type: :awesome_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AmazingPrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status::Plugins::HasAmazingPrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status::Plugins::HasAmazingPrintInspect::Concern, type: :amazing_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

require "convenient_service"

return unless defined? ConvenientService::AwesomePrintInspect::Config

# rubocop:disable RSpec/NestedGroups, RSpec/MultipleMemoizedHelpers
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status::Plugins::HasAwesomePrintInspect::Concern, type: :standard do
RSpec.describe ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status::Plugins::HasAwesomePrintInspect::Concern, type: :awesome_print do
include ConvenientService::RSpec::Matchers::DelegateTo

example_group "modules" do
Expand Down
2 changes: 0 additions & 2 deletions spec/support/convenient_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
ConvenientService.backtrace_cleaner.remove_silencers! if ::ConvenientService.debug?

ConvenientService::Dependencies.require_can_utilize_finite_loop
ConvenientService::Dependencies.require_awesome_print_inspect
ConvenientService::Dependencies.require_amazing_print_inspect
ConvenientService::Dependencies.require_rescues_result_unhandled_exceptions

ConvenientService::Dependencies.require_rspec_extentions
Expand Down
5 changes: 5 additions & 0 deletions spec/support/convenient_service/amazing_print.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

ConvenientService::Dependencies.require_amazing_print_inspect

ConvenientService::Dependencies.require_development_tools(amazing_print: true, awesome_print: false)
5 changes: 5 additions & 0 deletions spec/support/convenient_service/awesome_print.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

ConvenientService::Dependencies.require_awesome_print_inspect

ConvenientService::Dependencies.require_development_tools(amazing_print: false, awesome_print: true)

0 comments on commit cb6805e

Please sign in to comment.