I am new to rspec and ruby and am having trouble writing a test for the following method using doubles etc.
def choices player1_choice, player2_choice
@choices_array = [player1_choice, player2_choice]
Here is a basic unit test for this method. You would not need to use a double for this method.
describe YourClassName do context "#choices" do it "should return an array with 2 player choices" do player1_choice = "a" player2_choice = "b" output = choices(player1_choice, player2_choice) expect(output.count).to eq(2) expect(output).to eq(player1_choice) expect(output).to eq(player2_choice) end end end
Doubles/stubs are usually used around methods/objects that contain complex operations such as a network connection, integrating with a 3rd party library without implementation details, etc.