File: printing_struct.feature

package info (click to toggle)
ruby-table-print 1.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 296 kB
  • sloc: ruby: 1,823; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,457 bytes parent folder | download | duplicates (3)
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
Feature: Printing structs

  Scenario: A simple array of structs
    Given an array of structs named data with
      |title        | author |
      |First post!  | Ryan   |  
      |Second post! | John   |  
      |Third post!  | Peter  |
    When I table_print data
    Then the output should contain
    """
    TITLE        | AUTHOR
    -------------|-------
    First post!  | Ryan  
    Second post! | John  
    Third post!  | Peter
    """

  Scenario: A lambda column
    Given an array of structs named data with
      |title        | author |
      |First post!  | Ryan   |  
      |Second post! | John   |  
      |Third post!  | Peter  |
    When I table_print data, [:include => {:two => lambda{|hash| hash[:author]*2}}]
    Then the output should contain
    """
    TITLE        | AUTHOR | TWO       
    -------------|--------|-----------
    First post!  | Ryan   | RyanRyan  
    Second post! | John   | JohnJohn  
    Third post!  | Peter  | PeterPeter
    """

  Scenario: A method on the object
    Given an array of structs named data with
      |title        | author |
      |First post!  | Ryan   |  
      |Second post! | John   |  
      |Third post!  | Peter  |
    When I table_print data, [:include => :size]
    Then the output should contain
    """
    TITLE        | AUTHOR | SIZE
    -------------|--------|-----
    First post!  | Ryan   | 2   
    Second post! | John   | 2   
    Third post!  | Peter  | 2   
    """