Getting test method names when getting output

ruby

Getting test method names when getting output

Postby Hunt Jon » Fri, 19 Dec 2008 22:49:35 GMT

When I run a test file (e.g., ruby test_user.rb), I get the test
output about error and failure and about the overall number of tests,
assertions, pass and so on.

But I would like to see all the test method names including the test
that is passed.

Currently what I can see is a dot (.) indicating a pass.

Is there any way to get a list of tests inside a file?


Re: Getting test method names when getting output

Postby Daniel Berger » Fri, 19 Dec 2008 23:17:36 GMT



gem install turn

Regards,

Dan



Re: Getting test method names when getting output

Postby Phlip » Sat, 20 Dec 2008 00:00:17 GMT




Turn on verbose:

   ruby user_test.rb -v

In terms of style, the _test suffix should not be a prefix, because otherwise 
everything in your test folder starts with T, and that impairs your desktop 
tools, such as command line tab completion.

-- 
   Phlip

Similar Threads:

1.Hide "gets" method output, for passwords..

[Note:  parts of this message were removed to make it a legal post.]

HI All,

 I'm trying to find a platform independent way of hiding the STDOUT when a
password is being entered via the gets method...
I was able to hide all output in Linux by using Termios , but as you know
this doesn't work on Windows..

What would be nice , is a simple implementation of asterisks replacing the
actual characters displayed to STDOUT ...

Does anyone know if this is possible in Ruby?

 Thanks,

draygen

2.getting method names

How do I get  the name of the missing method inside  the missing_method
method?

 class Foo
    def missing_method(*args)
        puts " <#{???}> method is not yet implemented"
        #         ^^^^^^     What should I put here?
    end
end

f = Foo.new
f.boo # This should print "<boo> method is not yet implemented"

TIA,
-- shanko


3.getting method names for a Class

There are so many methods in Object and Module that return arrays of
method names that it can be a bit confusing. Here's a summary of my
current understanding. Is any of this wrong?

"instance_methods" is a method from Module.
Pass it true to include inherited methods (the default) and false to
exclude them.
To get the names of public *instance* methods in the class Foo, use
Foo.instance_methods.

"methods" is a method from Object.
Pass it true to get instance methods (the default) and false to get
singleton methods.
A singleton method on a Ruby Class is essentially like a static method in Java.
To get the names of public *class* methods in the class Foo, use
Foo.methods(false).

Foo.methods(false) == Foo.singleton_methods(false)

Why doesn't Foo.methods(true)  return the same thing as
Foo.instance_methods(true)?

I can see using a boolean parameter to tell whether you want inherited
methods to be included (as in the instance_methods method). However,
using a boolean parameter to tell whether you want instance or
singleton methods (as in the method "methods") seems bad. Maybe that
should be deprecated in favor of instance_methods and
singleton_methods.

R. Mark Volkmann
Partner, Object Computing, Inc.


4.Getting the name of an invoked method?

Hello,

In the C Ruby API, is there a clean way to get the name of the method
which has been invoked?  ie. If there is a single C function handling
multiple method calls, is there a way from C to find out which of the
methods was invoked?

The only way I've been able to find of doing this so far is through
poking into the internal stack, eg. rb_id2name(ruby_frame->last_func)
gives the name of the method called. This seems kind of ugly, though.
Is there a cleaner way?

Simon

5.Getting the current module(s), class name and method in Ruby 1.9

Hi, first of all I'm sorry since I already did this question some time ago 
(but I ca't find it now).

Basically I want the following:

---------------
module MyModule

  class MyClass
    def show_log
      puts "I'm here: ###### FIXME ######"
    end
  end

end


my_class = MyModule::MyClass.new
my_class.show_log
=> I'm here: MyModule::MyClass#show_log
---------------

When I did this question I remember that it was not possible with Ruby 1.8 but 
it was feasible in Ruby 1.9.

Could you please show me how to get it?
Thanks a lot.



-- 
Iaki Baz Castillo < XXXX@XXXXX.COM >

6. getting the name of arguments a method takes

7. Return of gets gets

8. gets gets



Return to ruby

 

Who is online

Users browsing this forum: No registered users and 89 guest