Sha256: 0c980979309dc65f238e381b171a7166e626f604bf34841182bc2c102aeef1dd

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

shared_context 'a class with alias to a clazz' do |aliaz, clazz, *variables|
  it do
    expect(subject).to respond_to(aliaz)
  end

  it "has an alias #{aliaz} for #{clazz}" do
    expect(subject.public_send(aliaz, *variables)).to eq(clazz.new(*variables))
  end
end

shared_context 'a class with mapped dsl' do
  {
    sum: Danica::Sum,
    product: Danica::Product,
    division: Danica::Division,
    sin: Danica::Sin,
    cos: Danica::Cos,
    power: Danica::Power
  }.each do |aliaz, clazz|
    it_behaves_like 'a class with alias to a clazz', aliaz, clazz, 2, 3
  end
  {
    squared_root: Danica::SquaredRoot,
    exponential: Danica::Exponential,
    group: Danica::Group,
    negative: Danica::Negative,
    number: Danica::Number
  }.each do |aliaz, clazz|
    it_behaves_like 'a class with alias to a clazz', aliaz, clazz, 9
  end
end

describe Danica::DSL do
  class Danica::DSL::Dummy
    include Danica::DSL
  end

  let(:subject) { described_class::Dummy.new }
  it_behaves_like 'a class with mapped dsl'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danica-2.2.1 spec/lib/danica/dsl_spec.rb
danica-2.2.0 spec/lib/danica/dsl_spec.rb