File: hash_spec.rb

package info (click to toggle)
ruby-nori 2.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 256 kB
  • sloc: ruby: 1,155; xml: 266; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 767 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
require "spec_helper"

describe Hash do

  describe "#normalize_param" do
    it "should have specs"
  end

  describe "#to_xml_attributes" do

    it "should turn the hash into xml attributes" do
      attrs = { :one => "ONE", "two" => "TWO" }.to_xml_attributes
      expect(attrs).to match(/one="ONE"/m)
      expect(attrs).to match(/two="TWO"/m)
    end

    it "should preserve _ in hash keys" do
      attrs = {
        :some_long_attribute => "with short value",
        :crash               => :burn,
        :merb                => "uses extlib"
      }.to_xml_attributes

      expect(attrs).to match(/some_long_attribute="with short value"/)
      expect(attrs).to match(/merb="uses extlib"/)
      expect(attrs).to match(/crash="burn"/)
    end
  end

end