diff options
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 7cad5c04a4..0bdf8ecba8 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -419,7 +419,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 @@ -502,7 +502,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 @@ -535,6 +535,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" @@ -542,7 +599,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 @@ -655,7 +712,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) |