RubySpecs

Hello,

Here comes stupid question time. I’ve been trying to learn JRuby, got
stuck on learning the monkeybars GUI because of a failure to load
OpenURI.
So, I thought I’d roll up my sleeves and try to pitch in to make some
RubySpecs pass. I thought I’d start with a simple-looking failing spec.
The problem is, I don’t understand the rationale, and was wondering if
anyone could give me a hand. Here it is:

it "calls #to_s on arguments that are neither Strings nor Encodings" 

do

  string = mock('string')

  string.should_receive(:to_str).twice.and_return('US-ASCII')

  Encoding.default_external = string

  Encoding.default_external.should == Encoding::ASCII

end

Can anyone explain? I’ve looked at the C implementation, and the only
reason I see to_str being called twice is first, to convert to a string
to
make sure that the encoding is ASCII-compatible, and then a second time
to
get a string used to look up the encoding. As far as I can tell this is
an
implementation detail, and the JRuby implementation doesn’t need the
second
call because it just uses the same string object for both the ASCII
check
and the actual encoding lookup. Perhaps I’m missing something…

Matt

Hi, Matt,

It seems to me that this issue should be best raised on RubySpecs list.

https://groups.google.com/group/rubyspec

Thanks.

Hiro