Sha256: 520b135aa766ee2a3c2777b922e410e2d94703b95f77fa2b2a0c9ca227085037

Contents?: true

Size: 803 Bytes

Versions: 13

Compression:

Stored size: 803 Bytes

Contents

module StyleTestMacros

  def xml(part)
    File.read(File.join(File.dirname(__FILE__), "data", "styles", "#{part}_styles.xml")).strip
  end

  def self.included(base)
    attr_reader :style
    base.extend ClassMethods
  end

  module ClassMethods

    def it_should_output_correct_xml(style_xml: nil)
      it "should be able to output the correct XML" do
        if style_xml.nil?
          style_xml = described_class.to_s.split(/::/).last
          style_xml = style_xml.gsub(/(.)([A-Z])/, '\1_\2').downcase
        end

        generated_xml = Nokogiri::XML::Builder.new do |xml|
          xml.styleFoo("xmlns:w" => "http://wnamespace.com") {
            style.build_xml(xml)
          }
        end.to_xml

        expect(generated_xml).to eq(xml(style_xml) + "\n")
      end
    end

  end

end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
openxml-docx-0.10.6 spec/support/style_test_macros.rb
openxml-docx-0.10.5 spec/support/style_test_macros.rb
openxml-docx-0.10.4 spec/support/style_test_macros.rb
openxml-docx-0.10.3 spec/support/style_test_macros.rb
openxml-docx-0.10.2 spec/support/style_test_macros.rb
openxml-docx-0.10.1 spec/support/style_test_macros.rb
openxml-docx-0.10.0 spec/support/style_test_macros.rb
openxml-docx-0.9.0 spec/support/style_test_macros.rb
openxml-docx-0.8.0 spec/support/style_test_macros.rb
openxml-docx-0.8.0.beta1 spec/support/style_test_macros.rb
rocx-0.7.0 spec/support/style_test_macros.rb
rocx-0.6.0 spec/support/style_test_macros.rb
rocx-0.5.8 spec/support/style_test_macros.rb