Sha256: d1b9a71c966418671f12a3da507f0504edd7c08f5b9478a87a9428d7ab37db73

Contents?: true

Size: 995 Bytes

Versions: 5

Compression:

Stored size: 995 Bytes

Contents

require "spec/spec_helper"

describe Irwi::Support::TemplateFinder do
  
  it { should_not be_nil }
  
  context "included in class" do
    
    before(:each) do
      @m = Object.new
      @m.send :extend, Irwi::Support::TemplateFinder
      @m.stub!(:controller_path).and_return('my_controller')
    end
    
    specify "should provide template_dir method" do 
      @m.should respond_to(:template_dir)
    end
    
    specify "should select template at controller_path when exists" do 
      Dir.should_receive(:glob).with("app/views/my_controller/my_template.html.*").and_return(['some_template'])
      
      @m.send( :template_dir, 'my_template' ).should == 'my_controller'
    end
    
    specify "should select template in base dir when it doesn't exists at controller_path" do 
      Dir.should_receive(:glob).with("app/views/my_controller/my_template.html.*").and_return([])
      
      @m.send( :template_dir, 'my_template' ).should == 'base_wiki_pages'
    end
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
irwi-0.2.4 spec/support/template_finder_spec.rb
irwi-0.2.3 spec/support/template_finder_spec.rb
irwi-0.2.2 spec/support/template_finder_spec.rb
irwi-0.2.1 spec/support/template_finder_spec.rb
irwi-0.2.0 spec/support/template_finder_spec.rb