Sha256: b5d0e6a8c2fe7aa758561c3c45c355ca17483e6d893977644def4a11b5cc8acb

Contents?: true

Size: 775 Bytes

Versions: 5

Compression:

Stored size: 775 Bytes

Contents

shared_examples 'a variable method to formated string' do |method, format|
  let(:name) { :delta }
  let(:value) { 10.0 }
  let(:arguments) { { name: name, latex: '\delta', gnu: 'del' } }
  let(:subject) { described_class.new(arguments) }

  context "when #{format} is not defined" do
    before { arguments.delete(format) }

    it 'returns name' do
      expect(subject.public_send(method)).to eq('delta')
    end

    context 'when value is defined' do
      before { arguments[:value] = value }

      it 'returns the value' do
        expect(subject.public_send(method)).to eq('10')
      end
    end
  end

  context "when #{format} has been defined" do
    it "returns #{format}" do
      expect(subject.public_send(method)).to eq(arguments[format])
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
danica-2.0.1 spec/support/shared_examples/variable.rb
danica-2.0.0 spec/support/shared_examples/variable.rb
danica-1.2.0 spec/support/shared_examples/variable.rb
danica-1.1.0 spec/support/shared_examples/variable.rb
danica-1.0.0 spec/support/shared_examples/variable.rb