Sha256: 273848323acf21fa51c30d6468cd67bb2f674f264c2731ed6af4a164300c96f1
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') shared_examples_for "measurement object" do it "should take a quantity and units" do m = measurement_with(:value => 11.3, :units => 'inches') m.value.should == 11.3 m.units.should == 'inches' end it "should default units to 'pixels', as we use it mostly for images" do m = measurement_with(:value => 22.19) m.value.should == 22.19 m.units.should == 'pixels' end it "should translate 'hundredths-' units to standard quantities" do m = measurement_with(:value => 1130, :units => 'hundredths-inches') m.value.should == 11.3 m.units.should == 'inches' end end describe Amazon::Associates::Measurement do describe "#initialize" do def measurement_with(opts) Amazon::Associates::Measurement.new(*opts.values_at(:value, :units).compact) end it_should_behave_like "measurement object" end describe "#from_xml" do def measurement_with(opts) doc = ROXML::XML::Document.new doc.root = ROXML::XML::Node.new('width', doc) doc.root.add_child( Nokogiri::XML::Text.new(opts[:value].to_s, doc)) doc.root['Units'] = opts[:units] unless opts[:units].blank? Amazon::Associates::Measurement.from_xml(doc.root) end it_should_behave_like "measurement object" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
amazon-associates-0.7.2 | spec/types/measurement_spec.rb |
amazon-associates-0.7.1 | spec/types/measurement_spec.rb |
amazon-associates-0.7.0 | spec/types/measurement_spec.rb |