spec/apkstats_spec.rb in danger-apkstats-0.2.0 vs spec/apkstats_spec.rb in danger-apkstats-0.3.0
- old
+ new
@@ -2,25 +2,70 @@
require File.expand_path("spec_helper", __dir__)
module Danger
describe Danger::DangerApkstats do
+ before do
+ ENV.delete("ANDROID_HOME")
+ ENV.delete("ANDROID_SDK_ROOT")
+ end
+
it "should be a plugin" do
expect(Danger::DangerApkstats.new(nil)).to be_a Danger::Plugin
end
- #
- # You should test your custom attributes and methods here
- #
describe "with Dangerfile" do
- before do
- @dangerfile = testing_dangerfile
- @my_plugin = @dangerfile.apkstats
+ let(:dangerfile) { testing_dangerfile }
+ let(:apkstats) { dangerfile.apkstats }
- # mock the PR data
- # you can then use this, eg. github.pr_author, later in the spec
+ before do
json = File.read(fixture_path + "github_pr.json")
- allow(@my_plugin.github).to receive(:pr_json).and_return(json)
+ allow(apkstats.github).to receive(:pr_json).and_return(json)
+ end
+
+ # compatibility
+ describe "#command_path=" do
+ context "unless command_path is given" do
+ it { expect { apkstats.send(:apkanalyzer_command) }.to raise_error(Danger::DangerApkstats::Error) }
+
+ context "with ANDROID_HOME" do
+ before do
+ ENV["ANDROID_HOME"] = "dummy"
+ end
+
+ it { expect(apkstats.send(:apkanalyzer_command)).to be_kind_of(Apkstats::Command::ApkAnalyzer) }
+ end
+ end
+
+ context "if command_path is given" do
+ before do
+ apkstats.command_path = "dummy"
+ end
+
+ it { expect(apkstats.send(:apkanalyzer_command)).to be_kind_of(Apkstats::Command::ApkAnalyzer) }
+ end
+ end
+
+ describe "#apkanalyzer_path=" do
+ context "unless analyzer_path is given" do
+ it { expect { apkstats.send(:apkanalyzer_command) }.to raise_error(Danger::DangerApkstats::Error) }
+
+ context "with ANDROID_HOME" do
+ before do
+ ENV["ANDROID_HOME"] = "dummy"
+ end
+
+ it { expect(apkstats.send(:apkanalyzer_command)).to be_kind_of(Apkstats::Command::ApkAnalyzer) }
+ end
+ end
+
+ context "if analyzer_path is given" do
+ before do
+ apkstats.apkanalyzer_path = "dummy"
+ end
+
+ it { expect(apkstats.send(:apkanalyzer_command)).to be_kind_of(Apkstats::Command::ApkAnalyzer) }
+ end
end
end
end
end