Permalink
Browse files

Change version, remove old specs.

  • Loading branch information...
1 parent d99cd24 commit 8cb1347f0222abed50e8ec9c2d3440cb1aa130e4 @LTe committed Nov 15, 2011
@@ -1,3 +0,0 @@
-class Eval
- VERSION = "0.0.1"
-end
@@ -1,43 +0,0 @@
-require File.expand_path("../../../muzang/spec/spec_helper", __FILE__)
-require '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
@@ -1,3 +0,0 @@
-class Livereload
- VERSION = "0.0.1"
-end
@@ -1,23 +0,0 @@
-require File.expand_path("../../../muzang/spec/spec_helper", __FILE__)
-require 'muzang-livereload'
-
-describe "LiveReload" do
- before(:each) do
- @bot = stub
- @livereload = LiveReload.new(@bot)
- @bot.stub(:plugins => { LiveReload => @livereload })
- @connection = stub(:msg => true)
- Kernel.stub(:load)
- @message = OpenStruct.new({:channel => "#test", :message => "!reload"})
- end
-
- it "should load plugins" do
- Kernel.should_receive(:load).with('muzang-livereload.rb')
- @livereload.call(@connection, @message)
- end
-
- it "should create new instance of plugin" do
- LiveReload.should_receive(:new).with(@bot)
- @livereload.call(@connection, @message)
- end
-end
@@ -1,51 +0,0 @@
-require "em-http-request"
-require "json"
-
-class Meme
- include Muzang::Plugin::Helpers
-
- MEMES = {
- "idont" => { :image_id => 2485, :generator => 74 },
- "yuno" => { :image_id => 166088, :generator => 2 },
- "orly" => { :image_id => 117049, :generator => 920 },
- "suc" => { :image_id => 1031, :generator => 121 },
- "all" => { :image_id => 1121885, :generator => 6013 }
- }
-
- def initialize(bot)
- @bot = bot
- end
-
- def call(connection, message)
- message.message.match(/^meme$/) do
- connection.msg("#{@bot.channel}", "Type 'meme [name of meme] \"Text0\" \"Text1\"'")
- connection.msg("#{@bot.channel}", "Available memes: #{MEMES.keys.join(" ")}")
- end
- message.message.match(/^meme (.*?) "(.*?)"( "(.*?)")?$/) do |m|
- if meme_ids = MEMES[m[1]]
- @generator = meme_ids[:generator]
- @image_id = meme_ids[:image_id]
- else
- return nil
- end
-
- @text0 = m[2]
- @text1 = m[4]
-
- http = EventMachine::HttpRequest.new('http://version1.api.memegenerator.net/Instance_Create')
- .get(:query => {:username => 'drug-bot',
- :password => 'drug-bot',
- :languageCode => 'en',
- :generatorID => @generator,
- :imageID => @image_id,
- :text0 => @text0,
- :text1 => @text1})
-
- http.callback {
- meme = JSON.parse(http.response)
- url = "http://version1.api.memegenerator.net#{meme['result']['instanceImageUrl']}"
- connection.msg("#{@bot.channel}", "Meme: #{url}")
- }
- end
- end
-end
@@ -1,3 +0,0 @@
-class Meme
- VERSION = "0.0.1"
-end
@@ -1,43 +0,0 @@
-require File.expand_path("../../../muzang/spec/spec_helper", __FILE__)
-require 'muzang-meme'
-
-describe "Meme" do
- before do
- @bot = stub(:channel => "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("../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
@@ -1,3 +0,0 @@
-class Motd
- VERSION = "0.0.1"
-end
@@ -1,18 +0,0 @@
-require File.expand_path("../../../muzang/spec/spec_helper", __FILE__)
-require 'muzang-motd'
-
-describe "Motd" do
- before do
- @message = OpenStruct.new({ :command => :join, :channel => "#test", :nick => "DRUG-bot" })
- @bot = stub
- @motd = Motd.new(@bot)
- @bot.stub(:plugins => { Motd => @motd })
- @connection = stub(:msg => true, :nick => "DRUG-bot")
- end
-
- it "should send message after join to channel" do
- @connection.should_receive(:msg).with("#test", "DRUG-bot | Version: #{Muzang::VERSION} | Plugins: *Motd* ")
- @motd.call(@connection, @message)
- end
-end
-
@@ -1,3 +0,0 @@
-class NerdPursuit
- VERSION = "0.0.1"
-end
@@ -1,76 +0,0 @@
-require File.expand_path("../../../muzang/spec/spec_helper", __FILE__)
-require 'muzang-nerdpursuit'
-require 'json'
-
-class NerdPursuit
- def current_question=(other)
- @current_question=other
- end
-
- def period(time)
- time / 1000.0
- end
-end
-
-describe "NerdPursuit" do
- before(:each) do
- @bot = stub
- @nerdpursuit = NerdPursuit.new(@bot)
- @connection = ConnectionMock.new
- @cq = JSON.parse(File.open("#{File.expand_path("../../lib/muzang-nerdpursuit/questions/ruby/matz.json", __FILE__)}").read)["question"]
- @nerdpursuit.current_question = @cq
- @message = OpenStruct.new({ :channel => "#test", :message => "!quiz", :nick => "LTe" })
- end
-
- it "should start quiz after !quiz message" do
- @nerdpursuit.call(@connection, @message)
- @nerdpursuit.quiz_time.should == true
- end
-
- it "should parse question and start quiz sequence" do
- EM.run do
- @nerdpursuit.call(@connection, @message)
- eventually(true) do
- @connection.messages.include? "Quiz time!" and
- @connection.messages.include? "Category: ruby" and
- @connection.messages.include? "Question: When Matz joined Heruku?" and
- @connection.messages.include? "Answer 1: 12th June 2008" and
- @connection.messages.include? "Answer 2: 12th July 2011" and
- @connection.messages.include? "Answer 3: 12th June 2011" and
- @connection.messages.include? "Answer 4: 12th June 2010"
- end
- end
- end
-
- it "should find winner" do
- EM.run do
- @message_lte = @message.dup
- @message_lte.message = "3"
- @nerdpursuit.call(@connection, @message)
- @nerdpursuit.call(@connection, @message_lte)
-
- eventually(true) do
- @connection.messages.include? "The winner is... LTe" and
- @connection.messages.include? "Right answer: 3"
- end
- end
- end
-
- it "should not allow for many answers" do
- EM.run do
- @nerdpursuit.call(@connection, @message)
- [1,2,3,4].each do |answer|
- @message.message = answer.to_s
- @nerdpursuit.call(@connection, @message)
- end
- @message.message = "3"; @message.nick = "PawelPacana"
- @nerdpursuit.call(@connection, @message)
-
- eventually(true) do
- @connection.messages.include? "Right answer: 3" and
- @connection.messages.include? "The winner is... PawelPacana" and
- !@connection.messages.include? "The winner is... LTe"
- end
- end
- end
-end
@@ -1,5 +1,5 @@
module Muzang
module Plugins
- VERSION = "0.0.1"
+ VERSION = "1.0.0"
end
end
@@ -1,3 +0,0 @@
-class Plusone
- VERSION = "0.0.1"
-end
@@ -1,67 +0,0 @@
-require File.expand_path("../../../muzang/spec/spec_helper", __FILE__)
-require 'muzang-plusone'
-
-describe "PlusOne" do
- before(:each) do
- @bot = stub
- @plusone = PlusOne.new(@bot)
- @plusone.stats = { "LTe" => 1, "ruby" => 1 }
- @connection = stub(:msg => true)
- @message = OpenStruct.new({ :channel => "#test", :message => "LTe: +1 for great irc bot", :nick => "LTe"})
- end
-
- it "should not add plus one for myself" do
- @connection.should_receive(:msg).with("#test", "LTe pisze w PHP")
- @plusone.call(@connection, @message)
- @plusone.stats["LTe"].should == 1
- end
-
- it "should not allow to add plus one for new user" do
- @message.nick = "new_user"
- @connection.should_receive(:msg).with("#test", "new_user pisze w PHP")
- @plusone.call(@connection, @message)
- @plusone.stats["LTe"].should == 1
- end
-
- it "should print stats" do
- @message.message = "!stats"; @message.nick = "LTe"
- @connection.should_receive(:msg).once
- @plusone.call(@connection, @message)
- end
-
- [
- "LTe: +1 for great irc bot",
- "LTe +1 for grat bot",
- "LTe +1"
- ].each do |m|
- it "should react on message #{m}" do
- proper_plus_one(m)
- end
- end
-
- [
- "LTe: +1",
- "LTe: plus (+1) feature is great",
- "I think +1 is great",
- "LTe: great +1"
- ].each do |m|
- it "should not react on message #{m}" do
- invalid_plus_one(m)
- end
- end
-
-end
-
-def invalid_plus_one(message)
- @message = OpenStruct.new({ :channel => "#test", :message => message, :nick => "ruby" })
- @connection.should_not_receive(:msg).with("#test", "ruby podarowal +1 dla *LTe*")
- @plusone.call(@connection, @message)
- @plusone.stats["LTe"].should == 1
-end
-
-def proper_plus_one(message)
- @message = OpenStruct.new({ :channel => "#test", :message => message, :nick => "ruby" })
- @connection.should_receive(:msg).with("#test", "ruby podarowal +1 dla *LTe*")
- @plusone.call(@connection, @message)
- @plusone.stats["LTe"].should == 2
-end
@@ -1,3 +0,0 @@
-class Reddit
- VERSION = "0.0.1"
-end
Oops, something went wrong.

0 comments on commit 8cb1347

Please sign in to comment.