Sha256: 9bc948d4bcf01d133ef7d23570a124b08ec90f149fdba58748641cbe2fa2e633
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe Sinclair do describe 'README' do describe 'Define method using block' do it 'adds the method' do klass = Class.new instance = klass.new builder = described_class.new(klass) builder.add_method(:random_number) { Random.rand(10..20) } builder.build expect(instance.random_number).to be_between(10, 20) end end describe 'Define method using string' do it 'adds the method' do klass = Class.new instance = klass.new builder = described_class.new(klass) builder.add_method(:random_number, 'Random.rand(10..20)') builder.build expect(instance.random_number).to be_between(10, 20) end end describe 'Define method using call to the class' do it 'performs the call to the class' do klass = Class.new builder = described_class.new(klass) builder.add_class_method(:attr_accessor, :number, type: :call) builder.build expect(klass.number).to be_nil klass.number = 10 expect(klass.number).to eq(10) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinclair-1.11.0 | spec/integration/readme/sinclair/types_of_definition_spec.rb |