Skip to content

Commit

Permalink
simplify test fixture setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonabc committed Feb 21, 2023
1 parent 7c00e00 commit 807d6fb
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions test/sources/gradle_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

if Licensed::Shell.tool_available?("gradle")
describe Licensed::Sources::Gradle do
let(:opts) { { "source_path" => fixtures, "root" => root } }
let(:config) { Licensed::AppConfiguration.new(opts) }
let(:source) { Licensed::Sources::Gradle.new(config) }

describe "Single project" do
let(:fixtures) { File.expand_path("../../fixtures/gradle/single_project", __FILE__) }
let(:config) { Licensed::AppConfiguration.new({ "source_path" => Dir.pwd, "root" => fixtures }) }
let(:source) { Licensed::Sources::Gradle.new(config) }
let(:root) { File.expand_path("../../fixtures/gradle/single_project", __FILE__) }
let(:fixtures) { root }

describe "enabled?" do
it "is true if build.gradle exists and gradle is available" do
Expand Down Expand Up @@ -53,20 +56,10 @@
end

describe "Multi project" do
let(:fixtures) { File.expand_path("../../fixtures/gradle/multi_project", __FILE__) }
let(:config) { Licensed::Configuration.new({
"apps" => [{ "source_path" => "#{Dir.pwd}/lib" }, { "source_path" => "#{Dir.pwd}/app" }],
"gradle" => { "configurations" => "runtimeClasspath" },
"root" => fixtures
})
}
let(:appConfig) { config.apps.last }
let(:libConfig) { config.apps.last }
let(:source) { Licensed::Sources::Gradle.new(appConfig) }
let(:root) { File.expand_path("../../fixtures/gradle/multi_project", __FILE__) }

describe "app subproject" do
let(:appConfig) { config.apps.last }
let(:source) { Licensed::Sources::Gradle.new(appConfig) }
let(:fixtures) { File.join(root, "app") }

describe "enabled?" do
it "is true if build.gradle exists and gradle is available" do
Expand Down Expand Up @@ -111,8 +104,8 @@
end

describe "lib subproject" do
let(:appConfig) { config.apps.first }
let(:source) { Licensed::Sources::Gradle.new(appConfig) }
let(:fixtures) { File.join(root, "lib") }

describe "enabled?" do
it "is true if build.gradle exists and gradle is available" do
Dir.chdir(fixtures) do
Expand Down Expand Up @@ -159,7 +152,7 @@

describe Licensed::Sources::Gradle::Dependency do
let(:fixtures) { File.expand_path("../../fixtures/gradle/single_project", __FILE__) }
let(:config) { Licensed::AppConfiguration.new({ "source_path" => Dir.pwd, "root" => fixtures }) }
let(:config) { Licensed::AppConfiguration.new({ "source_path" => fixtures, "root" => fixtures }) }
let(:source) { Licensed::Sources::Gradle.new(config) }

it "returns the dependency license" do
Expand Down

0 comments on commit 807d6fb

Please sign in to comment.