cucumber-in-the-yard 1.6.1 → 1.6.3
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.
- data/History.txt +13 -0
- data/README.md +27 -50
- data/example/child_feature/grandchild_feature/scenario.feature +52 -0
- data/example/child_feature/scenario.feature +52 -0
- data/example/scenario.feature +51 -0
- data/example/scenario_outline.feature +60 -0
- data/example/step_definitions/example.step.rb +7 -2
- data/example/step_definitions/first.step.rb +15 -0
- data/example/step_definitions/support/support.rb +6 -0
- data/example/transform.feature +13 -0
- data/lib/city.rb +2 -1
- data/lib/cucumber/city_builder.rb +10 -0
- data/lib/templates/default/feature/html/no_steps_defined.erb +1 -1
- data/lib/templates/default/feature/html/outline.erb +36 -29
- data/lib/templates/default/feature/html/scenario.erb +1 -1
- data/lib/templates/default/feature/html/steps.erb +20 -8
- data/lib/templates/default/feature/html/table.erb +16 -16
- data/lib/templates/default/feature/setup.rb +1 -1
- data/lib/templates/default/{tags → featuretags}/html/namespace.erb +0 -0
- data/lib/templates/default/{tags → featuretags}/html/setup.rb +0 -0
- data/lib/templates/default/fulldoc/html/css/common.css +25 -5
- data/lib/templates/default/requirements/html/namespace.erb +47 -34
- data/lib/templates/default/requirements/html/setup.rb +16 -5
- data/lib/templates/default/steptransformers/html/transformers.erb +5 -0
- data/lib/templates/default/steptransformers/html/undefined_steps.erb +30 -0
- data/lib/templates/default/steptransformers/setup.rb +17 -7
- data/lib/yard/code_objects/cucumber/namespace_object.rb +2 -2
- data/lib/yard/code_objects/step_definition.rb +2 -35
- data/lib/yard/code_objects/step_transform.rb +1 -34
- data/lib/yard/code_objects/step_transformer.rb +50 -0
- data/lib/yard/handlers/cucumber/feature_handler.rb +1 -1
- data/lib/yard/handlers/step_definition_handler.rb +0 -36
- data/lib/yard/handlers/step_transform_handler.rb +1 -33
- metadata +27 -22
- data/.autotest +0 -15
- data/autotest/discover.rb +0 -3
- data/example/example.third.feature +0 -33
- data/example/first_example.feature +0 -19
- data/example/second_example.feature +0 -51
- data/example/sub_features/second_example.feature +0 -51
- data/spec/city/feature_parser_spec_examples.rb +0 -153
- data/spec/city/gherkin_loader_spec.rb +0 -39
- data/spec/city/test.feature +0 -36
- data/spec/city/yard_handlers_cucumber_spec.rb +0 -24
- data/spec/city/yard_namespace_object_spec.rb +0 -8
- data/spec/city/yard_parser_cucumber_spec.rb +0 -215
- data/spec/city/yard_rb_extensions_spec.rb +0 -128
- data/spec/spec_helper.rb +0 -5
| @@ -1,215 +0,0 @@ | |
| 1 | 
            -
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         | 
| 2 | 
            -
            require File.dirname(__FILE__) + '/feature_parser_spec_examples.rb'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module YARD::Parser::Cucumber
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              describe YARD::CodeObjects::Cucumber::Tag do
         | 
| 7 | 
            -
                
         | 
| 8 | 
            -
                [:value].each do |attribute|
         | 
| 9 | 
            -
                  it "should respond to method #{attribute}" do
         | 
| 10 | 
            -
                    YARD::CodeObjects::Cucumber::Tag.new(:root,"tag_name").should respond_to(attribute)
         | 
| 11 | 
            -
                  end
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
                
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              describe YARD::CodeObjects::Cucumber::Step do
         | 
| 17 | 
            -
                
         | 
| 18 | 
            -
                [:value, :definition].each do |attribute|
         | 
| 19 | 
            -
                  it "should respond to method #{attribute}" do
         | 
| 20 | 
            -
                    YARD::CodeObjects::Cucumber::Step.new(:root,"name").should respond_to(attribute)
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
                
         | 
| 24 | 
            -
                it "should return the line prefix and the remainder" do
         | 
| 25 | 
            -
                  step = YARD::CodeObjects::Cucumber::Step.new(:root,"name") {|s| s.value = "Given something something" }
         | 
