Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins:
- rubocop-minitest
- rubocop-packaging
- rubocop-performance
- rubocop-rake
Expand All @@ -9,6 +8,8 @@ AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
NewCops: enable
SuggestExtensions:
rubocop-minitest: false
TargetRubyVersion: 3.2
Exclude:
- "bin/**/*"
Expand Down Expand Up @@ -75,16 +76,6 @@ Metrics/MethodLength:
Metrics/ParameterLists:
Max: 6

Minitest/EmptyLineBeforeAssertionMethods:
Enabled: false

Minitest/MultipleAssertions:
Max: 5

Minitest/TestFileName:
Exclude:
- "**/*.md"

Naming/MemoizedInstanceVariableName:
Enabled: false

Expand Down
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ gemspec

gem "concurrent-ruby", "~> 1.1"
gem "irb"
gem "mighty_test", "~> 0.4.1" unless RUBY_VERSION < "3.1"
gem "minitest", "~> 5.11"
gem "megatest", "~> 0.6.0"
gem "rake", "~> 13.0"
gem "rubocop", "1.82.1"
gem "rubocop-md", "2.0.3"
gem "rubocop-minitest", "0.38.2"
gem "rubocop-packaging", "0.6.0"
gem "rubocop-performance", "1.26.1"
gem "rubocop-rake", "0.7.1"
16 changes: 7 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/testtask"
require "megatest/test_task"
require "rubocop/rake_task"

task default: %i[test rubocop]
Expand All @@ -10,16 +10,14 @@ task test: %w[test:unit]

RuboCop::RakeTask.new

Rake::TestTask.new("test:unit") do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"] - FileList["test/**/*_e2e_test.rb"]
Megatest::TestTask.create("test:unit") do |t|
t.command = "bin/megatest"
t.tests = FileList["test/**/*_test.rb"] - FileList["test/**/*_e2e_test.rb"]
end

Rake::TestTask.new("test:e2e") do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_e2e_test.rb"]
Megatest::TestTask.create("test:e2e") do |t|
t.command = "bin/megatest"
t.tests = FileList["test/**/*_e2e_test.rb"]
end

# == "rake release" enhancements ==============================================
Expand Down
16 changes: 16 additions & 0 deletions bin/megatest
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'megatest' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "rubygems"
require "bundler/setup"

load Gem.bin_path("megatest", "megatest")
27 changes: 0 additions & 27 deletions bin/mt

This file was deleted.

6 changes: 2 additions & 4 deletions test/e2e/rails_setup_deploy_e2e_test.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# frozen_string_literal: true

require "test_helper"

require "net/http"
require "securerandom"

class RailsSetupDeployE2ETest < Minitest::Test
class RailsSetupDeployE2ETest < TomoTest
include Tomo::Testing::Local

def setup
setup do
@docker = Tomo::Testing::DockerImage.new
@docker.build_and_run
end
Expand Down
5 changes: 2 additions & 3 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

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

require "minitest/autorun"
require "minitest/rg"
class TomoTest < Megatest::Test
end
6 changes: 2 additions & 4 deletions test/tomo/cli/completions_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::CLI::CompletionsTest < Minitest::Test
def setup
class Tomo::CLI::CompletionsTest < TomoTest
setup do
@tester = Tomo::Testing::CLITester.new
end

Expand Down
6 changes: 2 additions & 4 deletions test/tomo/cli_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::CLITest < Minitest::Test
def setup
class Tomo::CLITest < TomoTest
setup do
@tester = Tomo::Testing::CLITester.new
end

Expand Down
10 changes: 4 additions & 6 deletions test/tomo/colors_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::ColorsTest < Minitest::Test
def setup
class Tomo::ColorsTest < TomoTest
setup do
# This forces color support detection to happen again
Tomo::Colors.remove_instance_variable(:@enabled)
end
Expand Down Expand Up @@ -55,10 +53,10 @@ def test_disabled_by_dumb_term
private

def with_tty(tty, &block)
$stdout.stub(:tty?, tty) { $stderr.stub(:tty?, tty, &block) }
stub($stdout, :tty?, -> { tty }) { stub($stderr, :tty?, -> { tty }, &block) }
end

def with_env(env, &)
ENV.stub(:[], ->(name) { env[name] }, &)
stub(ENV, :[], ->(name) { env[name] }, &)
end
end
6 changes: 2 additions & 4 deletions test/tomo/commands/init_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::Commands::InitTest < Minitest::Test
def setup
class Tomo::Commands::InitTest < TomoTest
setup do
@tester = Tomo::Testing::CLITester.new
end

Expand Down
4 changes: 1 addition & 3 deletions test/tomo/configuration_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::ConfigurationTest < Minitest::Test
class Tomo::ConfigurationTest < TomoTest
include Tomo::Testing::Local

def test_parses_a_config_file_that_contains_frozen_string_literals
Expand Down
5 changes: 2 additions & 3 deletions test/tomo/console/key_reader_test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# frozen_string_literal: true

require "test_helper"
require "stringio"

