Commit 65daa975 by Gabriel Falcão

starting to refactor the documentation

parent 56674ecc
...@@ -86,10 +86,8 @@ em { font-style: italic} ...@@ -86,10 +86,8 @@ em { font-style: italic}
ins { font-weight: bold; text-decoration: none} ins { font-weight: bold; text-decoration: none}
/*** lists ***/ /*** lists ***/
ul { padding-left:30px}
ol { padding-left:30px}
ol.arabic li { list-style-type: decimal} ol.arabic li { list-style-type: decimal}
ul li { list-style-type:square; font-size: 14px} ul li { list-style-type:none; font-size: 14px}
ol li { margin-bottom: .4em} ol li { margin-bottom: .4em}
ul ul { padding-left:1.2em} ul ul { padding-left:1.2em}
ul ul ul { padding-left:1em} ul ul ul { padding-left:1em}
......
{% extends "!layout.html" %} {% extends "!layout.html" %}
{% set script_files = script_files + [pathto("_static/jquery-1.4.2.min.js", 1)] %}
{%- macro secondnav() %} {%- macro secondnav() %}
{%- if prev %} {%- if prev %}
&laquo; <a href="{{ prev.link|e }}" title="{{ prev.title|e }}">previous</a> &laquo; <a href="{{ prev.link|e }}" title="{{ prev.title|e }}">previous</a>
...@@ -98,10 +98,4 @@ try { ...@@ -98,10 +98,4 @@ try {
var pageTracker = _gat._getTracker("UA-1277640-6"); var pageTracker = _gat._getTracker("UA-1277640-6");
pageTracker._trackPageview(); pageTracker._trackPageview();
} catch(err) {}</script> } catch(err) {}</script>
<script type="text/javascript">
$(function(){
});
</script>
{% endblock %} {% endblock %}
...@@ -104,9 +104,9 @@ walkthrough ...@@ -104,9 +104,9 @@ walkthrough
**tutorials** **tutorials**
* :ref:`writting your first feature <tutorial-simple>` * :ref:`write your first feature <tutorial-simple>`
* :ref:`steps with tables <tutorial-tables>` * :ref:`handling data with tables <tutorial-tables>`
* :ref:`scenario Outlines <tutorial-scenario-outlines>` * :ref:`say "no" to repetition, meet scenario outlines <tutorial-scenario-outlines>`
* :ref:`taking actions before and after tests <tutorial-hooks>` * :ref:`taking actions before and after tests <tutorial-hooks>`
furthermore furthermore
......
...@@ -3,3 +3,52 @@ ...@@ -3,3 +3,52 @@
================= =================
Scenario Outlines Scenario Outlines
================= =================
On our :ref:`first description file<tutorial-simple>`, `zero.feature`, all scenarios were
similar. This made us repeat most of the text again and again.
**Isn't there a better way to deal with this - when several scenarios are almost equal and only some values change?**
Yes, there is! :) You just need to use scenarios outlines.
An example is shown bellow:
.. highlight:: ruby
::
Feature: Compute factorial
In order to play with Lettuce
As beginners
We'll implement factorial
Scenario Outline: Factorials [0-4]
Given I have the number <number>
When I compute its factorial
Then I see the number <result>
Examples:
| number | result |
| 0 | 1 |
| 1 | 1 |
| 2 | 2 |
| 3 | 6 |
| 4 | 24 |
This way, you will only need to provide the values that really change,
reducing "copy & paste" work and making your tests more clear.
.. Note::
If you overwrite zero.feature using the example above, and goto
step [e], you'll see your description expanding to the five
previous scenarious:
.. image:: ./screenshot7.png
.. _Lettuce: http://lettuce.it
.. _Python: http://python.org
.. _Cucumber: http://cukes.info
.. _Ruby: http://ruby-lang.org/
.. _BDD: http://en.wikipedia.org/wiki/Behavior_Driven_Development
...@@ -411,52 +411,6 @@ quality of your software depends on these. ...@@ -411,52 +411,6 @@ quality of your software depends on these.
Have a nice lettuce...! ;) Have a nice lettuce...! ;)
Tips for describing similar features
====================================
On our first description file, `zero.feature`, all scenarios were
similar. This made us repeat most of the text again and again.
**Isn't there a better way to deal with this - when several scenarios are almost equal and only some values change?**
Yes, there is! :) You just need to use scenarios outlines.
An example is shown bellow:
.. highlight:: ruby
::
Feature: Compute factorial
In order to play with Lettuce
As beginners
We'll implement factorial
Scenario Outline: Factorials [0-4]
Given I have the number <number>
When I compute its factorial
Then I see the number <result>
Examples:
| number | result |
| 0 | 1 |
| 1 | 1 |
| 2 | 2 |
| 3 | 6 |
| 4 | 24 |
This way, you will only need to provide the values that really change,
reducing "copy & paste" work and making your tests more clear.
.. Note::
If you overwrite zero.feature using the example above, and goto
step [e], you'll see your description expanding to the five
previous scenarious:
.. image:: ./screenshot7.png
.. _Lettuce: http://lettuce.it .. _Lettuce: http://lettuce.it
.. _Python: http://python.org .. _Python: http://python.org
.. _Cucumber: http://cukes.info .. _Cucumber: http://cukes.info
......
.. _tutorial-tables: .. _tutorial-tables:
====== Handling data with tables
Tables =========================
======
Let us put that you are writting a MVC application. Along the tests
you will stumble in a kind of situation in which there is a few models
that must be added to the database. Maybe you will also need to check
the new state of those.
It means that as you write tests with lettuce, it can be very useful
to handle data within steps.
Step tables are here for you:
.. highlight:: ruby
::
Feature: bill students alphabetically
In order to bill students properly
As a finantial specialist
I want to bill those which name starts with some letter
Scenario: Bill students which name starts with "G"
Given I have the following students in my database:
| name | monthly due | billed |
| Anton | $ 500 | no |
| Jack | $ 400 | no |
| John | $ 540 | no |
| Garrick | $ 438.11 | no |
| Gabriel | $ 300 | no |
| Gloria | $ 442.65 | no |
| Gaye | $ 630.22 | no |
| Ken | $ 907.86 | no |
| Leonard | $ 742.84 | no |
When I bill names starting with "G"
Then I see those billed students:
| Garrick | $ 438.11 | yes |
| Gabriel | $ 300 | yes |
| Gloria | $ 442.65 | yes |
| Gaye | $ 630.22 | yes |
And those that weren't:
| Anton | $ 500 | no |
| Jack | $ 400 | no |
| John | $ 540 | no |
| Ken | $ 907.86 | no |
| Leonard | $ 742.84 | no |
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment