spec/paymill_spec.rb in paymill-0.2.0 vs spec/paymill_spec.rb in paymill-0.2.1
- old
+ new
@@ -5,7 +5,24 @@
context "given no api key exists" do
it "raises an authentication error" do
expect { Paymill.request(:get, "clients", {}) }.to raise_error(Paymill::AuthenticationError)
end
end
+
+ context "with an invalid api key" do
+ before(:each) do
+ WebMock.stub_request(:any, /#{Paymill::API_BASE}/).to_return(:body => "{}")
+ Paymill.api_key = "your-api-key"
+ end
+
+ it "attempts to get a url with one param" do
+ Paymill.request(:get, "transactions", { param_name: "param_value" })
+ WebMock.should have_requested(:get, "https://#{Paymill::api_key}:@#{Paymill::API_BASE}/#{Paymill::API_VERSION}/transactions?param_name=param_value")
+ end
+
+ it "attempts to get a url with more than one param" do
+ Paymill.request(:get, "transactions", { client: "client_id", order: "created_at_desc" })
+ WebMock.should have_requested(:get, "https://#{Paymill::api_key}:@#{Paymill::API_BASE}/#{Paymill::API_VERSION}/transactions?client=client_id&order=created_at_desc")
+ end
+ end
end
-end
\ No newline at end of file
+end