diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..59993fb --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,282 @@ +# This is a config synced from dry-rb/template-gem repo + +require: + - rubocop-on-rbs + +AllCops: + TargetRubyVersion: 3.0 + NewCops: disable + SuggestExtensions: false + Exclude: + - "**/vendor/**/*" # For GitHub Actions, see rubocop/rubocop#9832 + - benchmarks/*.rb + - spec/support/coverage.rb + - spec/support/warnings.rb + - spec/support/rspec_options.rb + - Gemfile.devtools + - "*.gemspec" + +Layout/SpaceAroundMethodCallOperator: + Enabled: false + +Layout/SpaceInLambdaLiteral: + Enabled: false + +Layout/MultilineMethodCallIndentation: + Enabled: true + EnforcedStyle: indented + +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + EnforcedStyle: no_space + EnforcedStyleForEmptyBraces: no_space + +Layout/LineLength: + Max: 100 + Exclude: + - "spec/**/*.rb" + +Lint/AmbiguousBlockAssociation: + Enabled: true + # because 'expect { foo }.to change { bar }' is fine + Exclude: + - "spec/**/*.rb" + +Lint/BooleanSymbol: + Enabled: false + +Lint/ConstantDefinitionInBlock: + Exclude: + - "spec/**/*.rb" + +Lint/RaiseException: + Enabled: false + +Lint/StructNewOverride: + Enabled: false + +Lint/SuppressedException: + Exclude: + - "spec/spec_helper.rb" + +Lint/LiteralAsCondition: + Exclude: + - "spec/**/*.rb" + +Naming/PredicateName: + Enabled: false + +Naming/FileName: + Exclude: + - "lib/*-*.rb" + +Naming/MethodName: + Enabled: false + +Naming/MethodParameterName: + Enabled: false + +Naming/MemoizedInstanceVariableName: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Metrics/AbcSize: + Max: 25 + +Metrics/CyclomaticComplexity: + Enabled: true + Max: 12 + +Style/FrozenStringLiteralComment: + Exclude: + - "config/am.conf.rb" + +Style/ExponentialNotation: + Enabled: false + +Style/HashEachMethods: + Enabled: false + +Style/HashTransformKeys: + Enabled: false + +Style/HashTransformValues: + Enabled: false + +Style/AccessModifierDeclarations: + Enabled: false + +Style/Alias: + Enabled: true + EnforcedStyle: prefer_alias_method + +Style/AsciiComments: + Enabled: false + +Style/BlockDelimiters: + Enabled: false + +Style/ClassAndModuleChildren: + Exclude: + - "spec/**/*.rb" + +Style/ConditionalAssignment: + Enabled: false + +Style/DateTime: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/EachWithObject: + Enabled: false + +Style/FormatString: + Enabled: false + +Style/FormatStringToken: + Enabled: false + +Style/GuardClause: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/Lambda: + Enabled: false + +Style/LambdaCall: + Enabled: false + +Style/ParallelAssignment: + Enabled: false + +Style/RaiseArgs: + Enabled: false + +Style/StabbyLambdaParentheses: + Enabled: false + +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + ConsistentQuotesInMultiline: false + +Style/StringLiteralsInInterpolation: + Enabled: true + EnforcedStyle: double_quotes + +Style/SymbolArray: + Exclude: + - "spec/**/*.rb" + +Style/TrailingUnderscoreVariable: + Enabled: false + +Style/MultipleComparison: + Enabled: false + +Style/Next: + Enabled: false + +Style/AccessorGrouping: + Enabled: false + +Style/EmptyLiteral: + Enabled: false + +Style/Semicolon: + Exclude: + - "spec/**/*.rb" + +Style/HashAsLastArrayItem: + Exclude: + - "spec/**/*.rb" + +Style/CaseEquality: + Exclude: + - "lib/dry/monads/**/*.rb" + - "lib/dry/struct/**/*.rb" + - "lib/dry/types/**/*.rb" + - "spec/**/*.rb" + +Style/ExplicitBlockArgument: + Exclude: + - "lib/dry/types/**/*.rb" + +Style/CombinableLoops: + Enabled: false + +Style/EmptyElse: + Enabled: false + +Style/DoubleNegation: + Enabled: false + +Style/MultilineBlockChain: + Enabled: false + +Style/NumberedParametersLimit: + Max: 2 + +Lint/UnusedBlockArgument: + Exclude: + - "spec/**/*.rb" + +Lint/UselessAssignment: + Exclude: + - "config/am.conf.rb" + +Lint/Debugger: + Exclude: + - "bin/console" + +Lint/BinaryOperatorWithIdenticalOperands: + Exclude: + - "spec/**/*.rb" + +Metrics/ParameterLists: + Exclude: + - "spec/**/*.rb" + +Lint/EmptyBlock: + Exclude: + - "spec/**/*.rb" + +Lint/EmptyFile: + Exclude: + - "spec/**/*.rb" + +Lint/UselessMethodDefinition: + Exclude: + - "spec/**/*.rb" + +Lint/SelfAssignment: + Enabled: false + +Lint/EmptyClass: + Enabled: false + +Naming/ConstantName: + Exclude: + - "spec/**/*.rb" + +Naming/VariableNumber: + Exclude: + - "spec/**/*.rb" + +Naming/BinaryOperatorParameterName: + Enabled: false diff --git a/Gemfile b/Gemfile index b2d75fe..83d3b52 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,3 @@ source "https://rubygems.org" gemspec gem "rake", "~> 13.0" - - - diff --git a/Rakefile b/Rakefile index 8dff82c..16fe6c2 100644 --- a/Rakefile +++ b/Rakefile @@ -3,14 +3,13 @@ require "bundler/gem_tasks" require "rspec/core/rake_task" -RSpec::Core::RakeTask.new(:spec) - require "rubocop/rake_task" +RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new -task default: %i[spec rubocop] +task default: %i[rubocop spec] -task :docker_tests do +task :docker_tests do ruby "spec/docker/run_docker_tests.rb" end diff --git a/activity_monitor.gemspec b/activity_monitor.gemspec index d36c685..5ccb057 100644 --- a/activity_monitor.gemspec +++ b/activity_monitor.gemspec @@ -37,10 +37,10 @@ Gem::Specification.new do |spec| spec.add_dependency "hanami-router", "~> 2.1.0" spec.add_dependency "zeitwerk", "~>2.6.13" spec.add_dependency "rack", "~> 2.0" - spec.add_dependency "rainbow", "~> 3.1.1" spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rubocop", "~> 1.21" + spec.add_development_dependency "rubocop-on-rbs", "~> 1.0.0" spec.add_development_dependency "puma", "~> 6.0" # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/bin/console b/bin/console index b32c327..cc58068 100755 --- a/bin/console +++ b/bin/console @@ -13,5 +13,3 @@ require "activity_monitor" require "irb" IRB.start(__FILE__) - - diff --git a/config.ru b/config.ru index 34eaa81..12a6a67 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "activity_monitor/standalone" run ActivityMonitor.run diff --git a/config/am.conf.rb b/config/am.conf.rb new file mode 100644 index 0000000..5176849 --- /dev/null +++ b/config/am.conf.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module ActivityMonitor + class Config + AM_CONF = { + root_slug: "/api/am", + enabled_services: %i[ + github + gitlab + bitbucket + sourcehut + codeberg + ] + }.freeze + end +end diff --git a/exe/am b/exe/am index de445f1..2c49dfc 100755 --- a/exe/am +++ b/exe/am @@ -4,4 +4,3 @@ require_relative "../lib/activity_monitor/cli/commands" ActivityMonitor::CLI::Commands - diff --git a/lib/activity_monitor.rb b/lib/activity_monitor.rb index 350f439..0c825d8 100644 --- a/lib/activity_monitor.rb +++ b/lib/activity_monitor.rb @@ -1,20 +1,18 @@ -#frozen_string_literal: true +# frozen_string_literal: true -require "hanami" if Gem.loaded_specs.has_key? "hanami" +require "hanami" if Gem.loaded_specs.key? "hanami" require "zeitwerk" loader = Zeitwerk::Loader.for_gem loader.inflector.inflect("cli" => "CLI") loader.setup module ActivityMonitor - def self.setup - unless instance_variable_defined?(:@am) - @am = ActivityMonitor::App::new + @am = ActivityMonitor::App.new end - if (defined? Hanami) && Hanami::app? + if (defined? Hanami) && Hanami.app? @am.set_config "is_hanami_app=", true end @@ -23,8 +21,6 @@ def self.setup end def self.run - self.setup + setup end - end - diff --git a/lib/activity_monitor/app.rb b/lib/activity_monitor/app.rb index 71f6792..ae42704 100644 --- a/lib/activity_monitor/app.rb +++ b/lib/activity_monitor/app.rb @@ -2,38 +2,32 @@ module ActivityMonitor class App - include ActivityMonitor::Logging def initialize - @am_config = ActivityMonitor::Config::new + @am_config = ActivityMonitor::Config.new + @router = ActivityMonitor::Router.select_router + @routes = ActivityMonitor::Router::Routes.new log.info("Initialized") # @hanami_config = ::Hanami::app::config end def call(env) - log.info "#{env}" - if env['REQUEST_PATH'] == "/activity_monitor" - ['200', {'Content-Type' => 'text/html'}, ["Hello from activity monitor "]] + if env["REQUEST_PATH"] == "/activity_monitor" + [200, {"Content-Type" => "text/html"}, ["Hello from activity monitor"]] end end - def self.env(e: ENV) - return e - end - def set_config(key, val) @am_config.public_send(key, val) end - def self.dump_config() - # puts "Hanami defined: #{defined?(Hanami)}" - #puts "prepared: #{::Hanami::app::prepared?}" - # puts "Hanami config: " + ::Hanami::app::config.to_s + " anything?>" + def dump_config + @am_config.dump end def say_hello - puts "Hello from #{self.to_s}" + puts "Hello from #{self}" end end end diff --git a/lib/activity_monitor/cli/commands.rb b/lib/activity_monitor/cli/commands.rb index 7840177..77e076a 100644 --- a/lib/activity_monitor/cli/commands.rb +++ b/lib/activity_monitor/cli/commands.rb @@ -5,38 +5,36 @@ require "activity_monitor" module ActivityMonitor - # ActivityMonitor::CLI provides the `bundle exec am` command line interface module CLI module Commands - extend Dry::CLI::Registry class Version < Dry::CLI::Command desc "Prints the version of Activity Monitor" def call(*) - puts "#{ActivityMonitor.version_string}" + puts ActivityMonitor.version_string end end module Generate - class HanamiProvider < Dry::CLI::Command desc "Generates a basic provider file for the Hanami framework" - + HANAMI_PROVIDER_PATH = "/config/providers" - def initialize(filename: 'activity_monitor', extension: 'rb') - - @filename = filename + '.' + extension # the provider defintion file that will be saved + def initialize(filename: "activity_monitor", extension: "rb") + super + @filename = "#{filename}.#{extension}" # the provider defintion file that will be saved end - + def call(*) - dir_path = Dir.pwd + HANAMI_PROVIDER_PATH # directory that contains the provider file - unless Dir.exist?(dir_path) - raise StandardError.new("Directory not found: #{dir_path}\n\tCurrent Directory: #{Dir.pwd}") + unless Dir.exist?(dir_path) + raise StandardError.new( + "Directory not found: #{dir_path}\n\tCurrent Directory: #{Dir.pwd}" + ) end t = ActivityMonitor::Templates::HanamiProvider.new @@ -45,20 +43,18 @@ def call(*) raise FileExistsError.new(file_path) end - puts "#{t.template}" - + puts t.template end end end - + register "version", Version, aliases: ["v", "-v", "--version"] register "generate", aliases: ["gen"] do |prefix| prefix.register "hanami-provider", Generate::HanamiProvider end - end end end -Dry::CLI::new(ActivityMonitor::CLI::Commands).call +Dry::CLI.new(ActivityMonitor::CLI::Commands).call diff --git a/lib/activity_monitor/config.rb b/lib/activity_monitor/config.rb index 6ab859d..eea87bc 100644 --- a/lib/activity_monitor/config.rb +++ b/lib/activity_monitor/config.rb @@ -1,19 +1,29 @@ -#frozen_string_literal: true +# frozen_string_literal: true + +require_relative("#{__dir__}/../../config/am.conf.rb") module ActivityMonitor class Config - attr_accessor :is_hanami_app, :root_slug - + attr_accessor :is_hanami_app, :root_slug, :router + def initialize - self.reset_config - @root_slug = "/activity_monitor" + reset_config + end + + def dump + ivars = instance_variables + + ivars.each do |v| + p v.to_s.ljust(20) + "=> #{instance_variable_get(v)}" + end end - + + private + def reset_config @is_hanami_app = false - @root_slug = "/activity_monitor" + @root_slug = AM_CONF[:root_slug] + @router = ActivityMonitor::Router.select_router end - end end - diff --git a/lib/activity_monitor/errors.rb b/lib/activity_monitor/errors.rb index adefa07..4069aef 100644 --- a/lib/activity_monitor/errors.rb +++ b/lib/activity_monitor/errors.rb @@ -1,28 +1,23 @@ # frozen_string_literal: true - module ActivityMonitor module Errors class ActivityMonitorError < StandardError - - def initialize() + def initialize super("ActivityMonitor encountered an unknown error!") end end - + class FileDoesNotExistError < ActivityMonitorError - def initialize(arg: nil) super("The file '#{arg}' does not exist !") end end class FileExistsError < ActivityMonitorError - - def initialize(arg: nil, dir: nil) + def initialize(arg: nil) super("The file '#{arg}' already exists!") end end - end end diff --git a/lib/activity_monitor/hanami_app.rb b/lib/activity_monitor/hanami_app.rb index a349584..a9bc9bb 100644 --- a/lib/activity_monitor/hanami_app.rb +++ b/lib/activity_monitor/hanami_app.rb @@ -2,20 +2,19 @@ module ActivityMonitor class HanamiApp - include ActivityMonitor::Logging - def initialize(app, name = nil) + def initialize(app, _name = nil) @app = app - @am_config = ActivityMonitor::Config::new + @am_config = ActivityMonitor::Config.new log.info("Hanami App Initialized") # @hanami_config = ::Hanami::app::config end def call(env) - log.info "#{@app}" - if env['REQUEST_PATH'] == "/activity_monitor" - ['200', {'Content-Type' => 'text/html'}, ["Hello from activity monitor "]] + log.info @app.to_s + if env["REQUEST_PATH"] == "/activity_monitor" + [200, {"Content-Type" => "text/html"}, ["Hello from activity monitor "]] end _, _, _ = response = @app.call(env) response diff --git a/lib/activity_monitor/logging.rb b/lib/activity_monitor/logging.rb index 6862f95..ddbb7c0 100644 --- a/lib/activity_monitor/logging.rb +++ b/lib/activity_monitor/logging.rb @@ -1,14 +1,13 @@ -#frozen_string_literal: true +# frozen_string_literal: true module ActivityMonitor module Logging - def log Logging.log end def self.log - @log ||= Logging::Logger::new(STDOUT) + @log ||= Logging::Logger.new($stdout) end end end diff --git a/lib/activity_monitor/logging/formatter.rb b/lib/activity_monitor/logging/formatter.rb index 0933649..c64eed2 100644 --- a/lib/activity_monitor/logging/formatter.rb +++ b/lib/activity_monitor/logging/formatter.rb @@ -1,47 +1,10 @@ -#frozen_string_literal: true +# frozen_string_literal: true require "logger" -require "rainbow" module ActivityMonitor module Logging class Formatter < Logger::Formatter - - def call(severity, time, progname, msg) - case severity - when "DEBUG" - bg = :darkslategray - fg = :black - when "INFO" - bg = :darkslategray - fg = :skyblue - when "WARN" - bg = :darkslategray - fg = :orange - when "ERROR" - bg = :black - fg = :red - when "FATAL" - bg = :black - fg = :crimson - when "ANY" - bg = :black - fg = :white - else - bg = :black - fg = :white - end - - - Format % [ Rainbow(severity[0..0]).fg(fg).bg(bg), \ - format_datetime(time), \ - $$, \ - Rainbow(severity).fg(fg).bg(bg), \ - progname, \ - msg2str(msg) - ] - - end end end end diff --git a/lib/activity_monitor/logging/logger.rb b/lib/activity_monitor/logging/logger.rb index c1ec502..d11dba1 100644 --- a/lib/activity_monitor/logging/logger.rb +++ b/lib/activity_monitor/logging/logger.rb @@ -1,25 +1,23 @@ -#frozen_string_literal: true +# frozen_string_literal: true require "logger" module ActivityMonitor module Logging class Logger < Logger - def initialize(*args) super - @level = defined?(env["RUBY_LOG_LEVEL"]) ? env["RUBY_LOG_LEVEL"] : Logger::DEBUG - - formatter = ActivityMonitor::Logging::Formatter.new + # @level = defined?(env["RUBY_LOG_LEVEL"]) ? env["RUBY_LOG_LEVEL"] : Logger::DEBUG + + # formatter = ActivityMonitor::Logging::Formatter.new @progname = "AM" - - @formatter = proc { |severity, datetime, progname, msg| - formatter.call(severity, datetime, progname, msg.dump) - } - end + # @formatter = proc { |severity, datetime, progname, msg| + # formatter.call(severity, datetime, progname, msg.dump) + # } + end end end end diff --git a/lib/activity_monitor/router.rb b/lib/activity_monitor/router.rb new file mode 100644 index 0000000..ac9967a --- /dev/null +++ b/lib/activity_monitor/router.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module ActivityMonitor + module Router + require_relative "router/default" + + def select_router + ActivityMonitor::Router::Default.new + end + + module_function :select_router + end +end diff --git a/lib/activity_monitor/router/default.rb b/lib/activity_monitor/router/default.rb new file mode 100644 index 0000000..1be9465 --- /dev/null +++ b/lib/activity_monitor/router/default.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module ActivityMonitor + module Router + class Default + def initialize + puts "Router intialized of type: Default" + end + + def process_route(_routes) + puts "process_route" + end + end + end +end diff --git a/lib/activity_monitor/router/router.rb b/lib/activity_monitor/router/router.rb deleted file mode 100644 index 8e6a81e..0000000 --- a/lib/activity_monitor/router/router.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module ActivityMonitor - class Router - - def initialize() - puts ENV.keys - end - end - - def self.env(e: ENV) - return e - end -end diff --git a/lib/activity_monitor/router/routes.rb b/lib/activity_monitor/router/routes.rb new file mode 100644 index 0000000..c7731c8 --- /dev/null +++ b/lib/activity_monitor/router/routes.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module ActivityMonitor + module Router + class Routes + def initialize + puts "Router intialized of type: Default" + end + + def process_route(routes) + puts "process_route #{routes}" + end + end + end +end diff --git a/lib/activity_monitor/standalone.rb b/lib/activity_monitor/standalone.rb index d18bc24..0f70a6c 100644 --- a/lib/activity_monitor/standalone.rb +++ b/lib/activity_monitor/standalone.rb @@ -1,4 +1,4 @@ -#frozen_string_literal: true +# frozen_string_literal: true require "activity_monitor" diff --git a/lib/activity_monitor/templates/hanami_provider.rb b/lib/activity_monitor/templates/hanami_provider.rb index 6d0feec..826894d 100644 --- a/lib/activity_monitor/templates/hanami_provider.rb +++ b/lib/activity_monitor/templates/hanami_provider.rb @@ -1,42 +1,39 @@ # frozen_string_literal: true -=begin -This class -=end +# +# This class require "hanami/cli" module ActivityMonitor module Templates class HanamiProvider - - def initialize() - @template ||= PROVIDER + def initialize + @template = PROVIDER end - PROVIDER = <<-PROVIDER_TEMPLATE -Hanami.app.register_provider(:activity_monitor, namespace: true) do |container| - - # ActivityMonitor initialisation procedure goes here - prepare do - require 'activity_monitor' - ActivityMonitor::setup - end - - # ActivityMonitor runtime procedure goes here - start do - app = ActivityMonitor::App::new - register 'app', app - end - - # ActivityMonitor exit procedure goes here - stop do - end -end - PROVIDER_TEMPLATE - - attr_accessor :template - + PROVIDER = <<~PROVIDER_TEMPLATE.freeze + Hanami.app.register_provider(:activity_monitor, namespace: true) do |container| + #{" "} + # ActivityMonitor initialisation procedure goes here + prepare do + require 'activity_monitor' + ActivityMonitor::setup + end + + # ActivityMonitor runtime procedure goes here + start do + app = ActivityMonitor::App::new + register 'app', app + end + + # ActivityMonitor exit procedure goes here + stop do#{" "} + end + end#{" "} + PROVIDER_TEMPLATE + + attr_accessor :template end end end diff --git a/lib/activity_monitor/version.rb b/lib/activity_monitor/version.rb index 2a8a015..e1e1730 100644 --- a/lib/activity_monitor/version.rb +++ b/lib/activity_monitor/version.rb @@ -3,9 +3,8 @@ module ActivityMonitor VERSION = "0.1.0" - def version_string - return VERSION + VERSION end module_function :version_string diff --git a/sig/activity_monitor/am.rb b/sig/activity_monitor/am.rbs similarity index 100% rename from sig/activity_monitor/am.rb rename to sig/activity_monitor/am.rbs diff --git a/spec/docker/run_docker_tests.rb b/spec/docker/run_docker_tests.rb index 151b6d3..b9095f8 100644 --- a/spec/docker/run_docker_tests.rb +++ b/spec/docker/run_docker_tests.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require "rainbow" -TEST_NAME="AM - Docker Tests - (debug)" -TEST_GEM_NAME="am" -WORK_D="/tmp/#{TEST_GEM_NAME}.test.d" +TEST_NAME = "AM - Docker Tests - (debug)" +TEST_GEM_NAME = "am" +WORK_D = "/tmp/#{TEST_GEM_NAME}.test.d".freeze def log_msg(str) puts "#{Rainbow(TEST_NAME).fg(:webpurple).bg(:lightsalmon)}: #{str}" end @@ -12,7 +14,7 @@ def log_msg(str) system("mkdir #{WORK_D}") Dir.chdir(WORK_D) && log_msg("Changed dir to #{Rainbow(WORK_D).fg(:lightsalmon)}") -#system("bundle", "gem", "#{TEST_GEM_NAME}", "--ci=github", "--no-test", "--no-changelog", "--no-coc", "--no-mit") +# system("bundle", "gem", "#{TEST_GEM_NAME}", "--ci=github", "--no-test", "--no-changelog", "--no-coc", "--no-mit") system("export BUNDLE_PATH=#{WORK_D}/.bundle") system("bundle", "init") system("echo 'gem \"activity_monitor_rb\", path: /app' >> Gemfile") diff --git a/spec/gem/install_spec.rb b/spec/gem/install_spec.rb index 5dcb786..260cba1 100644 --- a/spec/gem/install_spec.rb +++ b/spec/gem/install_spec.rb @@ -3,10 +3,6 @@ require "activity_monitor" RSpec.describe ActivityMonitor do - it "can be installed" do - - end + it "can be installed" do + end end - - - diff --git a/spec/unit/activity_monitor/cli/commands.rb b/spec/unit/activity_monitor/cli/commands.rb index 3823f85..51c8785 100644 --- a/spec/unit/activity_monitor/cli/commands.rb +++ b/spec/unit/activity_monitor/cli/commands.rb @@ -8,7 +8,6 @@ end it "can be setup" do - expect(ActivityMonitor::setup).to be_a_kind_of(ActivityMonitor::App) + expect(ActivityMonitor.setup).to be_a_kind_of(ActivityMonitor::App) end - end diff --git a/spec/unit/app_spec.rb b/spec/unit/app_spec.rb index 719240f..442c7d1 100644 --- a/spec/unit/app_spec.rb +++ b/spec/unit/app_spec.rb @@ -3,22 +3,19 @@ require "open3" require "activity_monitor" - - RSpec.describe "exe/am" do - let(:root) do Pathname(__dir__).join("../..").realpath end - + def output - Open3.capture3("exe/am #{args.join(' ')}", chdir: root) + Open3.capture3("exe/am #{args.join(" ")}", chdir: root) end context "no args" do let(:args) { [] } it "prints out usage" do - expect("#{output[1]}").to include("generate") + expect(output[1].to_s).to include("generate") end end end