File: ruby_project_spec.rb

package info (click to toggle)
ruby-rspec 3.13.0c0e0m0s1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,856 kB
  • sloc: ruby: 70,868; sh: 1,423; makefile: 99
file content (51 lines) | stat: -rw-r--r-- 1,578 bytes parent folder | download | duplicates (6)
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
40
41
42
43
44
45
46
47
48
49
50
51
module RSpec
  module Core
    RSpec.describe RubyProject do

      describe "#determine_root" do

        context "with ancestor containing spec directory" do
          it "returns ancestor containing the spec directory" do
            allow(RubyProject).to receive(:ascend_until).and_return('foodir')
            expect(RubyProject.determine_root).to eq("foodir")
          end
        end

        context "without ancestor containing spec directory" do
          it "returns current working directory" do
            allow(RubyProject).to receive(:find_first_parent_containing).and_return(nil)
            expect(RubyProject.determine_root).to eq(".")
          end
        end

      end

      describe "#ascend_until" do
        subject { RubyProject }

        def expect_ascend(source_path, *yielded_paths)
          expect { |probe|
            allow(File).to receive(:expand_path).with('.') { source_path }
            subject.ascend_until(&probe)
          }.to yield_successive_args(*yielded_paths)
        end

        it "works with a normal path" do
          expect_ascend("/var/ponies", "/var/ponies", "/var", "/")
        end

        it "works with a path with a trailing slash" do
          expect_ascend("/var/ponies/", "/var/ponies", "/var", "/")
        end

        it "works with a path with double slashes" do
          expect_ascend("/var//ponies/", "/var/ponies", "/var", "/")
        end

        it "works with a path with escaped slashes" do
          expect_ascend("/var\\/ponies/", "/var\\/ponies", "/")
        end
      end
    end
  end
end