maniok_bdd 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
| @@ -17,64 +17,85 @@ class ManiokBdd::GherkinFormatter | |
| 17 17 | 
             
                @feature = Feature.new gherkin_model_feature
         | 
| 18 18 | 
             
              end
         | 
| 19 19 |  | 
| 20 | 
            -
               | 
| 21 | 
            -
                 | 
| 20 | 
            +
              def scenario(gherkin_model_scenario)
         | 
| 21 | 
            +
                @feature.scenarios << (@current_scenario = Scenario.new(gherkin_model_scenario))
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def step(gherkin_model_step)
         | 
| 25 | 
            +
                @current_scenario.steps << Step.new(gherkin_model_step)
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              # to avoid undefined method `uri' & efo and keep Gherkin parser happy
         | 
| 29 | 
            +
              def uri(*)
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              def eof
         | 
| 33 | 
            +
              end
         | 
| 22 34 |  | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 35 | 
            +
              private
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              class GherkinCollection
         | 
| 38 | 
            +
                attr_reader :elements
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                def initialize(gherkin_object)
         | 
| 41 | 
            +
                  @gherkin_object = gherkin_object
         | 
| 42 | 
            +
                  @elements = []
         | 
| 26 43 | 
             
                end
         | 
| 27 44 |  | 
| 28 45 | 
             
                def to_s
         | 
| 29 | 
            -
                   | 
| 30 | 
            -
             | 
| 46 | 
            +
                  <<RUBY
         | 
| 47 | 
            +
            #{gherkin_to_maniok_block} do
         | 
| 31 48 |  | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 49 | 
            +
            #{print_elements}
         | 
| 50 | 
            +
            end
         | 
| 51 | 
            +
            RUBY
         | 
| 52 | 
            +
                end
         | 
| 34 53 |  | 
| 35 | 
            -
             | 
| 54 | 
            +
                private
         | 
| 36 55 |  | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
            RUBY_FEATURE
         | 
| 56 | 
            +
                def gherkin_to_maniok_block
         | 
| 57 | 
            +
                  "#{gherkin_model_name} \"#{@gherkin_object.name}\""
         | 
| 40 58 | 
             
                end
         | 
| 41 59 |  | 
| 42 | 
            -
                def  | 
| 43 | 
            -
                  @ | 
| 44 | 
            -
             | 
| 60 | 
            +
                def gherkin_model_name
         | 
| 61 | 
            +
                  @gherkin_object.class.name.split('::').last
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                def print_elements
         | 
| 65 | 
            +
                  @elements.map do |element|
         | 
| 66 | 
            +
                    element.to_s
         | 
| 45 67 | 
             
                  end.join("\n")
         | 
| 46 68 | 
             
                end
         | 
| 47 69 | 
             
              end
         | 
| 48 70 |  | 
| 49 | 
            -
               | 
| 50 | 
            -
                 | 
| 51 | 
            -
              end
         | 
| 71 | 
            +
              class Feature < GherkinCollection
         | 
| 72 | 
            +
                alias :scenarios :elements
         | 
| 52 73 |  | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
                   | 
| 74 | 
            +
                def to_s
         | 
| 75 | 
            +
                  # TODO later
         | 
| 76 | 
            +
                  #{@gherkin_model_feature.description}
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                  <<RUBY_FEATURE
         | 
| 79 | 
            +
            require 'spec_helper'
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            #{super.to_s}
         | 
| 82 | 
            +
            RUBY_FEATURE
         | 
| 58 83 | 
             
                end
         | 
| 59 84 |  | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
              class Scenario < GherkinCollection
         | 
| 88 | 
            +
                alias :steps :elements
         | 
| 89 | 
            +
             | 
| 60 90 | 
             
                def to_s
         | 
| 61 91 | 
             
                  <<RUBY_SCENARIO
         | 
| 62 | 
            -
               | 
| 92 | 
            +
              #{gherkin_to_maniok_block} do
         | 
| 63 93 |  | 
| 64 | 
            -
            #{ | 
| 94 | 
            +
            #{print_elements}
         | 
| 65 95 | 
             
              end
         | 
| 66 96 | 
             
            RUBY_SCENARIO
         | 
| 67 97 | 
             
                end
         | 
| 68 98 |  | 
| 69 | 
            -
                def print_steps
         | 
| 70 | 
            -
                  @steps.map do |step|
         | 
| 71 | 
            -
                    step.to_s
         | 
| 72 | 
            -
                  end.join("\n")
         | 
| 73 | 
            -
                end
         | 
| 74 | 
            -
              end
         | 
| 75 | 
            -
             | 
| 76 | 
            -
              def step(gherkin_model_step)
         | 
| 77 | 
            -
                @current_scenario.steps << Step.new(gherkin_model_step)
         | 
| 78 99 | 
             
              end
         | 
| 79 100 |  | 
| 80 101 | 
             
              class Step
         | 
| @@ -91,11 +112,4 @@ RUBY_STEP | |
| 91 112 | 
             
                end
         | 
| 92 113 | 
             
              end
         | 
| 93 114 |  | 
| 94 | 
            -
              # to avoid undefined method `uri' & efo and keep Gherkin parser happy
         | 
| 95 | 
            -
              def uri(*)
         | 
| 96 | 
            -
              end
         | 
| 97 | 
            -
             | 
| 98 | 
            -
              def eof
         | 
| 99 | 
            -
              end
         | 
| 100 | 
            -
             | 
| 101 115 | 
             
            end
         | 
    
        data/lib/maniok_bdd/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -2,14 +2,14 @@ | |
| 2 2 | 
             
            name: maniok_bdd
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 4 | 
             
              prerelease: 
         | 
| 5 | 
            -
              version: 0. | 
| 5 | 
            +
              version: 0.2.0
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| 8 8 | 
             
            - Jean-Michel Garnier
         | 
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2013- | 
| 12 | 
            +
            date: 2013-05-13 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies: []
         | 
| 14 14 | 
             
            description: 
         | 
| 15 15 | 
             
            email: jean-michel@21croissants.com
         | 
| @@ -40,23 +40,23 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 40 40 | 
             
              requirements:
         | 
| 41 41 | 
             
              - - ! '>='
         | 
| 42 42 | 
             
                - !ruby/object:Gem::Version
         | 
| 43 | 
            -
                  version: '0'
         | 
| 44 43 | 
             
                  segments:
         | 
| 45 44 | 
             
                  - 0
         | 
| 46 | 
            -
                  hash: - | 
| 45 | 
            +
                  hash: -3922873329849072388
         | 
| 46 | 
            +
                  version: '0'
         | 
| 47 47 | 
             
              none: false
         | 
| 48 48 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 49 49 | 
             
              requirements:
         | 
| 50 50 | 
             
              - - ! '>='
         | 
| 51 51 | 
             
                - !ruby/object:Gem::Version
         | 
| 52 | 
            -
                  version: '0'
         | 
| 53 52 | 
             
                  segments:
         | 
| 54 53 | 
             
                  - 0
         | 
| 55 | 
            -
                  hash: - | 
| 54 | 
            +
                  hash: -3922873329849072388
         | 
| 55 | 
            +
                  version: '0'
         | 
| 56 56 | 
             
              none: false
         | 
| 57 57 | 
             
            requirements: []
         | 
| 58 58 | 
             
            rubyforge_project: 
         | 
| 59 | 
            -
            rubygems_version: 1.8. | 
| 59 | 
            +
            rubygems_version: 1.8.25
         | 
| 60 60 | 
             
            signing_key: 
         | 
| 61 61 | 
             
            specification_version: 3
         | 
| 62 62 | 
             
            summary: BDD with POROs
         |