File: dynamic_spec.rb

package info (click to toggle)
ruby-factory-bot 6.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,372 kB
  • sloc: ruby: 7,827; makefile: 6
file content (50 lines) | stat: -rw-r--r-- 1,574 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
44
45
46
47
48
49
50
describe FactoryBot::Declaration::Dynamic do
  describe "#==" do
    context "when the attributes are equal" do
      it "the objects are equal" do
        block = -> {}
        declaration = described_class.new(:name, false, block)
        other_declaration = described_class.new(:name, false, block)

        expect(declaration).to eq(other_declaration)
      end
    end

    context "when the names are different" do
      it "the objects are NOT equal" do
        block = -> {}
        declaration = described_class.new(:name, false, block)
        other_declaration = described_class.new(:other_name, false, block)

        expect(declaration).not_to eq(other_declaration)
      end
    end

    context "when the blocks are different" do
      it "the objects are NOT equal" do
        declaration = described_class.new(:name, false, -> {})
        other_declaration = described_class.new(:name, false, -> {})

        expect(declaration).not_to eq(other_declaration)
      end
    end

    context "when one is ignored and the other isn't" do
      it "the objects are NOT equal" do
        block = -> {}
        declaration = described_class.new(:name, false, block)
        other_declaration = described_class.new(:name, true, block)

        expect(declaration).not_to eq(other_declaration)
      end
    end

    context "when comparing against another type of object" do
      it "the objects are NOT equal" do
        declaration = described_class.new(:name, false, -> {})

        expect(declaration).not_to eq(:not_a_declaration)
      end
    end
  end
end