cucumber

Plain text code posted by asdf
created at 29 Sep 08:41

Edit | Back
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
<markdown> 

Here at Hashrocket, we follow a well defined process for all our client projects. The process starts with discovery of business value, goes through wireframing, storycarding, look and feel, design and finally development of the product. 

In this article, I am going to focus on how we build products the Outside In and Behavior Driven Development (BDD) way.

As a case study, we are going to build part of a job candidate management system to be able to create, edit, show, list all, and search for candidates. The stories are defined in Pivotal Tracker as below: (you can also see details of the stories here.

We use pickler for easy interaction with Pivotal Tracker. We will use it to start a Cucumber feature for our first story "User views candidates". In this feature file, we will create a scenario and describe the expected behaviors: generate 3 candidates with fabrication, go to the candidate list page, and we should see the 3 candidates in the table sorted by first name. 

@http://www.pivotaltracker.com/story/show/18733537 @candidates
Feature: User views candidates
  In order to hire amazing people
  As a signed in user
  I want to see a list of candidates

  - Candidates page displays all candidates
  - Sorted by last name, first name
  - Fields displayed include:
  -- Name (last, first)
  -- Phone
  -- Emai
  -- Github
  -- Twitter
  -- Local
  -- Willing to Relocate
  -- Added On
  -- Status (pending, hired, rejected)

  Scenario: display candidates
    Given the following candidates:
      | first name | last name | phone        | email            | github      | twitter      | local | willing to relocate | added on   | status   |
      | Lisa       | Simpson   | 412-444-3333 | lisa@example.com | lisasgithub | lisastwitter | false | false               | 2011-02-10 | rejected |
      | Bart       | Simpson   | 412-333-2222 | bart@example.com | bartsgithub | bartstwitter | false | true                | 2010-02-02 | hired    |
      | Peter      | Griffin   | 312-333-2222 | joe@example.com  | joesgithub  | joestwitter  | true  | true                | 2009-01-01 | pending  |
    When I am on the candidate list page
    Then I should see the following table:
      | Name          | Phone        | Email            | Github      | Twitter      | Local | Willing to Relocate |
      | Bart Simpson  | 412-333-2222 | bart@example.com | bartsgithub | bartstwitter | false | true                |
      | Lisa Simpson  | 412-444-3333 | lisa@example.com | lisasgithub | lisastwitter | false | false               |
      | Peter Griffin | 312-333-2222 | joe@example.com  | joesgithub  | joestwitter  | true  | true                |

From an "Outside In" perspective, this would be the outer most layout of our application  we set expectation of the users interaction with the application. Of course, we haven't implemented this feature yet, so if we run cucumber it will fail because it cannot find a fabricator to generate a test object for a candidate. 

Let's then create a fabricator to make cucumber happy: 

</markdown>

  
3.05 KB in 3 ms with coderay