Skip to content
Merged
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
9 changes: 2 additions & 7 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins:
- rubocop-minitest
- rubocop-factory_bot
- rubocop-packaging
- rubocop-performance
Expand All @@ -10,6 +9,8 @@ AllCops:
DisplayStyleGuide: true
NewCops: enable
TargetRubyVersion: 2.7
SuggestExtensions:
rubocop-minitest: false
Exclude:
- "bin/*"
- "test/fixtures/**/*"
Expand Down Expand Up @@ -74,12 +75,6 @@ Metrics/MethodLength:
Metrics/ParameterLists:
Max: 6

Minitest/EmptyLineBeforeAssertionMethods:
Enabled: false

Minitest/MultipleAssertions:
Max: 6

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 @@ -7,7 +7,7 @@ gem "activesupport", "~> 7.1.3" # Needed for factory_bot 6.3
gem "cgi" # Needed for vcr on Ruby 3.5+
gem "factory_bot", "~> 6.3.0"
gem "irb"
gem "minitest", "~> 5.11"
gem "megatest", "~> 0.11.0"
gem "minitest-snapshots", "~> 1.1"
gem "mocha", "~> 3.0"
gem "observer"
Expand All @@ -17,10 +17,8 @@ gem "vcr", "~> 6.2"
gem "webmock", "~> 3.23"

if RUBY_VERSION >= "3.3"
gem "mighty_test", "~> 0.3"
gem "rubocop", "1.88.2"
gem "rubocop-factory_bot", "2.28.0"
gem "rubocop-minitest", "0.40.0"
gem "rubocop-packaging", "0.6.0"
gem "rubocop-performance", "1.26.1"
gem "rubocop-rake", "0.7.1"
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ Everyone interacting in this project’s codebases, issue trackers, chat rooms a

Pull requests are welcome!

To test your locally cloned version of `bundle update-interactive`, run `rake install`. This will install the gem and its executable so that you can try it out on other local projects.
To test your locally cloned version of `bundle update-interactive`, run `bundle exec rake install`. This will install the gem and its executable so that you can try it out on other local projects.

Before submitting a PR, make sure to run `rake` to see if there are any RuboCop or test failures.
Run `bundle exec rake` to run all tests and RuboCop checks. Please do this before opening a PR.

To run a specific test, use `bin/megatest <TEST>`.
9 changes: 4 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

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

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

if Gem.loaded_specs.key?("rubocop")
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.

3 changes: 1 addition & 2 deletions test/bundle_update_interactive/bundler_commands_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

require "test_helper"
require "bundler"

module BundleUpdateInteractive
class BundlerCommandsTest < Minitest::Test
class BundlerCommandsTest < Test
def setup
Gem.stubs(:bin_path).with("bundler", "bundle", Bundler::VERSION).returns("/exe/bundle")
end
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/changelog_locator_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class ChangelogLocatorTest < Minitest::Test
class ChangelogLocatorTest < Test
def test_fetches_changelog_uri_from_rubygems
VCR.use_cassette("changelog_requests") do
uri = ChangelogLocator.new.find_changelog_uri(name: "nokogiri", version: "1.16.6")
Expand Down
3 changes: 1 addition & 2 deletions test/bundle_update_interactive/cli/multi_select_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require "test_helper"
require "launchy"
require "tty/prompt/test"

module BundleUpdateInteractive
class CLI
class MultiSelectTest < Minitest::Test
class MultiSelectTest < Test
ARROW_UP = "\e[A"
ARROW_DOWN = "\e[B"
CTRL_A = "\u0001"
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/cli/options_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class CLI
class OptionsTest < Minitest::Test
class OptionsTest < Test
def test_prints_help_and_exits_when_given_dash_h
stdout, _stderr, status = capture_io_and_exit_status do
Options.parse(%w[-h])
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/cli/row_test.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class CLI
class RowTest < Minitest::Test
class RowTest < Test
def test_formatted_gem_name_for_vulnerable_gem_is_red_on_white
outdated_gem = build(:outdated_gem, name: "rails", vulnerable: true)
row = Row.new(outdated_gem)
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/cli_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class CLIIest < Minitest::Test
class CLITest < Test
def test_shows_help_and_exits
stdout, stderr, status = capture_io_and_exit_status do
CLI.new.run(argv: %w[--help])
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/git_committer_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class GitCommitterTest < Minitest::Test
class GitCommitterTest < Test
def setup
@git_committer = GitCommitter.new(nil)
end
Expand Down
3 changes: 1 addition & 2 deletions test/bundle_update_interactive/http_test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# frozen_string_literal: true

require "test_helper"
require "openssl"
require "net/http"

module BundleUpdateInteractive
class HttpTest < Minitest::Test
class HttpTest < Test
def test_gracefully_handles_openssl_error
Net::HTTP.stubs(:start).raises(OpenSSL::SSL::SSLError)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
module Latest
class GemRequirementTest < Minitest::Test
class GemRequirementTest < Test
def test_relax_doesnt_affect_greater_than_equal_requirements
assert_equal(">= 1.0.1", parse(">= 1.0.1").relax.to_s)
end
Expand Down
3 changes: 1 addition & 2 deletions test/bundle_update_interactive/latest/gemfile_editor_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require "test_helper"
require "fileutils"
require "tmpdir"

