Skip to content

Commit

Permalink
Writing combinator specs
Browse files Browse the repository at this point in the history
  E F, E > F, E + F, E ~ F
  • Loading branch information
Carl Lerche committed Oct 22, 2008
1 parent d27e66f commit 6554322
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/combinator_adjacent_to_spec.rb
@@ -0,0 +1,25 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "The adjacent to combinator" do

it "<div + p> should return the p tag" do
HTML.should have_nodes("div + p", 1)
end

it "<span + span> should return the last 3 span tags" do
HTML.should have_nodes("span[foo] + span", 3)
end

it "<span[foo] + span> should return the last 3 span tags" do
HTML.should have_nodes("span[foo] + span", 2)
end

it "<body + div> should not return anything" do
HTML.should have_nodes("body + div", 0)
end

it "<p + body> should not return anything" do
HTML.should have_nodes("p + body", 0)
end

end
33 changes: 33 additions & 0 deletions spec/combinator_child_of_spec.rb
@@ -0,0 +1,33 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "The child of combinator" do

it "<body > *> should return all the child nodes of the body" do
HTML.should have_nodes("body > *", 5)
end

it "<div > *> should return all the child nodes of the div" do
HTML.should have_nodes("div > *", 5)
end

it "<body > p> should return the p" do
HTML.should have_nodes("body > p", 3)
end

it "<body > span> should return nothing" do
HTML.should have_nodes("body > span", 0)
end

it "<div > body> should return nothing" do
HTML.should have_nodes("div > body", 0)
end

it "<body > div > span> should return the spans" do
HTML.should have_nodes("body > div > span", 4)
end

it "<html > div > span> should return nothing" do
HTML.should have_nodes("html > div > span", 0)
end

end
25 changes: 25 additions & 0 deletions spec/combinator_descendant_of_spec.rb
@@ -0,0 +1,25 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "The descendant of combinator" do

it "<body *> should return all the child nodes of the body" do
HTML.should have_nodes("body *", 10)
end

it "<div *> should return all the child nodes of the div" do
HTML.should have_nodes("div *", 5)
end

it "<body p> should return the p" do
HTML.should have_nodes("body p", 3)
end

it "<div body> should return nothing" do
HTML.should have_nodes("div body", 0)
end

it "<html div span> should return the spans" do
HTML.should have_nodes("html div span", 4)
end

end
9 changes: 9 additions & 0 deletions spec/combinator_sibling_of_spec.rb
@@ -0,0 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "The simbling of combinator" do

it "should be awesome" do

end

end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
@@ -1,4 +1,6 @@
require "rubygems"
require "libxml"
require 'spec'
require File.join(File.dirname(__FILE__), "..", "css")

HTML = <<HERE
Expand Down

0 comments on commit 6554322

Please sign in to comment.