Welcome to mirror list, hosted at ThFree Co, Russian Federation.

spec-doc.rb « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d1e778b120b208b6690f9423f633856352402b46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class SpecDoc
  def initialize(response)
    @html = Nokogiri::HTML(response.body)
  end

  def method_missing(method, *args)
    @html.send method, *args
  end

  def has_content?(string)
    escaped = string.gsub("'", "\\'")
    @html.xpath("//*[contains(text(), '#{escaped}')]").any?
  end
  def has_no_content?(string)
    ! has_content?(string)
  end

  def has_link?(text)
    @html.xpath("//a[text()='#{text}']").any?
  end
end

def doc
  SpecDoc.new response
end