Sha256: e625db33cb667c0ec2d09f4c68fea8a53ca754480c1a7268915a5f4b7b5edafb
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 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 an ImportNode as a return value" do @result.should be_an(ImportNode) end it "should create PlausibleRange nodes for any hashes with at least a min and max key in it" do @result.co2_emissions.should_not be_nil end it "should not create a PlausibleRange for entries missing min and max" do @result.should_not respond_to(:invalid_hash) end it "should be able to create a PlausibleRange with more complete information" do @result.more_complete_range.ci.should eql(0.6) @result.more_complete_range.description.should eql('Some good description') end it "should create DataNodes for entries that have an array of information" do @result.co2_readings.should be_a(DataNode) @result.co2_readings.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fathom-0.3.0 | spec/fathom/import/yaml_import_spec.rb |