| 26 | 
            -
                  step.keyword.should == "Given"
         | 
| 27 | 
            -
                  step.line.should == "something something"
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
                
         | 
| 30 | 
            -
              end
         | 
| 31 | 
            -
              
         | 
| 32 | 
            -
              describe YARD::CodeObjects::Cucumber::Scenario do
         | 
| 33 | 
            -
                
         | 
| 34 | 
            -
                [:value, :description, :steps, :tags ].each do |attribute|
         | 
| 35 | 
            -
                  it "should respond to method #{attribute}" do
         | 
| 36 | 
            -
                    YARD::CodeObjects::Cucumber::Scenario.new(:root,"name").should respond_to(attribute)
         | 
| 37 | 
            -
                  end
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
                
         | 
| 40 | 
            -
              end
         | 
| 41 | 
            -
              
         | 
| 42 | 
            -
              describe YARD::CodeObjects::Cucumber::Feature do
         | 
| 43 | 
            -
                
         | 
| 44 | 
            -
                [:value, :description, :scenarios, :background, :tags ].each do |attribute|
         | 
| 45 | 
            -
                  it "should respond to method #{attribute}" do
         | 
| 46 | 
            -
                    YARD::CodeObjects::Cucumber::Feature.new(:root,"name").should respond_to(attribute)
         | 
| 47 | 
            -
                  end
         | 
| 48 | 
            -
                end
         | 
| 49 | 
            -
                
         | 
| 50 | 
            -
              end
         | 
| 51 | 
            -
              
         | 
| 52 | 
            -
             | 
| 53 | 
            -
              describe FeatureParser do
         | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
                it "should accept source and a file when created" do
         | 
| 57 | 
            -
                  lambda { FeatureParser.new("source code","filename") }.should_not raise_exception(Exception)
         | 
| 58 | 
            -
                end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                [ "parse", "tokenize", "enumerator" ].each do |required_method|
         | 
| 61 | 
            -
                  it "should have a method named #{required_method}" do
         | 
| 62 | 
            -
                    FeatureParser.instance_methods.should include(required_method)
         | 
| 63 | 
            -
                  end
         | 
| 64 | 
            -
                end
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                it "should return itself when parse is called" do
         | 
| 67 | 
            -
                  parser = FeatureParser.new("source","filename")
         | 
| 68 | 
            -
                  parser.parse.should == parser
         | 
| 69 | 
            -
                end
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                context "feature file with tags, feature, and description" do
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                  before(:all) do
         | 
| 74 | 
            -
                    @feature = { :file => 'new.exciting.feature',
         | 
| 75 | 
            -
                      :name => "New Exciting Feature", 
         | 
| 76 | 
            -
                      :tags => [ "@bvt", "@build", "@wip" ],
         | 
| 77 | 
            -
                      :description => [ "This feature is going to save the company." ] }
         | 
| 78 | 
            -
                    
         | 
| 79 | 
            -
                    @parser = FeatureParser.new(%{
         | 
| 80 | 
            -
                      #{@feature[:tags].join(" ")}
         | 
| 81 | 
            -
                      Feature: #{@feature[:name]}
         | 
| 82 | 
            -
                      #{@feature[:description].join("\n")}
         | 
| 83 | 
            -
                      },@feature[:file])
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                      @parser = @parser.parse
         | 
| 86 | 
            -
                  end
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                  after(:all) do
         | 
| 89 | 
            -
                    @parser = nil
         | 
| 90 | 
            -
                  end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                  it_should_behave_like "a feature file"
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                end
         | 
| 95 | 
            -
                
         | 
| 96 | 
            -
                context "feature file with a description that uses step keywords" do
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                  before(:all) do
         | 
| 99 | 
            -
                    @feature = { :file => 'description.with.keywords.feature',
         | 
| 100 | 
            -
                      :name => "Fully Described Feature", 
         | 
| 101 | 
            -
                      :tags => [ "@bvt", "@build", "@wip" ],
         | 
| 102 | 
            -
                      :description => ["As a product owner",
         | 
| 103 | 
            -
                        "When I ask about the work done",
         | 
| 104 | 
            -
                        "Then I want to see what this cukes things is all about",
         | 
| 105 | 
            -
                        "And I really want a straight answer",
         | 
| 106 | 
            -
                        "Given that I can be provided with one"] }
         | 
