cucumber 0.3.101 → 0.3.102
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 +31 -2
- data/Manifest.txt +7 -4
- data/config/hoe.rb +2 -2
- data/examples/pure_java/README.textile +2 -2
- data/examples/self_test/features/step_definitions/sample_steps.rb +0 -12
- data/examples/self_test/features/support/env.rb +0 -6
- data/features/cucumber_cli.feature +11 -24
- data/features/custom_formatter.feature +38 -3
- data/features/default_snippets.feature +42 -0
- data/features/html_formatter/a.html +1 -1
- data/features/negative_tagged_hooks.feature +61 -0
- data/features/step_definitions/cucumber_steps.rb +1 -1
- data/features/support/env.rb +1 -1
- data/features/transform.feature +88 -12
- data/features/usage.feature +0 -6
- data/lib/cucumber/ast/feature.rb +4 -0
- data/lib/cucumber/ast/feature_element.rb +49 -42
- data/lib/cucumber/ast/step_invocation.rb +1 -1
- data/lib/cucumber/ast/tags.rb +25 -3
- data/lib/cucumber/cli/drb_client.rb +7 -1
- data/lib/cucumber/cli/main.rb +5 -3
- data/lib/cucumber/cli/options.rb +15 -24
- data/lib/cucumber/constantize.rb +8 -2
- data/lib/cucumber/core_ext/instance_exec.rb +2 -1
- data/lib/cucumber/core_ext/string.rb +12 -22
- data/lib/cucumber/filter.rb +2 -12
- data/lib/cucumber/formatter/console.rb +21 -21
- data/lib/cucumber/formatter/html.rb +1 -1
- data/lib/cucumber/formatter/pdf.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +1 -1
- data/lib/cucumber/language_support/language_methods.rb +19 -2
- data/lib/cucumber/language_support/step_definition_methods.rb +2 -25
- data/lib/cucumber/parser/feature.rb +13 -50
- data/lib/cucumber/parser/feature.tt +13 -47
- data/lib/cucumber/parser/natural_language.rb +1 -1
- data/lib/cucumber/rails/action_controller.rb +33 -0
- data/lib/cucumber/rails/active_record.rb +27 -0
- data/lib/cucumber/rails/rspec.rb +1 -1
- data/lib/cucumber/rails/test_unit.rb +9 -0
- data/lib/cucumber/rails/world.rb +7 -78
- data/lib/cucumber/rb_support/rb_dsl.rb +6 -4
- data/lib/cucumber/rb_support/rb_group.rb +11 -0
- data/lib/cucumber/rb_support/rb_language.rb +8 -2
- data/lib/cucumber/rb_support/rb_step_definition.rb +23 -8
- data/lib/cucumber/rb_support/rb_transform.rb +35 -0
- data/lib/cucumber/rb_support/rb_world.rb +7 -1
- data/lib/cucumber/step_match.rb +25 -6
- data/lib/cucumber/step_mother.rb +9 -32
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/templates/cucumber_environment.rb +2 -2
- data/rails_generators/cucumber/templates/env.rb +1 -8
- data/spec/cucumber/ast/feature_element_spec.rb +24 -23
- data/spec/cucumber/ast/scenario_outline_spec.rb +1 -1
- data/spec/cucumber/cli/options_spec.rb +5 -14
- data/spec/cucumber/core_ext/string_spec.rb +11 -13
- data/spec/cucumber/parser/feature_parser_spec.rb +6 -6
- data/spec/cucumber/step_mother_spec.rb +41 -38
- metadata +11 -8
- data/examples/self_test/features/transform_sample.feature +0 -10
- data/spec/cucumber/rails/stubs/mini_rails.rb +0 -18
- data/spec/cucumber/rails/stubs/test_help.rb +0 -1
- data/spec/cucumber/rails/world_spec.rb +0 -16
| @@ -197,7 +197,7 @@ module Cucumber | |
| 197 197 | 
             
                  end
         | 
| 198 198 |  | 
| 199 199 | 
             
                  def visit_tag_name(tag_name)
         | 
