File: association_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 (38 lines) | stat: -rw-r--r-- 1,206 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
describe FactoryBot::Declaration::Association do
  describe "#==" do
    context "when the attributes are equal" do
      it "the objects are equal" do
        declaration = described_class.new(:name, options: true)
        other_declaration = described_class.new(:name, options: true)

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

    context "when the names are different" do
      it "the objects are NOT equal" do
        declaration = described_class.new(:name, options: true)
        other_declaration = described_class.new(:other_name, options: true)

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

    context "when the options are different" do
      it "the objects are NOT equal" do
        declaration = described_class.new(:name, options: true)
        other_declaration = described_class.new(:name, other_options: true)

        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)

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