spec/whm/server_spec.rb in lumberg-1.0.1 vs spec/whm/server_spec.rb in lumberg-1.0.3

- old
+ new

@@ -84,29 +84,26 @@ it "calls the proper URL" do JSON.should_receive(:parse).with("[]").and_return([]) @whm.perform_request('my_function') @whm.function.should == 'my_function' @whm.params.should be_empty - @whm.raw_response.should be_a(Net::HTTPOK) end it "calls the proper URL and arguments" do JSON.should_receive(:parse).with("[]").and_return([]) @whm.perform_request('my_function', :arg1 => 1, :arg2 => 'test') @whm.function.should == 'my_function' - @whm.params.should == "arg1=1&arg2=test" - @whm.raw_response.should be_a(Net::HTTPOK) + @whm.params.should == {:arg1 => 1, :arg2 => 'test'} end it "changes params to booleans when given a block" do req = @whm.perform_request('my_function', :block => 1) do |p| p.boolean_params = :true, :false end - - @whm.boolean_params.should include(:true, :false) req[:params].should include(:true => true, :false => false, :other => 2) end + end end describe "@ssl_verify" do it "does not verify SSL certs for HTTP requests by default" do @@ -133,79 +130,10 @@ @whm.function.should == 'applist' end end end - describe "#response_type" do - - use_vcr_cassette "whm/server/response_type" - - it "detects an action function" do - @whm.perform_request('testing') - @whm.send(:response_type).should == :action - end - - it "detects an error function" do - @whm.perform_request('testing_error') - @whm.send(:response_type).should == :error - end - - it "detects a query function" do - @whm.perform_request('testing_query') - @whm.send(:response_type).should == :query - end - - it "detects an unknown function" do - @whm.perform_request('testing_unknown') - @whm.send(:response_type).should == :unknown - end - - it "forces response type" do - @whm.force_response_type = :magic - @whm.send(:response_type).should == :magic - @whm.perform_request('testing') - end - - it "resets response_type each request" do - @whm.force_response_type.should be_nil - @whm.force_response_type = :magic - @whm.send(:response_type).should == :magic - - @whm.force_response_type = :magic - @whm.perform_request('testing') - @whm.force_response_type.should be_nil - end - - - it "returns true for a successful :action" do - @whm.perform_request('testing') - response = @whm.send(:format_response) - response[:success].should be(true) - end - - it "returns true for a successful :query" do - @whm.perform_request('testing_query') - response = @whm.send(:format_response) - response[:success].should be(true) - response[:params].should have_key(:acct) - end - - it "returns false on :error" do - @whm.perform_request('testing_error') - response = @whm.send(:format_response) - response[:success].should be(false) - response[:message].should match(/Unknown App Req/) - end - - it "returns false on :unknown" do - @whm.perform_request('testing_unknown') - response = @whm.send(:format_response) - response[:success].should be(false) - response[:message].should match(/Unknown error occurred .*wtf.*/) - end - end - describe "#gethostname" do use_vcr_cassette "whm/server/gethostname" it "returns the hostname" do result = @whm.get_hostname @@ -289,41 +217,9 @@ @whm.account end it "raises to super" do expect { @whm.asdf }.to raise_error(NoMethodError) - end - end - - describe "#prepare_request" do - context "when @basic_auth is true" do - before do - @whm.basic_auth = true - @req = @whm.instance_eval { - prepare_request(URI.parse("http://example.com/")) - } - end - - it "sets Authorization header to 'Basic {base64text}'" do - test_auth = Base64.encode64("#{@whm.user}:#{@whm.hash}") - auth = @req['Authorization'] - auth.should_not be_nil - auth.should == "Basic #{test_auth}" - end - end - - context "when @basic_auth is false" do - before do - @req = @whm.instance_eval { - prepare_request(URI.parse("http://example.com/")) - } - end - it "sets Authorization header to 'WHM user:hash'" do - test_auth = "#{@whm.user}:#{@whm.hash}" - auth = @req['Authorization'] - auth.should_not be_nil - auth.should == "WHM #{test_auth}" - end end end describe "#list_ips" do use_vcr_cassette "whm/server/listips"