6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/ruhl/rspec/rails.rb', line 6
def self.included(parent)
ruby = <<-RUBY
before do
f = "#{caller[0].split(':').first}"
f = f.sub("\.\/spec","#{::Rails.root}\/app").sub('_spec.rb','')
@view_nodes = Nokogiri::HTML.fragment(File.read(f))
end
def ruhl_view
@view_nodes
end
def data_ruhl(path)
tag = ruhl_view.css(path).first
unless tag
raise Spec::Matchers::MatcherError.new("CSS selector: "+ path + " not found")
end
tag.attribute('data-ruhl').to_s
end
RUBY
parent.class_eval ruby
end
|