mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Refactors strategy_calculator_spec.rb to conform to Let's Not style (#1351)
This commit is contained in:
parent
a40b555cb0
commit
ba3b937111
1 changed files with 15 additions and 21 deletions
|
@ -1,30 +1,24 @@
|
|||
describe FactoryBot::StrategyCalculator do
|
||||
let(:strategy) do
|
||||
define_class("MyAwesomeClass")
|
||||
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
|
||||
|
||||
context "when a class" do
|
||||
subject { FactoryBot::StrategyCalculator.new(strategy).strategy }
|
||||
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
|
||||
|
||||
it "returns the class passed" do
|
||||
expect(subject).to eq strategy
|
||||
end
|
||||
expect(FactoryBot::Internal).to have_received(:strategy_by_name).with(:build)
|
||||
end
|
||||
|
||||
context "when a symbol" do
|
||||
before do
|
||||
allow(FactoryBot::Internal).to receive(:strategy_by_name).and_return(strategy)
|
||||
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
|
||||
|
||||
subject { FactoryBot::StrategyCalculator.new(:build).strategy }
|
||||
|
||||
it "finds the strategy by name" do
|
||||
subject
|
||||
expect(FactoryBot::Internal).to have_received(:strategy_by_name).with(:build)
|
||||
end
|
||||
|
||||
it "returns the strategy found" do
|
||||
expect(subject).to eq strategy
|
||||
end
|
||||
expect(calculator).to eq strategy
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue