Sha256: 959eb6b799210980d5bc3b57e8f04ff98f6c56782ecec22c4cba384f744ee5f1
Contents?: true
Size: 1.29 KB
Versions: 11
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Sinclair::MethodBuilder do subject(:builder) { described_class.new(klass) } let(:klass) { Class.new } let(:definitions) { Sinclair::MethodDefinitions.new } let(:value) { Random.rand } let(:method_name) { :the_method } let(:instance) { klass.new } before do definitions.add(method_name, value.to_s) end describe '#build_methods' do context 'when building an instance method' do let(:type) { described_class::INSTANCE_METHOD } it do expect { builder.build_methods(definitions, type) } .to add_method(method_name).to(instance) end context 'when the method is called' do before { builder.build_methods(definitions, type) } it do expect(instance.the_method).to eq(value) end end end context 'when building a class method' do let(:type) { described_class::CLASS_METHOD } it do expect { builder.build_methods(definitions, type) } .to add_class_method(method_name).to(klass) end context 'when the method is called' do before { builder.build_methods(definitions, type) } it do expect(klass.the_method).to eq(value) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems