From 57f0f2fe7bae26327fd5c9e0a7c68f7bc6e58e27 Mon Sep 17 00:00:00 2001 From: Lovro Bikic Date: Fri, 25 Oct 2024 00:20:58 +0200 Subject: [PATCH] Refactor --- .../lib/polariscope/scanner/gem_versions_spec.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/spec/lib/polariscope/scanner/gem_versions_spec.rb b/spec/lib/polariscope/scanner/gem_versions_spec.rb index a3a5ccc..17841eb 100644 --- a/spec/lib/polariscope/scanner/gem_versions_spec.rb +++ b/spec/lib/polariscope/scanner/gem_versions_spec.rb @@ -27,14 +27,20 @@ end describe '#versions_for' do - let(:dependencies) { ['devise', 'rails'] } - before { allow(Polariscope::Scanner::RubyVersions).to receive(:available_versions) } - it 'returns only distinct versions for given gem name' do - expect(scanner.versions_for('devise').map(&:to_s)).to contain_exactly('4.6.2', '4.5.0') + context 'when ruby is not in dependencies' do + let(:dependencies) { ['devise', 'rails'] } + + it 'returns distinct versions for given gem name' do + expect(scanner.versions_for('devise').map(&:to_s)).to contain_exactly('4.6.2', '4.5.0') + end + + it "doesn't fetch ruby versions" do + scanner - expect(Polariscope::Scanner::RubyVersions).not_to have_received(:available_versions) + expect(Polariscope::Scanner::RubyVersions).not_to have_received(:available_versions) + end end context 'when ruby is in dependencies' do