Sha256: 7aec8118ea83d2bb2d83f10706586f695e0cac896a87bfbb5fe0e00aae418e36

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe 'Mutating regexen' do
  context 'for a singleton method' do
    context 'that contains `.*`' do
      before do
        write_file 'thing.rb', """
          class Thing
            def self.regex
              /.*/
            end
          end
        """
      end

      context 'with an expectation that a string matches the regex' do
        before do
          write_file 'spec/thing_spec.rb', """
            $: << '.'
            require 'thing'

            describe 'Thing.regex' do
              specify do
                'hello'.should match(Thing.regex)
              end
            end
          """
          mutate 'Thing.regex spec/thing_spec.rb'
        end

        specify 'the mutation passes' do
          all_output.should include('passed')
        end
      end

      context 'with an expectation that the regex is a Regexp' do
        before do
          write_file 'spec/thing_spec.rb', """
            $: << '.'
            require 'thing'

            describe 'Thing.regex' do
              specify { Thing.regex.should be_kind_of(Regexp) }
            end
          """
          mutate 'Thing.regex spec/thing_spec.rb'
        end

        specify 'the mutation fails' do
          all_output.should include('failed')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.1.1 spec/functional/singleton_method/regex_spec.rb
mutant-0.1.0 spec/functional/singleton_method/regex_spec.rb