2013-03-19 18:54:55 -04:00
|
|
|
|
# encoding: utf-8
|
2012-12-02 18:55:21 -05:00
|
|
|
|
require 'helper'
|
|
|
|
|
|
2013-05-12 17:25:30 -04:00
|
|
|
|
class TestSidekiq < Minitest::Test
|
2012-12-02 18:55:21 -05:00
|
|
|
|
describe 'json processing' do
|
|
|
|
|
it 'loads json' do
|
|
|
|
|
assert_equal ({"foo" => "bar"}), Sidekiq.load_json("{\"foo\":\"bar\"}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'dumps json' do
|
|
|
|
|
assert_equal "{\"foo\":\"bar\"}", Sidekiq.dump_json({ "foo" => "bar" })
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2013-02-02 05:47:58 -05:00
|
|
|
|
describe "redis connection" do
|
|
|
|
|
it "returns error without creating a connection if block is not given" do
|
2013-05-12 17:25:30 -04:00
|
|
|
|
mock = Minitest::Mock.new
|
2013-02-02 05:47:58 -05:00
|
|
|
|
mock.expect :create, nil #Sidekiq::RedisConnection, create
|
|
|
|
|
assert_raises(ArgumentError) {
|
|
|
|
|
Sidekiq.redis
|
|
|
|
|
}
|
|
|
|
|
assert_raises(MockExpectationError, "create should not be called") do
|
|
|
|
|
mock.verify
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2013-03-19 18:54:55 -04:00
|
|
|
|
describe "❨╯°□°❩╯︵┻━┻" do
|
|
|
|
|
before { $stdout = StringIO.new }
|
|
|
|
|
after { $stdout = STDOUT }
|
|
|
|
|
|
|
|
|
|
it "allows angry developers to express their emotional constitution and remedies it" do
|
|
|
|
|
Sidekiq.❨╯°□°❩╯︵┻━┻
|
|
|
|
|
assert_equal "Calm down, bro\n", $stdout.string
|
|
|
|
|
end
|
|
|
|
|
end
|
2012-12-02 18:55:21 -05:00
|
|
|
|
end
|