require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper])) describe Ziya::Gauges::Thermo do describe "#initialize" do before( :each ) do @gauge = Ziya::Gauges::Thermo.new( "test_license", "override" ) end it "should create a gauge with the correct license" do @gauge.license.should == "test_license" end it "should create a gauge with the correct id" do @gauge.design_id.should == "override" end end describe "#to_xml" do it "should produce the correct xml for the std gauge" do buff = Ziya::Gauges::Thermo.new( "test_license" ).to_xml buff.scan( / 100 ) buff = gauge.to_xml buff.scan( /end_scale=\"(.*?\d+)\"/ ).should == [["80"]] end it "user can override thermo color" do gauge = Ziya::Gauges::Thermo.new( "test_license" ) gauge.set_preferences( :gauge_color => "00FF00" ) buff = gauge.to_xml buff.scan( /end_scale=\"(.*?\d+)\"/ ).should == [["20"]] buff.scan( /color=\"(\w+)\"/ ).uniq.should == [["ffffff"], ["00FF00"], ["ffff00"], ["cccccc"], ["aaaaaa"], ["880000"]] end end end