merged cont.
[opensuse:yast-rest-service.git] / webyast / test / unit / restdoc_test.rb
1 #--
2 # Webyast Webservice framework
3 #
4 # Copyright (C) 2009, 2010 Novell, Inc. 
5 #   This library is free software; you can redistribute it and/or modify
6 # it only under the terms of version 2.1 of the GNU Lesser General Public
7 # License as published by the Free Software Foundation. 
8 #
9 #   This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
12 # details. 
13 #
14 #   You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software 
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 #++
18
19 require File.dirname(__FILE__) + '/../test_helper'
20
21 class RestdocTest < ActiveSupport::TestCase
22
23   def setup
24     @dummy_path = 'dummy/plugin/path'
25     Rails.configuration.stubs(:plugin_paths).returns(@dummy_path)
26     Dir.stubs(:'[]').with("#{@dummy_path}/*").returns(["#{@dummy_path}/dummy_plugin"])
27     File.stubs(:directory?).with("#{@dummy_path}/dummy_plugin/app").returns(true)
28     File.stubs(:directory?).with("#{@dummy_path}/dummy_plugin/public").returns(true)
29     Dir.stubs(:'[]').with("#{@dummy_path}/dummy_plugin/public/**/restdoc/index.html").returns(
30       ["#{@dummy_path}/dummy_plugin/public/controller/restdoc/index.html"])
31     File.stubs(:file?).with("#{@dummy_path}/dummy_plugin/public/controller/restdoc/index.html").returns(true)
32   end
33
34   def teardown
35     Mocha::Mockery.instance.stubba.unstub_all
36   end
37
38   def test_find
39     r = Restdoc.find :all
40
41     assert_equal ["controller/restdoc/index.html"], r
42   end
43
44   def test_find_nothing
45     Dir.stubs(:'[]').with("#{@dummy_path}/dummy_plugin/public/**/restdoc/index.html").returns([])
46
47     r = Restdoc.find :all
48
49     assert_equal [], r
50   end
51 end