Sha256: 24e59db61cc4bb23f52ab7d58173cf41b216cec5db0bf5f49487d8ee47cb6edf

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'
require 'sugar-high/methods'

class Abc
  def hello_kristian
    'hi'
  end

  protected

  def howdy_kristian
    'hi'
  end

  private

  def humm_kristian
    'hi'
  end
end

describe "SugarHigh" do
  describe "Methods" do
    before do
      @obj = Abc.new
    end

    it "should find all 3 methods saying 'hi' to kristian" do
      @obj.get_methods(:all).sort.grep(/(.*)_kristian$/).should have(3).items
    end

    it "should find public methods saying 'hi' to kristian" do
      @obj.get_methods(:public).sort.grep(/(.*)_kristian$/).should have(1).items
    end


    it "should find public methods saying 'hi' to kristian" do
      @obj.get_methods(:protected).sort.grep(/(.*)_kristian$/).should have(1).items
    end

    it "should find public and protected methods saying 'hi' to kristian" do
      @obj.get_methods(:public, :protected).sort.grep(/(.*)_kristian$/).should have(2).items
    end

    it "should find private and protected methods saying 'hi' to kristian" do
      @obj.get_methods(:private, :protected).sort.grep(/(.*)_kristian$/).should have(2).items
    end

    it "should find private and public methods saying 'hi' to kristian" do
      @obj.get_methods(:private, :public).sort.grep(/(.*)_kristian$/).should have(2).items
    end

    it "should find all 3 methods saying 'hi' to kristian" do
      @obj.get_methods(:private, :public, :protected).sort.grep(/(.*)_kristian$/).should have(3).items
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sugar-high-0.7.3 spec/sugar-high/methods_spec.rb
sugar-high-0.7.2 spec/sugar-high/methods_spec.rb
sugar-high-0.7.1 spec/sugar-high/methods_spec.rb
sugar-high-0.7.0 spec/sugar-high/methods_spec.rb