Sha256: aab3f470ae54405ba09adf60f58c303401f11a4ca965c09fcdba842955e58d21

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe Cinch::Plugins::Convert do

  include Cinch::Test

  before(:each) do
    @bot = make_bot(Cinch::Plugins::Convert)
  end

  describe 'configuration' do
    it 'should handle the units binary\'s absence with grace' do
      @bot = make_bot(Cinch::Plugins::Convert, { :units_path => '/usr/baddir/units' })
      msg = make_message(@bot, '!convert 3 foo to bar')
      get_replies(msg).last.chomp.
        should == 'test: Sorry, there\'s a configuration issue.'
    end
  end

  describe 'conversions' do
    it 'should alow users to convert units' do
      msg = make_message(@bot, '!convert 2 inches to feet')
      get_replies(msg).last.chomp.
        should == 'test: 2 inches is 0.16666667 feet.'
    end

    it 'should allow users to convert temps' do
      msg = make_message(@bot, '!convert tempF(32) to tempC')
      get_replies(msg).last.chomp.
        should == 'test: tempF(32) is 0 tempC.'
    end

    it 'should return an error on conformability issues' do
      msg = make_message(@bot, '!convert 15 minutes to gallons')
      get_replies(msg).last.chomp.
        should == 'test: Sorry, there was a conformability error when making that conversion.'
    end

    it 'should return an error on invalid units' do
      msg = make_message(@bot, '!convert 15 foo to bar')
      get_replies(msg).last.chomp.
        should == 'test: Sorry, unknown unit \'foo\'.'
    end

    it 'shouldn\'t return anything on invalid conversions' do
      msg = make_message(@bot, '!convert foo 15 foo baz bar')
      get_replies(msg).
        should be_empty
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cinch-convert-1.0.0 spec/cinch-convert_spec.rb