Sha256: 9a5f3128c667ec9185b9aa14a79471eb7d2e8577c55170231ca236a09be456b0

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'
require 'muzang-plugins/muzang-meme'

describe "Meme" do
  before do
    @bot = stub(:channels => ["#test"])
    @meme = Meme.new(@bot)
    @connection = ConnectionMock.new
    @url = "http://version1.api.memegenerator.net:80/Instance_Create?username=drug-bot&password=drug-bot&languageCode=en&generatorID=2&imageID=166088&text0=hi0&text1=hi1"
    @file = File.expand_path("../support/responses/meme.response", __FILE__)
    EventMachine::MockHttpRequest.pass_through_requests = false
    EventMachine::MockHttpRequest.register_file(@url, :get, @file)
    EventMachine::MockHttpRequest.activate!
    @message = OpenStruct.new({:channel => "#test", :message => "meme", :nick => "LTe" })
  end

  it "should print pretty help" do
    EM.run do
      @meme.call(@connection, @message)
      eventually(true) do
        @connection.messages.include?("Type 'meme [name of meme] \"Text0\" \"Text1\"'") and
        @connection.messages.include?("Available memes: #{Meme::MEMES.keys.join(" ")}")
      end
    end
  end

  it "should create meme and send message" do
    @message.message = "meme yuno \"hi0\" \"hi1\""
    EM.run do
      @meme.call(@connection, @message)
      eventually(1) { @connection.message_count }
      eventually(true) { @connection.messages.include? "Meme: http://version1.api.memegenerator.net//cache/instances/400x/10/10725/10982714.jpg" }
    end
  end

  it "should not create meme" do
    @message.message = "meme asdkasdj \"hi0\" \"hi1\""
    EM.run do
      @meme.call(@connection, @message)
      eventually(0) { @connection.message_count }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
muzang-plugins-1.1.1 spec/meme_spec.rb
muzang-plugins-1.1.0 spec/meme_spec.rb
muzang-plugins-1.0.2 spec/meme_spec.rb
muzang-plugins-1.0.1 spec/meme_spec.rb
muzang-plugins-1.0.0 spec/meme_spec.rb