Sha256: 2731b3cd05e440eea5153a3975a90268cab0b634565ef84d094755fb7f770775
Contents?: true
Size: 740 Bytes
Versions: 5
Compression:
Stored size: 740 Bytes
Contents
# encoding: utf-8 shared_examples 'it calls super' do |method| around do |example| # Restore original method after each example original = "original_#{method}" superclass.class_eval do alias_method original, method example.call undef_method method alias_method method, original end end it "delegates to the superclass ##{method} method" do # This is the most succinct approach I could think of to test whether the # superclass method is called. All of the built-in rspec helpers did not # seem to work for this. called = false superclass.class_eval { define_method(method) { |_| called = true } } expect { subject }.to change { called }.from(false).to(true) end end
Version data entries
5 entries across 5 versions & 1 rubygems