Sha256: 91570a95bf627583469a5a8a7ca8c3cae901e2e8e111f62c25dc25f98a6ceba7
Contents?: true
Size: 1.3 KB
Versions: 16
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Sinclair::MethodBuilder::StringMethodBuilder do describe '#build' do subject(:builder) do described_class.new(klass, definition, type: type) end let(:klass) { Class.new } let(:instance) { klass.new } let(:value) { Random.rand } let(:method_name) { :the_method } let(:definition) do Sinclair::MethodDefinition.from(method_name, value.to_s) end context 'when type is instance' do let(:type) { Sinclair::MethodBuilder::INSTANCE_METHOD } it do expect { builder.build } .to add_method(method_name).to(instance) end context 'when the method is built' do before { builder.build } it 'returns the result of the code when called' do expect(instance.the_method).to eq(value) end end end context 'when type is class' do let(:type) { Sinclair::MethodBuilder::CLASS_METHOD } it do expect { builder.build } .to add_class_method(method_name).to(klass) end context 'when the method is built' do before { builder.build } it 'returns the result of the code when called' do expect(klass.the_method).to eq(value) end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems