Sha256: 37d7dea988a256762d733531532bca9e9391f72d3e36703409833dded68d2142
Contents?: true
Size: 1.99 KB
Versions: 7
Compression:
Stored size: 1.99 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Lint describe UnreachableCode do let(:uc) { UnreachableCode.new } UnreachableCode::NODE_TYPES.each do |t| it "registers an offence for #{t} before other statements" do inspect_source(uc, ['foo = 5', "#{t}", 'bar' ]) expect(uc.offences.size).to eq(1) end it "accepts code with conditional #{t}" do inspect_source(uc, ['foo = 5', "#{t} if test", 'bar' ]) expect(uc.offences).to be_empty end it "accepts #{t} as the final expression" do inspect_source(uc, ['foo = 5', "#{t} if test" ]) expect(uc.offences).to be_empty end end UnreachableCode::FLOW_COMMANDS.each do |t| it "registers an offence for #{t} before other statements" do inspect_source(uc, ['foo = 5', "#{t} something", 'bar' ]) expect(uc.offences.size).to eq(1) end it "accepts code with conditional #{t}" do inspect_source(uc, ['foo = 5', "#{t} something if test", 'bar' ]) expect(uc.offences).to be_empty end it "accepts #{t} as the final expression" do inspect_source(uc, ['foo = 5', "#{t} something if test" ]) expect(uc.offences).to be_empty end end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems