Files
ubicloud/rhizome/host/spec/vm_path_spec.rb
Daniel Farina 505340b2a5 Update rubocop-rspec to 2.26.0 and fix new style checks
As-is, automated upgrade patch generation fails CI with these style
issues:

    rhizome/host/spec/storage_volume_spec.rb:96:9: C: [Correctable] RSpec/ExampleWording: Do not use the future tense when describing your tests.
        it "will retry after purging if spdk artifacts exist" do
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    rhizome/host/spec/storage_volume_spec.rb:106:9: C: [Correctable] RSpec/ExampleWording: Do not use the future tense when describing your tests.
        it "won't retry more than once" do
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
    rhizome/host/spec/vm_path_spec.rb:16:7: C: [Correctable] RSpec/ExampleWording: Do not use the future tense when describing your tests.
      it "will snakeify difficult characters" do
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    spec/lib/clog_spec.rb:11:7: C: [Correctable] RSpec/ExampleWording: Do not use the future tense when describing your tests.
      it "will add the thread name to the structure data, if defined" do
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

So, handle them and update rubocop-rspec.
2024-01-05 09:23:40 +03:00

37 lines
1005 B
Ruby

# frozen_string_literal: true
require_relative "../lib/vm_path"
RSpec.describe VmPath do
subject(:vp) { described_class.new("test'vm") }
it "can compute a path" do
expect(vp.guest_ephemeral).to eq("/vm/test'vm/guest_ephemeral")
end
it "can escape a path" do
expect(vp.q_guest_ephemeral).to eq("/vm/test\\'vm/guest_ephemeral")
end
it "snakifies difficult characters" do
expect(vp.serial_log).to eq("/vm/test'vm/serial.log")
end
it "can read file contents" do
expect(File).to receive(:read).with(vp.serial_log).and_return("\n")
expect(vp.read_serial_log).to eq("")
end
context "when writing" do
it "affixes a newline if it is missing" do
expect(File).to receive(:write).with(vp.serial_log, "test content\n")
vp.write_serial_log("test content")
end
it "doesn't add more newlines than necessary" do
expect(File).to receive(:write).with(vp.serial_log, "test content\n")
vp.write_serial_log("test content\n")
end
end
end