I currently have:
describe 'least number of moves from x to y' do
it 'has a populated chessboard' do
@wp='white-pawn'
@bp='black-pawn'
expect(ChessBoard.new.populate_new_board).to eq [
['white-castle','white-knight','white-bishop','white-queen','white-king','white-bishop','white-knight','white-castle'],
[@wp,@wp,@wp,@wp,@wp,@wp,@wp,@wp],
[nil,nil,nil,nil,nil,nil,nil,nil],
[nil,nil,nil,nil,nil,nil,nil,nil],
[nil,nil,nil,nil,nil,nil,nil,nil],
[nil,nil,nil,nil,nil,nil,nil,nil],
[@bp,@bp,@bp,@bp,@bp,@bp,@bp,@bp],
['black-castle','black-knight','black-bishop','black-king','black-queen','black-bishop','black-knight','black-castle']]
end
which works ok.
I want to change to use let!, so I tried:
describe 'least number of moves from x to y' do
let!(:wp){'white-pawn'}
let!(:bp){'black-pawn'}
it 'has a populated chessboard' do
expect(ChessBoard.new.populate_new_board).to eq [
['white-castle','white-knight','white-bishop','white-queen','white-king','white-bishop','white-knight','white-castle'],
[@wp,@wp,@wp,@wp,@wp,@wp,@wp,@wp],
[nil,nil,nil,nil,nil,nil,nil,nil],
[nil,nil,nil,nil,nil,nil,nil,nil],
[nil,nil,nil,nil,nil,nil,nil,nil],
[nil,nil,nil,nil,nil,nil,nil,nil],
[@bp,@bp,@bp,@bp,@bp,@bp,@bp,@bp],
['black-castle','black-knight','black-bishop','black-king','black-queen','black-bishop','black-knight','black-castle']]
end
but it fails because I now get nil for all the @bp and @wp values.
How to fix, i.e. write the let syntax correct for the expect?