| 107 | 
            -
                    
         | 
| 108 | 
            -
                    @parser = FeatureParser.new(%{
         | 
| 109 | 
            -
                      #{@feature[:tags].join(" ")}
         | 
| 110 | 
            -
                      Feature: #{@feature[:name]}
         | 
| 111 | 
            -
                      #{@feature[:description].join("\n")}
         | 
| 112 | 
            -
                      },@feature[:file])
         | 
| 113 | 
            -
             | 
| 114 | 
            -
                      @parser = @parser.parse
         | 
| 115 | 
            -
                  end
         | 
| 116 | 
            -
             | 
| 117 | 
            -
                  after(:all) do
         | 
| 118 | 
            -
                    @parser = nil
         | 
| 119 | 
            -
                  end
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                  it_should_behave_like "a feature file"
         | 
| 122 | 
            -
             | 
| 123 | 
            -
                end
         | 
| 124 | 
            -
                
         | 
| 125 | 
            -
             | 
| 126 | 
            -
                context "feature file with background and one scenario" do
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                  before(:all) do
         | 
| 129 | 
            -
             | 
| 130 | 
            -
                    @feature = { :file => "ninja.exciting.feature",
         | 
| 131 | 
            -
                      :name => "Ninja Feature Set", 
         | 
| 132 | 
            -
                      :tags => [ "@bvt", "@build", "@wip" ],
         | 
| 133 | 
            -
                      :description => ["This feature is going to save the company"] }
         | 
| 134 | 
            -
             | 
| 135 | 
            -
                    @background = [ "Given that I have taken a nap" ]
         | 
| 136 | 
            -
                      
         | 
| 137 | 
            -
                    @scenarios = [ { :tags => ["@ninja"],
         | 
| 138 | 
            -
                      :title => ["Ninja striking an opponent in the morning"],
         | 
| 139 | 
            -
                      :steps => [ "Given that there is an opponent", 
         | 
| 140 | 
            -
                      "And a reason to fight him", 
         | 
| 141 | 
            -
                      "When I karate strike him", 
         | 
| 142 | 
            -
                      "Then I expect him to fall" ] } ]
         | 
| 143 | 
            -
             | 
| 144 | 
            -
                      @parser = FeatureParser.new(%{
         | 
| 145 | 
            -
                        #{@feature[:tags].join(" ")}
         | 
| 146 | 
            -
                        Feature: #{@feature[:name]}
         | 
| 147 | 
            -
                        #{@feature[:description].join("\n")}
         | 
| 148 | 
            -
                          Background:
         | 
| 149 | 
            -
                        #{@background.join("\n")}
         | 
| 150 | 
            -
                          #{@scenarios.first[:tags].join(" ")}
         | 
| 151 | 
            -
                        Scenario: #{@scenarios.first[:title].join("\n")}
         | 
| 152 | 
            -
                        #{@scenarios.first[:steps].join("\n")}
         | 
| 153 | 
            -
                        },@feature[:file])
         | 
| 154 | 
            -
                      @parser = @parser.parse
         | 
| 155 | 
            -
                  end
         | 
| 156 | 
            -
                        
         | 
| 157 | 
            -
                  after(:all) do
         | 
| 158 | 
            -
                    @parser = nil
         | 
| 159 | 
            -
                  end
         | 
| 160 | 
            -
             | 
| 161 | 
            -
                  it_should_behave_like "a feature file"
         | 
| 162 | 
            -
                  it_should_behave_like "a feature file with a background"
         | 
| 163 | 
            -
                  it_should_behave_like "a feature file with scenarios"
         | 
| 164 | 
            -
                        
         | 
| 165 | 
            -
                end
         | 
| 166 | 
            -
             | 
| 167 | 
            -
                context "feature file no background and multiple scenarios" do
         | 
| 168 | 
            -
             | 
| 169 | 
            -
                  before(:all) do
         | 
| 170 | 
            -
             | 
| 171 | 
            -
                    @feature = { :file => "ninja.strike.feature",
         | 
| 172 | 
            -
                      :name => "Ninja Feature Set", 
         | 
| 173 | 
            -
                      :tags => [ "@kill", "@silently", "@sneak" ],
         | 
| 174 | 
            -
                      :description => ["This feature is going to save the company"] }
         | 
| 175 | 
            -
             | 
