spec/payment_spec.rb in slidepay-0.0.2 vs spec/payment_spec.rb in slidepay-0.0.4
- old
+ new
@@ -1,9 +1,19 @@
require "slidepay"
require "spec_helper"
describe SlidePay::Payment do
+ describe "class constants" do
+ it "should include an id_attribute" do
+ expect(SlidePay::Payment::ID_ATTRIBUTE).to eq("payment_id")
+ end
+
+ it "should include a root url" do
+ expect(SlidePay::Payment::URL_ROOT).to eq("payment")
+ end
+ end
+
it "should have an id_attribute" do
p = SlidePay::Payment.new()
expect(p.id_attribute).to eq("payment_id")
end
@@ -83,8 +93,57 @@
it "should return true for successful refund" do
SlidePay.stub(:post) { a_response_object(successful_object_response) }
p = SlidePay::Payment.new()
expect(p.refund()).to eq(true)
+ end
+ end
+
+ describe "class methods" do
+ describe "search" do
+ it "should be represented by several instance methods" do
+ public_methods = SlidePay::Payment.public_methods
+
+ expect(public_methods.include?(:find_where)).to be_true
+ expect(public_methods.include?(:find_greater_than)).to be_true
+ expect(public_methods.include?(:find_less_than)).to be_true
+ expect(public_methods.include?(:find_between)).to be_true
+ end
+
+ describe "find_where" do
+ it "should make a put request to /payment" do
+ SlidePay.should_receive(:put)
+ .with(path: "payment", data: payment_where_sfa.to_json, token: nil, api_key: nil, endpoint: nil)
+ .and_return(a_response_object(payment_search_response))
+ SlidePay::Payment.find_where(created: "12/13/2013")
+ end
+ end
+
+ describe "find_less_than" do
+ it "should make a put request to /payment" do
+ SlidePay.should_receive(:put)
+ .with(path: "payment", data: payment_less_than_sfa.to_json, token: nil, api_key: nil, endpoint: nil)
+ .and_return(a_response_object(payment_search_response))
+ SlidePay::Payment.find_less_than(created: "10/08/2012")
+ end
+ end
+
+ describe "find_greater_than" do
+ it "should make a put request to /payment" do
+ SlidePay.should_receive(:put)
+ .with(path: "payment", data: payment_greater_than_sfa.to_json, token: nil, api_key: nil, endpoint: nil)
+ .and_return(a_response_object(payment_search_response))
+ SlidePay::Payment.find_greater_than(created: "10/08/2013 23:28:40")
+ end
+ end
+
+ describe "find_between" do
+ it "should make a put request to /payment" do
+ SlidePay.should_receive(:put)
+ .with(path: "payment", data: payment_between_sfa.to_json, token: nil, api_key: nil, endpoint: nil)
+ .and_return(a_response_object(payment_search_response))
+ SlidePay::Payment.find_between({:created => "10/08/2013 23:28"}, {:created => "10/08/2013 23:28:40"})
+ end
+ end
end
end
end
\ No newline at end of file