Sha256: f0f7e0d83b240eca436f23c4249ecd19386b9894b3b7e2ec4b49decb94b95e32

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 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
  {
    addition:       Danica::Operator::Addition,
    sum:            Danica::Operator::Addition,
    multiplication: Danica::Operator::Multiplication,
    product:        Danica::Operator::Multiplication,
    division:       Danica::Operator::Division,
    sin:            Danica::Operator::Sin,
    cos:            Danica::Operator::Cos,
    power:          Danica::Operator::Power
  }.each do |aliaz, clazz|
    it_behaves_like 'a class with alias to a clazz', aliaz, clazz, 2, 3
  end
  {
    squared_root:  Danica::Operator::SquaredRoot,
    exponential:   Danica::Operator::Exponential,
    group:         Danica::Wrapper::Group,
    negative:      Danica::Wrapper::Negative,
    number:        Danica::Wrapper::Number,
    num:           Danica::Wrapper::Number,
    plus_minus:    Danica::Wrapper::PlusMinus
  }.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

1 entries across 1 versions & 1 rubygems

Version Path
danica-2.3.1 spec/lib/danica/dsl_spec.rb