<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[177] trunk/spec: Gotta rename the spec, too</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>177</dd>
<dt>Author</dt> <dd>arex</dd>
<dt>Date</dt> <dd>2008-06-04 04:48:26 -0400 (Wed, 04 Jun 2008)</dd>
</dl>
<h3>Log Message</h3>
<pre>Gotta rename the spec, too</pre>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkspecbrowser_specrb">trunk/spec/browser_spec.rb</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkspecie_specrb">trunk/spec/ie_spec.rb</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkspecbrowser_specrbfromrev176trunkspecie_specrb"></a>
<div class="copfile"><h4>Copied: trunk/spec/browser_spec.rb (from rev 176, trunk/spec/ie_spec.rb) (0 => 177)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/spec/browser_spec.rb         (rev 0)
+++ trunk/spec/browser_spec.rb        2008-06-04 08:48:26 UTC (rev 177)
</span><span class="lines">@@ -0,0 +1,226 @@
</span><ins>+require File.dirname(__FILE__) + '/spec_helper.rb'
+
+describe IE do
+
+ before :all do
+ @browser = IE.new
+ end
+
+ # Exists
+ describe "#exists?" do
+ it "should return true if we are at a page" do
+ @browser.should_not exist
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ @browser.should exist
+ end
+
+ it "should return false after IE#close" do
+ @browser.close
+ @browser.should_not exist
+ end
+ end
+
+ describe "#html" do
+ it "should return the html of the page" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ @browser.html.should == File.read(File.dirname(__FILE__) + "/html/non_control_elements.html")
+ end
+ end
+
+ describe "#title" do
+ it "should return the current page title" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ @browser.title.should == "Non-control elements"
+ end
+ end
+
+ describe "#text" do
+ it "should return the text of the page" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ @browser.text.should include("Dubito, ergo cogito, ergo sum.")
+ end
+
+ it "should return the text also if the content-type is text/plain" do
+ # more specs for text/plain? what happens if we call other methods?
+ @browser.goto(TEST_HOST + "/plain_text")
+ @browser.text.strip.should == 'This is text/plain'
+ end
+
+ it "should return text in the correct charset (utf-8)" do
+ @browser.goto(TEST_HOST + "/utf8_text.html")
+ @browser.text.strip.should == "\303\246\303\245\303\270"
+ end
+
+ it "should return text in the correct charset (latin-1)" do
+ @browser.goto(TEST_HOST + "/latin1_text.html")
+ @browser.text.strip.should == "\370\345\346"
+ end
+ end
+
+ describe "#url" do
+ it "should return the current url" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ @browser.url.should == TEST_HOST + "/non_control_elements.html"
+ end
+ end
+
+ describe "#document" do
+ it "should return the underlying object" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ if RUBY_PLATFORM =~ /java/
+ @browser.document.should be_instance_of(Java::ComGargoylesoftwareHtmlunitHtml::HtmlHtml)
+ else
+ @browser.document.should be_instance_of(WIN32OLE)
+ end
+ end
+ end
+
+ # Show methods
+ describe "#method_missing" do
+ it "should return all div elements on the page in a human readable format" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ temp_stdout = StringIO.new
+ old_stdout = $stdout
+ $stdout = temp_stdout
+ begin
+ @browser.show_divs
+ ensure
+ $stdout = old_stdout
+ end
+ temp_stdout.string.should ==
+'Found 8 divs
+1:
+2: id="outer_container"
+3: id="header" title="Header and primary navigation" class="profile"
+4: id="promo" name="invalid_attribute" value="invalid_attribute"
+5: id="content"
+6: id="best_language" onclick="this.innerHTML = \'Ruby!\'" style="color: red; text-decoration: underline; cursor: pointer;"
+7: id="html_test" class="some_class" title="This is a title"
+8: id="footer" title="Closing remarks" class="profile"
+'
+ end
+
+ it "should raise NoMethodError if the collection does not exist" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ lambda { @browser.show_no_such_collection }.should raise_error(NoMethodError)
+ end
+ end
+
+ # Manipulation methods
+ describe ".start" do
+ it "should go to the given URL and return an instance of itself" do
+ @browser = Celerity::IE.start(TEST_HOST + "/non_control_elements.html")
+ @browser.should be_instance_of(Celerity::IE)
+ @browser.title.should == "Non-control elements"
+ end
+ end
+
+ describe "#goto" do
+ # waiting for JRuby OpenSSL
+ # it "should handle HTTPS" do
+ # pending
+ # end
+
+ it "should go to the given url without raising errors" do
+ lambda { @browser.goto(TEST_HOST + "/non_control_elements.html") }.should_not raise_error
+ end
+ end
+
+ describe "#refresh" do
+ it "should refresh the page" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ @browser.span(:name, 'footer').click
+ @browser.span(:name, 'footer').text.should include('Javascript')
+ @browser.refresh
+ @browser.span(:name, 'footer').text.should_not include('Javascript')
+ end
+ end
+
+ describe "#execute_script" do
+ it "should execute the given JavaScript on the current page" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ @browser.pre(:id, 'rspec').text.should_not == "javascript text"
+ @browser.execute_script("document.getElementById('rspec').innerHTML = 'javascript text'")
+ @browser.pre(:id, 'rspec').text.should == "javascript text"
+ end
+ end
+
+ describe "#back" do
+ it "should go to the previous page" do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ orig_url = @browser.url
+ @browser.goto(TEST_HOST + "/tables.html")
+ new_url = @browser.url
+ orig_url.should_not == new_url
+ @browser.back
+ orig_url.should == @browser.url
+ end
+ end
+
+ # Other
+ describe "#contains_text" do
+ before :each do
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ end
+
+ it "should raise ArgumentError when called with no or wrong arguments" do
+ lambda { @browser.contains_text }.should raise_error(ArgumentError)
+ lambda { @browser.contains_text(nil) }.should raise_error(ArgumentError)
+ lambda { @browser.contains_text(42) }.should raise_error(ArgumentError)
+ end
+
+ it "should return the index if the given text exists" do
+ @browser.contains_text('Dubito, ergo cogito, ergo sum.').should be_instance_of(Fixnum)
+ @browser.contains_text(/Dubito.*sum./).should_not be_nil
+ end
+
+ it "should return nil if the text doesn't exist" do
+ @browser.contains_text('no_such_text').should be_nil
+ @browser.contains_text(/no_such_text/).should be_nil
+ end
+
+ it "should not raise error on a blank page" do
+ @browser = IE.new
+ lambda { @browser.contains_text('') }.should_not raise_error
+ end
+ end
+
+ describe "#add_checker" do
+ it "should raise ArgumentError when not given any arguments" do
+ lambda { @browser.add_checker }.should raise_error(ArgumentError)
+ end
+
+ it "should run the given proc on each page load" do
+ output = ''
+ proc = Proc.new { |ie| output << ie.text }
+ @browser.add_checker(proc)
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ output.should include('Dubito, ergo cogito, ergo sum')
+ end
+
+ it "should run the given block on each page load" do
+ output = ''
+ @browser.add_checker { |ie| output << ie.text }
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ output.should include('Dubito, ergo cogito, ergo sum')
+ end
+ end
+
+ describe "#disable_checker" do
+ it "should remove a previously added checker" do
+ output = ''
+ checker = lambda { |ie| output << ie.text }
+ @browser.add_checker(checker)
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ output.should include('Dubito, ergo cogito, ergo sum')
+ @browser.disable_checker(checker)
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
+ output.should include('Dubito, ergo cogito, ergo sum')
+ end
+ end
+
+ after :all do
+ @browser.close
+ end
+
+end
</ins></span></pre></div>
<a id="trunkspecie_specrb"></a>
<div class="delfile"><h4>Deleted: trunk/spec/ie_spec.rb (176 => 177)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/spec/ie_spec.rb        2008-06-03 13:57:57 UTC (rev 176)
+++ trunk/spec/ie_spec.rb        2008-06-04 08:48:26 UTC (rev 177)
</span><span class="lines">@@ -1,226 +0,0 @@
</span><del>-require File.dirname(__FILE__) + '/spec_helper.rb'
-
-describe IE do
-
- before :all do
- @browser = IE.new
- end
-
- # Exists
- describe "#exists?" do
- it "should return true if we are at a page" do
- @browser.should_not exist
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- @browser.should exist
- end
-
- it "should return false after IE#close" do
- @browser.close
- @browser.should_not exist
- end
- end
-
- describe "#html" do
- it "should return the html of the page" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- @browser.html.should == File.read(File.dirname(__FILE__) + "/html/non_control_elements.html")
- end
- end
-
- describe "#title" do
- it "should return the current page title" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- @browser.title.should == "Non-control elements"
- end
- end
-
- describe "#text" do
- it "should return the text of the page" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- @browser.text.should include("Dubito, ergo cogito, ergo sum.")
- end
-
- it "should return the text also if the content-type is text/plain" do
- # more specs for text/plain? what happens if we call other methods?
- @browser.goto(TEST_HOST + "/plain_text")
- @browser.text.strip.should == 'This is text/plain'
- end
-
- it "should return text in the correct charset (utf-8)" do
- @browser.goto(TEST_HOST + "/utf8_text.html")
- @browser.text.strip.should == "\303\246\303\245\303\270"
- end
-
- it "should return text in the correct charset (latin-1)" do
- @browser.goto(TEST_HOST + "/latin1_text.html")
- @browser.text.strip.should == "\370\345\346"
- end
- end
-
- describe "#url" do
- it "should return the current url" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- @browser.url.should == TEST_HOST + "/non_control_elements.html"
- end
- end
-
- describe "#document" do
- it "should return the underlying object" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- if RUBY_PLATFORM =~ /java/
- @browser.document.should be_instance_of(Java::ComGargoylesoftwareHtmlunitHtml::HtmlHtml)
- else
- @browser.document.should be_instance_of(WIN32OLE)
- end
- end
- end
-
- # Show methods
- describe "#method_missing" do
- it "should return all div elements on the page in a human readable format" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- temp_stdout = StringIO.new
- old_stdout = $stdout
- $stdout = temp_stdout
- begin
- @browser.show_divs
- ensure
- $stdout = old_stdout
- end
- temp_stdout.string.should ==
-'Found 8 divs
-1:
-2: id="outer_container"
-3: id="header" title="Header and primary navigation" class="profile"
-4: id="promo" name="invalid_attribute" value="invalid_attribute"
-5: id="content"
-6: id="best_language" onclick="this.innerHTML = \'Ruby!\'" style="color: red; text-decoration: underline; cursor: pointer;"
-7: id="html_test" class="some_class" title="This is a title"
-8: id="footer" title="Closing remarks" class="profile"
-'
- end
-
- it "should raise NoMethodError if the collection does not exist" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- lambda { @browser.show_no_such_collection }.should raise_error(NoMethodError)
- end
- end
-
- # Manipulation methods
- describe ".start" do
- it "should go to the given URL and return an instance of itself" do
- @browser = Celerity::IE.start(TEST_HOST + "/non_control_elements.html")
- @browser.should be_instance_of(Celerity::IE)
- @browser.title.should == "Non-control elements"
- end
- end
-
- describe "#goto" do
- # waiting for JRuby OpenSSL
- # it "should handle HTTPS" do
- # pending
- # end
-
- it "should go to the given url without raising errors" do
- lambda { @browser.goto(TEST_HOST + "/non_control_elements.html") }.should_not raise_error
- end
- end
-
- describe "#refresh" do
- it "should refresh the page" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- @browser.span(:name, 'footer').click
- @browser.span(:name, 'footer').text.should include('Javascript')
- @browser.refresh
- @browser.span(:name, 'footer').text.should_not include('Javascript')
- end
- end
-
- describe "#execute_script" do
- it "should execute the given JavaScript on the current page" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- @browser.pre(:id, 'rspec').text.should_not == "javascript text"
- @browser.execute_script("document.getElementById('rspec').innerHTML = 'javascript text'")
- @browser.pre(:id, 'rspec').text.should == "javascript text"
- end
- end
-
- describe "#back" do
- it "should go to the previous page" do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- orig_url = @browser.url
- @browser.goto(TEST_HOST + "/tables.html")
- new_url = @browser.url
- orig_url.should_not == new_url
- @browser.back
- orig_url.should == @browser.url
- end
- end
-
- # Other
- describe "#contains_text" do
- before :each do
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- end
-
- it "should raise ArgumentError when called with no or wrong arguments" do
- lambda { @browser.contains_text }.should raise_error(ArgumentError)
- lambda { @browser.contains_text(nil) }.should raise_error(ArgumentError)
- lambda { @browser.contains_text(42) }.should raise_error(ArgumentError)
- end
-
- it "should return the index if the given text exists" do
- @browser.contains_text('Dubito, ergo cogito, ergo sum.').should be_instance_of(Fixnum)
- @browser.contains_text(/Dubito.*sum./).should_not be_nil
- end
-
- it "should return nil if the text doesn't exist" do
- @browser.contains_text('no_such_text').should be_nil
- @browser.contains_text(/no_such_text/).should be_nil
- end
-
- it "should not raise error on a blank page" do
- @browser = IE.new
- lambda { @browser.contains_text('') }.should_not raise_error
- end
- end
-
- describe "#add_checker" do
- it "should raise ArgumentError when not given any arguments" do
- lambda { @browser.add_checker }.should raise_error(ArgumentError)
- end
-
- it "should run the given proc on each page load" do
- output = ''
- proc = Proc.new { |ie| output << ie.text }
- @browser.add_checker(proc)
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- output.should include('Dubito, ergo cogito, ergo sum')
- end
-
- it "should run the given block on each page load" do
- output = ''
- @browser.add_checker { |ie| output << ie.text }
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- output.should include('Dubito, ergo cogito, ergo sum')
- end
- end
-
- describe "#disable_checker" do
- it "should remove a previously added checker" do
- output = ''
- checker = lambda { |ie| output << ie.text }
- @browser.add_checker(checker)
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- output.should include('Dubito, ergo cogito, ergo sum')
- @browser.disable_checker(checker)
- @browser.goto(TEST_HOST + "/non_control_elements.html")
- output.should include('Dubito, ergo cogito, ergo sum')
- end
- end
-
- after :all do
- @browser.close
- end
-
-end
</del></span></pre>
</div>
</div>
</body>
</html>