Skip to content

Instantly share code, notes, and snippets.

@yorickpeterse
Created March 11, 2014 19:24
Show Gist options
  • Save yorickpeterse/cff63c2df5d91783b815 to your computer and use it in GitHub Desktop.
Save yorickpeterse/cff63c2df5d91783b815 to your computer and use it in GitHub Desktop.
class SomeScraper
def initialize(document)
@document = document
end
def parse
return @document.at('p.foo').text
end
end
# some_scraper_spec.rb
describe SomeScraper do
before do
node = double(:node, :text => 'Foo')
document = double(:document, :at => node)
@scraper = described_class.new(document)
end
example 'return the text' do
@scraper.parse.should == 'Foo'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment