From ccbb19a42d9f244b6e68934c98336cfe447a991e Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sun, 9 Nov 2014 23:43:01 +0100 Subject: [PATCH] Rewrote all XPath evaluator type specs. --- spec/oga/xpath/evaluator/types/float_spec.rb | 9 ++++----- spec/oga/xpath/evaluator/types/int_spec.rb | 9 ++++----- spec/oga/xpath/evaluator/types/string_spec.rb | 6 ++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/spec/oga/xpath/evaluator/types/float_spec.rb b/spec/oga/xpath/evaluator/types/float_spec.rb index edd4077..e0e1f76 100644 --- a/spec/oga/xpath/evaluator/types/float_spec.rb +++ b/spec/oga/xpath/evaluator/types/float_spec.rb @@ -3,20 +3,19 @@ require 'spec_helper' describe Oga::XPath::Evaluator do context 'float types' do before do - document = parse('') - @evaluator = described_class.new(document) + @document = parse('') end example 'return a float' do - @evaluator.evaluate('1.2').should == 1.2 + evaluate_xpath(@document, '1.2').should == 1.2 end example 'return a negative float' do - @evaluator.evaluate('-1.2').should == -1.2 + evaluate_xpath(@document, '-1.2').should == -1.2 end 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 diff --git a/spec/oga/xpath/evaluator/types/int_spec.rb b/spec/oga/xpath/evaluator/types/int_spec.rb index 35364c3..cd0666b 100644 --- a/spec/oga/xpath/evaluator/types/int_spec.rb +++ b/spec/oga/xpath/evaluator/types/int_spec.rb @@ -3,20 +3,19 @@ require 'spec_helper' describe Oga::XPath::Evaluator do context 'integer types' do before do - document = parse('') - @evaluator = described_class.new(document) + @document = parse('') end example 'return an integer' do - @evaluator.evaluate('1').should == 1 + evaluate_xpath(@document, '1').should == 1 end example 'return a negative integer' do - @evaluator.evaluate('-2').should == -2 + evaluate_xpath(@document, '-2').should == -2 end 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 diff --git a/spec/oga/xpath/evaluator/types/string_spec.rb b/spec/oga/xpath/evaluator/types/string_spec.rb index f310350..5f27788 100644 --- a/spec/oga/xpath/evaluator/types/string_spec.rb +++ b/spec/oga/xpath/evaluator/types/string_spec.rb @@ -3,13 +3,11 @@ require 'spec_helper' describe Oga::XPath::Evaluator do context 'string types' do before do - document = parse('') - evaluator = described_class.new(document) - @string = evaluator.evaluate('"foo"') + @document = parse('') end example 'return the literal string' do - @string.should == 'foo' + evaluate_xpath(@document, '"foo"').should == 'foo' end end end