File: pathname_path_spec.rb

package info (click to toggle)
ruby-guard 2.18.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,344 kB
  • sloc: ruby: 9,256; makefile: 6
file content (37 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require "guard/watcher/pattern/pathname_path"

RSpec.describe Guard::Watcher::Pattern::PathnamePath do
  subject { described_class.new(path) }
  describe "#match result" do
    subject { described_class.new(path).match(filename) }
    context "when constructed with an unclean Pathname" do
      let(:path) { Pathname("./foo.rb") }

      context "when matched file is a string" do
        context "when filename matches" do
          let(:filename) { "foo.rb" }
          specify { expect(subject).to eq([Pathname("foo.rb")]) }
        end

        context "when filename does not match" do
          let(:filename) { "bar.rb" }
          specify { expect(subject).to be_nil }
        end
      end

      context "when matched file is an unclean Pathname" do
        context "when filename matches" do
          let(:filename) { Pathname("./foo.rb") }
          specify { expect(subject).to eq([Pathname("foo.rb")]) }
        end

        context "when filename does not match" do
          let(:filename) { Pathname("./bar.rb") }
          specify { expect(subject).to be_nil }
        end
      end
    end
  end
end