Mange / roadie

@@ -142,6 +142,7 @@
Loading
142 142
    # Valid modes:
143 143
    #   `:html` (default)
144 144
    #   `:xhtml`
145 +
    #   `:xml`
145 146
    def mode=(mode)
146 147
      if VALID_MODES.include?(mode)
147 148
        @mode = mode
@@ -151,7 +152,7 @@
Loading
151 152
    end
152 153
153 154
    private
154 -
    VALID_MODES = %i[html xhtml].freeze
155 +
    VALID_MODES = %i[html xhtml xml].freeze
155 156
    private_constant :VALID_MODES
156 157
157 158
    def stylesheet
@@ -182,6 +183,7 @@
Loading
182 183
      format = {
183 184
        html: save_options::AS_HTML,
184 185
        xhtml: save_options::AS_XHTML,
186 +
        xml: save_options::AS_XML,
185 187
      }.fetch(mode)
186 188
187 189
      dom.dup.to_html(

@@ -70,6 +70,9 @@
Loading
70 70
71 71
      document.mode = :html
72 72
      expect(document.mode).to eq(:html)
73 +
74 +
      document.mode = :xml
75 +
      expect(document.mode).to eq(:xml)
73 76
    end
74 77
75 78
    it "does not allow unknown modes" do
@@ -126,6 +129,21 @@
Loading
126 129
          expect(document.transform).to include("{{hello}}")
127 130
        end
128 131
      end
132 +
133 +
      context "in XML mode" do
134 +
        it "doesn't replace empty tags with self-closed ones" do
135 +
          document = Document.new "<img src='https://google.com/image.png'></img>"
136 +
          document.mode = :xml
137 +
138 +
          expect(document.transform_partial).to end_with('</img>')
139 +
        end
140 +
141 +
        it "does not escape curly braces" do
142 +
          document = Document.new "<a href='https://google.com/{{hello}}'>Hello</a>"
143 +
          document.mode = :xhtml
144 +
          expect(document.transform_partial).to include("{{hello}}")
145 +
        end
146 +
      end
129 147
    end
130 148
131 149
    describe "partial transforming" do
@@ -159,6 +177,21 @@
Loading
159 177
          expect(document.transform_partial).to include("{{hello}}")
160 178
        end
161 179
      end
180 +
181 +
      context "in XML mode" do
182 +
        it "doesn't replace empty tags with self-closed ones" do
183 +
          document = Document.new "<img src='https://google.com/image.png'></img>"
184 +
          document.mode = :xml
185 +
186 +
          expect(document.transform_partial).to end_with('</img>')
187 +
        end
188 +
189 +
        it "does not escape curly braces" do
190 +
          document = Document.new "<a href='https://google.com/{{hello}}'>Hello</a>"
191 +
          document.mode = :xhtml
192 +
          expect(document.transform_partial).to include("{{hello}}")
193 +
        end
194 +
      end
162 195
    end
163 196
  end
164 197
Files Coverage
lib 98.64%
spec 96.47%
Project Totals (57 files) 97.25%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading