Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vcr to record changelog lookups for better test coverage #7

Merged
merged 2 commits into from
Jul 17, 2024
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
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ gem "minitest-snapshots", "~> 1.1"
gem "mocha", "~> 2.4"
gem "observer"
gem "rake", "~> 13.0"
gem "vcr", "~> 6.2"
gem "webmock", "~> 3.23"

if RUBY_VERSION >= "3.3"
gem "mighty_test", "~> 0.3"
Expand Down
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