File: spec_fixtures.rb

package info (click to toggle)
ruby-iniparse 1.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 472 kB
  • sloc: ruby: 2,409; makefile: 3
file content (76 lines) | stat: -rw-r--r-- 1,495 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
module IniParse
  module Test
    class Fixtures
      @@fixtures = {}

      def self.[](fix)
        if @@fixtures.has_key?(fix)
          @@fixtures[fix]
        else
          @@fixtures[fix] = File.read(
            File.join(File.expand_path('fixtures', File.dirname(__FILE__)), fix)
          )
        end
      end

      def self.[]=(fix, val)
        @@fixtures[fix] = val
      end
    end
  end
end

IniParse::Test::Fixtures[:comment_before_section] = <<-FIX.gsub(/^  /, '')
  ; This is a comment
  [first_section]
  key = value
FIX

IniParse::Test::Fixtures[:blank_before_section] = <<-FIX.gsub(/^  /, '')

  [first_section]
  key = value
FIX

IniParse::Test::Fixtures[:blank_in_section] = <<-FIX.gsub(/^  /, '')
  [first_section]

  key = value
FIX

IniParse::Test::Fixtures[:option_before_section] = <<-FIX.gsub(/^  /, '')
  foo = bar
  [foo]
  another = thing
FIX

IniParse::Test::Fixtures[:invalid_line] = <<-FIX.gsub(/^  /, '')
  this line is not valid
FIX

IniParse::Test::Fixtures[:section_with_equals] = <<-FIX.gsub(/^  /, '')
  [first_section = name]
  key = value
  [another_section = a name]
  another = thing
FIX

IniParse::Test::Fixtures[:comment_line] = <<-FIX.gsub(/^  /, '')
  [first_section]
  ; block comment ;
  ; with more lines ;
  key = value
FIX

IniParse::Test::Fixtures[:duplicate_section] = <<-FIX.gsub(/^  /, '')
  [first_section]
  key = value
  another = thing

  [second_section]
  okay = yes

  [first_section]
  third = fourth
  another = again
FIX