Sha256: 7256683abfd6f4c8394d7fe98ce5e495241f12b6219ea7d7abc9dea04f2c83e5

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

require 'great_pretender/pretender'
require 'ostruct'

class PrefixSlugPretender
  def say_hello
    "Hello, guest!"
  end
end

class TestSlugPretender
  def ohai
    "ohai"
  end
end

describe GreatPretender::Pretender do

  let(:mockup) { OpenStruct.new(slug: "prefix_slug/test_slug") }
  let(:pretender) { GreatPretender::Pretender.new(mockup) }
  let(:recipient) do
    mod = pretender.to_module
    Class.new { include mod }.new
  end

  it "delegates methods to pretenders named after mockups" do
    expect(recipient.ohai).to eq("ohai")
  end

  it "delegates methods to pretenders in the slug chain" do
    expect(recipient.say_hello).to eq("Hello, guest!")
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
great_pretender-0.1.1 spec/lib/great_pretender/pretender_spec.rb