File: private_attributes_spec.rb

package info (click to toggle)
ruby-factory-bot 6.5.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,492 kB
  • sloc: ruby: 9,242; makefile: 6; sh: 4
file content (19 lines) | stat: -rw-r--r-- 334 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
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