spec/ruhl_spec.rb in ruhl-0.9.2 vs spec/ruhl_spec.rb in ruhl-0.9.3

- old
+ new

@@ -180,11 +180,10 @@ nodes[3]['value'].should == 'tin' nodes[4]['value'].should == 'man' end end - describe "use.html" do before do @html = File.read html(:use) @doc = create_doc end @@ -199,18 +198,71 @@ it "email will be set" do @doc.xpath('/html/body/div//input')[2]['value'].should == "jane@stonean.com" end end - + describe "collection_of_strings.html" do before do @html = File.read html(:collection_of_strings) + @doc = create_doc end - it "will have the string values in the li's" do - doc = create_doc - puts doc.to_s + describe "with no nested data-ruhls or other actions" do + it "will have 5 line items" do + @doc.xpath("//ul[@id='call-to_s']").first.children.length.should == 10 + end + + it "will have correct content" do + @doc.xpath("//ul[@id='call-to_s']//li").first.inner_html.should == "Object oriented" + end + + describe 'called from within a _use' do + it "will have correct line items" do + @doc.xpath("/html/body//ul[@id='_use-call-to_s']/li").children.length.should == 2 + end + + it "will have correct content" do + @doc.xpath("/html/body/ul[@id='_use-call-to_s']//li").first.inner_html.should == "Auntie" + end + end + end + + describe "with a nested data-ruhl" do + it "will have 5 line items" do + @doc.xpath("/html/body//ul[@id='call-upcase']").first.children.length.should == 10 + end + + it "will have correct content" do + @doc.xpath("/html/body/ul[@id='call-upcase']/li//span").first.inner_html. + should == "OBJECT ORIENTED" + end + end + + describe "with an additional action" do + it "will have 5 line items" do + @doc.xpath("/html/body//ul[@id='call-reverse']").first.children.length.should == 10 + end + + it "will have correct content" do + @doc.xpath("/html/body/ul[@id='call-reverse']//li").first.inner_html. + should == "detneiro tcejbO" + end + + it "last item will have correct content" do + @doc.xpath("/html/body/ul[@id='call-reverse']//li").last.inner_html. + should == "ecruos nepo" + end + end + end + + describe "when no method" do + before do + @html = "<p data-ruhl='nonexistant_method'>I am bad</p>"#File.read html(:debug) + end + + it 'should complain' do + lambda{ @doc = create_doc }.should raise_error(NoMethodError) end end end