Class: TestConfiguration
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TestConfiguration
- Defined in:
- lib/configuration.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_accessor ⇒ Object
- #test_nesting ⇒ Object
- #test_setup ⇒ Object
- #xtest_common_usecase ⇒ Object
Instance Method Details
#setup ⇒ Object
164 165 166 |
# File 'lib/configuration.rb', line 164 def setup @conf = Configuration.new("./test") end |
#teardown ⇒ Object
219 220 221 |
# File 'lib/configuration.rb', line 219 def teardown FileUtils.rm_r(@conf.base) end |
#test_accessor ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/configuration.rb', line 174 def test_accessor assert(@conf["file1"] = "bar") assert_equal(@conf[[:file1]], "bar") assert_equal(@conf[["file1"]], "bar") assert_equal(@conf["file1"], "bar") assert(File.exist?("#{@conf.base}/file1.yaml")) assert(@conf["file2"] = "foo") assert_equal(@conf[:file2], "foo") assert_equal(@conf["file2"], "foo") assert(File.exist?("#{@conf.base}/file2.yaml")) assert(@conf[[:file3, :sub]] = "baz") assert_equal(@conf[[:file3, :sub]], "baz") assert_equal(@conf["file3", "sub"], "baz") assert(File.exist?("#{@conf.base}/file3.yaml")) assert(!File.exist?("#{@conf.base}/file3")) assert(@conf.exist?(:file3)) assert(!@conf.exist?(:file)) #assert_raise { @conf end |
#test_nesting ⇒ Object
197 198 |
# File 'lib/configuration.rb', line 197 def test_nesting end |
#test_setup ⇒ Object
168 169 170 171 172 |
# File 'lib/configuration.rb', line 168 def test_setup assert(@conf) assert(@conf.base) assert(File.directory?(@conf.base)) end |
#xtest_common_usecase ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/configuration.rb', line 200 def xtest_common_usecase @conf.setup(%w( main plugins plugins/demo )) @conf.merge( "main.language" => "de", "main.channels" => %w(foo bar baz), "plugins.demo.value" => 42 ) @conf["plugins.demo.other"] = 24 @conf["main.language"].replace("en") @conf.update file, key = @conf.send(:split, "main.language") File.open(file, "w") { |fh| fh.write({"language" => "en"}.to_yaml) } @conf.rehash end |