On Sat, Oct 29, 2011 at 06:30, Faith Tarcha <faith / centrum.sk> wrote:

> It should also correspond with this code that is in a different ruby
> file (and pass the rake test) :
>
> it "should randomly generate a title for the story" do
>  @story_gen.title.should be_true
>  end

You've already been given some help re making the title.  But now
let's look at the test.  It doesn't seem very meaningful.  It only
means that title should return something that's not either nil or
false (the only two things in Ruby that are false).  You could have it
just return true, "", "this is a title", 1, or even 0, and that test
would pass.

Try to make it also pass these tests:

  it "should generate a two-word title" do
    @story_gen.title.split.length should == 2
  end

  it "should generate a title with the first word from the first list" do
    @title_adj.should_include? @story_gen.title.split.[0]
  end

  it "should generate a title with the second word from the second list" do
    @title_noun.should_include? @story_gen.title.split.[1]
  end

Can you understand what these mean, and how they ensure that your code
does what it's supposed to do?  (For the last two, there may be some
way to say "this should be in that collection" rather than "this
collection should include that", which would communicate

Getting good at creating tests will help you immensely later.

-Dave

-- 
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)