Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 84 lines (71 sloc) 2.205 kb
cbce3c7 @drbrain Make test file requires directory independent
drbrain authored
1 require File.expand_path('../helper', __FILE__)
5f10762 @jimweirich Disable expected rdoc task warnings in test.
authored
2 begin
6816aae @drbrain Silence warning when loading to test deprecated features
drbrain authored
3 old_stderr = $stderr
4 dev_null = File.exist?('/dev/null') ? '/dev/null' : 'NUL'
5 $stderr = open dev_null, 'w'
5f10762 @jimweirich Disable expected rdoc task warnings in test.
authored
6 require 'rake/rdoctask'
7 ensure
6816aae @drbrain Silence warning when loading to test deprecated features
drbrain authored
8 $stderr.close
9 $stderr = old_stderr
5f10762 @jimweirich Disable expected rdoc task warnings in test.
authored
10 end
a8d3e87 @FooBarWidget Add unit tests for RDocTask.
FooBarWidget authored
11
0534fa5 @drbrain Tests now inherit from Rake::TestCase instead of Test::Unit::TestCase…
drbrain authored
12 class TestRakeRDocTask < Rake::TestCase
a8d3e87 @FooBarWidget Add unit tests for RDocTask.
FooBarWidget authored
13 include Rake
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
14
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
15 def setup
cbce3c7 @drbrain Make test file requires directory independent
drbrain authored
16 super
17
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
18 Task.clear
19 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
20
a8d3e87 @FooBarWidget Add unit tests for RDocTask.
FooBarWidget authored
21 def test_tasks_creation
22 Rake::RDocTask.new
23 assert Task[:rdoc]
24 assert Task[:clobber_rdoc]
25 assert Task[:rerdoc]
26 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
27
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
28 def test_tasks_creation_with_custom_name_symbol
a8d3e87 @FooBarWidget Add unit tests for RDocTask.
FooBarWidget authored
29 rd = Rake::RDocTask.new(:rdoc_dev)
30 assert Task[:rdoc_dev]
31 assert Task[:clobber_rdoc_dev]
32 assert Task[:rerdoc_dev]
33 assert_equal :rdoc_dev, rd.name
34 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
35
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
36 def test_tasks_creation_with_custom_name_string
37 rd = Rake::RDocTask.new("rdoc_dev")
38 assert Task[:rdoc_dev]
39 assert Task[:clobber_rdoc_dev]
40 assert Task[:rerdoc_dev]
41 assert_equal "rdoc_dev", rd.name
42 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
43
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
44 def test_tasks_creation_with_custom_name_hash
45 options = { :rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force" }
46 rd = Rake::RDocTask.new(options)
47 assert Task[:"rdoc"]
48 assert Task[:"rdoc:clean"]
49 assert Task[:"rdoc:force"]
50 assert_raises(RuntimeError) { Task[:clobber_rdoc] }
51 assert_equal options, rd.name
52 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
53
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
54 def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given
ffad055 @drbrain Suppress unused variable warnings for 1.9.3dev
drbrain authored
55 Rake::RDocTask.new(:clobber_rdoc => "rdoc:clean")
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
56 assert Task[:rdoc]
57 assert Task[:"rdoc:clean"]
58 assert Task[:rerdoc]
59 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
60
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
61 def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
62 assert_raises(ArgumentError) do
63 Rake::RDocTask.new(:foo => "bar")
64 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
65
b74000b @FooBarWidget Make it possible to completely customize the RDoc task names.
FooBarWidget authored
66 begin
67 Rake::RDocTask.new(:foo => "bar")
68 rescue ArgumentError => e
69 assert_match(/foo/, e.message)
70 end
71 end
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
72
3364539 @FooBarWidget Add a hook method to RDocTask so that the Hanna RDoc template doesn't…
FooBarWidget authored
73 def test_inline_source_option_is_only_appended_if_option_not_already_given
74 rd = Rake::RDocTask.new
75 rd.options << '--inline-source'
76 assert_equal 1, rd.option_list.grep('--inline-source').size
2365bd2 @drbrain Remove trailing whitespace from rake
drbrain authored
77
3364539 @FooBarWidget Add a hook method to RDocTask so that the Hanna RDoc template doesn't…
FooBarWidget authored
78 rd = Rake::RDocTask.new
79 rd.options << '-S'
80 assert_equal 1, rd.option_list.grep('-S').size
81 assert_equal 0, rd.option_list.grep('--inline-source').size
82 end
a8d3e87 @FooBarWidget Add unit tests for RDocTask.
FooBarWidget authored
83 end
Something went wrong with that request. Please try again.