lundi 4 mai 2020

Subject (a class) returns itself in a method

I'm doing an exercise on a course and I have to write code to make the following test pass:

  it 'returns itself when exiting a journey' do
    expect(subject.finish(station)).to eq(subject)
  end

I've written:

    class Journey
      ...
      def finish(station)
        Journey
      end
      ...
    end

I get the error:

expected: #<Journey:0x00007fd90091e7c8>
            got: Journey

       (compared using ==)

       Diff:
       @@ -1,2 +1,2 @@
       -#<Journey:0x00007fd90091e7c8>
       +Journey

It felt a bit too easy when I was writing it but I'm not sure how else to go about this. Any help would be greatly appreciated, thanks!

Aucun commentaire:

Enregistrer un commentaire