| 176 | 
            -
                    @scenarios = [  
         | 
| 177 | 
            -
                      { :tags => ["@ninja"], 
         | 
| 178 | 
            -
                        :title => ["Killing Scenario"],
         | 
| 179 | 
            -
                        :steps => [ "Given that there is an opponent", 
         | 
| 180 | 
            -
                                    "And a reason to fight him", 
         | 
| 181 | 
            -
                                    "When I karate strike him", 
         | 
| 182 | 
            -
                                    "Then I expect him to fall" ] },
         | 
| 183 | 
            -
                      { :tags => [], 
         | 
| 184 | 
            -
                        :title => ["Dissappearing Scenario"],
         | 
| 185 | 
            -
                        :steps => [ "Given that I have defeated an opponent", 
         | 
| 186 | 
            -
                                    "And there are no more opponents", 
         | 
| 187 | 
            -
                                    "When I stop to take a breath", 
         | 
| 188 | 
            -
                                    "Then I expect to dissapear" ] } ]
         | 
| 189 | 
            -
             | 
| 190 | 
            -
                      @parser = FeatureParser.new(%{
         | 
| 191 | 
            -
                        #{@feature[:tags].join(" ")}
         | 
| 192 | 
            -
                        Feature: #{@feature[:name]}
         | 
| 193 | 
            -
                        #{@feature[:description].join("\n")} 
         | 
| 194 | 
            -
                        #{@scenarios.collect {|scenario|
         | 
| 195 | 
            -
                          scenario[:tags].join(" ") + 
         | 
| 196 | 
            -
                          "\nScenario: " + scenario[:title].join("\n") + "\n" +
         | 
| 197 | 
            -
                          scenario[:steps].join("\n")  
         | 
| 198 | 
            -
                        }.join("\n")}},@feature[:file])
         | 
| 199 | 
            -
                      @parser = @parser.parse
         | 
| 200 | 
            -
                  end
         | 
| 201 | 
            -
                        
         | 
| 202 | 
            -
                  after(:all) do
         | 
| 203 | 
            -
                    @parser = nil
         | 
| 204 | 
            -
                  end
         | 
| 205 | 
            -
             | 
| 206 | 
            -
                  it_should_behave_like "a feature file"
         | 
| 207 | 
            -
                  it_should_behave_like "a feature file with scenarios"
         | 
| 208 | 
            -
                        
         | 
| 209 | 
            -
                end
         | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
             | 
| 213 | 
            -
              end
         | 
| 214 | 
            -
              
         | 
| 215 | 
            -
            end
         | 
| @@ -1,128 +0,0 @@ | |
| 1 | 
            -
            require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module YARD::CodeObjects
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              describe YARD::CodeObjects do
         | 
| 6 | 
            -
             | 
| 7 | 
            -
                shared_examples_for "CodeObjects" do
         | 
| 8 | 
            -
                  it "should respond to all defined attributes" do
         | 
| 9 | 
            -
                    @attributes.each {|attribute| @object.should respond_to(attribute) }
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
                describe StepDefinitionObject do
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  before(:each) do
         | 
| 16 | 
            -
                    @attributes = [ :value, :keyword, :constants, :compare_value ]
         | 
| 17 | 
            -
                    @object = StepDefinitionObject.new(:root,:unique_name)
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                  class TestObject
         | 
| 21 | 
            -
                    attr_accessor :name, :value
         | 
| 22 | 
            -
                    def initialize ; yield self ; end
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                  it_should_behave_like "CodeObjects"
         | 
| 26 | 
            -
                  
         | 
| 27 | 
            -
                  describe "compare_value" do
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                    [ { :value => "/THERE (?:IS|ARE) THREE \#\{ CONSTANTS \} IN HERE \#\{ FOR\} YOU TO \#\{FIND \}",
         | 
| 30 | 
            -
                      :results => [ 'CONSTANTS', 'FOR', 'FIND' ] } ].each do |data|
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                        it "should find all the constants within the step definition" do
         | 
| 33 | 
            -
                          
         | 
| 34 | 
            -
                          stepdef = StepDefinitionObject.new(:root,"name")
         | 
| 35 | 
            -
                          stepdef.value = data[:value]
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                          
         | 
| 38 | 
            -
                          data[:results].each do |result|
         | 
| 39 | 
            -
                            stepdef._value_constants(data[:value]).should include(result)
         | 
