Sha256: 4531e695fdb2e7ad14f19c063a2ea5318c6e80093972ecae50d1cbad3a3809bc

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# coding: utf-8

require 'spec_helper'

describe ONIX2::Title do

  Given(:doc) { load_xml "title.xml" }

  describe "should correctly convert to a string" do
    Given(:title) { ONIX2::Title.from_xml(doc) }
    Then { title.to_xml.to_s.start_with? "<Title>" }
  end

  describe "should provide read access to first level attributes" do
    Given(:title){ ONIX2::Title.from_xml(doc) }

    Then { title.title_type == 1 }
    Then { title.title_text == "Good Grief" }
    Then { title.subtitle == "A Constructive Approach to the Problem of Loss" }
  end

  context "should provide write access to first level attributes" do
    Given(:title){ ONIX2::Title.new }
    describe :title_type= do
      When { title.title_type = 1 }
      Then { title.to_xml.to_s.include? "<TitleType>01</TitleType>" }
    end
    describe :title_text= do
      When { title.title_text = "Good Grief" }
      Then { title.to_xml.to_s.include? "<TitleText>Good Grief</TitleText>" }
    end
    describe :subtitle= do
      When { title.subtitle = "Blah" }
      Then { title.to_xml.to_s.include? "<Subtitle>Blah</Subtitle>" }
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onix2-1.0.0 spec/title_spec.rb