module BundleUpdateInteractive
module Latest
class GemfileEditorTest < Minitest::Test
class GemfileEditorTest < Test
def setup
@original_dir = Dir.pwd
@temp_dir = Dir.mktmpdir
Expand Down
7 changes: 3 additions & 4 deletions test/bundle_update_interactive/latest/updater_test.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# frozen_string_literal: true

require "test_helper"
require "bundler"

module BundleUpdateInteractive
module Latest
class UpdaterTest < Minitest::Test
class UpdaterTest < Test
def test_generate_report_doesnt_run_bundle_outdated_and_always_returns_no_withheld_gems
Dir.chdir(File.expand_path("../../fixtures", __dir__)) do
within_fixture_copy do
updated_lockfile = File.read("Gemfile.lock.updated")
BundlerCommands.expects(:read_updated_lockfile).with.returns(updated_lockfile)
BundlerCommands.expects(:parse_outdated).never
Expand All @@ -19,7 +18,7 @@ def test_generate_report_doesnt_run_bundle_outdated_and_always_returns_no_withhe
end

def test_generate_report_relaxes_gemfile_and_restores_it
Dir.chdir(File.expand_path("../../fixtures", __dir__)) do
within_fixture_copy do
updatable_gems = { "sqlite3" => build(:outdated_gem, name: "sqlite3") }
editor = GemfileEditor.new
editor.expects(:with_relaxed_gemfile).returns(updatable_gems)
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/lockfile_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class LockfileTest < Minitest::Test
class LockfileTest < Test
def test_parses_a_lockfile_into_entries_by_name
lockfile = Lockfile.parse(File.read(File.expand_path("../fixtures/Gemfile.lock", __dir__)))

Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/outdated_gem_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class OutdatedGemTest < Minitest::Test
class OutdatedGemTest < Test
def test_changelog_uri_delegates_to_changelog_locator_for_rubygems_source
changelog_locator = mock
ChangelogLocator.expects(:new).returns(changelog_locator)
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive/semver_change_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

require "test_helper"

module BundleUpdateInteractive
class SemverChangeTest < Minitest::Test
class SemverChangeTest < Test
def test_prerelease_is_considered_patch
change = SemverChange.new("7.2.0.beta2", "7.2.0.beta3")

Expand Down
3 changes: 1 addition & 2 deletions test/bundle_update_interactive/updater_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require "test_helper"
require "bundler"
require "bundler/audit"
require "bundler/audit/scanner"

module BundleUpdateInteractive
class UpdaterTest < Minitest::Test
class UpdaterTest < Test
def test_generates_a_report_of_updatable_gems_that_can_be_rendered_as_a_table
VCR.use_cassette("changelog_requests") do
Dir.chdir(File.expand_path("../fixtures", __dir__)) do
Expand Down
4 changes: 1 addition & 3 deletions test/bundle_update_interactive_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

require "test_helper"

class BundleUpdateInteractiveTest < Minitest::Test
class BundleUpdateInteractiveTest < BundleUpdateInteractive::Test
def test_that_it_has_a_version_number
refute_nil ::BundleUpdateInteractive::VERSION
end
Expand Down
11 changes: 1 addition & 10 deletions test/integration/cli_integration_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require "test_helper"
require "json"
require "open3"
require "tmpdir"

module BundleUpdateInteractive
class CLIIntegrationIest < Minitest::Test
class CLIIntegrationIest < Test
def test_updates_lock_file_based_on_selected_gem_while_honoring_gemfile_requirement
out, _gemfile, lockfile = within_fixture_copy("integration") do
run_bundle_update_interactive(argv: [], key_presses: "j \n")
Expand Down Expand Up @@ -118,14 +117,6 @@ def run_bundle_update_interactive(argv:, key_presses: "\n")
end
end

def within_fixture_copy(fixture, &block)
fixture_path = File.join(File.expand_path("../fixtures", __dir__), fixture)
Dir.mktmpdir do |tmp|
FileUtils.cp_r(fixture_path, tmp)
Dir.chdir(File.join(tmp, File.basename(fixture_path)), &block)
end
end

def fetch_latest_gem_version_from_rubygems_api(name)
WebMock.allow_net_connect!
VCR.turned_off do
Expand Down
2 changes: 1 addition & 1 deletion test/support/bundler_audit_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def mock_vulnerable_gems(*gem_names)
end
end

Minitest::Test.include(BundlerAuditTestHelpers)
BundleUpdateInteractive::Test.include(BundlerAuditTestHelpers)
4 changes: 2 additions & 2 deletions test/support/capture_io_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module CaptureIOHelpers
private

# Patch Minitest's capture_io to make it compatible with TTY::Prompt
# Patch Megatest's capture_io to make it compatible with TTY::Prompt
def capture_io
super do
$stdout.extend(TTY::Prompt::StringIOExtensions) if $stdout.is_a?(StringIO)
Expand Down Expand Up @@ -37,4 +37,4 @@ def capture_io_and_exit_status(stdin_data: "")
end
end

Minitest::Test.prepend(CaptureIOHelpers)
BundleUpdateInteractive::Test.prepend CaptureIOHelpers
2 changes: 1 addition & 1 deletion test/support/factory_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

FactoryBot.find_definitions

module Minitest
module BundleUpdateInteractive
class Test
include FactoryBot::Syntax::Methods
end
Expand Down
Loading