diff --git a/spec/generate_empty_ruby_project_spec.rb b/spec/generate_empty_ruby_project_spec.rb index 63000e4..90ad5af 100644 --- a/spec/generate_empty_ruby_project_spec.rb +++ b/spec/generate_empty_ruby_project_spec.rb @@ -22,6 +22,15 @@ expect(result["spec/spec_helper.rb"]).to include('require_relative "../boot/finish"') end + it "uses the current foobara version as the minimum dependency" do + expect(outcome).to be_success + + current_version = Gem.loaded_specs["foobara"].version.to_s + gemspec_path = result.keys.find { |path| path.end_with?(".gemspec") } + + expect(result.fetch(gemspec_path)).to include(">= #{current_version}") + end + it "uses the generated project library path in the README" do expect(outcome).to be_success diff --git a/src/generators/gemspec_generator.rb b/src/generators/gemspec_generator.rb index 1d3a521..fc8cbd4 100644 --- a/src/generators/gemspec_generator.rb +++ b/src/generators/gemspec_generator.rb @@ -12,6 +12,10 @@ def template_path def target_path "#{kebab_case_full_project_name}.gemspec" end + + def current_foobara_version + Gem.loaded_specs["foobara"].version + end end end end diff --git a/templates/gemspec.gemspec.erb b/templates/gemspec.gemspec.erb index b8e8f98..4cb623d 100644 --- a/templates/gemspec.gemspec.erb +++ b/templates/gemspec.gemspec.erb @@ -23,7 +23,7 @@ Gem::Specification.new do |spec| "CHANGELOG.md" ] - spec.add_dependency "foobara", ">= 0.0.136", "< 2.0.0" + spec.add_dependency "foobara", ">= <%= current_foobara_version %>", "< 2.0.0" spec.require_paths = ["lib"] spec.metadata["rubygems_mfa_required"] = "true"