Sha256: 29e559bbf1d7adb237a47ae3becce1566a8a8bfc59b8138400e15d40350de8fc

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

# encoding: utf-8

describe AbstractMapper::SoleRule do

  let(:rule)  { test.new(node) }
  let(:test)  { AbstractMapper::Test::Rule = Class.new(described_class) }
  let(:nodes) { [node] }
  let(:node)  { AbstractMapper::Node.new }

  describe ".new" do

    subject { rule }

    it { is_expected.to be_kind_of AbstractMapper::Rule }
    it { is_expected.to be_frozen }

    it "denies second argument" do
      expect { test.new(node, node) }.to raise_error(ArgumentError)
    end

  end # describe .new

  describe "#node" do

    subject { rule.node }
    it { is_expected.to eql node }

  end # describe #node

  describe "#transproc" do

    before do
      test.send(:define_method, :optimize?) { node > 3          }
      test.send(:define_method, :optimize)  { -node if node < 7 }
    end

    let(:array) { [5, 1, 38, 4] }

    subject { test.transproc[array] }
    it { is_expected.to eql [-5, 1, -4] }

  end # describe #transproc

end # describe AbstractMapper::SoleRule

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abstract_mapper-0.0.2 spec/unit/abstract_mapper/sole_rule_spec.rb