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 38 39
|
# frozen_string_literal: true
require "guard/watcher/pattern"
RSpec.describe Guard::Watcher::Pattern do
describe ".create" do
subject { described_class.create(pattern) }
context "when a string is given" do
let(:pattern) { "foo.rb" }
it { is_expected.to be_a(described_class::SimplePath) }
end
context "when a Pathname is given" do
let(:pattern) { Pathname("foo.rb") }
it { is_expected.to be_a(described_class::PathnamePath) }
end
context "when an regexp string is given" do
let(:pattern) { "^foo.*$" }
it { is_expected.to be_a(described_class::Matcher) }
it "shows a warning" do
expect(described_class::DeprecatedRegexp)
.to receive(:show_deprecation).with(pattern)
subject
end
end
context "when a regexp is given" do
let(:pattern) { /foo\.rb/ }
it { is_expected.to be_a(described_class::Matcher) }
end
context "when a custom matcher" do
let(:pattern) { Class.new { def match; end } }
it { is_expected.to be_a(described_class::Matcher) }
end
end
end
|