[#362083] Teaching Programming Languages (including Ruby) — Samuel Williams <space.ship.traveller@...>

Hello,

20 messages 2010/05/02

[#362098] Main working window for Ruby is DOS? — Kaye Ng <sbstn26@...>

I know nothing about programming and am not a techy person, so please

16 messages 2010/05/03

[#362116] School teacher still at it learning programming language — Hilary Bailey <my77elephants@...>

Now I while glimpsing at the beauty of Ruby, there is the software of

11 messages 2010/05/03

[#362166] Something I expected to work, but didn't! — Kurtis Rainbolt-greene <kurtisrainboltgreene@...>

irb(main):001:0> x = 2

11 messages 2010/05/04

[#362215] for-in vs. map closures — Mike Austin <mike_ekim@...>

I was experimenting with closures and JavaScript's and Ruby's

11 messages 2010/05/05

[#362286] ri on sqlite — Intransition <transfire@...>

What do others think of a creating a new ri tool which uses a SQLite

17 messages 2010/05/06

[#362341] ease of porting (translating) ruby to C (vs. python)? — bwv549 <jtprince@...>

In a very small bioinformatics group I know of, they are deciding

17 messages 2010/05/07

[#362375] Strings iteration — Viorel <viorelvladu@...>

I have some names like aaxxbbyy where xx is '01'..'10' and yy is also

14 messages 2010/05/08

[#362425] Any future for curses applications/toolkits like rbcurse ? — "R. Kumar" <sentinel.2001@...>

Have apps moved over to the web (or GUI) totally ? Will there be any

21 messages 2010/05/10
[#362441] Re: Any future for curses applications/toolkits like rbcurse ? — botp <botpena@...> 2010/05/10

On Mon, May 10, 2010 at 2:13 PM, R. Kumar <sentinel.2001@gmx.com> wrote:

[#362448] Re: Any future for curses applications/toolkits like rbcurse ? — "R. Kumar" <sentinel.2001@...> 2010/05/10

interface and/or the installation itself is terrible.

[#362458] Re: Any future for curses applications/toolkits like rbcurse ? — botp <botpena@...> 2010/05/10

On Mon, May 10, 2010 at 10:28 PM, R. Kumar <sentinel.2001@gmx.com> wrote:

[#362460] Re: Any future for curses applications/toolkits like rbcurse ? — "R. Kumar" <sentinel.2001@...> 2010/05/10

botp wrote:

[#362463] Re: Any future for curses applications/toolkits like rbcurse ? — "R. Kumar" <sentinel.2001@...> 2010/05/10

Strange. I cant push a gem even after yanking.

[#362452] Unit Test of method calling system() - how? — Martin Hansen <mail@...>

How can I unit test the two methods:

16 messages 2010/05/10

[#362498] In Ruby, can the coerce() method know what operator it is th — Jian Lin <blueskybreeze@...>

In Ruby, it seems that a lot of coerce() help can be done by

12 messages 2010/05/11
[#362546] Re: In Ruby, can the coerce() method know what operator it is th — Caleb Clausen <vikkous@...> 2010/05/11

On 5/10/10, Jian Lin <blueskybreeze@gmail.com> wrote:

[#362611] Re: In Ruby, can the coerce() method know what operator it is th — Colin Bartlett <colinb2r@...> 2010/05/12

On Tue, May 11, 2010 at 4:46 PM, Caleb Clausen <vikkous@gmail.com> wrote:

[#362657] Asynchronous HTTP request — Daniel DeLorme <dan-ml@...42.com>

Does anyone know how to do the following, but without threads, purely

28 messages 2010/05/13

[#362718] Range on strings. — Vikrant Chaudhary <nasa42@...>

Hi,

13 messages 2010/05/14

[#362787] class best way for getters ? — unbewusst.sein@... (Une B騅ue)

i have a class "HFSFile" initialized by a parsed string

12 messages 2010/05/15

[#362979] curl library? — Xeno Campanoli / Eskimo North and Gmail <xeno.campanoli@...>

Two questions:

14 messages 2010/05/18
[#362980] Re: curl library? — Xeno Campanoli / Eskimo North and Gmail <xeno.campanoli@...> 2010/05/18

On 10-05-18 02:35 PM, Xeno Campanoli / Eskimo North and Gmail wrote:

[#362982] Re: curl library? — Luis Parravicini <lparravi@...> 2010/05/18

On Tue, May 18, 2010 at 6:56 PM, Xeno Campanoli / Eskimo North and

[#362984] Re: curl library? — Xeno Campanoli / Eskimo North and Gmail <xeno.campanoli@...> 2010/05/18

Well, I got that -dev thing installed with apt-get, and then I tried again and

[#363027] Retrieve instance — Walle Wallen <walle.sthlm@...>

Quick question. Can I somehow retrieve the instance of the class Test in

11 messages 2010/05/19

[#363076] Scrape javascript content — Phil Mcdonnell <phil.a.mcdonnell@...>

I'm trying to scrape a page that hides some data behind a javascript

11 messages 2010/05/20

[#363115] OMG, why are there so many Strings in ObjectSpace! — timr <timrandg@...>

I was playing around looking at ObjectSpace in irb and was astounded

14 messages 2010/05/21

[#363225] Redefine a Class? — Mark T <paradisaeidae@...>

Currently this raises: superclass mismatch for class Soda (TypeError)

12 messages 2010/05/25

[#363240] Funny IO.select behaviour — Dennis Nedry <dennis@...>

I've been debugging my full screen console ruby editor.

13 messages 2010/05/25

[#363348] Ruby as Client Side Language in Web Browser (replacing JS) — "Simone R." <k5mmx@...>

Hi everybody,

17 messages 2010/05/27

[#363412] A better way to write this function? — Jason Lillywhite <jason.lillywhite@...>

Here is my attempt at Newton's second law in Ruby:

14 messages 2010/05/28

[#363417] Interrupting the evaluation of a ruby script — Emmanuel Emmanuel <emmanuel.bacry@...>

This is my problem :

12 messages 2010/05/28
[#363447] Re: Interrupting the evaluation of a ruby script — Branden Tanga <branden.tanga@...> 2010/05/28

Emmanuel Emmanuel wrote:

[#363483] Re: Interrupting the evaluation of a ruby script — Emmanuel Emmanuel <emmanuel.bacry@...> 2010/05/29

[#363426] A complete beginners question — Ant Walliams <anthonywainwright@...>

Hi there,

19 messages 2010/05/28

[#363432] Dynamic SVG with Ruby/Tk — Yotta Meter <spam@...>

The example I'm looking for in regards to ruby/SVG differs from the

14 messages 2010/05/28

[#363467] Date.today problem on linux with Ruby 1.8.6 — Jarmo Pertman <jarmo.p@...>

Hello.

10 messages 2010/05/29

[#363524] enumerator problem in 1.9.1 — Bug Free <amberarrow@...>

The following line:

19 messages 2010/05/31
[#363528] Re: enumerator problem in 1.9.1 — botp <botpena@...> 2010/05/31

On Mon, May 31, 2010 at 9:04 AM, Bug Free <amberarrow@yahoo.com> wrote:

[#363533] Re: enumerator problem in 1.9.1 — Robert Klemme <shortcutter@...> 2010/05/31

2010/5/31 botp <botpena@gmail.com>:

Re: Unit Test of method calling system() - how?

From: Caleb Clausen <vikkous@...>
Date: 2010-05-11 16:16:54 UTC
List: ruby-talk #362549
On 5/11/10, Martin Hansen <mail@maasha.dk> wrote:
> @Caleb
>
>> I would extract a helper from both methods which does the bulk of the
>> work (the first 2 lines) but does not exit. Then test the helper and
>> don't bother testing the methods that call it.
>
> Hm, I thought all this unit testing was about testing the interface -
> these are private methods. But perhaps this is one of those rare cases
> where you have to do all sorts of tricks? I was wondering if a special
> class for printing usage would be in order?

"Testing the interface" means different things to different people, I
guess. I think it is fairly obvious that the method below does not
need any tests, it's clear to see that it's correct just by looking at
it:

def foo_and_exit
  foo
  exit
end

I'm assuming that foo itself is tested, of course.

Yes, foo may not be the direct interface as seen by callers, but it is
very very close to it. Good enough for government work, as a former
colleague used to say.

I encourage you not to use mocks as others in this thread are
suggesting. Mocks divorce your tests from reality and force you to
test the implementation rather than the interface. The fact that you
program's usage feature invokes the print_wiki command is surely an
internal detail, not an essential part of its interface, yes? Binding
your test to that internal detail is a greater sin than skipping the
test of exit in my opinion.

Mocks are necessary when testing externalities like databases and
network servers which are hard to set up or may not be available when
tests are run. So, ask yourself this question: is it reasonable to
expect that print_wiki will always be available when your tests are
run? Is it something that will already be installed or be fairly easy
to install and set up?

>> You then have the problem that this print_wiki command is printing
>> something to stdout, which you want to test. Either capture stdout in
>> the test and verify it contains what you want, or use backticks
>> (`...`) instead of system in your helper method.
>
> Actually, 'print_wiki' outputs to stderr - which makes sense if you are
> executing a command and piping the output to a file. You want to see the
> usage info as an indicator that your did something wrong (if you did
> mess up), and not have the usage information in the output file!

All right, stderr then. Same problem really. Except backticks won't
work for you.

There are some existing utilities out there for capturing stderr and
stdout, but I'm not sure what to suggest. It's also pretty easy to
write your own.

>> Since print_wiki might change its behavior, you might think about
>> making the assertion that tests print_wiki's output string somewhat
>> loose.... just verify that some expected substring occurs in there
>> somewhere, rather than verifying that it is exactly equal to some
>> expected string.
>
> Yup, that makes sense.
>
>> $0 is also going to present you some problems in a test... it will not
>> be the same value in the test as it is when run from your main
>> program. Not sure what to suggest about that without more context.
>
> Better to supply the base name of the script as an argument?

Yeah, probably.

>> 3 other points:
>>
>>   looks like both methods have an unintended extra trailing + on their
>> first line
>
> No??? On my screen they end with + ".wiki".

Ah, pastie hid their horizonal scroll bar way down at the bottom where
I couldn't see it. My mistake. ( Your love of excessive indentation
isn't helping here. ;)

>>   standard style is to use 2 spaces for indentation; you appear to be
>> using 8
>
> I do use a tab space of 2, however, this is the result of pasting from
> vi and then tabs are expanded wildly (I have no solution for this).

I suggest that you not use tabs. Use 2 spaces.

In This Thread