Cucumber Features

Expand All

Collapse All

Feature: Rodolfo CLI

As a developer
I want to generate pdf reports from the cli
In order to be able to use it the reports from any programming language

Background

  1. Given a file named "myrecipe/schema.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {
      "id": "http://www.example.com/json-schema/v2/tpl/example-template",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Example Template"
    }
  2. And a file named "myrecipe/template.rb" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    module Rodolfo
      # Example
      class Template < Prawn::Document
        def initialize(data, options = {})
          @data = data
          super page_size: 'A4', page_layout: :portrait, **options
        end
    
        def render
          text @data[:msg]
          super
        end
      end
    end
    
  3. And a file named "myrecipe/data.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {"msg": "Hello World"}
features/cli.feature:38

Scenario: Getting the current cli version

  1. When I run `rodolfo --version`
    aruba-0.14.2/lib/aruba/cucumber/command.rb:13
  2. Then the exit status should be 0
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  3. And the stdout should contain the current Rodolfo version
    features/step_definitions/steps.rb:1
features/cli.feature:43

Scenario: Getting the json schema of a template

  1. When I run `rodolfo schema myrecipe`
    aruba-0.14.2/lib/aruba/cucumber/command.rb:13
  2. Then the output should contain "Example Template"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:159
features/cli.feature:47

Scenario: Running the cli without specifying a template

  1. When I run `rodolfo`
    aruba-0.14.2/lib/aruba/cucumber/command.rb:13
  2. Then the exit status should be 0
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  3. And the output should contain "rodolfo help [COMMAND]"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:159
features/cli.feature:52

Scenario: Generate a pdf

  1. When I run `rodolfo render myrecipe` interactively
    aruba-0.14.2/lib/aruba/cucumber/command.rb:49
  2. And I pipe in the file "myrecipe/data.json"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:67
  3. Then the exit status should be 0
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  4. And the stdout should contain the generated pdf contents
    features/step_definitions/steps.rb:22
  5. And the pdf should include:
    features/step_definitions/steps.rb:12
    Hello World
  6. And the pdf should contain 1 page
    features/step_definitions/steps.rb:18
  7. And the pdf should contain metadata
    features/step_definitions/steps.rb:29
features/cli.feature:62

Scenario: Generate a pdf on a file

  1. When I run `rodolfo render myrecipe --save-to output.pdf` interactively
    aruba-0.14.2/lib/aruba/cucumber/command.rb:49
  2. And I pipe in the file "myrecipe/data.json"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:67
  3. Then the exit status should be 0
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  4. And the file named "output.pdf" should exist and be a valid pdf
    features/step_definitions/steps.rb:5
  5. And the pdf should include:
    features/step_definitions/steps.rb:12
    Hello World
  6. And the pdf should contain 1 page
    features/step_definitions/steps.rb:18
features/cli.feature:71

Scenario: Generate a pdf with missing field required on json schema

  1. Given a file named "myrecipe/schema.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {
      "id": "http://www.example.com/json-schema/v2/tpl/example-template",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Example",
      "required": ["name", "country"],
      "properties": {
          "name": {"type": "string"},
          "country": {"type": "string"}
      }
    }
  2. And a file named "myrecipe/data.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {"name": "Carlos"}
  3. When I run `rodolfo render myrecipe` interactively
    aruba-0.14.2/lib/aruba/cucumber/command.rb:49
  4. And I pipe in the file "myrecipe/data.json"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:67
  5. Then the exit status should be 2
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  6. And the stdout should contain "did not contain a required property of 'country' in schema"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:159
features/cli.feature:94

Scenario: Generate a pdf with missing field NOT required on json schema It should fail anyway because of the json parser "strict" option

  1. Given a file named "myrecipe/schema.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {
      "id": "http://www.example.com/json-schema/v2/tpl/example-template",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Example",
      "required": [],
      "properties": {
          "name": {"type": "string"},
          "country": {"type": "string"}
      }
    }
  2. And a file named "myrecipe/data.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {"name": "Carlos"}
  3. When I run `rodolfo render myrecipe` interactively
    aruba-0.14.2/lib/aruba/cucumber/command.rb:49
  4. And I pipe in the file "myrecipe/data.json"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:67
  5. Then the exit status should be 2
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  6. And the stdout should contain "did not contain a required property of 'country' in schema"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:159
features/cli.feature:120

Scenario: Generate a pdf with missing data which is not required on the json schema

  1. Given a file named "myrecipe/schema.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {
      "id": "http://www.example.com/json-schema/v2/tpl/example-template",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Example",
      "required": ["name"],
      "properties": {
          "name": {"type": "string"}
      }
    }
  2. And a file named "myrecipe/template.rb" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    module Rodolfo
      # Example
      class Template < Prawn::Document
        def initialize(data, options = {})
          @data = data
          super page_size: 'A4', page_layout: :portrait, **options
        end
    
        def render
          text @data[:msg]
          text @data[:user][:name]
          super
        end
      end
    end
  3. And a file named "myrecipe/data.json" with:
    aruba-0.14.2/lib/aruba/cucumber/file.rb:23
    {"name": "Carlos"}
  4. When I run `rodolfo render myrecipe` interactively
    aruba-0.14.2/lib/aruba/cucumber/command.rb:49
  5. And I pipe in the file "myrecipe/data.json"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:67
  6. Then the exit status should be 2
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  7. And the stdout should contain "Missing or incorrect data, template can't be rendered"
    aruba-0.14.2/lib/aruba/cucumber/command.rb:159
features/cli.feature:160

Scenario: Getting pdf info

  1. Given a file example.pdf
    features/step_definitions/steps.rb:40
  2. When I run `rodolfo read example.pdf`
    aruba-0.14.2/lib/aruba/cucumber/command.rb:13
  3. Then the exit status should be 0
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
features/cli.feature:165

Scenario: Scaffold a recipe

  1. When I run `rodolfo g new-recipe "an example recipe"`
    aruba-0.14.2/lib/aruba/cucumber/command.rb:13
  2. Then the exit status should be 0
    aruba-0.14.2/lib/aruba/cucumber/command.rb:277
  3. And the directory "new-recipe" should exist
    aruba-0.14.2/lib/aruba/cucumber/file.rb:91
  4. And the file "new-recipe/data.json" should exist
    aruba-0.14.2/lib/aruba/cucumber/file.rb:91
  5. And the file "new-recipe/schema.json" should exist
    aruba-0.14.2/lib/aruba/cucumber/file.rb:91
  6. And the file "new-recipe/template.rb" should exist
    aruba-0.14.2/lib/aruba/cucumber/file.rb:91