File: definition_file_paths_spec.rb

package info (click to toggle)
ruby-factory-bot-rails 6.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 316 kB
  • sloc: ruby: 635; makefile: 6; sh: 4
file content (43 lines) | stat: -rw-r--r-- 1,398 bytes parent folder | download | duplicates (3)
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
# frozen_string_literal: true

describe FactoryBotRails::DefinitionFilePaths do
  describe "#files" do
    it "returns a list of definition files that only exist" do
      definition_file_paths = ["spec/fixtures/factories", "not_exist_directory"]

      files = described_class.new(definition_file_paths).files

      expect(files).to eq ["spec/fixtures/factories.rb"]
    end
  end

  describe "#directories" do
    it "returns a hash of definition directories that only exist" do
      definition_file_paths = ["spec/fixtures/factories", "not_exist_directory"]

      directories = described_class.new(definition_file_paths).directories

      expect(directories).to eq(
        "spec/fixtures/factories" => [:rb]
      )
    end

    it "converts Pathname objects to strings" do
      definition_file_paths = [Pathname.new("spec/fixtures/factories")]

      directories = described_class.new(definition_file_paths).directories

      expect(directories).to eq("spec/fixtures/factories" => [:rb])
    end
  end

  describe "#any?" do
    it "returns true only if definition file paths exist" do
      definition_file_paths = ["spec/fixtures/factories", "not_exist_directory"]
      expect(described_class.new(definition_file_paths).any?).to eq true

      definition_file_paths = ["not_exist_directory"]
      expect(described_class.new(definition_file_paths).any?).to eq false
    end
  end
end