spec/iblinter_spec.rb in danger-iblinter-0.0.4 vs spec/iblinter_spec.rb in danger-iblinter-0.0.5
- old
+ new
@@ -2,13 +2,37 @@
require File.expand_path("spec_helper", __dir__)
require_relative "../lib/iblinter/iblinter"
describe IBLinterRunner do
- it "command arguments works" do
- binary_path = File.absolute_path "path/to/binary"
- options = {}
- cmd = "#{binary_path} lint --reporter json"
- iblinter = IBLinterRunner.new(binary_path)
- expect(iblinter.lint_command(options)).to eq cmd
+ let(:options) { {} }
+ let(:cmd) { "swift run iblinter lint --reporter json" }
+ let(:binary_path) { nil }
+ let(:execute_command) { nil }
+ let(:iblinter) { IBLinterRunner.new(binary_path, execute_command) }
+
+ context "binary_path is passed" do
+ let(:binary_path) { File.absolute_path "path/to/binary" }
+ let(:cmd) { "#{binary_path} lint --reporter json" }
+
+ it "should return valid command" do
+ expect(iblinter.lint_command(options)).to eq cmd
+ end
+ end
+
+ context "execute_command is passed" do
+ let(:execute_command) { "swift run iblinter" }
+
+ it "should return valid command" do
+ expect(iblinter.lint_command(options)).to eq cmd
+ end
+ end
+
+ context "binary_path and execute_command are passed" do
+ let(:execute_command) { "swift run iblinter" }
+ let(:binary_path) { File.absolute_path "path/to/binary" }
+
+ it "should ignore binary_path" do
+ expect(iblinter.lint_command(options)).to eq cmd
+ end
end
end