Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5977657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:24:09+00:00 2026-05-22T21:24:09+00:00

Have been trouble debugging this Ruby unit test, but can’t figure what I’m doing

  • 0

Have been trouble debugging this Ruby unit test, but can’t figure what I’m doing wrong. Here is the code:

My problem is with the best_sentence_choice method; here is what Textmate is returning to me:

    require 'test/unit.rb'
require 'wordplay.rb'

class TestWordPlay < Test::Unit::TestCase

  def test_sentences
    assert_equal(["a", "b", "c d", "e f g"], "a.b. c d. e f g".sentences)

    test_text = %q{Hello. This is a test
      of sentence separation. This is the end of the test.}
      assert_equal("This is the end of the test", test_text.sentences[2])
end

def test_words
  assert_equal(%w{this is a test}, "this is a test".words)
  assert_equal(%w{these are mostly words}, "these are, mostly, words".words)
end

# Testing best sentence choice
def test_sentence_choice
  assert_equal('This is a great test')
              WordPlay.best_sentence(['This is a test', 'This is another test', 'This is a great test']
              %w{test great this}))
  assert_equal('This is a great test', WordPlay.best_sentence(['This is a great test'],
                                                                %w{'still the best'}))

end                                                                            
end

Here is what Textmate is returning:

    /Users/pdenlinger/ruby/wordplaylib/wordplaytest.rb:23: syntax error, unexpected tQWORDS_BEG, expecting ')'
              %w{test great this}))
                 ^
/Users/pdenlinger/ruby/wordplaylib/wordplaytest.rb:23: syntax error, unexpected ')', expecting kEND
              %w{test great this}))
                                  ^

Can you help? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:24:09+00:00Added an answer on May 22, 2026 at 9:24 pm

    On this line

    WordPlay.best_sentence(['This is a test', 'This is another test', 'This is a great test'] %w{test great this}))
    

    you don’t seem to have a comma after the first argument. Then there are two closing parentheses but you have only one opening parentesis.

    Please consider editing your question to make the code more readable (hint: if a line starts with 4 spaces and is preceded by an empty line, it’ll look like code).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may have been asked before, but I had trouble finding an answer,
No doubt elements of this question have been asked before, but I'm having trouble
Hello I have been having trouble with this for a while now. I have
I've been have trouble understand this problem. If I change the variable name fifthViewController
I have been having a lot of trouble figuring out how I can access
I have been using SmartGWT but have run into trouble mixing SmartGWT with other
I've been working on a small blog form but have been having trouble with
(Note, this question has been marked answered in Debugging Sharepoint timer jobs but I'm
I have been following this tutorial. I'm having conceptual trouble at the point where
I have been through the sed one liners but am still having trouble with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.