Sha256: 9655b74dec9e86675f2266aa2c66fe95a078b0c1da9f02e24cf40e338b834bd9

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'

describe :translate do
  it "correctly parses :ServiceKind" do
    expect(Helper.translate(:ServiceKind, '7')).to eq(:rates)
  end

  it "fails gracefully if it can't find the :serviceKind" do
    expect(Helper.translate(:ServiceKind, '100')).to eq('100')
  end

  it "correctly parses :integer" do
    expect(Helper.translate(:integer, '2343')).to eq(2343)
  end

  it "correctly parses :datetime" do
    expect(Helper.translate(:datetime, '2012-10-24T00:00:00Z')).to eq(DateTime.parse('2012-10-24T00:00:00Z').to_time.utc)
  end

  it "correctly parses :unixtime" do
    expect(Helper.translate(:unix_time, '1293868800')).to eq(Time.at(1293868800).utc)
  end
end

describe :pluralize do
  it "pluralizes words correctly" do
    expect(Helper.pluralize('crock')).to eq('crocks')
    expect(Helper.pluralize('utility')).to eq('utilities')
  end
end

describe :underscored do
  it "underscores camelcased words correctly" do
    expect(Helper.underscore('yourAvgUtility')).to eq('your_avg_utility')
    expect(Helper.underscore('YourAvgUtility')).to eq('your_avg_utility')
  end
end

describe Helper::Rule do
  it "should have a attribute name" do
    rule = Helper::Rule.new(:attr_name,"xpath",:DateTime)
    expect(rule.attr_name).to eq :attr_name
    expect(rule.xpath).to eq "xpath"
    expect(rule.type).to eq :DateTime
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
greenbutton-0.0.1 spec/helper_spec.rb