File: xml_source_spec.rb

package info (click to toggle)
ruby-riddle 2.3.1-2~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,752 kB
  • sloc: sql: 25,022; php: 5,992; ruby: 4,757; sh: 59; makefile: 5
file content (53 lines) | stat: -rw-r--r-- 1,442 bytes parent folder | download
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# frozen_string_literal: true

require 'spec_helper'

describe Riddle::Configuration::XMLSource do
  it "should be invalid without an xmlpipe command, name and type if there's no parent" do
    source = Riddle::Configuration::XMLSource.new("xml1", "xmlpipe")
    source.should_not be_valid
    
    source.xmlpipe_command = "ls /var/null"
    source.should be_valid
    
    source.name = nil
    source.should_not be_valid
    
    source.name = "xml1"
    source.type = nil
    source.should_not be_valid
  end
  
  it "should be invalid without only a name and type if there is a parent" do
    source = Riddle::Configuration::XMLSource.new("xml1", "xmlpipe")
    source.should_not be_valid
    
    source.parent = "xmlparent"
    source.should be_valid
    
    source.name = nil
    source.should_not be_valid
    
    source.name = "xml1"
    source.type = nil
    source.should_not be_valid
  end
  
  it "should raise a ConfigurationError if rendering when not valid" do
    source = Riddle::Configuration::XMLSource.new("xml1", "xmlpipe")
    lambda { source.render }.should raise_error(Riddle::Configuration::ConfigurationError)
  end
  
  it "should render correctly when valid" do
    source = Riddle::Configuration::XMLSource.new("xml1", "xmlpipe")
    source.xmlpipe_command = "ls /var/null"
    
    source.render.should == <<-XMLSOURCE
source xml1
{
  type = xmlpipe
  xmlpipe_command = ls /var/null
}
    XMLSOURCE
  end
end