Sha256: b87884bdfcfe17ffd89cf5a5922e6a63388a0692f71e3e12433730c02c4e7778

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: false

require 'spec_helper'

describe 'yard Sinclair#add_class_method' do
  let(:klass) { Class.new }

  describe 'Adding a method by String' do
    it 'returns the hostname' do
      builder = Sinclair.new(klass)
      builder.add_class_method(:hostname, 'ENV["HOSTNAME"]')
      builder.build
      ENV['HOSTNAME'] = 'myhost'

      expect(klass.hostname).to eq('myhost')
    end
  end

  describe 'Adding a method by Block' do
    it 'returns the timeout' do
      builder = Sinclair.new(klass)
      builder.add_class_method(:timeout) { ENV['TIMEOUT'] }
      builder.build
      ENV['TIMEOUT'] = '300'

      expect(klass.timeout).to eq('300')
    end
  end

  describe 'Passing type block' do
    it 'creates new method' do
      builder = Sinclair.new(klass)
      builder.add_class_method(:timeout, type: :block) { ENV['TIMEOUT'] }
      builder.build
      ENV['TIMEOUT'] = '300'

      expect(klass.timeout).to eq('300')
    end
  end

  describe 'Passing type call' do
    it 'creates new method' do
      builder = Sinclair.new(klass)
      builder.add_class_method(:attr_accessor, :timeout, type: :call)
      builder.build

      klass.timeout = 10
      expect(klass.timeout).to eq(10)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-2.1.0 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-2.0.1 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-2.0.0 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.16.3 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.16.2 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.16.1 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.16.0 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.15.0 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.14.2 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.14.1 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.14.0 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.13.0 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.12.1 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.12.0 spec/integration/yard/sinclair/add_class_method_spec.rb
sinclair-1.11.0 spec/integration/yard/sinclair/add_class_method_spec.rb