Skip to content

Commit

Permalink
Use vcr to record actual changelog lookups for better test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrictson committed Jul 17, 2024
1 parent af2715a commit 69ede70
Show file tree
Hide file tree
Showing 3 changed files with 4,983 additions and 50 deletions.
24 changes: 9 additions & 15 deletions test/bundle_update_interactive_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ def test_that_it_has_a_version_number
end

def test_it_renders_updateable_gems
Dir.chdir(File.expand_path("fixtures", __dir__)) do
updated_lockfile = File.read("Gemfile.lock.updated")
fake_changelog_locator = FakeChangelogLocator.new
BundleUpdateInteractive::BundlerCommands.expects(:read_updated_lockfile).returns(updated_lockfile)
BundleUpdateInteractive::ChangelogLocator.expects(:new).at_least_once.returns(fake_changelog_locator)
# TODO: mock Bundler::Audit
report = BundleUpdateInteractive::Report.generate
use_vcr_cassette("test_it_renders_updateable_gems") do
Dir.chdir(File.expand_path("fixtures", __dir__)) do
updated_lockfile = File.read("Gemfile.lock.updated")
BundleUpdateInteractive::BundlerCommands.expects(:read_updated_lockfile).returns(updated_lockfile)
# TODO: mock Bundler::Audit
report = BundleUpdateInteractive::Report.generate

gem_update_table = BundleUpdateInteractive::CLI::Table.new(report.updateable_gems).render
assert_matches_snapshot(gem_update_table)
end
end

class FakeChangelogLocator
def find_changelog_uri(name:, version: nil)
"http://example/#{name}/v#{version}"
gem_update_table = BundleUpdateInteractive::CLI::Table.new(report.updateable_gems).render
assert_matches_snapshot(gem_update_table)
end
end
end
end
Loading

0 comments on commit 69ede70

Please sign in to comment.