1
it "should set token of player 1 to X" do
            @game.setplayer1
            @game.player1.should eql "X"
        end

My method

def setplayer1
        @output.player1.eql? "X"        
    end¨

I´am still getting expected:

  Failure/Error: @game.player1.should eql "X"

   expected: "X"
        got: nil

I don´t know where is the problem and why it´s not passing the test.

jikra01
  • 15
  • 2

1 Answers1

1

your setplayer1 doesn't actually set player1 to be any value, so when you access it, its still nil.

A side note, it is more preferred to use <attribute_name>= as your setter method instead of set_<attribute_name>. Note that you can use attr_accessor for to generate simple getters and setters, see What is attr_accessor in Ruby? for more details.