Help with Specify

8 views
Skip to first unread message

Alexander Karsten

unread,
May 26, 2015, 10:34:57 AM5/26/15
to rs...@googlegroups.com
Hello,

I am trying to learn RSpec by building a connect four game. I have a board class, that stores the game board as an array and I'm trying to validate the dimensions of the array.
However I feel like im going horribly wrong here and hours of googling were to no help.

How do I do this right?

  context "board array" do
    specify { expect(subject.board).to be_a Array }

    specify { expect(subject.board.length).to eq 6 }

    specify { expect(subject.board.all? { |row| row.length == 7 }).to be_truthy }
  end

Thank you very much for your time.

Xavier Shay

unread,
May 26, 2015, 10:37:27 AM5/26/15
to rs...@googlegroups.com
In what way is this not working for you?
 
My guess is likely that you haven't defined `subject`?
 
context do
  subject { Game.new }
  # ...
end
 
Xavier
--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
 

Myron Marston

unread,
May 26, 2015, 10:39:32 AM5/26/15
to rs...@googlegroups.com
What you have there looks fine, assuming that's nested in some parent example group that defines `subject`.  What problem are you having with what you've written?  If you're getting a failure, please paste it in a reply, including the stack trace.

Myron

Reply all
Reply to author
Forward
0 new messages