diff --git a/spec/oga/css/evaluator/paths_spec.rb b/spec/oga/css/evaluator/paths_spec.rb
new file mode 100644
index 0000000..2174d01
--- /dev/null
+++ b/spec/oga/css/evaluator/paths_spec.rb
@@ -0,0 +1,127 @@
+require 'spec_helper'
+
+describe 'CSS selector evaluation' do
+ before do
+ @document = parse('')
+ end
+
+ context 'regular paths' do
+ before do
+ @set = evaluate_css(@document, 'a')
+ end
+
+ it_behaves_like :node_set, :length => 1
+
+ example 'return the node' do
+ @set[0].should == @document.children[0]
+ end
+ end
+
+ context 'nested paths' do
+ before do
+ @set = evaluate_css(@document, 'a b')
+ end
+
+ it_behaves_like :node_set, :length => 2
+
+ example 'include the first node' do
+ @set[0].should == @document.children[0].children[0]
+ end
+
+ example 'include the second node' do
+ @set[1].should == @document.children[0].children[1]
+ end
+ end
+
+ context 'paths with namespaces' do
+ before do
+ @set = evaluate_css(@document, 'a ns1|c')
+ end
+
+ it_behaves_like :node_set, :length => 1
+
+ example 'include the node' do
+ @set[0].should == @document.children[0].children[2]
+ end
+ end
+
+ context 'paths with name wildcards' do
+ before do
+ @set = evaluate_css(@document, 'a *')
+ end
+
+ it_behaves_like :node_set, :length => 3
+
+ example 'include the first node' do
+ @set[0].should == @document.children[0].children[0]
+ end
+
+ example 'include the second node' do
+ @set[1].should == @document.children[0].children[1]
+ end
+
+ example 'include the second node' do
+ @set[2].should == @document.children[0].children[2]
+ end
+ end
+
+ context 'paths with namespace wildcards' do
+ before do
+ @set = evaluate_css(@document, 'a *|c')
+ end
+
+ it_behaves_like :node_set, :length => 1
+
+ example 'include the node' do
+ @set[0].should == @document.children[0].children[2]
+ end
+ end
+
+ context 'paths with namespaces and name wildcards' do
+ before do
+ @set = evaluate_css(@document, 'a ns1|*')
+ end
+
+ it_behaves_like :node_set, :length => 1
+
+ example 'include the node' do
+ @set[0].should == @document.children[0].children[2]
+ end
+ end
+
+ context 'paths with full wildcards' do
+ before do
+ @set = evaluate_css(@document, 'a *|*')
+ end
+
+ it_behaves_like :node_set, :length => 3
+
+ example 'include the first node' do
+ @set[0].should == @document.children[0].children[0]
+ end
+
+ example 'include the second node' do
+ @set[1].should == @document.children[0].children[1]
+ end
+
+ example 'include the second node' do
+ @set[2].should == @document.children[0].children[2]
+ end
+ end
+
+ context 'paths without namespaces and with name wildcards' do
+ before do
+ @set = evaluate_css(@document, 'a |*')
+ end
+
+ it_behaves_like :node_set, :length => 2
+
+ example 'include the first node' do
+ @set[0].should == @document.children[0].children[0]
+ end
+
+ example 'include the second node' do
+ @set[1].should == @document.children[0].children[1]
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index f54dabd..fa88d15 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -7,11 +7,14 @@ end
require_relative '../lib/oga'
require_relative 'support/parsing'
+require_relative 'support/evaluation'
require_relative 'support/shared_examples'
RSpec.configure do |config|
config.color = true
+
config.include Oga::ParsingHelpers
+ config.include Oga::EvaluationHelpers
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
diff --git a/spec/support/evaluation.rb b/spec/support/evaluation.rb
new file mode 100644
index 0000000..8afe164
--- /dev/null
+++ b/spec/support/evaluation.rb
@@ -0,0 +1,16 @@
+module Oga
+ module EvaluationHelpers
+ ##
+ # Parses and evaluates a CSS expression.
+ #
+ # @param [Oga::XML::Document] document
+ # @param [String] css
+ # @return [Oga::XML::NodeSet]
+ #
+ def evaluate_css(document, css)
+ xpath = parse_css(css)
+
+ return Oga::XPath::Evaluator.new(document).evaluate_ast(xpath)
+ end
+ end # EvaluationHelpers
+end # Oga