| 40 | 
            -
                            stepdef._value_constants.should include(result)
         | 
| 41 | 
            -
                          end
         | 
| 42 | 
            -
                          
         | 
| 43 | 
            -
                        end
         | 
| 44 | 
            -
                      end
         | 
| 45 | 
            -
                    
         | 
| 46 | 
            -
                    
         | 
| 47 | 
            -
                    [ { :value => "/WHEN THE \#\{NOUN\} HITS THE FAN/", 
         | 
| 48 | 
            -
                              :constants => [ TestObject.new{|c| c.name = "NOUN" ; c.value = "/SMURF/" } ], :result => "WHEN THE SMURF HITS THE FAN" },
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                              { :value => "/\#\{ SUBJECT \} WALK INTO THE \#\{ PLACE\} AND ASK THE \#\{PERSON \}/", 
         | 
| 51 | 
            -
                              :constants => [ TestObject.new{|c| c.name = "SUBJECT" ; c.value = "/1 PERSON/" }, 
         | 
| 52 | 
            -
                                TestObject.new{|c| c.name = "PLACE" ; c.value = "/BAR/" },
         | 
| 53 | 
            -
                                TestObject.new{|c| c.name = "PERSON" ; c.value = "/BARTENDER/" } ], 
         | 
| 54 | 
            -
                                :result => "1 PERSON WALK INTO THE BAR AND ASK THE BARTENDER" },
         | 
| 55 | 
            -
                                        
         | 
| 56 | 
            -
                       ].each do |data|
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                      it "should replace all constants found within (#{data[:value]}) the value" do
         | 
| 59 | 
            -
                        
         | 
| 60 | 
            -
                        stepdef = StepDefinitionObject.new(:root,"name")
         | 
| 61 | 
            -
                        stepdef.value = data[:value]
         | 
| 62 | 
            -
                        stepdef.constants = data[:constants]
         | 
| 63 | 
            -
                        
         | 
| 64 | 
            -
                        stepdef.compare_value.should == data[:result]
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                      end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                    end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
                  end
         | 
| 72 | 
            -
                  
         | 
| 73 | 
            -
                  
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                describe StepTransformObject do
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                  before(:each) do
         | 
| 80 | 
            -
                    @attributes = [ :value ]
         | 
| 81 | 
            -
                    @object = StepTransformObject.new(:root,:unique_name)
         | 
| 82 | 
            -
                  end
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                  it_should_behave_like "CodeObjects"
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                end
         | 
| 87 | 
            -
             | 
| 88 | 
            -
              end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
            end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
            module YARD::Handlers::Ruby::Legacy
         | 
| 93 | 
            -
             | 
| 94 | 
            -
              describe YARD::Handlers::Ruby::Legacy do
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                shared_examples_for "Handlers" do
         | 
| 97 | 
            -
                  it "should match #{@match_criteria}" do
         | 
| 98 | 
            -
                    @handler::MATCH.should == @match_criteria
         | 
| 99 | 
            -
                  end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                  it "should respond to the method process" do
         | 
| 102 | 
            -
                    @handler.should respond_to(:process)
         | 
| 103 | 
            -
                  end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                end
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                describe StepDefinitionHandler do
         | 
| 108 | 
            -
                  before(:each) do
         | 
| 109 | 
            -
                    @handler = StepDefinitionHandler
         | 
| 110 | 
            -
                    @match_criteria = /^((When|Given|And|Then)\s*(\/[^\/]+\/).+)$/
         | 
| 111 | 
            -
                  end
         | 
| 112 | 
            -
                  
         | 
| 113 | 
            -
                  it_should_behave_like "Handlers"
         | 
| 114 | 
            -
                end
         | 
| 115 | 
            -
                
         | 
| 116 | 
            -
                describe StepTransformHandler do
         | 
| 117 | 
            -
                  before(:each) do
         | 
| 118 | 
            -
                    @handler = StepTransformHandler
         | 
| 119 | 
            -
                    @match_criteria = /^Transform\s*(\/[^\/]+\/).+$/
         | 
| 120 | 
            -
                  end
         | 
| 121 | 
            -
                  
         | 
| 122 | 
            -
                  it_should_behave_like "Handlers"
         | 
| 123 | 
            -
                end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
              end
         | 
| 127 | 
            -
             | 
| 128 | 
            -
            end
         |