Sha256: 6d6c0b2758e45eb40b27c0e198555c897912c59ffc8a274e05e328c0dd2b360d

Contents?: true

Size: 1.63 KB

Versions: 16

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Fasterer::RescueCall do
  let(:file_path) { RSpec.root.join('support', 'rescue_call', file_name) }

  let(:rescue_element) do
    sexpd_file = Fasterer::Parser.parse(File.read(file_path))
    sexpd_file[2]
  end

  let(:rescue_call) do
    Fasterer::RescueCall.new(rescue_element)
  end

  describe 'plain rescue call' do
    let(:file_name) { 'plain_rescue.rb' }

    it 'should detect constant' do
      expect(rescue_call.rescue_classes).to eq(Sexp.new())
    end
  end

  describe 'rescue call with class' do
    let(:file_name) { 'rescue_with_class.rb' }

    it 'should detect integer' do
      expect(rescue_call.rescue_classes).to eq(Sexp.new(:NoMethodError))
    end
  end

  describe 'rescue call with class and variable' do
    let(:file_name) { 'rescue_with_class_and_variable.rb' }

    it 'should detect string' do
      expect(rescue_call.rescue_classes).to eq(Sexp.new(:NoMethodError))
    end
  end

  describe 'rescue call with variable' do
    let(:file_name) { 'rescue_with_variable.rb' }

    it 'should detect variable' do
      expect(rescue_call.rescue_classes).to eq(Sexp.new())
    end
  end

  describe 'rescue call with multiple classes' do
    let(:file_name) { 'rescue_with_multiple_classes.rb' }

    it 'should detect method' do
      expect(rescue_call.rescue_classes).to eq(Sexp.new(:NoMethodError, :StandardError))
    end
  end

  describe 'rescue call with multiple classes and variable' do
    let(:file_name) { 'rescue_with_multiple_classes_and_variable.rb' }

    it 'should detect method' do
      expect(rescue_call.rescue_classes).to eq(Sexp.new(:NoMethodError, :StandardError))
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fasterer-0.11.0 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.10.1 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.10.0 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.9.0 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.8.3 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.8.2 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.8.1 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.8.0 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.7.1 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.7.0 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.6.0 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.5.1 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.5.0 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.4.2 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.4.1 spec/lib/fasterer/rescue_call_spec.rb
fasterer-0.4.0 spec/lib/fasterer/rescue_call_spec.rb