File: private_attributes_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 (19 lines) | stat: -rw-r--r-- 334 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
describe "setting private attributes" do
  it "raises a NoMethodError" do
    define_class("User") do
      private

      attr_accessor :foo
    end

    FactoryBot.define do
      factory :user do
        foo { 123 }
      end
    end

    expect {
      FactoryBot.build(:user)
    }.to raise_error NoMethodError, /foo=/
  end
end