forked from bernerdschaefer/akephalos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
112 lines (100 loc) · 7.27 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta content='text/html; charset=utf-8' http-equiv='content-type' />
<title>
akephalos
</title>
<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0;' name='viewport' />
<link charset='utf-8' href='stylesheets/screen.css' media='screen' rel='stylesheet' type='text/css' />
<link href='stylesheets/iphone.css' media='only screen and (max-width: 480px)' rel='stylesheet' type='text/css' />
</head>
<body>
<header>
<h1>
<a href='/akephalos'>
akephalos
</a>
</h1>
</header>
<article>
<section>
<p>Akephalos is a full-stack headless browser for integration testing with
Capybara. It is built on top of <a href="http://htmlunit.sourceforge.net">HtmlUnit</a>,
a GUI-less browser for the Java platform, but can be run on both JRuby and
MRI with no need for JRuby to be installed on the system.</p>
</section>
<section>
<h2>Installation</h2>
</section>
<aside>
<div class="highlight"><pre>gem install akephalos</pre></div>
</aside>
<section>
<h2>Setup</h2>
<p>Configuring akephalos is as simple as requiring it and setting Capybara's
javascript driver:</p>
</section>
<aside>
<div class="highlight"><pre><span class="nb">require</span> <span class="s1">'akephalos'</span>
<span class="no">Capybara</span><span class="o">.</span><span class="n">javascript_driver</span> <span class="o">=</span> <span class="ss">:akephalos</span></pre></div>
</aside>
<section>
<h2>Basic Usage</h2>
<p>Akephalos provides a driver for Capybara, so using Akephalos is no
different than using Selenium or Rack::Test. For a full usage guide, check
out Capybara's DSL <a href="http://github.com/jnicklas/capybara">documentation</a>. It
makes no assumptions about the testing framework being used, and works with
RSpec, Cucumber, and Test::Unit.</p>
<p>Here's some sample RSpec code:</p>
</section>
<aside>
<div class="highlight"><pre><span class="n">describe</span> <span class="s2">"Home Page"</span> <span class="k">do</span>
 <span class="n">before</span> <span class="p">{</span> <span class="n">visit</span> <span class="s2">"/"</span> <span class="p">}</span>
 <span class="n">context</span> <span class="s2">"searching"</span> <span class="k">do</span>
 <span class="n">before</span> <span class="k">do</span>
 <span class="n">fill_in</span> <span class="s2">"Search"</span><span class="p">,</span> <span class="ss">:with</span> <span class="o">=></span> <span class="s2">"akephalos"</span>
 <span class="n">click_button</span> <span class="s2">"Go"</span>
 <span class="k">end</span>
 <span class="n">it</span> <span class="s2">"returns results"</span> <span class="p">{</span> <span class="n">page</span><span class="o">.</span><span class="n">should</span> <span class="n">have_css</span><span class="p">(</span><span class="s2">"#results"</span><span class="p">)</span> <span class="p">}</span>
 <span class="n">it</span> <span class="s2">"includes the search term"</span> <span class="p">{</span> <span class="n">page</span><span class="o">.</span><span class="n">should</span> <span class="n">have_content</span><span class="p">(</span><span class="s2">"akephalos"</span><span class="p">)</span> <span class="p">}</span>
 <span class="k">end</span>
<span class="k">end</span></pre></div>
</aside>
<section>
<h2>Configuration</h2>
<p>There are now a few configuration options available through Capybara's new
<code>register_driver</code> API.</p>
<h3>Using a different browser</h3>
<p>HtmlUnit supports a few browser implementations, and you can choose which
browser you would like to use through Akephalos. By default, Akephalos uses
Firefox 3.6.</p>
</section>
<aside>
<div class="highlight"><pre><span class="no">Capybara</span><span class="o">.</span><span class="n">register_driver</span> <span class="ss">:akephalos</span> <span class="k">do</span> <span class="o">|</span><span class="n">app</span><span class="o">|</span>
 <span class="c1"># available options:</span>
 <span class="c1"># :ie6, :ie7, :ie8, :firefox_3, :firefox_3_6</span>
 <span class="no">Capybara</span><span class="o">::</span><span class="no">Driver</span><span class="o">::</span><span class="no">Akephalos</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="ss">:browser</span> <span class="o">=></span> <span class="ss">:ie8</span><span class="p">)</span>
<span class="k">end</span></pre></div>
</aside>
<section>
<h3>Ignoring javascript errors</h3>
<p>By default HtmlUnit (and Akephalos) will raise an exception when an error
is encountered in javascript files. This is generally desireable, except
that certain libraries aren't supported by HtmlUnit. If possible, it's
best to keep the default behavior, and use Filters (see below) to mock
offending libraries. If needed, however, you can configure Akephalos to
ignore javascript errors.</p>
</section>
<aside>
<div class="highlight"><pre><span class="no">Capybara</span><span class="o">.</span><span class="n">register_driver</span> <span class="ss">:akephalos</span> <span class="k">do</span> <span class="o">|</span><span class="n">app</span><span class="o">|</span>
 <span class="no">Capybara</span><span class="o">::</span><span class="no">Driver</span><span class="o">::</span><span class="no">Akephalos</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="ss">:validate_scripts</span> <span class="o">=></span> <span class="kp">false</span><span class="p">)</span>
<span class="k">end</span></pre></div>
</aside>
<section>
<h2>More</h2>
<ul>
<li><p><a href="akephalos-bin.html">bin/akephalos</a> allows you to start an interactive
shell or DRb server, as well as perform other maintenance features.</p></li>
<li><p><a href="filters.html">Filters</a> allows you to declare mock responses for
external resources and services requested by the browser.</p></li>
</ul>
<h2>Resources</h2>
<ul>
<li><a href="http://bernerdschaefer.github.com/akephalos/api">API Documentation</a></li>
<li><a href="http://github.com/bernerdschaefer/akephalos">Source code</a> and
<a href="http://github.com/bernerdschaefer/akephalos/issues">issues</a> are hosted on
github.</li>
</ul>
</section>
</article>
<footer>
<p>
© 2010 · Bernerd Schaefer
</p>
</footer>
</body>
</html>