From 856c2e8429696a94b116c28e5c20687f71da197e Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 26 Feb 2020 15:24:21 -0700 Subject: Extract fixture file helper --- spec/fixtures/build.gradle.kts | 11 +++++++++++ spec/integration/java/gradle_spec.rb | 16 +--------------- spec/spec_helper.rb | 2 ++ spec/support/fixture_file_helper.rb | 5 +++++ 4 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 spec/fixtures/build.gradle.kts create mode 100644 spec/support/fixture_file_helper.rb diff --git a/spec/fixtures/build.gradle.kts b/spec/fixtures/build.gradle.kts new file mode 100644 index 0000000..494fc8b --- /dev/null +++ b/spec/fixtures/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + `java-library` +} +repositories { + jcenter() +} +dependencies { + api("org.apache.commons:commons-math3:3.6.1") + implementation("com.google.guava:guava:28.1-jre") + testImplementation("junit:junit:4.12") +} diff --git a/spec/integration/java/gradle_spec.rb b/spec/integration/java/gradle_spec.rb index f9e7bcc..ddde21c 100644 --- a/spec/integration/java/gradle_spec.rb +++ b/spec/integration/java/gradle_spec.rb @@ -58,21 +58,7 @@ plugins { ].each do |gradle_version| %w{8 11}.each do |java_version| context "when scanning a gradle (v#{gradle_version}) project that uses a kotlin build script" do - let(:build_file_content) do - <<~KOTLIN -plugins { - `java-library` -} -repositories { - jcenter() -} -dependencies { - api("org.apache.commons:commons-math3:3.6.1") - implementation("com.google.guava:guava:28.1-jre") - testImplementation("junit:junit:4.12") -} - KOTLIN - end + let(:build_file_content) { fixture_file_content("build.gradle.kts") } it 'scans a gradle project' do runner.add_file('build.gradle.kts', build_file_content) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1889335..15c9dad 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,10 +2,12 @@ require 'license/management' require 'json' require 'securerandom' require 'json-schema' +require 'support/fixture_file_helper' require 'support/integration_test_helper' require 'support/matchers' RSpec.configure do |config| + config.include FixtureFileHelper config.include IntegrationTestHelper, type: :integration config.define_derived_metadata(file_path: /\/spec\/integration/) do |metadata| metadata[:type] = :integration diff --git a/spec/support/fixture_file_helper.rb b/spec/support/fixture_file_helper.rb new file mode 100644 index 0000000..c98b98a --- /dev/null +++ b/spec/support/fixture_file_helper.rb @@ -0,0 +1,5 @@ +module FixtureFileHelper + def fixture_file_content(path) + IO.read(License::Management.root.join("spec/fixtures/#{path}")) + end +end -- cgit v1.2.3