theme_spec.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:2k
源码类别:

Ajax

开发平台:

Others

  1. require File.dirname(__FILE__) + '/../spec_helper'
  2. describe 'Given a new test theme' do
  3.   before(:each) do
  4.     @theme = Theme.new("test", "test")
  5.   end
  6.   it 'layout path should be "#{RAILS_ROOT}/themes/test/layouts/default.html.erb"'  do
  7.     @theme.layout('index').should == "#{RAILS_ROOT}/themes/test/layouts/default.html.erb"
  8.   end  
  9. end
  10. describe 'Given the default theme' do
  11.   before(:each) do
  12.     @theme = Blog.default.current_theme
  13.   end
  14.   it 'theme should be typographic' do
  15.     @theme.name.should == 'typographic'
  16.   end
  17.   it 'theme description should be correct' do
  18.     @theme.description.should ==
  19.       File.open(RAILS_ROOT + '/themes/typographic/about.markdown') {|f| f.read}
  20.   end
  21.   it 'theme_from_path should find the correct theme' do
  22.     Theme.theme_from_path(RAILS_ROOT + 'themes/typographic').name.should == 'typographic'
  23.     Theme.theme_from_path(RAILS_ROOT + 'themes/scribbish').name.should == 'scribbish'
  24.   end
  25.   it '#search_theme_path finds the right things' do
  26.     Theme.should_receive(:themes_root).and_return(RAILS_ROOT + '/test/mocks/themes')
  27.     Theme.search_theme_directory.collect{|t| File.basename(t)}.sort.should ==
  28.       %w{ 123-numbers-in-path CamelCaseDirectory i-have-special-chars typographic }
  29.   end
  30.   it 'find_all finds all the installed themes' do
  31.     Theme.find_all.collect{|t| t.name}.should include(@theme.name)
  32.     Theme.find_all.size.should ==
  33.       Dir.glob(RAILS_ROOT + '/themes/[a-zA-Z0-9]*').select do |file|
  34.         File.readable? "#{file}/about.markdown"
  35.       end.size
  36.   end
  37. end