Forum: RSpec Basic help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-19 10:28
Hi All,

1. Just now I installed rspec1.2.0 and dependencies

2. Tried the 2 programs mentioned in http://rspec.info/.

# bowling_spec.rb
require 'bowling'

describe Bowling do
  before(:each) do
    @bowling = Bowling.new
  end

  it "should score 0 for gutter game" do
    20.times { @bowling.hit(0) }
    @bowling.score.should == 0
  end
end

# bowling.rb
class Bowling
  def hit(pins)
  end

  def score
    0
  end
end


3. Run the bowling_spec.rb file

>ruby bowling_spec.rb --format specdoc

4. getting error like

bowling_spec.rb:6: undefined method `describe' for main:Object
(NoMethodError)

5. So i tried to add these lines,

require 'rspec' --> no Such file to Load
require 'spec' -->  No Error But also no output mentioned as per that
website.

Please anyone help to continue that program.

Regards,
P.Raveendran
http://raveendran.wordpress.com
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-03-19 13:47
(Received via mailing list)
On Thu, Mar 19, 2009 at 4:28 AM, jazzez ravi <lists@ruby-forum.com>
wrote:
>  before(:each) do
> class Bowling
>
>>ruby bowling_spec.rb --format specdoc

Use the spec command (that's what's there on http://rspec.info):

spec bowling_spec.rb --format specdoc

Cheers,
David
F86901feca747abbb5c6c020362ef2e7?d=identicon&s=25 Zach Dennis (zdennis)
on 2009-03-19 14:26
(Received via mailing list)
On Thu, Mar 19, 2009 at 5:28 AM, jazzez ravi <lists@ruby-forum.com>
wrote:
>  before(:each) do
> class Bowling
>
> require 'spec' -->  No Error But also no output mentioned as per that
> website.
>
> Please anyone help to continue that program.

Try to put this at the top:

require 'rubygems'
require 'spec'

I have an environment variable set to always load rubygems on my
system so I can omit the require of it explicitly in code:

RUBYOPTS=-rubygems



>
--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-20 04:42
David Chelimsky wrote:
> On Thu, Mar 19, 2009 at 4:28 AM, jazzez ravi <lists@ruby-forum.com>
> wrote:
>> �before(:each) do
>> class Bowling
>>
>>>ruby bowling_spec.rb --format specdoc
>
> Use the spec command (that's what's there on http://rspec.info):
>
> spec bowling_spec.rb --format specdoc
>
> Cheers,
> David

Hi David,

spec bowling_spec.rb --format specdoc is working ..

Thank you

Regards,
P.Raveendran
http://raveendran.wordpress.com
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-20 04:57
Zach Dennis wrote:
> On Thu, Mar 19, 2009 at 5:28 AM, jazzez ravi <lists@ruby-forum.com>
> wrote:
>> �before(:each) do
>> class Bowling
>>
>> require 'spec' --> �No Error But also no output mentioned as per that
>> website.
>>
>> Please anyone help to continue that program.
>
> Try to put this at the top:
>
> require 'rubygems'
> require 'spec'
>
> I have an environment variable set to always load rubygems on my
> system so I can omit the require of it explicitly in code:
>
> RUBYOPTS=-rubygems
>
>
>
>>
> --
> Zach Dennis
> http://www.continuousthinking.com
> http://www.mutuallyhuman.com

Hi Zach,

I tried this one too. But the same error occurred.

spec bowling_spec.rb --format specdoc is working ..

Thank you


Regards,
P.Raveendran
http://raveendran.wordpress.com
This topic is locked and can not be replied to.