class Tomo::Console
class KeyReaderTest < Minitest::Test
def setup
class KeyReaderTest < TomoTest
setup do
@input = StringIO.new
@input.define_singleton_method(:raw) do |&block|
block.call
Expand Down
3 changes: 1 addition & 2 deletions test/tomo/console_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "stringio"

class Tomo::ConsoleTest < Minitest::Test
class Tomo::ConsoleTest < TomoTest
def test_interactive_is_true_for_tty
assert_predicate Tomo::Console.new({}, tty), :interactive?
end
Expand Down
4 changes: 1 addition & 3 deletions test/tomo/host_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::HostTest < Minitest::Test
class Tomo::HostTest < TomoTest
def test_parse_hostname
host = Tomo::Host.parse("app.example.com")
assert_equal("app.example.com", host.address)
Expand Down
4 changes: 1 addition & 3 deletions test/tomo/path_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::PathTest < Minitest::Test
class Tomo::PathTest < TomoTest
def test_join
path = Tomo::Path.new("/some/path").join("tmp/file.txt")

Expand Down
4 changes: 1 addition & 3 deletions test/tomo/paths_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

require "test_helper"

class Tomo::PathsTest < Minitest::Test
class Tomo::PathsTest < TomoTest
def test_raises_if_setting_does_not_exist
paths = Tomo::Paths.new({})
assert_raises(NoMethodError) { paths.storage }
Expand Down
3 changes: 1 addition & 2 deletions test/tomo/plugin/bundler/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/bundler"

class Tomo::Plugin::Bundler::TasksTest < Minitest::Test
class Tomo::Plugin::Bundler::TasksTest < TomoTest
def test_install
tester = configure(release_path: "/app/release")
tester.mock_script_result(/bundle check/, exit_status: 1)
Expand Down
5 changes: 2 additions & 3 deletions test/tomo/plugin/core/helpers_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/core"

class Tomo::Plugin::Core::HelpersTest < Minitest::Test
def setup
class Tomo::Plugin::Core::HelpersTest < TomoTest
setup do
@tester = Tomo::Testing::MockPluginTester.new(
settings: { application: "test" }
)
Expand Down
5 changes: 2 additions & 3 deletions test/tomo/plugin/core/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/core"
require "shellwords"
require "time"

class Tomo::Plugin::Core::TasksTest < Minitest::Test
def setup
class Tomo::Plugin::Core::TasksTest < TomoTest
setup do
configure
end

Expand Down
3 changes: 1 addition & 2 deletions test/tomo/plugin/env/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/env"

class Tomo::Plugin::Env::TasksTest < Minitest::Test
class Tomo::Plugin::Env::TasksTest < TomoTest
def test_setup_allows_integer_value
tester = Tomo::Testing::MockPluginTester.new(
"env",
Expand Down
3 changes: 1 addition & 2 deletions test/tomo/plugin/git/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/git"

class Tomo::Plugin::Git::TasksTest < Minitest::Test
class Tomo::Plugin::Git::TasksTest < TomoTest
def test_config_sets_name_and_email_with_user_by_default
tester = configure
tester.run_task("git:config")
Expand Down
3 changes: 1 addition & 2 deletions test/tomo/plugin/nodenv/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/nodenv"

class Tomo::Plugin::Nodenv::TasksTest < Minitest::Test
class Tomo::Plugin::Nodenv::TasksTest < TomoTest
def test_install_modifies_bashrc
bashrc = <<~SH
# example bashrc
Expand Down
5 changes: 2 additions & 3 deletions test/tomo/plugin/puma/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/puma"

class Tomo::Plugin::Puma::TasksTest < Minitest::Test
def setup
class Tomo::Plugin::Puma::TasksTest < TomoTest
setup do
configure
end

Expand Down
3 changes: 1 addition & 2 deletions test/tomo/plugin/rails/helpers_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/rails"

class Tomo::Plugin::Rails::HelpersTest < Minitest::Test
class Tomo::Plugin::Rails::HelpersTest < TomoTest
def test_rake_runs_bundle_exec_rake_in_current_path
tester = Tomo::Testing::MockPluginTester.new("bundler", "rails", settings: { current_path: "/app/current" })
tester.call_helper(:rake, "db:migrate")
Expand Down
3 changes: 1 addition & 2 deletions test/tomo/plugin/rails/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/rails"

class Tomo::Plugin::Rails::TasksTest < Minitest::Test
class Tomo::Plugin::Rails::TasksTest < TomoTest
def test_db_console
tester = Tomo::Testing::MockPluginTester.new(
"bundler", "rails", settings: { current_path: "/app/current" }
Expand Down
3 changes: 1 addition & 2 deletions test/tomo/plugin/rbenv/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

require "test_helper"
require "tomo/plugin/rbenv"

class Tomo::Plugin::Rbenv::TasksTest < Minitest::Test
class Tomo::Plugin::Rbenv::TasksTest < TomoTest
def test_install_uses_ruby_version_file_for_ruby_version
tester = configure(release_path: "/tmp/tomo/20201027184921")
tester.mock_script_result("cat /tmp/tomo/20201027184921/.ruby-version", stdout: "2.7.1\n")
Expand Down
Loading