diff options
Diffstat (limited to 'spec/bundler/commands/newgem_spec.rb')
-rw-r--r-- | spec/bundler/commands/newgem_spec.rb | 107 |
1 files changed, 101 insertions, 6 deletions
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 297d380059..ac452a737a 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -12,12 +12,7 @@ RSpec.describe "bundle gem" do def bundle_exec_rubocop prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec")) - rubocop_version = RUBY_VERSION > "2.4" ? "1.7.0" : "0.81.0" - gems = ["minitest", "rake", "rake-compiler", "rspec", "rubocop -v #{rubocop_version}", "test-unit"] - gems.unshift "parallel -v 1.19.2" if RUBY_VERSION < "2.5" - gems += ["rubocop-ast -v 1.4.0"] if rubocop_version == "1.7.0" - path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app(gem_name)) : system_gem_path - realworld_system_gems gems, :path => path + bundle "config set path #{rubocop_gems}", :dir => bundled_app(gem_name) bundle "exec rubocop --debug --config .rubocop.yml", :dir => bundled_app(gem_name) end @@ -351,6 +346,55 @@ RSpec.describe "bundle gem" do end end + shared_examples_for "--github-username option" do |github_username| + before do + bundle "gem #{gem_name} --github-username=#{github_username}" + end + + it "generates a gem skeleton" do + gem_skeleton_assertions + end + + it "contribute URL set to given github username" do + expect(bundled_app("#{gem_name}/README.md").read).not_to include("[USERNAME]") + expect(bundled_app("#{gem_name}/README.md").read).to include("github.com/#{github_username}") + end + end + + shared_examples_for "github_username configuration" do + context "with github_username setting set to some value" do + before do + global_config "BUNDLE_GEM__GITHUB_USERNAME" => "different_username" + bundle "gem #{gem_name}" + end + + it "generates a gem skeleton" do + gem_skeleton_assertions + end + + it "contribute URL set to bundle config setting" do + expect(bundled_app("#{gem_name}/README.md").read).not_to include("[USERNAME]") + expect(bundled_app("#{gem_name}/README.md").read).to include("github.com/different_username") + end + end + + context "with github_username setting set to false" do + before do + global_config "BUNDLE_GEM__GITHUB_USERNAME" => "false" + bundle "gem #{gem_name}" + end + + it "generates a gem skeleton" do + gem_skeleton_assertions + end + + it "contribute URL set to [USERNAME]" do + expect(bundled_app("#{gem_name}/README.md").read).to include("[USERNAME]") + expect(bundled_app("#{gem_name}/README.md").read).not_to include("github.com/bundleuser") + end + end + end + shared_examples_for "generating a gem" do it "generates a gem skeleton" do bundle "gem #{gem_name}" @@ -920,6 +964,57 @@ RSpec.describe "bundle gem" do end end + context "testing --github-username option against git and bundle config settings", :readline do + context "without git config set" do + before do + sys_exec("git config --global --unset github.user") + end + context "with github-username option in bundle config settings set to some value" do + before do + global_config "BUNDLE_GEM__GITHUB_USERNAME" => "different_username" + end + it_behaves_like "--github-username option", "gh_user" + end + + context "with github-username option in bundle config settings set to false" do + before do + global_config "BUNDLE_GEM__GITHUB_USERNAME" => "false" + end + it_behaves_like "--github-username option", "gh_user" + end + end + + context "with git config set" do + context "with github-username option in bundle config settings set to some value" do + before do + global_config "BUNDLE_GEM__GITHUB_USERNAME" => "different_username" + end + it_behaves_like "--github-username option", "gh_user" + end + + context "with github-username option in bundle config settings set to false" do + before do + global_config "BUNDLE_GEM__GITHUB_USERNAME" => "false" + end + it_behaves_like "--github-username option", "gh_user" + end + end + end + + context "testing github_username bundle config against git config settings", :readline do + context "without git config set" do + before do + sys_exec("git config --global --unset github.user") + end + + it_behaves_like "github_username configuration" + end + + context "with git config set" do + it_behaves_like "github_username configuration" + end + end + context "gem naming with underscore", :readline do let(:gem_name) { "test_gem" } |