diff --git a/spec/integration/editor_spec.rb b/spec/integration/editor_spec.rb index 5ac904c..4adcf99 100644 --- a/spec/integration/editor_spec.rb +++ b/spec/integration/editor_spec.rb @@ -37,7 +37,7 @@ expect { status = described_class.open("newfile.txt", text: "Some text", - command: editor_command) + command: editor_command) }.to output(/Some text/).to_stdout_from_any_process expect(status).to eq(true) @@ -70,7 +70,8 @@ editor_command = "ruby #{fixtures_path("echo.rb")}" expect { - described_class.open("newfile1.txt", "newfile2.txt", text: "Some text", + described_class.open("newfile1.txt", "newfile2.txt", + text: "Some text", command: editor_command) }.to output(/newfile1\.txt newfile2\.txt/).to_stdout_from_any_process @@ -100,7 +101,7 @@ "\e[2K\e[1G\e[1A" * 3, "\e[2K\e[1G\e[J", "Select an editor? \e[32m#{echo}\e[0m\n", - "\e[1A\e[2K\e[1G", + "\e[1A\e[2K\e[1G" ].join expect { @@ -133,7 +134,7 @@ "\e[2K\e[1G\e[1A" * 3, "\e[2K\e[1G\e[J", "Which one do you fancy? \e[32m#{cat}\e[0m\n", - "\e[1A\e[2K\e[1G", + "\e[1A\e[2K\e[1G" ].join expect { diff --git a/spec/unit/available_spec.rb b/spec/unit/available_spec.rb index da856c4..71e5bc2 100644 --- a/spec/unit/available_spec.rb +++ b/spec/unit/available_spec.rb @@ -41,7 +41,7 @@ allow(described_class).to receive(:exist?).with("vim").and_return(true) allow(described_class).to receive(:exist?).with("emacs").and_return(true) - expect(described_class.available).to eql(["vim", "emacs"]) + expect(described_class.available).to eql(%w[vim emacs]) end it "doesn't find any text editor" do diff --git a/spec/unit/command_path_spec.rb b/spec/unit/command_path_spec.rb index da015f8..dd60d51 100644 --- a/spec/unit/command_path_spec.rb +++ b/spec/unit/command_path_spec.rb @@ -11,8 +11,8 @@ allow(editor).to receive(:system).and_return(true) editor.open(filename) - expect(editor).to have_received(:system). - with({}, "vim", "/usr/bin/hello world.rb") + expect(editor).to have_received(:system) + .with({}, "vim", "/usr/bin/hello world.rb") end it "escapes path separators on Windows" do @@ -25,7 +25,7 @@ allow(editor).to receive(:system).and_return(true) editor.open(filename) - expect(editor).to have_received(:system). - with({}, "vim", "C:\\User\\hello world.rb") + expect(editor).to have_received(:system) + .with({}, "vim", "C:\\User\\hello world.rb") end end diff --git a/spec/unit/command_spec.rb b/spec/unit/command_spec.rb index 37ae0bf..6a04c6f 100644 --- a/spec/unit/command_spec.rb +++ b/spec/unit/command_spec.rb @@ -54,7 +54,7 @@ end it "finds more than one editor" do - allow(described_class).to receive(:available).and_return(["vim", "emacs"]) + allow(described_class).to receive(:available).and_return(%w[vim emacs]) prompt = spy(:prompt, enum_select: "vim", up: "", clear_line: "") allow(TTY::Prompt).to receive(:new).and_return(prompt) @@ -64,7 +64,7 @@ end it "doesn't show menu choice when disabled" do - allow(described_class).to receive(:available).and_return(["vim", "emacs"]) + allow(described_class).to receive(:available).and_return(%w[vim emacs]) allow(TTY::Prompt).to receive(:new) editor = described_class.new(show_menu: false) diff --git a/spec/unit/new_spec.rb b/spec/unit/new_spec.rb index 924c8f7..9d4a821 100644 --- a/spec/unit/new_spec.rb +++ b/spec/unit/new_spec.rb @@ -13,4 +13,3 @@ expect(editor.env).to eq({"FOO" => "bar"}) end end - diff --git a/spec/unit/open_spec.rb b/spec/unit/open_spec.rb index 222fce7..98346dd 100644 --- a/spec/unit/open_spec.rb +++ b/spec/unit/open_spec.rb @@ -95,16 +95,19 @@ end it "fails to open editor with unknown command" do - allow(described_class).to receive(:available).with(:unknown).and_return(["unknown"]) + allow(described_class).to receive(:available).with(:unknown) + .and_return(["unknown"]) editor = described_class.new(command: :unknown) status = editor.open(fixtures_path("content.txt")) expect(status).to eq(false) end it "fails to open editor with unknown command and raises" do - allow(described_class).to receive(:available).with(:unknown).and_return(["unknown"]) + allow(described_class).to receive(:available).with(:unknown) + .and_return(["unknown"]) expect { - described_class.open(fixtures_path("content.txt"), command: :unknown, + described_class.open(fixtures_path("content.txt"), + command: :unknown, raise_on_failure: true) }.to raise_error(TTY::Editor::CommandInvocationError) end