summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-02-26 15:24:21 -0700
committermo khan <mo.khan@gmail.com>2020-02-26 15:24:21 -0700
commit856c2e8429696a94b116c28e5c20687f71da197e (patch)
tree469e433d6d690ba17c3333e02a8579801fb93cd8
parent7ce136081df3b6d60d010b9fc66f313ea87f992f (diff)
Extract fixture file helper
-rw-r--r--spec/fixtures/build.gradle.kts11
-rw-r--r--spec/integration/java/gradle_spec.rb16
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/fixture_file_helper.rb5
4 files changed, 19 insertions, 15 deletions
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