| 200 | 
            -
                    tag = format_string( | 
| 200 | 
            +
                    tag = format_string(tag_name, :tag).indent(@indent)
         | 
| 201 201 | 
             
                    # TODO should we render tags at all? skipped for now. difficult to place due to page breaks
         | 
| 202 202 | 
             
                  end
         | 
| 203 203 |  | 
| @@ -23,11 +23,24 @@ module Cucumber | |
| 23 23 | 
             
                    end
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 |  | 
| 26 | 
            +
                  def execute_transforms(args)
         | 
| 27 | 
            +
                    transformed = nil
         | 
| 28 | 
            +
                    args.map do |arg|
         | 
| 29 | 
            +
                      transforms.detect {|t| transformed = t.invoke arg }
         | 
| 30 | 
            +
                      transformed || arg
         | 
| 31 | 
            +
                    end
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 26 34 | 
             
                  def add_hook(phase, hook)
         | 
| 27 35 | 
             
                    hooks[phase.to_sym] << hook
         | 
| 28 36 | 
             
                    hook
         | 
| 29 37 | 
             
                  end
         | 
| 30 38 |  | 
| 39 | 
            +
                  def add_transform(transform)
         | 
| 40 | 
            +
                    transforms.unshift transform
         | 
| 41 | 
            +
                    transform
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 31 44 | 
             
                  def add_step_definition(step_definition)
         | 
| 32 45 | 
             
                    step_definitions << step_definition
         | 
| 33 46 | 
             
                    step_definition
         | 
| @@ -47,6 +60,10 @@ module Cucumber | |
| 47 60 | 
             
                    @hooks ||= Hash.new{|h,k| h[k] = []}
         | 
| 48 61 | 
             
                  end
         | 
| 49 62 |  | 
| 63 | 
            +
                  def transforms
         | 
| 64 | 
            +
                    @transforms ||= []
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
             | 
| 50 67 | 
             
                  def execute_before(scenario)
         | 
| 51 68 | 
             
                    hooks_for(:before, scenario).each do |hook|
         | 
| 52 69 | 
             
                      invoke(hook, 'Before', scenario, true)
         | 
| @@ -54,7 +71,7 @@ module Cucumber | |
| 54 71 | 
             
                  end
         | 
| 55 72 |  | 
| 56 73 | 
             
                  def execute_after(scenario)
         | 
| 57 | 
            -
                    hooks_for(:after, scenario). | 
| 74 | 
            +
                    hooks_for(:after, scenario).reverse_each do |hook|
         | 
| 58 75 | 
             
                      invoke(hook, 'After', scenario, true)
         | 
| 59 76 | 
             
                    end
         | 
| 60 77 | 
             
                  end
         | 
| @@ -72,4 +89,4 @@ module Cucumber | |
| 72 89 | 
             
                  end
         | 
| 73 90 | 
             
                end
         | 
| 74 91 | 
             
              end
         | 
| 75 | 
            -
            end
         | 
| 92 | 
            +
            end
         | 
| @@ -4,36 +4,13 @@ module Cucumber | |
| 4 4 | 
             
              module LanguageSupport
         | 
| 5 5 | 
             
                module StepDefinitionMethods
         | 
| 6 6 | 
             
                  def step_match(name_to_match, name_to_report)
         | 
| 7 | 
            -
                    if( | 
| 8 | 
            -
                      StepMatch.new(self, name_to_match, name_to_report,  | 
| 7 | 
            +
                    if(groups = groups(name_to_match))
         | 
| 8 | 
            +
                      StepMatch.new(self, name_to_match, name_to_report, groups)
         | 
| 9 9 | 
             
                    else
         | 
| 10 10 | 
             
                      nil
         | 
| 11 11 | 
             
                    end
         | 
| 12 12 | 
             
                  end
         | 
| 13 13 |  | 
| 14 | 
            -
                  # Formats the matched arguments of the associated Step. This method
         | 
| 15 | 
            -
                  # is usually called from visitors, which render output.
         | 
| 16 | 
            -
                  #
         | 
| 17 | 
            -
                  # The +format+ can either be a String or a Proc.
         | 
| 18 | 
            -
                  #
         | 
| 19 | 
            -
                  # If it is a String it should be a format string according to
         | 
| 20 | 
            -
                  # <tt>Kernel#sprinf</tt>, for example:
         | 
| 21 | 
            -
                  #
         | 
| 22 | 
            -
                  #   '<span class="param">%s</span></tt>'
         | 
| 23 | 
            -
                  #
         | 
| 24 | 
            -
                  # If it is a Proc, it should take one argument and return the formatted
         | 
| 25 | 
            -
                  # argument, for example:
         | 
| 26 | 
            -
                  #
         | 
| 27 | 
            -
                  #   lambda { |param| "[#{param}]" }
         | 
| 28 | 
            -
                  #
         | 
| 29 | 
            -
                  def format_args(step_name, format)
         | 
| 30 | 
            -
                    step_name.gzub(regexp, format)
         | 
| 31 | 
            -
                  end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  def same_regexp?(regexp)
         | 
| 34 | 
            -
                    self.regexp == regexp
         | 
| 35 | 
            -
                  end
         | 
| 36 | 
            -
             | 
| 37 14 | 
             
                  def backtrace_line
         | 
| 38 15 | 
             
                    "#{file_colon_line}:in `#{regexp.inspect}'"
         | 
| 39 16 | 
             
                  end
         | 
| @@ -55,14 +55,6 @@ module Cucumber | |
| 55 55 | 
             
                  end
         | 
| 56 56 |  | 
| 57 57 | 
             
                  module FeatureSub2
         | 
| 58 | 
            -
                    def has_tags?(tag_names)
         | 
| 59 | 
            -
                      tags.has_tags?(tag_names)
         | 
| 60 | 
            -
                    end
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                    def has_all_tags?(tag_names)
         | 
| 63 | 
            -
                      tags.has_all_tags?(tag_names)
         | 
| 64 | 
            -
                    end
         | 
| 65 | 
            -
             | 
| 66 58 | 
             
                    def build(filter)
         | 
| 67 59 | 
             
                      if(filter.nil? || feature_elements.accept?(filter) || (!bg.empty? && filter.accept?(bg)))
         | 
| 68 60 | 
             
                        background = bg.respond_to?(:build) ? bg.build : nil      
         | 
| @@ -218,20 +210,12 @@ module Cucumber | |
| 218 210 | 
             
                      ts.elements.detect{|e| e.tag.line == line}
         | 
| 219 211 | 
             
                    end
         | 
| 220 212 |  | 
| 221 | 
            -
                    def has_tags?(tags)
         | 
| 222 | 
            -
                      (tag_names & tags).any?
         | 
| 223 | 
            -
                    end
         | 
| 224 | 
            -
             | 
| 225 | 
            -
                    def has_all_tags?(tags)
         | 
| 226 | 
            -
                      (tags & tag_names) == tags
         | 
| 227 | 
            -
                    end
         | 
| 228 | 
            -
             | 
| 229 213 | 
             
                    def build
         | 
| 230 214 | 
             
                      Ast::Tags.new(ts.line, tag_names)
         | 
| 231 215 | 
             
                    end
         | 
| 232 216 |  | 
| 233 217 | 
             
                    def tag_names
         | 
| 234 | 
            -
                      @tag_names ||= ts.elements.map{|e| e.tag. | 
| 218 | 
            +
                      @tag_names ||= ts.elements.map{|e| e.tag.text_value}
         | 
| 235 219 | 
             
                    end
         | 
| 236 220 | 
             
                  end
         | 
| 237 221 |  | 
| @@ -313,9 +297,6 @@ module Cucumber | |
| 313 297 | 
             
                  end
         | 
| 314 298 |  | 
| 315 299 | 
             
                  module Tag0
         | 
| 316 | 
            -
                    def tag_name
         | 
| 317 | 
            -
                      elements[1]
         | 
| 318 | 
            -
                    end
         | 
| 319 300 | 
             
                  end
         | 
| 320 301 |  | 
| 321 302 | 
             
                  def _nt_tag
         | 
| @@ -339,7 +320,7 @@ module Cucumber | |
| 339 320 | 
             
                      s2, i2 = [], index
         | 
| 340 321 | 
             
                      loop do
         | 
| 341 322 | 
             
                        if has_terminal?('\G[^@\\r\\n\\t ]', true, index)
         | 
| 342 | 
            -
                          r3 =  | 
| 323 | 
            +
                          r3 = true
         | 
| 343 324 | 
             
                          @index += 1
         | 
| 344 325 | 
             
                        else
         | 
| 345 326 | 
             
                          r3 = nil
         | 
| @@ -510,14 +491,8 @@ module Cucumber | |
| 510 491 | 
             
                      steps.at_line?(line)
         | 
| 511 492 | 
             
                    end
         | 
| 512 493 |  | 
| 513 | 
            -
                    def  | 
| 514 | 
            -
                       | 
| 515 | 
            -
                      feature_tags.has_tags?(tag_names)
         | 
| 516 | 
            -
                    end
         | 
| 517 | 
            -
             | 
| 518 | 
            -
                    def has_all_tags?(tag_names)
         | 
| 519 | 
            -
                      feature_tags = self.parent.tags
         | 
| 520 | 
            -
                      feature_tags.has_all_tags?(tag_names)
         | 
| 494 | 
            +
                    def matches_tags?(tag_names)
         | 
| 495 | 
            +
                      Ast::Tags.matches?(self.parent.tags.tag_names, tag_names)
         | 
| 521 496 | 
             
                    end
         | 
| 522 497 |  | 
| 523 498 | 
             
                    def build
         | 
| @@ -712,14 +687,10 @@ module Cucumber | |
| 712 687 | 
             
                      tags.at_line?(line)
         | 
| 713 688 | 
             
                    end
         | 
| 714 689 |  | 
| 715 | 
            -
                    def  | 
| 716 | 
            -
                       | 
| 717 | 
            -
                       | 
| 718 | 
            -
             | 
| 719 | 
            -
             | 
| 720 | 
            -
                    def has_all_tags?(tag_names)
         | 
| 721 | 
            -
                      feature_tags = self.parent.parent.tags
         | 
| 722 | 
            -
                      tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
         | 
| 690 | 
            +
                    def matches_tags?(tag_names)
         | 
| 691 | 
            +
                      feature_tag_names = self.parent.parent.tags.tag_names
         | 
| 692 | 
            +
                      source_tag_names = (feature_tag_names + tags.tag_names).uniq
         | 
| 693 | 
            +
                      Ast::Tags.matches?(source_tag_names, tag_names)
         | 
| 723 694 | 
             
                    end
         | 
| 724 695 |  | 
| 725 696 | 
             
                    def matches_name?(regexp_to_match)
         | 
| @@ -855,14 +826,10 @@ module Cucumber | |
| 855 826 | 
             
                      steps.at_line?(line)
         | 
| 856 827 | 
             
                    end
         | 
| 857 828 |  | 
| 858 | 
            -
                    def  | 
| 859 | 
            -
                       | 
| 860 | 
            -
                       | 
| 861 | 
            -
             | 
| 862 | 
            -
             | 
| 863 | 
            -
                    def has_all_tags?(tag_names)
         | 
| 864 | 
            -
                      feature_tags = self.parent.parent.tags
         | 
| 865 | 
            -
                      tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
         | 
| 829 | 
            +
                    def matches_tags?(tag_names)
         | 
| 830 | 
            +
                      feature_tag_names = self.parent.parent.tags.tag_names
         | 
| 831 | 
            +
                      source_tag_names = (feature_tag_names + tags.tag_names).uniq
         | 
| 832 | 
            +
                      Ast::Tags.matches?(source_tag_names, tag_names)
         | 
| 866 833 | 
             
                    end
         | 
| 867 834 |  | 
| 868 835 | 
             
                    def matches_name?(regexp_to_match)
         | 
| @@ -1201,11 +1168,7 @@ module Cucumber | |
| 1201 1168 | 
             
                      table.at_line?(line)
         | 
| 1202 1169 | 
             
                    end
         | 
| 1203 1170 |  | 
| 1204 | 
            -
                    def  | 
| 1205 | 
            -
                      true
         | 
| 1206 | 
            -
                    end
         | 
| 1207 | 
            -
             | 
| 1208 | 
            -
                    def has_all_tags?(tag_names)
         | 
| 1171 | 
            +
                    def matches_tags?(tag_names)
         | 
| 1209 1172 | 
             
                      true
         | 
| 1210 1173 | 
             
                    end
         | 
| 1211 1174 |  | 
| @@ -18,14 +18,6 @@ module Cucumber | |
| 18 18 | 
             
                    bg:background? 
         | 
| 19 19 | 
             
                    feature_elements
         | 
| 20 20 | 
             
                    comment? {
         | 
| 21 | 
            -
                      def has_tags?(tag_names)
         | 
| 22 | 
            -
                        tags.has_tags?(tag_names)
         | 
| 23 | 
            -
                      end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                      def has_all_tags?(tag_names)
         | 
| 26 | 
            -
                        tags.has_all_tags?(tag_names)
         | 
| 27 | 
            -
                      end
         | 
| 28 | 
            -
             | 
| 29 21 | 
             
                      def build(filter)
         | 
| 30 22 | 
             
                        if(filter.nil? || feature_elements.accept?(filter) || (!bg.empty? && filter.accept?(bg)))
         | 
| 31 23 | 
             
                          background = bg.respond_to?(:build) ? bg.build : nil      
         | 
| @@ -47,26 +39,18 @@ module Cucumber | |
| 47 39 | 
             
                        ts.elements.detect{|e| e.tag.line == line}
         | 
| 48 40 | 
             
                      end
         | 
| 49 41 |  | 
| 50 | 
            -
                      def has_tags?(tags)
         | 
| 51 | 
            -
                        (tag_names & tags).any?
         | 
| 52 | 
            -
                      end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                      def has_all_tags?(tags)
         | 
| 55 | 
            -
                        (tags & tag_names) == tags
         | 
| 56 | 
            -
                      end
         | 
| 57 | 
            -
             | 
| 58 42 | 
             
                      def build
         | 
| 59 43 | 
             
                        Ast::Tags.new(ts.line, tag_names)
         | 
| 60 44 | 
             
                      end
         | 
| 61 45 |  | 
| 62 46 | 
             
                      def tag_names
         | 
| 63 | 
            -
                        @tag_names ||= ts.elements.map{|e| e.tag. | 
| 47 | 
            +
                        @tag_names ||= ts.elements.map{|e| e.tag.text_value}
         | 
| 64 48 | 
             
                      end
         | 
| 65 49 | 
             
                    }
         | 
| 66 50 | 
             
                  end
         | 
| 67 51 |  | 
| 68 52 | 
             
                  rule tag
         | 
| 69 | 
            -
                    '@'  | 
| 53 | 
            +
                    '@' [^@\r\n\t ]+
         | 
| 70 54 | 
             
                  end
         | 
| 71 55 |  | 
| 72 56 | 
             
                  rule comment
         | 
| @@ -92,14 +76,8 @@ module Cucumber | |
| 92 76 | 
             
                        steps.at_line?(line)
         | 
| 93 77 | 
             
                      end
         | 
| 94 78 |  | 
| 95 | 
            -
                      def  | 
| 96 | 
            -
                         | 
| 97 | 
            -
                        feature_tags.has_tags?(tag_names)
         | 
| 98 | 
            -
                      end
         | 
| 99 | 
            -
             | 
| 100 | 
            -
                      def has_all_tags?(tag_names)
         | 
| 101 | 
            -
                        feature_tags = self.parent.tags
         | 
| 102 | 
            -
                        feature_tags.has_all_tags?(tag_names)
         | 
| 79 | 
            +
                      def matches_tags?(tag_names)
         | 
| 80 | 
            +
                        Ast::Tags.matches?(self.parent.tags.tag_names, tag_names)
         | 
| 103 81 | 
             
                      end
         | 
| 104 82 |  | 
| 105 83 | 
             
                      def build
         | 
| @@ -138,14 +116,10 @@ module Cucumber | |
| 138 116 | 
             
                        tags.at_line?(line)
         | 
| 139 117 | 
             
                      end
         | 
| 140 118 |  | 
| 141 | 
            -
                      def  | 
| 142 | 
            -
                         | 
| 143 | 
            -
                         | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
                      def has_all_tags?(tag_names)
         | 
| 147 | 
            -
                        feature_tags = self.parent.parent.tags
         | 
| 148 | 
            -
                        tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
         | 
| 119 | 
            +
                      def matches_tags?(tag_names)
         | 
| 120 | 
            +
                        feature_tag_names = self.parent.parent.tags.tag_names
         | 
| 121 | 
            +
                        source_tag_names = (feature_tag_names + tags.tag_names).uniq
         | 
| 122 | 
            +
                        Ast::Tags.matches?(source_tag_names, tag_names)
         | 
| 149 123 | 
             
                      end
         | 
| 150 124 |  | 
| 151 125 | 
             
                      def matches_name?(regexp_to_match)
         | 
| @@ -179,14 +153,10 @@ module Cucumber | |
| 179 153 | 
             
                        steps.at_line?(line)
         | 
| 180 154 | 
             
                      end
         | 
| 181 155 |  | 
| 182 | 
            -
                      def  | 
| 183 | 
            -
                         | 
| 184 | 
            -
                         | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 187 | 
            -
                      def has_all_tags?(tag_names)
         | 
| 188 | 
            -
                        feature_tags = self.parent.parent.tags
         | 
| 189 | 
            -
                        tags.has_all_tags?(tag_names) || feature_tags.has_all_tags?(tag_names)
         | 
| 156 | 
            +
                      def matches_tags?(tag_names)
         | 
| 157 | 
            +
                        feature_tag_names = self.parent.parent.tags.tag_names
         | 
| 158 | 
            +
                        source_tag_names = (feature_tag_names + tags.tag_names).uniq
         | 
| 159 | 
            +
                        Ast::Tags.matches?(source_tag_names, tag_names)
         | 
| 190 160 | 
             
                      end
         | 
| 191 161 |  | 
| 192 162 | 
             
                      def matches_name?(regexp_to_match)
         | 
| @@ -268,11 +238,7 @@ module Cucumber | |
| 268 238 | 
             
                        table.at_line?(line)
         | 
| 269 239 | 
             
                      end
         | 
| 270 240 |  | 
| 271 | 
            -
                      def  | 
| 272 | 
            -
                        true
         | 
| 273 | 
            -
                      end
         | 
| 274 | 
            -
             | 
| 275 | 
            -
                      def has_all_tags?(tag_names)
         | 
| 241 | 
            +
                      def matches_tags?(tag_names)
         | 
| 276 242 | 
             
                        true
         | 
| 277 243 | 
             
                      end
         | 
| 278 244 |  | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            module Cucumber
         | 
| 2 2 | 
             
              module Parser
         | 
| 3 3 | 
             
                class NaturalLanguage
         | 
| 4 | 
            -
                  KEYWORD_KEYS = %w{name native encoding feature background scenario scenario_outline examples given when then but}
         | 
| 4 | 
            +
                  KEYWORD_KEYS = %w{name native encoding space_after_keyword feature background scenario scenario_outline examples given when then and but}
         | 
| 5 5 |  | 
| 6 6 | 
             
                  class << self
         | 
| 7 7 | 
             
                    def get(step_mother, lang)
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            ActionController::Base.class_eval do
         | 
| 2 | 
            +
              cattr_accessor :allow_rescue
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              alias_method :rescue_action_without_bypass, :rescue_action
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def rescue_action(exception)
         | 
| 7 | 
            +
                if ActionController::Base.allow_rescue
         | 
| 8 | 
            +
                  rescue_action_without_bypass(exception)
         | 
| 9 | 
            +
                else
         | 
| 10 | 
            +
                  raise exception
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            begin
         | 
| 16 | 
            +
              ActionController::Failsafe.class_eval do
         | 
| 17 | 
            +
                alias_method :failsafe_response_without_bypass, :failsafe_response
         | 
| 18 | 
            +
              
         | 
| 19 | 
            +
                def failsafe_response(exception)
         | 
| 20 | 
            +
                  raise exception
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            rescue NameError # Failsafe was introduced in Rails 2.3.2
         | 
| 24 | 
            +
              ActionController::Dispatcher.class_eval do
         | 
| 25 | 
            +
                def self.failsafe_response(output, status, exception = nil)
         | 
| 26 | 
            +
                  raise exception
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            Before('@allow_rescue') do
         | 
| 32 | 
            +
              ActionController::Base.allow_rescue = true
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            if defined?(ActiveRecord::Base)
         | 
| 2 | 
            +
              Cucumber::Rails::World.use_transactional_fixtures = true
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              Before do
         | 
| 5 | 
            +
                @__cucumber_ar_connection = ActiveRecord::Base.connection
         | 
| 6 | 
            +
                if @__cucumber_ar_connection.respond_to?(:increment_open_transactions)
         | 
| 7 | 
            +
                  @__cucumber_ar_connection.increment_open_transactions
         | 
| 8 | 
            +
                else
         | 
| 9 | 
            +
                  ActiveRecord::Base.__send__(:increment_open_transactions)
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
                @__cucumber_ar_connection.begin_db_transaction
         | 
| 12 | 
            +
                ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              After do
         | 
| 16 | 
            +
                @__cucumber_ar_connection.rollback_db_transaction
         | 
| 17 | 
            +
                if @__cucumber_ar_connection.respond_to?(:decrement_open_transactions)
         | 
| 18 | 
            +
                  @__cucumber_ar_connection.decrement_open_transactions
         | 
| 19 | 
            +
                else
         | 
| 20 | 
            +
                  ActiveRecord::Base.__send__(:decrement_open_transactions)
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            else
         | 
| 24 | 
            +
              module Cucumber::Rails
         | 
| 25 | 
            +
                def World.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/lib/cucumber/rails/rspec.rb
    CHANGED
    
    
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              require 'test/unit/testresult'
         | 
| 3 | 
            +
            rescue LoadError => e
         | 
| 4 | 
            +
              e.message << "\nYou must gem install test-unit. For more info see https://rspec.lighthouseapp.com/projects/16211/tickets/292"
         | 
| 5 | 
            +
              e.message << "\nAlso make sure you have rack 1.0.0 or higher."
         | 
| 6 | 
            +
              raise e
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
            # So that Test::Unit doesn't launch at the end - makes it think it has already been run.
         | 
| 9 | 
            +
            Test::Unit.run = true if Test::Unit.respond_to?(:run=)
         | 
    
        data/lib/cucumber/rails/world.rb
    CHANGED
    
    | @@ -1,6 +1,3 @@ | |
| 1 | 
            -
            # Based on code from Brian Takita, Yurii Rashkovskii and Ben Mabey
         | 
| 2 | 
            -
            # Adapted by Aslak Hellesøy
         | 
| 3 | 
            -
             | 
| 4 1 | 
             
            if defined?(ActiveRecord::Base)
         | 
| 5 2 | 
             
              require 'test_help' 
         | 
| 6 3 | 
             
            else
         | 
| @@ -8,93 +5,25 @@ else | |
| 8 5 | 
             
              require 'action_controller/integration'
         | 
| 9 6 | 
             
            end
         | 
| 10 7 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
            rescue LoadError => e
         | 
| 14 | 
            -
              e.message << "\nYou must gem install test-unit. For more info see https://rspec.lighthouseapp.com/projects/16211/tickets/292"
         | 
| 15 | 
            -
              e.message << "\nAlso make sure you have rack 1.0.0 or higher."
         | 
| 16 | 
            -
              raise e
         | 
| 17 | 
            -
            end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            # So that Test::Unit doesn't launch at the end - makes it think it has already been run.
         | 
| 20 | 
            -
            Test::Unit.run = true if Test::Unit.respond_to?(:run=)
         | 
| 8 | 
            +
            require 'cucumber/rails/test_unit'
         | 
| 9 | 
            +
            require 'cucumber/rails/action_controller'
         | 
| 21 10 |  | 
| 22 | 
            -
             | 
| 11 | 
            +
            unless ::Rails.configuration.cache_classes
         | 
| 12 | 
            +
              warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb).  This setting is known to break Cucumber's use_transactional_fixtures method. Set config.cache_classes to true if you want to use transactional fixtures.  For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
         | 
| 13 | 
            +
            end
         | 
| 23 14 |  | 
| 24 15 | 
             
            module Cucumber #:nodoc:
         | 
| 25 16 | 
             
              module Rails
         | 
| 26 | 
            -
                # All scenarios will execute in the context of a new instance of Cucumber::Rails:World if this file 
         | 
| 27 | 
            -
                # is loaded. This gives Step Definitions access to all the methods from Rails' ActionController::IntegrationTest
         | 
| 28 17 | 
             
                class World < ActionController::IntegrationTest
         | 
| 29 | 
            -
                  if defined?(ActiveRecord::Base)
         | 
| 30 | 
            -
                    self.use_transactional_fixtures = false
         | 
| 31 | 
            -
                  else
         | 
| 32 | 
            -
                    def self.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
             | 
| 35 18 | 
             
                  def initialize #:nodoc:
         | 
| 36 19 | 
             
                    @_result = Test::Unit::TestResult.new
         | 
| 37 20 | 
             
                  end
         | 
| 38 21 | 
             
                end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                def self.use_transactional_fixtures
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  unless ::Rails.configuration.cache_classes
         | 
| 43 | 
            -
                    warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/test.rb).  This setting is known to break Cucumber's use_transactional_fixtures method. Set config.cache_classes to true if you want to use transactional fixtures.  For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
         | 
| 44 | 
            -
                  end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                  World.use_transactional_fixtures = true
         | 
| 47 | 
            -
                  if defined?(ActiveRecord::Base)
         | 
| 48 | 
            -
                    $__cucumber_toplevel.Before do
         | 
| 49 | 
            -
                      @__cucumber_ar_connection = ActiveRecord::Base.connection
         | 
| 50 | 
            -
                      if @__cucumber_ar_connection.respond_to?(:increment_open_transactions)
         | 
| 51 | 
            -
                        @__cucumber_ar_connection.increment_open_transactions
         | 
| 52 | 
            -
                      else
         | 
| 53 | 
            -
                        ActiveRecord::Base.__send__(:increment_open_transactions)
         | 
| 54 | 
            -
                      end
         | 
| 55 | 
            -
                      @__cucumber_ar_connection.begin_db_transaction
         | 
| 56 | 
            -
                      ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
         | 
| 57 | 
            -
                    end
         | 
| 58 | 
            -
                    
         | 
| 59 | 
            -
                    $__cucumber_toplevel.After do
         | 
| 60 | 
            -
                      @__cucumber_ar_connection.rollback_db_transaction
         | 
| 61 | 
            -
                      if @__cucumber_ar_connection.respond_to?(:decrement_open_transactions)
         | 
| 62 | 
            -
                        @__cucumber_ar_connection.decrement_open_transactions
         | 
| 63 | 
            -
                      else
         | 
| 64 | 
            -
                        ActiveRecord::Base.__send__(:decrement_open_transactions)
         | 
| 65 | 
            -
                      end
         | 
| 66 | 
            -
                    end
         | 
| 67 | 
            -
                  end
         | 
| 68 | 
            -
                end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                def self.bypass_rescue
         | 
| 71 | 
            -
                  ActionController::Base.class_eval do
         | 
| 72 | 
            -
                    alias_method :rescue_action_without_bypass, :rescue_action
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                    def rescue_action(exception)
         | 
| 75 | 
            -
                      raise exception
         | 
| 76 | 
            -
                    end
         | 
| 77 | 
            -
                  end
         | 
| 78 | 
            -
             | 
| 79 | 
            -
                  begin
         | 
| 80 | 
            -
                    ActionController::Failsafe.class_eval do
         | 
| 81 | 
            -
                      alias_method :failsafe_response_without_bypass, :failsafe_response
         | 
| 82 | 
            -
                    
         | 
| 83 | 
            -
                      def failsafe_response(exception)
         | 
| 84 | 
            -
                        raise exception
         | 
| 85 | 
            -
                      end
         | 
| 86 | 
            -
                    end
         | 
| 87 | 
            -
                  rescue NameError # Failsafe was introduced in Rails 2.3.2
         | 
| 88 | 
            -
                    ActionController::Dispatcher.class_eval do
         | 
| 89 | 
            -
                      def self.failsafe_response(output, status, exception = nil)
         | 
| 90 | 
            -
                        raise exception
         | 
| 91 | 
            -
                      end
         | 
| 92 | 
            -
                    end
         | 
| 93 | 
            -
                  end
         | 
| 94 | 
            -
                end
         | 
| 95 22 | 
             
              end
         | 
| 96 23 | 
             
            end
         | 
| 97 24 |  | 
| 25 | 
            +
            require 'cucumber/rails/active_record'
         | 
| 26 | 
            +
             | 
| 98 27 | 
             
            World do
         | 
| 99 28 | 
             
              Cucumber::Rails::World.new
         | 
| 100 29 | 
             
            end
         |