Sha256: d494ea1db53be4efd24e77b7cd75d051314ece56a66a3b932ada247eed0bb344

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require File.dirname(__FILE__) + '/test_helper'
require 'microformat/string'
require 'microformat/array'

context "A string should be coercable into" do
  specify "an integer" do
    "2".coerce.should.equal 2
  end

  specify "a float" do
    "4.0".coerce.should.equal 4.0
  end

  specify "a datetime" do
    "1985-03-13".coerce.should.equal Time.parse("1985-03-13")
  end

  specify "a boolean" do
    "true".coerce.should.be true
    "false".coerce.should.be false
  end
end

context "A string with HTML" do
  specify "should be able to remove the HTML" do
    string = %[<ol> <li><a href="http://diveintomark.org/xml/blink.xml" type="application/rss+xml">dive into mark b-links</a></li> <li><a href="http://www.thauvin.net/blog/xml.jsp?format=rdf" type="application/rss+xml">Eric&#39;s Weblog</a></li> <li><a href="http://intertwingly.net/blog/index.rss2" type="application/rss+xml">Sam Ruby</a></li> <li><a href="http://diveintomark.org/xml/atom.xml" type="application/atom+xml">dive into mark</a></li> <li><a href="http://www.decafbad.com/blog/index.rss" type="application/rss+xml">0xDECAFBAD</a></li> </ol>]
    string.strip_html.strip.should.equal "dive into mark b-links Eric&#39;s Weblog Sam Ruby dive into mark 0xDECAFBAD"
  end
end

context "An array sent first_or_self" do
  setup do
    @array = %w[one two]
  end

  specify "should return itself if it has more than one element" do
    @array.first_or_self.should.be @array
  end

  specify "should return its first element if it has only one element" do
    @array.pop
    @array.first_or_self.should.be.an.instance_of String
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mofo-0.2.1 test/ext_test.rb
mofo-0.2 test/ext_test.rb