summaryrefslogtreecommitdiffstats
path: root/spec/unit/indirector/plain_spec.rb
blob: 0894f70f062111970fd5480ffc5bc915d500a252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env rspec
require 'spec_helper'
require 'puppet/indirector/plain'

describe Puppet::Indirector::Plain do
  before do
    Puppet::Indirector::Terminus.stubs(:register_terminus_class)
    @model = mock 'model'
    @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
    Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)

    module Testing; end
    @plain_class = class Testing::MyPlain < Puppet::Indirector::Plain
      self
    end

    @searcher = @plain_class.new

    @request = stub 'request', :key => "yay"
  end

  it "should return return an instance of the indirected model" do
    object = mock 'object'
    @model.expects(:new).with(@request.key).returns object
    @searcher.find(@request).should equal(object)
  end
end