Sha256: 38186bf9e721fcce69d49cda480fde9424f320e255ff7694a198fc0002431396

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require "bbq-widget/version"

module Bbq

  module Widget

    class WithinCssId

      attr_accessor :css_id
      private :css_id=

      # parent must respond to capybara dsl. It does not matter
      # if it is user or widget
      def initialize(parent, css_id)
        @parent = parent
        self.css_id = "##{css_id}"
        return self
      end

      def withinme
        if @withinme
          yield
        else
          begin
            @withinme = true
            @parent.within(:css, css_id) do
              yield
            end
          ensure
            @withinme = false
          end
        end
      end

      def method_missing(method_id, *arguments, &block)
        withinme do
          @parent.send(method_id, *arguments, &block)
        end
      end

      if RUBY_VERSION < '1.9'
        def respond_to?(method_id, include_private = false)
          @parent.respond_to?(method_id) || super
        end
      else
        def respond_to_missing?(method_id, include_private = false)
          @parent.respond_to?(method_id) || super
        end
      end

      def has?(*params)
        see?(*params)
      end

      def has!(*params)
        see!(*params)
      end

      def lacks?(*params)
        not_see?(*params)
      end

      def lacks!(*params)
        not_see!(*params)
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bbq-widget-0.0.2 lib/bbq-widget/within_css_id.rb