1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/spec/factory_bot/null_object_spec.rb
Avielle c716ce01b4 Replace 'girl' with 'bot' everywhere (#1051)
Also: add a deprecation warning to factory_girl, asking users to switch to
factory_bot

https://github.com/thoughtbot/factory_girl/issues/921
2017-10-20 15:20:28 -04:00

22 lines
703 B
Ruby

require "spec_helper"
describe FactoryBot::NullObject do
let(:methods_to_respond_to) { %w[id age name admin?] }
let(:methods_to_not_respond_to) { %w[email date_of_birth title] }
subject { FactoryBot::NullObject.new(methods_to_respond_to) }
it "responds to the given methods" do
methods_to_respond_to.each do |method_name|
expect(subject.__send__(method_name)).to be_nil
expect(subject).to respond_to(method_name)
end
end
it "does not respond to other methods" do
methods_to_not_respond_to.each do |method_name|
expect { subject.__send__(method_name) }.to raise_error(NoMethodError)
expect(subject).not_to respond_to(method_name)
end
end
end