# Ruby Spec

**URL:** <https://www.ruby-forum.com/t/ruby-spec/145442>\
**Category:** Ruby\
**Created:** [August 9, 2008, 3:30pm UTC](https://www.ruby-forum.com/t/ruby-spec/145442 "2008-08-09T15:30:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayuresh\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Mayuresh\_K](https://www.ruby-forum.com/u/Mayuresh_K)\
**Post date:** [August 9, 2008, 3:30pm UTC](https://www.ruby-forum.com/t/ruby-spec/145442/1 "2008-08-09T15:30:32Z")

</div>

Hello,

Is there a Ruby language specification?

I read the following on wikipedia;  
There is currently no specification of the Ruby language, so the  
original implementation is considered to be the de facto reference.

I’m no authority on these matters, but wouldn’t it be safer to draft a  
specification formally?

~Mayuresh

---

<div class="post-metadata">

**Author:** ![Mayuresh\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Mayuresh\_K](https://www.ruby-forum.com/u/Mayuresh_K)\
**Post date:** [August 9, 2008, 3:45pm UTC](https://www.ruby-forum.com/t/ruby-spec/145442/2 "2008-08-09T15:45:46Z")

</div>

2008/8/9 Mayuresh K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I read the following on wikipedia;  
> There is currently no specification of the Ruby language, so the  
> original implementation is considered to be the de facto reference.
> 
> I’m no authority on these matters, but wouldn’t it be safer to draft a  
> specification formally?

Rubinius and JRuby use a shared RSpec suite which they use to test  
compatiability. It’s not the Official Spec™ but I think it’s the  
closest to one.

Farrel

---

<div class="post-metadata">

**Author:** ![Mayuresh\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Mayuresh\_K](https://www.ruby-forum.com/u/Mayuresh_K)\
**Post date:** [August 10, 2008, 4:55am UTC](https://www.ruby-forum.com/t/ruby-spec/145442/3 "2008-08-10T04:55:54Z")

</div>

Mayuresh K. wrote:

> I’m no authority on these matters, but wouldn’t it be safer to draft a  
> specification formally?
> 
> ~Mayuresh

I don’t know that Ruby will ever have a formal spec (a la Python), but  
there are ongoing discussions involving the major players. You can find  
more info at [http://ruby-design.pbwiki.com/](http://ruby-design.pbwiki.com/). There is also a RubySpec  
project that can be found on github (I think this is what Farrel was  
refering to): [http://github.com/rubyspec/rubyspec/tree/master](http://github.com/rubyspec/rubyspec/tree/master).  
Unfortunately, the spec is currently focused on 1.8.

-Josh

---

<div class="post-metadata">

**Author:** ![Mayuresh\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Mayuresh\_K](https://www.ruby-forum.com/u/Mayuresh_K)\
**Post date:** [August 10, 2008, 6:28am UTC](https://www.ruby-forum.com/t/ruby-spec/145442/4 "2008-08-10T06:28:57Z")

</div>

On Aug 9, 2008, at 06:42 , Farrel L. wrote:

> Rubinius and JRuby use a shared RSpec suite which they use to test  
> compatiability. It’s not the Official Spec™ but I think it’s the  
> closest to one.

that is so far from an actual specification it isn’t funny.

---

<div class="post-metadata">

**Author:** ![Mayuresh\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Mayuresh\_K](https://www.ruby-forum.com/u/Mayuresh_K)\
**Post date:** [August 11, 2008, 9:50am UTC](https://www.ruby-forum.com/t/ruby-spec/145442/5 "2008-08-11T09:50:24Z")

</div>

Ryan D. wrote:

> On Aug 9, 2008, at 06:42 , Farrel L. wrote:
> 
> > Rubinius and JRuby use a shared RSpec suite which they use to test  
> > compatiability. It’s not the Official Spec™ but I think it’s the  
> > closest to one.
> 
> that is so far from an actual specification it isn’t funny.

I think that substituting a suite of tests (or “expected behaviors”) is  
more in keeping with “the Ruby way” than a formal language  
specification. After all, isn’t the primary goal of a language spec to  
ensure that your program will run on a given system? Why can’t a test  
suite give me that assurance as well as a formal spec?

In fact, Joel Spolsky’s bit on “Martian Headsets”  
([Martian Headsets – Joel on Software](http://joelonsoftware.com/items/2008/03/17.html)) is rather informative  
for this discussion. If Ruby had a standard, but not a comprehensive  
test suite, we’d probably be _less_ confident of the  
cross-implementation compatibility of our programs. That’s not to say  
that a formal specification would be a bad thing, just that between a  
test suite and a formal spec, the spec is less important.

---

<div class="post-metadata">

**Author:** ![Mayuresh\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Mayuresh\_K](https://www.ruby-forum.com/u/Mayuresh_K)\
**Post date:** [August 10, 2008, 6:59am UTC](https://www.ruby-forum.com/t/ruby-spec/145442/6 "2008-08-10T06:59:55Z")

</div>

On Saturday 09 August 2008 23:26:28 Ryan D. wrote:

> On Aug 9, 2008, at 06:42 , Farrel L. wrote:
> 
> > Rubinius and JRuby use a shared RSpec suite which they use to test  
> > compatiability. It’s not the Official Spec™ but I think it’s the  
> > closest to one.
> 
> that is so far from an actual specification it isn’t funny.

Erm, how? Is there something particularly deficient about the actual  
specs?  
Or are you just uncomfortable with having a test suite be a  
specification?

If it’s the latter, read on.

My thoughts: If you’ve ever filed a decent bug report, you’ve already  
done  
this. Even for an “enhancement”, even for older trackers like Bugzilla,  
there’s an expectation that you’ll write something like this:

Steps to reproduce:

1. Log in
2. Go to your profile
3. Click on ‘foo’

Expected result:  
It should ‘bar’ when I click ‘foo’.

Actual result:  
I got an “Internal Server Error: 500” error. Log pasted below.

Now, actually parse that out. Sounds exactly like a regression test, to  
me. “Steps to reproduce” are steps to setup the test. “Expected result”  
is  
your assertions.

Again, who says it has to be a bug? Test-driven development suggests  
that you  
should code by writing the test first, then fix it. Shouldn’t the same  
hold  
true for enhancements, also? All that would change is that “Expected  
result”  
would be some feature that doesn’t exist yet.

Behavior-driven development ([behaviour-driven.org](http://behaviour-driven.org)) and supporting  
software  
(rspec.info) only make this relationship more explicit. Given a  
properly-formatted feature specification (similar to above), you can  
actually  
generate skeleton integration tests (called “stories”).

It works the other way around, too – Rspec will generate  
English-language  
versions of its tests, which can be used as a specification.

When you think about it, any open standard should have at least an open  
implementation. If it is meant to allow multiple implementations, it  
should  
also have an automated test suite – for the Web, we have  
[validator.w3.org](http://validator.w3.org),  
as well as the Acid2 (and now Acid3) tests, as an easy way to measure a  
particular implementation’s adherence to the standard.

We all agree that a suite of compatibility tests is a good thing, right?

Here are those links again, in case your client didn’t make them into  
links:

[http://behavior-driven.org](http://behavior-driven.org)

> **[RSpec: Behaviour Driven Development for Ruby](http://rspec.info)**

> **[The W3C Markup Validation Service](https://validator.w3.org)**
>
> W3C's easy-to-use
> markup validation service, based on SGML and XML parsers.
