Refactor each before(:each) into separate methods.
Reason: So you don't create a bunch of cards that aren't used for most tests.
I believe you can define methods in specs, so here's some sample code:
...
def counter
@counter ||= Counter.new([Card.new('J', 'Hearts'),
Card.new('2', 'Hearts'),
Card.new('3', 'Hearts'),
Card.new('4', 'Hearts')],
Card.new('5', 'Hearts'))
end
def bad_counter
@bad_counter =|| Counter.new([Card.new('J', 'Clubs'),
Card.new('2', 'Hearts'),
Card.new('3', 'Hearts'),
Card.new('4', 'Hearts')],
Card.new('5', 'Hearts'))
end
...
describe '#right_jack_score' do
it 'has a score of one with right jack' do
expect(counter.right_jack_score).to eq 1
end // it
it 'has a score of zero with wrong jack' do
expect(bad_counter.right_jack_score).to eq 0
end // it
end /// describe #right_jack_score
Refactor each before(:each) into separate methods. Reason: So you don't create a bunch of cards that aren't used for most tests.
I believe you can define methods in specs, so here's some sample code: