[#402707] Require a ruby project to automatically include the modules in classes defined in the same .rb file — Marc Heiler <lists@...>

Hi.

11 messages 2013/01/03
[#402738] Re: Require a ruby project to automatically include the modules in classes defined in the same .rb file — Josh Cheek <josh.cheek@...> 2013/01/04

On Wed, Jan 2, 2013 at 9:58 PM, Marc Heiler <lists@ruby-forum.com> wrote:

[#402764] Best practice for &&, ||, and, or — sto.mar@...

Hi group,

33 messages 2013/01/05
[#402786] Re: Best practice for &&, ||, and, or — "Jan E." <lists@...> 2013/01/05

Hi,

[#402812] newbie question what am I doing wrong? — "Lee V." <lists@...>

I wrote this simple program but it won't work. What am I doing wrong?

13 messages 2013/01/07

[#402856] Ruby on Android - usb/serialport — Scott Macri <lists@...>

Hello,

12 messages 2013/01/07

[#402880] One liner for filenames — Peter Bailey <lists@...>

Hello,

18 messages 2013/01/08

[#402890] Pure Ruby Jobs — Brandon Weaver <keystonelemur@...>

One thing has been bugging me lately. I've been looking around for jobs in

15 messages 2013/01/09

[#402958] how to open pop up window table? — Arup Rakshit <lists@...>

There is `text label` on a webpage, and I am trying to click on that to

13 messages 2013/01/10

[#403015] How Ruby environment varibles work in realtime program? — Arup Rakshit <lists@...>

Hi,

11 messages 2013/01/11

[#403051] Array methods creating confusions as per their functionalities — Arup Rakshit <lists@...>

Can any one just elaborate how the below works in Ruby, by definition

10 messages 2013/01/12

[#403062] How to take information from a text file and add them to an array — Adam Kennedy <lists@...>

Hi Im trying to take a list of usernames from a text file then add them

13 messages 2013/01/12

[#403083] Can anyone tell me the computational logic of Unpack() method of string? — Arup Rakshit <lists@...>

Hi,

17 messages 2013/01/12

[#403116] Garbage Collection and Fibers — Na Na <lists@...>

Hi,

20 messages 2013/01/13

[#403127] Conversion of Ruby-code to c/c++ code :: URGENT Plz help — "Nilesh S." <lists@...>

Hi.. I urgent require to convert the following ruby-code to c/c++ code.

11 messages 2013/01/14

[#403139] Installation query — Ron Herrema <lists@...>

I'm new to Ruby and am enjoying it, but when I installed, I attempted to

19 messages 2013/01/14

[#403205] Escaped backslashes in input strings - newbie question — John Sampson <jrs.idx@...>

I am trying to find a way of removing escaped characters in input

13 messages 2013/01/16
[#403208] Re: Escaped backslashes in input strings - newbie question — Alexander McMillan <alexandermcmillan@...> 2013/01/16

[#403244] Adding file directory automatically — Adam Kennedy <lists@...>

I have a bit of code that will add an amount to an array and then print

23 messages 2013/01/17

[#403326] question about string concatenation — David Richards <lists@...>

I'm puzzled about why the following happens (I'm using v1.9.3):

11 messages 2013/01/20

[#403377] Getting error "getaddrinfo: No such host is known. (Socke tError)" with mechanize gem — Arup Rakshit <lists@...>

I tried the below code:

9 messages 2013/01/22
[#403379] Re: Getting error "getaddrinfo: No such host is known. (Socke tError)" with mechanize gem — Robert Klemme <shortcutter@...> 2013/01/22

On Tue, Jan 22, 2013 at 3:52 PM, Arup Rakshit <lists@ruby-forum.com> wrote:

[#403423] Reading and looping through Excel — cristian cristian <lists@...>

Hi all!

16 messages 2013/01/24

[#403456] Can we attach documents to excel columns using Ruby? — Arup Rakshit <lists@...>

Suppose I do have some folders in a directory. Now say directory name

12 messages 2013/01/24

[#403540] Please explain in English — jooma lavata <lists@...>

I'm learning Ruby and I'm reading some expression that I saw on the

20 messages 2013/01/28

[#403553] Learning Ruby and proving your knowledge — Nathaniel Sokoll-Ward <lists@...>

Hey all,

19 messages 2013/01/28

[#403581] newbie question.. — Zebulon Bowles <lists@...>

So I'm taking a class on Ruby and it seems as though the teacher has

12 messages 2013/01/29

[#403607] (Errno::EINVAL) occurs during the File::rename() execution — Arup Rakshit <lists@...>

Hi I wrote the below code to rename the file names. The logic is during

12 messages 2013/01/30

[#403642] How to copy the directory files only to another directory? — Arup Rakshit <lists@...>

Hi,

18 messages 2013/01/30

[#403656] Does Ruby has any default database with it? — Arup Rakshit <lists@...>

I will do webpage scraping using Ruby and required Gems. But looking for

28 messages 2013/01/30
[#403657] Re: Does Ruby has any default database with it? — Brandon Weaver <keystonelemur@...> 2013/01/30

Normally sqlite is the go to being that it's the default of rails. Check

[#403667] Re: Does Ruby has any default database with it? — Justin Collins <justincollins@...> 2013/01/30

On 01/30/2013 10:21 AM, Arup Rakshit wrote:

[#403671] Re: Does Ruby has any default database with it? — Tony Arcieri <tony.arcieri@...> 2013/01/30

On Wed, Jan 30, 2013 at 12:07 PM, Justin Collins <justincollins@ucla.edu>wrote:

[#403674] Re: Does Ruby has any default database with it? — Arup Rakshit <lists@...> 2013/01/30

Tony Arcieri wrote in post #1094436:

[#403678] Re: Does Ruby has any default database with it? — Justin Collins <justincollins@...> 2013/01/30

On 01/30/2013 12:27 PM, Arup Rakshit wrote:

[#403735] Re: Does Ruby has any default database with it? — tamouse mailing lists <tamouse.lists@...> 2013/02/01

I think the best course for a new project is to start simple, go with

[#403698] Select "columns" from multidimensional array? — Joel Pearson <lists@...>

There's probably a simpler answer to this than the ways I've come up

51 messages 2013/01/31

[#403718] Ruby Project Ideas to get someone hired... — Colby Callahan <colby.callahan@...>

I have started learning Ruby this past week and have down the basics of

15 messages 2013/01/31

Re: require "test/unit"

From: tamouse mailing lists <tamouse.lists@...>
Date: 2013-01-05 02:30:51 UTC
List: ruby-talk #402757
That's davetron1000 :)

On Fri, Jan 4, 2013 at 8:24 PM, D. Deryl Downey <me@daviddwdowney.com>wrote=
:

> I would also recommend you get the book called Build Awesome Command-Line
> Applications in Ruby, by David Bryant Copeland. Excellent book!
>
>   tamouse mailing lists <tamouse.lists@gmail.com>
>  January 4, 2013 9:21 PM
>
> There is a structure for building command-line applications that may
> be something you want to adopt.
>
> I'm going to point you to davetron1000's gems: methadone and GLI, both
> of which are builders for command-line apps (kind of like rails is for
> web apps). They provide some nifty things for making nice CLI apps,
> but possibly the tl;dr is that you implement the bare minimum in the
> part that does the part to take arguments from the command line, and
> then pass them to your classes/modules/etc, which are in separate
> files.
>
> Generally, a CLI app structure looks like this:
>
> my_cli_app/
> Gemfile
> Rakefile
> bin/
> my_cli_app # this contains the command line interaction part
> lib/
> my_cli_app/ # these implement specific features of the module/class
> version.rb
> classOne.rb
> ...
> my_cli_app.rb # this implements the module/class
> my_cli_app.gemspec # describes how to build this gem
> README.rdoc # application documentation that gets bundled in rdoc
> spec/ # rspec tests for the app's classes
> test/ # Test::Unit tests for app's classes
>
> (and if you're awesome)
>
> feature/ # cucumber/aruba tests for the app
>
>   Derrick B. <lists@ruby-forum.com>
>  January 4, 2013 3:07 PM
>
> You're right, I should not have stated that in that way, but my main
> point was directly related to how I thought the OP was adding the test
> class into the current code, and not separately. He was receiving an
> error, which I also encountered, so I gave my solution.
>
> Thank you for the clarification on proper test class usage. It should
> help me, and the OP, to steer away from such errors by separating the
> code.
>
>   sto.mar@web.de
>  January 4, 2013 2:56 PM
>
>
> Defining the class to be tested in the test file does not make
> any sense, since you want to use your class elsewhere, and not only
> in tests. You would define it in a separate file and require it
> (with `require' or `require_relative').
>
>
>   Derrick B. <lists@ruby-forum.com>
>  January 4, 2013 1:48 PM
>
> I'm kind of new to using test/unit ( and Ruby! :) ), but I was getting
> that same error, too. What I discovered was just adding a test class to
> my existing code caused that error until I stripped the code down to
> just classes. For example, I wrote a simple Calculator class with four
> methods (add, subtract, multiply, divide). I then added code for it to
> be interactive. I had to then remove that extra code so that my file
> contains only the Calculator class and the TestClass, which included the
> test cases, then it worked.
>
> So, I think (and I am guessing here) that your test files should only
> include classes to be tested and the actual testing class. That would
> make sense, because when testing code, you are mainly concerned with
> static test cases which cover all possible execution paths, so why
> bother with user interaction.
>
> Here are the two files, the original and the one modified for testing:
>
> ######## Original #################
> class Calculator
> def initialize(a, b)
> @a, @b =3D a, b
> end
> def add
> @a + @b
> end
> def sub
> @a - @b
> end
> def mul
> @a * @b
> end
> def div
> return "undef" if @b =3D=3D 0
> @a / @b
> end
> end
>
> x, y =3D ARGV[0].to_i, ARGV[1].to_i
> if ARGV.length =3D=3D 0
> print "Usage calc 3 4\n"
> exit
> end
> c =3D Calculator.new( x, y )
> puts "#{x} plus #{y} equals: #{c.add}"
> puts "#{x} minus #{y} equals: #{c.sub}\n"
> puts "#{x} times #{y} equals: #{c.mul}\n"
> puts "#{x} divided by #{y} equals: #{c.div}\n"
>
>
> ######## For Testing #################
> require 'test/unit'
>
> class Calculator
> def initialize(a, b)
> @a, @b =3D a, b
> end
> def add
> @a + @b
> end
> def sub
> @a - @b
> end
> def mul
> @a * @b
> end
> def div
> return "undef" if @b =3D=3D 0
> @a / @b
> end
> end
>
> class TestClass < Test::Unit::TestCase
> def test_add
> c =3D Calculator.new( 12, 3 )
> assert_equal 15, c.add
> end
> def test_sub
> c =3D Calculator.new( 12, 3 )
> assert_equal 9, c.sub
> end
> def test_mul
> c =3D Calculator.new( 12, 3 )
> assert_equal 36, c.mul
> end
> def test_div
> c =3D Calculator.new( 12, 3 )
> assert_equal 4, c.div
> end
> end
>
>   Mattias A. <lists@ruby-forum.com>
>  December 31, 2012 4:21 AM
> Hi Dami=C3=A1n M. Gonz=C3=A1lez!
>
> Tanks for your reply, i have found below but it do not answer my
> question or I do not know how to read/use it.. :/
>
> class Test::Unit::TestCase
> In Files
> lib/minitest/unit.rb
> lib/test/unit/parallel.rb
> lib/test/unit/testcase.rb
> Parent
> MiniTest::Unit::TestCase
>
> Included Modules
> Test::Unit::Assertions
> Public Class Methods
> test_order() click to toggle source
> # File lib/test/unit/testcase.rb, line 20
> def self.test_order
> :sorted
> endPublic Instance Methods
> on_parallel_worker?() click to toggle source
> # File lib/test/unit/parallel.rb, line 149
> def on_parallel_worker?
> true
> endrun(runner) click to toggle source
> # File lib/test/unit/testcase.rb, line 15
> def run runner
> @options =3D runner.options
> super runner
> endGenerated by RDoc 3.12.
>
> Generated with the Darkfish Rdoc Generator 3.
>
>
> --
> D. Deryl Downey
>
> "The bug which you would fright me with I seek" - William Shakespeare - T=
he Winter's Tale, Act III, Scene II - A court of Justice.
>
>
>
>

Attachments (2)

In This Thread