File: strategy_calculator_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 (24 lines) | stat: -rw-r--r-- 938 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
20
21
22
23
24
describe FactoryBot::StrategyCalculator do
  it "returns the class passed when it is instantiated with a class" do
    strategy = define_class("MyAwesomeClass")
    calculator = FactoryBot::StrategyCalculator.new(strategy).strategy

    expect(calculator).to eq strategy
  end

  it "finds the strategy by name when instantiated with a symbol" do
    strategy = define_class("MyAwesomeClass")
    allow(FactoryBot::Internal).to receive(:strategy_by_name).and_return(strategy)
    FactoryBot::StrategyCalculator.new(:build).strategy

    expect(FactoryBot::Internal).to have_received(:strategy_by_name).with(:build)
  end

  it "returns the strategy found when instantiated with a symbol" do
    strategy = define_class("MyAwesomeClass")
    allow(FactoryBot::Internal).to receive(:strategy_by_name).and_return(strategy)
    calculator = FactoryBot::StrategyCalculator.new(:build).strategy

    expect(calculator).to eq strategy
  end
end