Sha256: 12c1e199c967564f80b329b08a8adbd3407822cbbb5ce102b34061a6b18f9b5b

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require 'muzang-plugins/muzang-eval'

describe "Eval" do
  before(:each) do
    @bot = stub
    @eval = Eval.new(@bot)
    @connection = ConnectionMock.new
    @message = OpenStruct.new({ :channel => "#test", :message => "% 1 + 1", :nick => "LTe" })
  end

  it "should eval ruby code" do
    @message.message = "% 1 + 1"
    EM.run do
      @eval.call(@connection, @message)
      eventually(true) { @connection.messages.include? "2" }
    end
  end

  it "@codegram should give me a t-shirt" do
    @message.message = "% \"@codegram\""
    EM.run do
      @eval.call(@connection, @message)
      eventually(true) { @connection.messages.include? "@codegram" }
    end
  end

  it "should not eval system method" do
    @message.message = "% system('rm -rf /')"
    EM.run do
      @eval.call(@connection, @message)
      eventually(true) { @connection.messages.include? "Error: Insecure operation - system" }
    end
  end

  it "should not crash after raise Exception" do
    @message.message = "% raise Exception"
    EM.run do
      @eval.call(@connection, @message)
      eventually(true) { @connection.messages.include? "Error: Exception" }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
muzang-plugins-1.1.4 spec/muzang-eval_spec.rb
muzang-plugins-1.1.3 spec/muzang-eval_spec.rb
muzang-plugins-1.1.2 spec/muzang-eval_spec.rb
muzang-plugins-1.1.1 spec/muzang-eval_spec.rb
muzang-plugins-1.1.0 spec/muzang-eval_spec.rb
muzang-plugins-1.0.2 spec/muzang-eval_spec.rb
muzang-plugins-1.0.1 spec/muzang-eval_spec.rb
muzang-plugins-1.0.0 spec/muzang-eval_spec.rb