Sha256: 6574783eca10bc35d1f5e15eb26fde5bbd88b70e6cc3696234ec9ab985066267

Contents?: true

Size: 744 Bytes

Versions: 20

Compression:

Stored size: 744 Bytes

Contents

require 'nokogiri'

module Ruhl
  module Rspec
    module Rails
      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
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ruhl-1.3.6 lib/ruhl/rspec/rails.rb
ruhl-1.3.5 lib/ruhl/rspec/rails.rb
ruhl-1.3.4 lib/ruhl/rspec/rails.rb
ruhl-1.3.3 lib/ruhl/rspec/rails.rb
ruhl-1.3.2 lib/ruhl/rspec/rails.rb
ruhl-1.3.1 lib/ruhl/rspec/rails.rb
ruhl-1.3.0 lib/ruhl/rspec/rails.rb
ruhl-1.2.0 lib/ruhl/rspec/rails.rb
ruhl-1.1.1 lib/ruhl/rspec/rails.rb
ruhl-1.1.0 lib/ruhl/rspec/rails.rb
ruhl-1.0.0 lib/ruhl/rspec/rails.rb
ruhl-0.26.1 lib/ruhl/rspec/rails.rb
ruhl-0.26.0 lib/ruhl/rspec/rails.rb
ruhl-0.25.0 lib/ruhl/rspec/rails.rb
ruhl-0.24.0 lib/ruhl/rspec/rails.rb
ruhl-0.23.0 lib/ruhl/rspec/rails.rb
ruhl-0.22.0 lib/ruhl/rspec/rails.rb
ruhl-0.21.0 lib/ruhl/rspec/rails.rb
ruhl-0.20.0 lib/ruhl/rspec/rails.rb
ruhl-0.19.0 lib/ruhl/rspec/rails.rb