Sha256: c33f6de32cf991565e9d8b4dc7d63ee170e276fde061abedce0b852687b163e0

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

module Rack::Insight
  module RspecMatchers

    RSpec::Matchers.define :have_row do |container, key, value|
      match do |response|
        if value
          response.should have_selector("#{container} tr", :content => key) do |row|
            row.should contain(value)
          end
        else
          response.should have_selector("#{container} tr", :content => key)
        end
      end

      failure_message_for_should do |response|
        "Expected: \n#{response.body}\nto have a row matching #{key}"
      end
    end

    RSpec::Matchers.define :have_li do |container, key, value|
      match do |response|
        if value
          response.should have_selector("#{container} li", :content => key) do |row|
            row.should contain(value)
          end
        else
          response.should have_selector("#{container} li", :content => key)
        end
      end

      failure_message_for_should do |response|
        "Expected: \n#{response.body}\nto have a li matching #{key}"
      end
    end

    RSpec::Matchers.define :have_heading do |text|
      match do |response|
        response.should have_selector("#rack-insight_toolbar li") do |heading|
          heading.should contain(text)
        end
      end

      failure_message_for_should do |response|
        "Expected: \n#{response.body}\nto have heading #{text}"
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/rspec_matchers.rb
rack-insight-0.6.3 lib/rack/insight/rspec_matchers.rb
rack-insight-0.6.2 lib/rack/insight/rspec_matchers.rb
rack-insight-0.5.30 lib/rack/insight/rspec_matchers.rb
rack-insight-0.5.29 lib/rack/insight/rspec_matchers.rb
rack-insight-0.5.28 lib/rack/insight/rspec_matchers.rb
rack-insight-0.5.27 lib/rack/insight/rspec_matchers.rb