Created
November 21, 2011 03:03
-
-
Save medwards/1381493 to your computer and use it in GitHub Desktop.
how to pass tests yick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Might be bad bc I removed some other junk in the diff | |
diff --git a/lib/play.rb b/lib/play.rb | |
index e8e7ceb..7ddc757 100644 | |
--- a/lib/play.rb | |
+++ b/lib/play.rb | |
@@ -76,14 +76,16 @@ module Play | |
# Returns the Client subclass that matches the client requested | |
# in the config subclass. | |
def self.client | |
+ if not :test | |
+ client_name = config['client'] | |
+ else | |
+ client_name = 'test' | |
+ end | |
+ client_class = client_name.capitalize + 'Client' | |
require 'play/' + client_class.downcase | |
return Play.const_get(client_class) | |
rescue NameError | |
raise NotImplementedError, | |
"\"#{config['client']}\" is not a supported music client type." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
diff --git a/test/api_test.rb b/test/api_test.rb
index 4ace513..ad76383 100644
--- a/test/api_test.rb
+++ b/test/api_test.rb
@@ -1,4 +1,5 @@
require 'helper'
+require 'play/testclient'
include Rack::Test::Methods
def app
@@ -27,7 +28,7 @@ context "Api" do
end
test "/api/say" do
get "/api/say", { :message => "Holman is sexy" }
resp = parse_json(last_response.body.strip)
assert_equal "Okay.", resp[:success]
@@ -134,28 +135,28 @@ context "Api" do
end
test "/api/volume" do
post "/api/volume", {:level => 3}
resp = parse_json(last_response.body.strip)
assert_equal 'true', resp[:success]
end
test "/api/volume with a float" do
post "/api/volume", {:level => '2.5'}
resp = parse_json(last_response.body.strip)
assert_equal 'true', resp[:success]
end
test "/api/pause" do
post "/api/pause"
resp = parse_json(last_response.body.strip)
assert_equal 'true', resp[:success]
end
test "/api/next" do
post "/api/next"
resp = parse_json(last_response.body.strip)
assert_equal 'true', resp[:success]