diff options
author | Kouhei Sutou <kou@clear-code.com> | 2019-12-11 14:02:33 +0900 |
---|---|---|
committer | Sutou Kouhei <kou@clear-code.com> | 2019-12-11 16:17:54 +0900 |
commit | 27f5e98aaee329219d4ffdd52f4da876c5e84f22 (patch) | |
tree | 54b2c123eed6d909e510379725ce73f972f8976a /spec | |
parent | bada03dd6d4d15828fb5b2cf7f744948e88a69a3 (diff) | |
download | bundler-27f5e98aaee329219d4ffdd52f4da876c5e84f22.tar.gz |
bundler gem: Support test-unit as a testing framework
Diffstat (limited to 'spec')
-rw-r--r-- | spec/commands/newgem_spec.rb | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index 2c8ab4b5ef..6c2fcb6e92 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -420,7 +420,7 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/spec/#{require_path}_spec.rb")).to_not exist expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to_not exist expect(bundled_app("#{gem_name}/test/#{require_path}.rb")).to_not exist - expect(bundled_app("#{gem_name}/test/minitest_helper.rb")).to_not exist + expect(bundled_app("#{gem_name}/test/test_helper.rb")).to_not exist end end @@ -503,7 +503,7 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/test/test_helper.rb").read).to include(%(require "#{require_path}")) end - it "requires 'minitest_helper'" do + it "requires 'test_helper'" do expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include(%(require "test_helper")) end @@ -536,6 +536,63 @@ RSpec.describe "bundle gem" do end end + context "--test parameter set to test-unit" do + before do + bundle "gem #{gem_name} --test=test-unit" + end + + it "depends on a specific version of test-unit" do + Dir.chdir(bundled_app(gem_name)) do + builder = Bundler::Dsl.new + builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile")) + builder.dependencies + test_unit_dep = builder.dependencies.find {|d| d.name == "test-unit" } + expect(test_unit_dep).to be_specific + end + end + + it "builds spec skeleton" do + expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb")).to exist + expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist + end + + it "requires the main file" do + expect(bundled_app("#{gem_name}/test/test_helper.rb").read).to include(%(require "#{require_path}")) + end + + it "requires 'test_helper'" do + expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include(%(require "test_helper")) + end + + it "creates a default test which fails" do + expect(bundled_app("#{gem_name}/test/#{require_path}_test.rb").read).to include("assert_equal(\"expected\", \"actual\")") + end + end + + context "gem.test setting set to test-unit" do + before do + bundle "config set gem.test test-unit" + bundle "gem #{gem_name}" + end + + it "creates a default rake task to run the test suite" do + rakefile = strip_whitespace <<-RAKEFILE + require "bundler/gem_tasks" + require "rake/testtask" + + Rake::TestTask.new(:test) do |t| + t.libs << "test" + t.libs << "lib" + t.test_files = FileList["test/**/*_test.rb"] + end + + task :default => :test + RAKEFILE + + expect(bundled_app("#{gem_name}/Rakefile").read).to eq(rakefile) + end + end + context "--test with no arguments" do before do bundle "gem #{gem_name} --test" @@ -543,7 +600,7 @@ RSpec.describe "bundle gem" do it "defaults to rspec" do expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to exist - expect(bundled_app("#{gem_name}/test/minitest_helper.rb")).to_not exist + expect(bundled_app("#{gem_name}/test/test_helper.rb")).to_not exist end it "creates a .travis.yml file to test the library against the current Ruby version on Travis CI" do @@ -647,7 +704,7 @@ RSpec.describe "bundle gem" do ext.lib_dir = "lib/#{gem_name}" end - task :default => [:clobber, :compile, :spec] + task :default => [:clobber, :compile] RAKEFILE expect(bundled_app("#{gem_name}/Rakefile").read).to eq(rakefile) |