Sha256: ad1c84d8510513df85d69a6604a65d743c379f062d6c832d897f5ee1b7f0a46d

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 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.text.
        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.text.
        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.text.
        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.text.
        should == 'test: Sorry, there was an 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.text.
        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

3 entries across 3 versions & 1 rubygems

Version Path
cinch-convert-1.0.3 spec/cinch-convert_spec.rb
cinch-convert-1.0.2 spec/cinch-convert_spec.rb
cinch-convert-1.0.1 spec/cinch-convert_spec.rb