On Jun 28, 2010, at 1:14 PM, bertly_the_coder wrote: > Hey Guys, > I am working on my first TDD/BDDD example and running into a problem, > when I run 'ruby app.rb" The app seems to run fine, but when I run > it's rspec 'spec app_spec.rb" I get a no method defined. > > app.rb > require 'rubygems' > require 'open-uri' > require 'hpricot' > > class Timer > #this is the retrieve method used to retrieve the contents of the xml > file > > def self.retrieve > doc = Hpricot(open('some site')) > #get the times > times = doc/"//times" > puts times > end > end > > Timer.retrieve - this works fine > > rspec > require 'app' > > describe Timer do > it "should retrieve the xml info from the site" do > Timer.should retrieve > end > > end > > error: > NameError in 'Timer should retrieve the xml info from the site' > undefined local variable or method `retrieve' for > #<Spec::Example::ExampleGroup::Subclass_1:0xb6dc9c70> > ./app.rb:7:
This error tells you that there is no retrieve() method on the example itself, but the expression "Timer.should retrieve" expects there to be. Try something like this: describe Timer do it "retrieves xml from the site" do Timer.retrieve.should == "whatever you're expecting" end end > Hope that's clear enough, I am a tad confused about what's going on, > it looks pretty clear cut. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users