Rewrote all XPath evaluator type specs.

This commit is contained in:
Yorick Peterse 2014-11-09 23:43:01 +01:00
parent c5c3c5dbc3
commit ccbb19a42d
3 changed files with 10 additions and 14 deletions

View File

@ -3,20 +3,19 @@ require 'spec_helper'
describe Oga::XPath::Evaluator do describe Oga::XPath::Evaluator do
context 'float types' do context 'float types' do
before do before do
document = parse('<a></a>') @document = parse('')
@evaluator = described_class.new(document)
end end
example 'return a float' do example 'return a float' do
@evaluator.evaluate('1.2').should == 1.2 evaluate_xpath(@document, '1.2').should == 1.2
end end
example 'return a negative float' do example 'return a negative float' do
@evaluator.evaluate('-1.2').should == -1.2 evaluate_xpath(@document, '-1.2').should == -1.2
end end
example 'return floats as a Float' do example 'return floats as a Float' do
@evaluator.evaluate('1.2').is_a?(Float).should == true evaluate_xpath(@document, '1.2').is_a?(Float).should == true
end end
end end
end end

View File

@ -3,20 +3,19 @@ require 'spec_helper'
describe Oga::XPath::Evaluator do describe Oga::XPath::Evaluator do
context 'integer types' do context 'integer types' do
before do before do
document = parse('<a></a>') @document = parse('')
@evaluator = described_class.new(document)
end end
example 'return an integer' do example 'return an integer' do
@evaluator.evaluate('1').should == 1 evaluate_xpath(@document, '1').should == 1
end end
example 'return a negative integer' do example 'return a negative integer' do
@evaluator.evaluate('-2').should == -2 evaluate_xpath(@document, '-2').should == -2
end end
example 'return integers as a Float' do example 'return integers as a Float' do
@evaluator.evaluate('1').is_a?(Float).should == true evaluate_xpath(@document, '1').is_a?(Float).should == true
end end
end end
end end

View File

@ -3,13 +3,11 @@ require 'spec_helper'
describe Oga::XPath::Evaluator do describe Oga::XPath::Evaluator do
context 'string types' do context 'string types' do
before do before do
document = parse('<a></a>') @document = parse('')
evaluator = described_class.new(document)
@string = evaluator.evaluate('"foo"')
end end
example 'return the literal string' do example 'return the literal string' do
@string.should == 'foo' evaluate_xpath(@document, '"foo"').should == 'foo'
end end
end end
end end