[rspec-users] undefined method

bertly_the_coder muchira at gmail.com
Mon Jun 28 14:14:19 EDT 2010


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:


Hope that's clear enough, I am a tad confused about what's going on,
it looks pretty clear cut.


More information about the rspec-users mailing list