Commit f9b35f55 authored by Matthias Kaeppler's avatar Matthias Kaeppler

Fix test runtime ID not working with bin/spring

The problem was that when running under `spring`, the process name is
not `rspec` anymore. I think we don't need to test
the process name anyway, we can instead rely on just `Rails.env`.
parent b9765bd3
......@@ -16,7 +16,7 @@ module Gitlab
matches << :console if console?
matches << :sidekiq if sidekiq?
matches << :rake if rake?
matches << :rspec if rspec?
matches << :test_suite if test_suite?
if matches.one?
matches.first
......@@ -48,8 +48,8 @@ module Gitlab
!!(defined?(::Rake) && Rake.application.top_level_tasks.any?)
end
def rspec?
Rails.env.test? && process_name == 'rspec'
def test_suite?
Rails.env.test?
end
def console?
......@@ -64,10 +64,6 @@ module Gitlab
puma? || sidekiq?
end
def process_name
File.basename($0)
end
def max_threads
if puma?
Puma.cli_config.options[:max_threads]
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::Runtime do
before do
allow(described_class).to receive(:process_name).and_return('ruby')
stub_rails_env('production')
end
context "when unknown" do
......@@ -47,7 +48,7 @@ describe Gitlab::Runtime do
expect(subject.sidekiq?).to be(false)
expect(subject.console?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
......@@ -74,7 +75,7 @@ describe Gitlab::Runtime do
expect(subject.sidekiq?).to be(false)
expect(subject.console?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
......@@ -106,7 +107,7 @@ describe Gitlab::Runtime do
expect(subject.puma?).to be(false)
expect(subject.console?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
......@@ -131,7 +132,7 @@ describe Gitlab::Runtime do
expect(subject.sidekiq?).to be(false)
expect(subject.puma?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
......@@ -139,14 +140,14 @@ describe Gitlab::Runtime do
end
end
context "rspec" do
context "test suite" do
before do
allow(described_class).to receive(:process_name).and_return('rspec')
stub_rails_env('test')
end
it "identifies itself" do
expect(subject.identify).to eq(:rspec)
expect(subject.rspec?).to be(true)
expect(subject.identify).to eq(:test_suite)
expect(subject.test_suite?).to be(true)
end
it "does not identify as others" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment