Sha256: c1ab567281a8ba3c9cce069c087f4173f4b9708a2e3b8c41efc197b763d9786c

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

require 'nokogiri'

module Ruhl
  module Rspec
    module Sinatra
      def self.included(parent)

        ruby = <<-RUBY
          before do
            f = File.basename("#{caller[0].split(':').first}")
            f = "#{app.views}/" + f.sub('_spec.rb','')
            puts f
            @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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruhl-0.19.0 lib/ruhl/rspec/sinatra.rb