Sha256: 8b65c4029788e54a453c55569f64dac0a0e623612aee58ee2d509c647dd433ab

Contents?: true

Size: 1.27 KB

Versions: 16

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'
require 'cucumber/rb_support/rb_transform'

module Cucumber
  module RbSupport
    describe RbTransform do
      def transform(regexp)
        RbTransform.new(nil, regexp, lambda { |a| })
      end

      describe "#to_s" do
        it "does not touch positive lookahead captures" do
          expect(transform(/^xy(?=z)/).to_s).to eq "xy(?=z)"
        end

        it "does not touch negative lookahead captures" do
          expect(transform(/^xy(?!z)/).to_s).to eq "xy(?!z)"
        end

        it "does not touch positive lookbehind captures" do
          expect(transform(/^xy(?<=z)/).to_s).to eq "xy(?<=z)"
        end

        it "does not touch negative lookbehind captures" do
          expect(transform(/^xy(?<!z)/).to_s).to eq "xy(?<!z)"
        end

        it "converts named captures" do
          expect(transform(/^(?<str>xyz)/).to_s).to eq "(?:<str>xyz)"
        end

        it "converts captures groups to non-capture groups" do
          expect(transform(/(a|b)bc/).to_s).to eq "(?:a|b)bc"
        end

        it "leaves non capture groups alone" do
          expect(transform(/(?:a|b)bc/).to_s).to eq "(?:a|b)bc"
        end

        it "strips away anchors" do
          expect(transform(/^xyz$/).to_s).to eq "xyz"
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
cucumber-2.99.0 spec/cucumber/rb_support/rb_transform_spec.rb
mobiusloop-0.1.5 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.4.0 spec/cucumber/rb_support/rb_transform_spec.rb
mobiusloop-0.1.3 spec/cucumber/rb_support/rb_transform_spec.rb
mobiusloop-0.1.2 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.3.3 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.3.2 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.3.1 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.3.0 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.2.0 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.1.0 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.0.2 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.0.1 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.0.0 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.0.0.rc.5 spec/cucumber/rb_support/rb_transform_spec.rb
cucumber-2.0.0.rc.4 spec/cucumber/rb_support/rb_transform_spec.rb