aslakhellesoy-cucumber 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +0 -1
- data/README.txt +1 -0
- metadata +1 -2
- data/README.textile +0 -191
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aslakhellesoy-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Aslak Helles\xC3\xB8y"
|
@@ -75,7 +75,6 @@ files:
|
|
75
75
|
- History.txt
|
76
76
|
- License.txt
|
77
77
|
- Manifest.txt
|
78
|
-
- README.textile
|
79
78
|
- README.txt
|
80
79
|
- Rakefile
|
81
80
|
- TODO.txt
|
data/README.textile
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
h1. Cucumber
|
2
|
-
|
3
|
-
"Cucumber":http://github.com/aslakhellesoy/cucumber is a tool that can execute feature documentation written in plain text.
|
4
|
-
Cucumber targets non technical business analysts, interaction designers, domain experts, testers (for the plain text part)
|
5
|
-
and programmers (for the steps, which are written in Ruby).
|
6
|
-
|
7
|
-
Cucumber itself is also written in Ruby, but it can be used to "test" code written in Ruby, Java (or web applications written
|
8
|
-
in any language). When "IronRuby":http://www.ironruby.net/ matures it can be used to "test" .NET code too.
|
9
|
-
|
10
|
-
Cucumber only requires minimal use of Ruby programming, so don't be afraid to try it out even if the code you're
|
11
|
-
developing is in a different language. Most programmers should pick up the required Ruby skills and be productive
|
12
|
-
with Cucumber in a few of days.
|
13
|
-
|
14
|
-
While Cucumber can be thought of as a "testing" tool, the intent of the tool is to support "BDD":http://behaviour-driven.org/
|
15
|
-
This means that the "tests" (plain text feature descriptions with scenarios) are typically written before anything else, and
|
16
|
-
the production code is then written outside-in, to make them pass.
|
17
|
-
|
18
|
-
h2. Installation
|
19
|
-
|
20
|
-
After you have installed Ruby or JRuby - install Cucumber with the following commands:
|
21
|
-
|
22
|
-
Ruby:
|
23
|
-
<pre><code>gem sources --add http://gems.github.com/
|
24
|
-
gem install aslakhellesoy-cucumber
|
25
|
-
</code></pre>
|
26
|
-
|
27
|
-
JRuby:
|
28
|
-
<pre><code>jruby -S gem sources --add http://gems.github.com/
|
29
|
-
jruby -S gem install aslakhellesoy-cucumber
|
30
|
-
</code></pre>
|
31
|
-
|
32
|
-
h2. Getting started
|
33
|
-
|
34
|
-
There are several ways to get started, depending on the architecture of your application.
|
35
|
-
Take a look at the "examples":http://github.com/aslakhellesoy/cucumber/tree/master/examples.
|
36
|
-
Each example directory has a Rakefile, and you can run the features in an example directory with
|
37
|
-
|
38
|
-
<pre><code>rake features</code></pre>
|
39
|
-
|
40
|
-
The examples deliberately have errors so you can get a taste of how the error output looks like. You can get help by asking
|
41
|
-
for it:
|
42
|
-
|
43
|
-
<pre><code>cucumber --help</code></pre>
|
44
|
-
|
45
|
-
h2. Ruby on Rails
|
46
|
-
|
47
|
-
Cucumber has very nice Rails support, and I really recommend using "Webrat":http://github.com/brynary/webrat
|
48
|
-
in the step definitions. Here is how to get you started.
|
49
|
-
|
50
|
-
h3. Install Cucumber, Webrat and RSpec
|
51
|
-
|
52
|
-
<pre><code>git submodule add cucumber git://github.com/aslakhellesoy/cucumber.git vendor/plugins/cucumber
|
53
|
-
git submodule add webrat git://github.com/brynary/webrat.git vendor/plugins/webrat
|
54
|
-
git submodule add rspec git://github.com/dchelimsky/rspec.git vendor/plugins/rspec
|
55
|
-
git submodule add rspec-rails git://github.com/dchelimsky/rspec-rails.git vendor/plugins/rspec-rails
|
56
|
-
</code></pre>
|
57
|
-
|
58
|
-
If your own Rails code is not in Git, just replace "submodule add" with "clone".
|
59
|
-
|
60
|
-
h3. Install Other dependencies
|
61
|
-
|
62
|
-
<pre><code>gem install hpricot cucumber</code></pre>
|
63
|
-
|
64
|
-
Yes, you did already install cucumber as a plugin, but this will install all the dependent libraries you need.
|
65
|
-
|
66
|
-
h3. Bootstrap Cucumber
|
67
|
-
|
68
|
-
You'll need a Rake task and a couple of files that configure Cucumber for use with Ruby on Rails and Webrat.
|
69
|
-
You create these with:
|
70
|
-
|
71
|
-
<pre><code>ruby script/generate cucumber</code></pre>
|
72
|
-
|
73
|
-
Check out the generated files. If you need to, you can go and tweak them later.
|
74
|
-
|
75
|
-
h3. Start a feature
|
76
|
-
|
77
|
-
It's really, really recommended that you write your features by hand - in collaboration with your
|
78
|
-
customer / business analyst / domain expert / interaction designer. However, to get you started (and so you can see how to use
|
79
|
-
Webrat), you can use the feature generator to generate the first few features:
|
80
|
-
|
81
|
-
<pre><code>ruby script/generate feature Frooble name color description</code></pre>
|
82
|
-
|
83
|
-
This will generate a simple plain text feature with associated steps. Don't get addicted to this
|
84
|
-
generator - you're better off writing these by hand in the long run. See the BDD tips section below.
|
85
|
-
|
86
|
-
h3. Run features
|
87
|
-
|
88
|
-
<pre><code>rake features</code></pre>
|
89
|
-
|
90
|
-
This should result in failing scenarios, because you haven't written any code yet (I hope). Now you it's time
|
91
|
-
to write some code, or generate some. Try this:
|
92
|
-
|
93
|
-
<pre><code>script/generate rspec_scaffold Frooble name:string color:string description:text
|
94
|
-
rake db:migrate
|
95
|
-
rake features
|
96
|
-
</code></pre>
|
97
|
-
|
98
|
-
h3. Tips
|
99
|
-
|
100
|
-
These tips apply to Rails development in general...
|
101
|
-
|
102
|
-
* Talk to models directly in *Given* steps to set up a known state. Don't use fixtures.
|
103
|
-
* Use Webrat in *When* steps
|
104
|
-
* Use *response.should have_tag(...)* (and models) in *Then* steps to verify the *outcomes* (which are on the screen, not only in the database).
|
105
|
-
* Organise steps in files named accordingly to resources used
|
106
|
-
* Avoid keeping state in @variables in steps. It will couple your steps and make them harder to reuse.
|
107
|
-
|
108
|
-
h3. View spec redundancy
|
109
|
-
|
110
|
-
Since I recommend you verify outcomes (*Then* steps) by looking at the HTML, you might end up having some degree
|
111
|
-
of redundancy with view specs. I recommend you delete generated view specs if you run into too much maintenance
|
112
|
-
headaches and rely on the features instead of view specs. However, in some cases it can be handy to use both.
|
113
|
-
|
114
|
-
h2. BDD
|
115
|
-
|
116
|
-
If you have found a bug or want to add a feature, start by writing a new feature or scenario that describes the
|
117
|
-
|
118
|
-
Now run the features again. The one you wrote should have yellow, pending steps - or failing, red ones.
|
119
|
-
(If you don't get that you're doing something wrong, or the feature is already implemented).
|
120
|
-
|
121
|
-
This is when you start writing code. You might as well get used to doing it this way, because we won't accept
|
122
|
-
any patches unless you also have stories or specs for your code. This is because we don't want to end up with a
|
123
|
-
brittle, unmaintainable, undocumented pile of code that nobody understands. (Yes, stores and specs are *documentation* too).
|
124
|
-
|
125
|
-
If you think this sounds annoying, try it out anyway. You'll end up writing better (and less) code this way. Trust me.
|
126
|
-
Work outside-in (the outside being the story, the inside being the low level code). Do it the "BDD":http://en.wikipedia.org/wiki/Behavior_driven_development way.
|
127
|
-
|
128
|
-
h3. Business value and MMF
|
129
|
-
|
130
|
-
You should discuss the "In order to" part of the feature and pop the "why" stack max 5 times (ask why recursively)
|
131
|
-
until you end up with one of the following business values:
|
132
|
-
|
133
|
-
* Protect revenue
|
134
|
-
* Increase revenue
|
135
|
-
* Manage cost
|
136
|
-
|
137
|
-
If you're about to implement a feature that doesn't support one of those values, chances are you're about to
|
138
|
-
implement a non-valuable feature. Consider tossing it altogether or pushing it down in your backlog. Focus on
|
139
|
-
implementing the MMFs (Minimal Marketable Features) that will yield the most value.
|
140
|
-
|
141
|
-
h3. Outcomes and bottom-up scenarios.
|
142
|
-
|
143
|
-
The value provided by a system is what you can get out of it - not what you put into it. Just like the value
|
144
|
-
is expressed at the top of a feature (In order to...), the value should be in the steps of a scenarios too,
|
145
|
-
more precicely in the *Then* steps.
|
146
|
-
|
147
|
-
When you're writing a new scenario, I recommend you start with the formulation of the desired outcome. Write the
|
148
|
-
*Then* steps first. Then write the *When* step to discover the action/operation and finally write the *Given*
|
149
|
-
steps that need to be in place in order for the When/Then to make sense.
|
150
|
-
|
151
|
-
h2. Background and Credits
|
152
|
-
|
153
|
-
Cucumber is a rewrite of RSpec's "Story runner", which was originally written by Dan North. Dan's original
|
154
|
-
implementation required that stories be written in Ruby. Shortly after, David Chelimsky added
|
155
|
-
"plain text":http://blog.davidchelimsky.net/articles/2007/10/21/story-runner-in-plain-english support with
|
156
|
-
contributions from half a dozen other people.
|
157
|
-
|
158
|
-
The business value guidelines and general wording in features is based on several conversations and blog posts
|
159
|
-
by Chris Matts, Liz Keogh and Dan North.
|
160
|
-
|
161
|
-
This brought executable stories a little closer to non-technical users, which is one of the target audiences
|
162
|
-
for this kind of tool.
|
163
|
-
|
164
|
-
However, the RSpec Story runner has several shortcomings which is rather common for tools that move into new territory.
|
165
|
-
Some of the biggest problems with it are:
|
166
|
-
|
167
|
-
* Hard to get started with. A special "all.rb" file must be written before it can be used.
|
168
|
-
* No out of the box Rake support, which puts a lot of people off.
|
169
|
-
* No i18n, so if you want to write stories in a different language than English you're out of luck.
|
170
|
-
* Poor error reporting. No way to know on what line a plain text story failed during execution or parsing.
|
171
|
-
* Limited colouring of output.
|
172
|
-
* No simple way to execute only one scenario.
|
173
|
-
* No command line tool to run stories.
|
174
|
-
* No easy before or after hooks.
|
175
|
-
|
176
|
-
While all of this could have been fixed in the existing codebase, I figured it would be easier to do a rewrite from scratch.
|
177
|
-
I also had some ideas for extensions of the story grammar (like FIT style tables that you can see in some of the examples),
|
178
|
-
so I decided to base it on a proper
|
179
|
-
"grammar":http://github.com/aslakhellesoy/cucumber/tree/master/lib/cucumber/treetop_parser/feature.treetop.erb using
|
180
|
-
"Treetop":http://treetop.rubyforge.org/.
|
181
|
-
|
182
|
-
Cucumber addresses all of the above mentioned shortcomings of RSpec's Story runner.
|
183
|
-
If the community likes it, perhaps it will replace the RSpec story runner - either by
|
184
|
-
being assumed into RSpec proper, or remaining a separate tool like now.
|
185
|
-
|
186
|
-
The term "Feature" has been adopted in favour of "Story" because I believe it is a more
|
187
|
-
appropriate term. A feature's scenarios typically grow over time - fed by several user
|
188
|
-
stories.
|
189
|
-
|
190
|
-
The name Cucumber means absolutely nothing, it was suggested by my girlfriend who was eating a cucumber sandwich
|
191
|
-
while I started to write it.
|