From d47ca19ffa8a43220dd1d89a63c42d5774414abd Mon Sep 17 00:00:00 2001 From: Yorick Peterse <yorickpeterse@gmail.com> Date: Fri, 14 Nov 2014 00:24:54 +0100 Subject: [PATCH] Remaining CSS evaluation specs. --- .../evaluator/pseudo_classes/only_child_spec.rb | 17 +++++++++++++++++ .../pseudo_classes/only_of_type_spec.rb | 17 +++++++++++++++++ .../css/evaluator/pseudo_classes/root_spec.rb | 13 +++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 spec/oga/css/evaluator/pseudo_classes/only_child_spec.rb create mode 100644 spec/oga/css/evaluator/pseudo_classes/only_of_type_spec.rb create mode 100644 spec/oga/css/evaluator/pseudo_classes/root_spec.rb diff --git a/spec/oga/css/evaluator/pseudo_classes/only_child_spec.rb b/spec/oga/css/evaluator/pseudo_classes/only_child_spec.rb new file mode 100644 index 0000000..d83f540 --- /dev/null +++ b/spec/oga/css/evaluator/pseudo_classes/only_child_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'CSS selector evaluation' do + context ':only-child pseudo class' do + before do + @document = parse('<root><a><c /></a><b><c /></b></root>') + + @root = @document.children[0] + @c1 = @root.children[0].children[0] + @c2 = @root.children[1].children[0] + end + + example 'return a node set containing <c> nodes' do + evaluate_css(@document, 'root :only-child').should == node_set(@c1, @c2) + end + end +end diff --git a/spec/oga/css/evaluator/pseudo_classes/only_of_type_spec.rb b/spec/oga/css/evaluator/pseudo_classes/only_of_type_spec.rb new file mode 100644 index 0000000..8a21230 --- /dev/null +++ b/spec/oga/css/evaluator/pseudo_classes/only_of_type_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'CSS selector evaluation' do + context ':only-of-type pseudo class' do + before do + @document = parse('<root><a><c /></a><b><c /></b></root>') + + @root = @document.children[0] + @c1 = @root.children[0].children[0] + @c2 = @root.children[1].children[0] + end + + example 'return a node set containing <c> nodes' do + evaluate_css(@document, 'root a :only-of-type').should == node_set(@c1) + end + end +end diff --git a/spec/oga/css/evaluator/pseudo_classes/root_spec.rb b/spec/oga/css/evaluator/pseudo_classes/root_spec.rb new file mode 100644 index 0000000..f045f6e --- /dev/null +++ b/spec/oga/css/evaluator/pseudo_classes/root_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe 'CSS selector evaluation' do + context ':root pseudo class' do + before do + @document = parse('<root><a /></root>') + end + + example 'return a node set containing the root node' do + evaluate_css(@document, ':root').should == @document.children + end + end +end