summaryrefslogtreecommitdiffstats
path: root/spec/link_spec.rb
blob: 6120677a04857f8e298aa0f70ab4217a7014a666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#

require 'spec_helper'
#
describe Iotas::Link do
    #
    it "from particle data" do
        @spin = Iotas::Spin.new 'dom0'
        p = @spin.require_p Iotas::Particle
        p.set_data Iotas::LNK_SRC, 'input1'
        p.set_data Iotas::LNK_DSTS, 'concat1?follow,output1'
        p.set_data Iotas::LNK_FIELDS, 'f0,f2'
        p.set_data Iotas::LNK_CONDF, 'f0,f1,f2'
        p.set_data Iotas::LNK_CONDV, 'v0v1v2'
        lnk = Iotas::Link.from_particle_data p
        lnk.src.should eql 'input1'
        lnk.dsts.should eql 'concat1?follow,output1'
        lnk.fields.should eql 'f0,f2'
        lnk.cond_fields.should eql 'f0,f1,f2'
        lnk.cond_value.should eql 'v0v1v2'
    end
    #
    it "link->json->link" do
        link = Iotas::Link.new  'input1', 'concat1?follow,output1', 'f0,f2', 'f0,f1,f2', 'v0v1v2'
        lnk = Iotas::Link.json_create( JSON.load( JSON.generate(link) ) )
        link.src.should eql lnk.src
        link.dsts.should eql lnk.dsts
        link.fields.should eql lnk.fields
        link.cond_fields.should eql lnk.cond_fields
        link.cond_value.should eql lnk.cond_value
        JSON.generate(link).should eql JSON.generate(lnk)
    end
    #
end
#
# EOF