Sha256: 8f83d3ea760792c233581d72e9bf4795c868d0f81b07e50bf66ca34e112b762a

Contents?: true

Size: 634 Bytes

Versions: 3

Compression:

Stored size: 634 Bytes

Contents

module DescribeURI
  def describe_uri(uri, &block)
    describe "with uri: #{uri.inspect}" do
      before { @uri = uri }
      subject { Gitable::URI.parse(@uri) }
      URIChecker.new(self, &block)
    end
  end

  class URIChecker
    def initialize(example_group, &block)
      @example_group = example_group
      instance_eval(&block)
    end

    def it_sets(parts)
      parts.each do |part, value|
        it "sets #{part} to #{value.inspect}" do
          expect(subject.send(part)).to eq(value)
        end
      end
    end

    def method_missing(*args, &block)
      @example_group.send(*args, &block)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitable-0.4.0 spec/describe_uri.rb
gitable-0.3.1 spec/describe_uri.rb
gitable-0.3.0 spec/describe_uri.rb