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

  • SEARCH
  • Home
  • 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 6238035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:08:26+00:00 2026-05-24T11:08:26+00:00

I think I searched for an answer about my problem but I did not

  • 0

I think I searched for an answer about my problem but I did not see any post that respond to it. So here is yet another question about LocalJumpError…

I’m a relatively newbie in Ruby and I’ve just decided to follow good pratices and write tests prior to all Ruby stuff I code.

But I got something like a little issue here that I just don’t understand. Here is my test :

class TestFilesInfoLoggerHashCreation < Test::Unit::TestCase
   def setup
      @logger = FilesInfoLogger
   end
   # some other tests
   def test_shall_not_raise_an_exception_if_argument_is_a_string
     assert_nothing_raise @logger.get_log('foo')
   end
end

And here is the code that is supposed to verify the specific test above:

module FilesInfoLogger
  extend self
  def get_log(list)
     hash = Hash.new {||h,k| h[k] = (block_given?)? yield(k):''}
     if list.respond_to? :each 
       list.each {|file| hash[file]}
     else
       ([]<< list).each {|file| hash[file]}
     end
  end
end

So when i run FilesInfoLogger.get_log('foo') with irb everything seems to work fine, I mean nothing is raised. But when i run the test, it fails returning this :

test_shall_not_raise_an_exception_if_argument_is_a_string(TestFilesInfoLoggerHashCreation) [test/files_info_logger_test.rb:43]:
{"foo"=>""}.
 Exception raised:
 <#<LocalJumpError: no block given (yield)>>.

I don’t understand why according to test unit an exception about no block given is raised especially since I test that condition with block_given?. What am I missing?

Thanks for your answers.

  • 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-24T11:08:26+00:00Added an answer on May 24, 2026 at 11:08 am

    It looks like assert_nothing_raised expects a block as an argument. Instead, you are passing it the result of calling @logger.get_log('foo'). Try this:

    assert_nothing_raised do
      @logger.get_log('foo')
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched a lot about UTF8 decoding, but not found the answer yet.
Hello I searched for an answer to this question but didn't find any here.
I searched across the web but I didn't find any satisfying answer. I have
i think this is a simple question but I've searched around and can't seem
I think the file that is produced is an .asm file, any idea how
I think most people here understand the importance of fully automated builds. The problem
I have searched internet and stackoverflow thoroughly, but I haven't found answer to my
I've searched through the site and haven't found a question/answer that quite answer my
I've searched around for solutions to this problem, and the only answer I can
I searched around google and stackoverflow, but didnt quite find the right answer. im

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.