Skip to content

Commit

Permalink
Merge pull request #2118 from newrelic/2117_gemspec_test
Browse files Browse the repository at this point in the history
Create test for agent_helper in gem files
  • Loading branch information
fallwith committed Jul 11, 2023
2 parents c479a08 + 91265ef commit 974fa24
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion newrelic_rpm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Gem::Specification.new do |s|
'homepage_uri' => 'https://newrelic.com/ruby'
}

reject_list = File.read('./.build_ignore').split("\n")
reject_list = File.read(File.expand_path('../.build_ignore', __FILE__)).split("\n")
file_list = `git ls-files -z`.split("\x0").reject { |f| reject_list.any? { |rf| f.start_with?(rf) } }
# test/agent_helper.rb is a requirement for the NewRelic::Agent.require_test_helper public API
test_helper_path = 'test/agent_helper.rb'
Expand Down
22 changes: 22 additions & 0 deletions test/new_relic/gemspec_files_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require 'minitest/autorun'

class GemspecFilesTest < Minitest::Test
def test_the_test_agent_helper_is_shipped_in_the_gem_files
skip if defined?(Rails::VERSION)
skip 'Gemspec test requires a newer version of Rubygems' unless Gem.respond_to?(:open_file)

gem_spec_file_path = File.expand_path('../../../newrelic_rpm.gemspec', __FILE__)

Dir.chdir(File.dirname(gem_spec_file_path)) do
gem_spec = eval(Gem.open_file(gem_spec_file_path, 'r:UTF-8:-', &:read))

assert gem_spec, "Failed to parse '#{gem_spec_file_path}'"
assert_equal('newrelic_rpm', gem_spec.name)
assert_includes(gem_spec.files, 'test/agent_helper.rb')
end
end
end

0 comments on commit 974fa24

Please sign in to comment.