Sha256: 175de352b2950adc1cfa784056b534928701953a65dcedf61e44b1d89cfe4d4d
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') include Fathom describe YAMLImport do before do @demo_yaml_location = File.expand_path(File.dirname(__FILE__) + "/../../support/demo.yml") @demo_yaml = open(@demo_yaml_location).read @opts = {:content => @demo_yaml} @yi = YAMLImport.new(@opts) @result = @yi.import end it "should not work unless content is set" do lambda{YAMLImport.new.import}.should raise_error lambda{YAMLImport.new(@opts)}.should_not raise_error end it "should create PlausibleRange nodes for any hashes with at least a min and max key in it" do @result.find {|r| r.name == "CO2 Emissions"}.should_not be_nil end it "should not create a PlausibleRange for entries missing min and max" do @result.find {|r| r.name == "Invalid Hash"}.should be_nil end it "should be able to create a PlausibleRange with more complete information" do more_complete_range = @result.find {|r| r.name == "More Complete Range"} more_complete_range.ci.should eql(0.6) more_complete_range.description.should eql('Some good description') end it "should create DataNodes for entries that have an array of information" do data_node = @result.find {|r| r.name == 'CO2 Readings'} data_node.should be_a(DataNode) data_node.values.should eql([10,20,30]) end it "should store the imported values in the knowledge base" do Fathom.knowledge_base['CO2 Emissions'].should be_a(PlausibleRange) Fathom.kb['CO2 Emissions'].min.should eql(1_000_000) end it "should import from the class level" do YAMLImport.import(@opts) Fathom.knowledge_base['CO2 Emissions'].should be_a(PlausibleRange) Fathom.kb['CO2 Emissions'].min.should eql(1_000_000) end end
Version data entries
4 entries across 4 versions & 1 rubygems