@@ -232,13 +232,14 @@ def self.from_xml(val)
232232 it "should translate text to integers" do
233233 @definition . blocks . first [ '3' ] . should == 3
234234 @definition . blocks . first [ '792' ] . should == 792
235+ @definition . blocks . first [ '08' ] . should == 8
236+ @definition . blocks . first [ '279.23' ] . should == 279
235237 end
236238
237- it "should raise on non-integer values" do
238- proc { @definition . blocks . first [ '08' ] } . should raise_error ( ArgumentError )
239- proc { @definition . blocks . first [ '793.12' ] } . should raise_error ( ArgumentError )
240- proc { @definition . blocks . first [ 'junk 11' ] } . should raise_error ( ArgumentError )
241- proc { @definition . blocks . first [ '11sttf' ] } . should raise_error ( ArgumentError )
239+ it "should extract whatever is possible and fall back to 0" do
240+ @definition . blocks . first [ 'junk 11' ] . should eql ( 0 )
241+ @definition . blocks . first [ '.?sttf' ] . should eql ( 0 )
242+ @definition . blocks . first [ '11sttf' ] . should eql ( 11 )
242243 end
243244
244245 context "when passed an array" do
@@ -284,41 +285,17 @@ def self.from_xml(val)
284285 @definition . blocks . first [ '0.3' ] . should == BigDecimal . new ( "0.3" )
285286 end
286287
287- it "should extract what it can, and fall back to 0" do
288- @definition . blocks . first [ 'junk 11' ] . should eql ( BigDecimal . new ( "0" ) )
289- @definition . blocks . first [ '11sttf' ] . should eql ( BigDecimal . new ( "11.0" ) )
290- end
291-
292- context "when passed an array" do
293- it "should translate the array elements to integer" do
294- @definition . blocks . first . call ( [ "12.1" , "328.2" ] ) . should == [ BigDecimal . new ( "12.1" ) , BigDecimal . new ( "328.2" ) ]
295- end
296- end
297- end
298-
299- describe "Fixnum" do
300- before do
301- @definition = ROXML ::Definition . new ( :fixnumvalue , :as => Fixnum )
302- end
303-
304- it_should_behave_like "block shorthand type declaration"
305-
306- it "should translate text to integers" do
307- @definition . blocks . first [ '3' ] . should == 3
308- @definition . blocks . first [ '792' ] . should == 792
309- @definition . blocks . first [ '08' ] . should == 8
310- @definition . blocks . first [ '279.23' ] . should == 279
288+ it "should raise on non-decimal values" do
289+ proc { @definition . blocks . first [ 'junk 11' ] } . should raise_error ( ArgumentError )
311290 end
312291
313- it "should extract whatever is possible and fall back to 0" do
314- @definition . blocks . first [ 'junk 11' ] . should eql ( 0 )
315- @definition . blocks . first [ '.?sttf' ] . should eql ( 0 )
316- @definition . blocks . first [ '11sttf' ] . should eql ( 11 )
292+ it "should extract what it can" do
293+ @definition . blocks . first [ '11sttf' ] . should eql ( BigDecimal . new ( "11.0" ) )
317294 end
318295
319296 context "when passed an array" do
320297 it "should translate the array elements to integer" do
321- @definition . blocks . first . call ( [ "792" , "12 ", "328" ] ) . should == [ 792 , 12 , 328 ]
298+ @definition . blocks . first . call ( [ "12.1 " , "328.2 " ] ) . should == [ BigDecimal . new ( "12.1" ) , BigDecimal . new ( " 328.2" ) ]
322299 end
323300 end
324301 end
0 commit comments