From 83b469597f6041876505fa9ac7632c2640af19d7 Mon Sep 17 00:00:00 2001 From: Jessica Lynn Suttles Date: Tue, 12 Feb 2013 12:56:39 -0800 Subject: [PATCH] organizes specs --- spec/lib/microformats2/collection_spec.rb | 23 +++++++++++++++---- spec/lib/microformats2_spec.rb | 17 +------------- .../{simple_hcard.html => hcard-simple.html} | 0 ....html => hentry-pauthor-hcard-nested.html} | 0 4 files changed, 20 insertions(+), 20 deletions(-) rename spec/support/{simple_hcard.html => hcard-simple.html} (100%) rename spec/support/{nested_hentry.html => hentry-pauthor-hcard-nested.html} (100%) diff --git a/spec/lib/microformats2/collection_spec.rb b/spec/lib/microformats2/collection_spec.rb index 7a9b9fc..1a7f96b 100644 --- a/spec/lib/microformats2/collection_spec.rb +++ b/spec/lib/microformats2/collection_spec.rb @@ -2,9 +2,24 @@ require "spec_helper" require "microformats2" describe Microformats2::Collection do - describe "with simple .h-card" do + describe "programatic case" do + cases_dir = "spec/support/cases/microformats.org/microformats-2" + html_files = Dir.entries(cases_dir).keep_if { |f| f =~ /([.]html$)/ } + + html_files.each do |html_file| + it "#{html_file}" do + json_file = html_file.gsub(/([.]html$)/, ".js") + html = open(File.join(cases_dir, html_file)).read + json = open(File.join(cases_dir, json_file)).read + + JSON.parse(Microformats2.parse(html).to_json).should == JSON.parse(json) + end + end + end + + describe ".h-card simple" do before do - html = "spec/support/simple_hcard.html" + html = "spec/support/hcard-simple.html" @collection = Microformats2.parse(html) end @@ -46,9 +61,9 @@ describe Microformats2::Collection do end end - describe "with .h-entry .p-author.h-card nested" do + describe ".h-entry .p-author.h-card nested" do before do - html = "spec/support/nested_hentry.html" + html = "spec/support/hentry-pauthor-hcard-nested.html" @collection = Microformats2.parse(html) end diff --git a/spec/lib/microformats2_spec.rb b/spec/lib/microformats2_spec.rb index 7b4ad44..3b2ca52 100644 --- a/spec/lib/microformats2_spec.rb +++ b/spec/lib/microformats2_spec.rb @@ -19,7 +19,7 @@ describe Microformats2 do Microformats2.read_html(@html).should include @html end it "can be a file path to html" do - html = "spec/support/simple_hcard.html" + html = "spec/support/hcard-simple.html" Microformats2.read_html(html).should include "
" end it "can be a url to html" do @@ -27,19 +27,4 @@ describe Microformats2 do Microformats2.read_html(html).should include "google" end end - - describe "programatic case" do - cases_dir = "spec/support/cases/microformats.org/microformats-2" - html_files = Dir.entries(cases_dir).keep_if { |f| f =~ /([.]html$)/ } - - html_files.each do |html_file| - it "#{html_file}" do - json_file = html_file.gsub(/([.]html$)/, ".js") - html = open(File.join(cases_dir, html_file)).read - json = open(File.join(cases_dir, json_file)).read - - JSON.parse(Microformats2.parse(html).to_json).should == JSON.parse(json) - end - end - end end diff --git a/spec/support/simple_hcard.html b/spec/support/hcard-simple.html similarity index 100% rename from spec/support/simple_hcard.html rename to spec/support/hcard-simple.html diff --git a/spec/support/nested_hentry.html b/spec/support/hentry-pauthor-hcard-nested.html similarity index 100% rename from spec/support/nested_hentry.html rename to spec/support/hentry-pauthor-hcard-nested.html