spec/mousetrap/plan_spec.rb in hashrocket-mousetrap-0.2.1 vs spec/mousetrap/plan_spec.rb in hashrocket-mousetrap-0.3.0
- old
+ new
@@ -14,6 +14,28 @@
# setupChargeCode: TEST_SETUP
# recurringChargeCode: TEST_RECURRING
# billingFrequencyUnit: months
# setupChargeAmount: "0.00"
# billingFrequencyPer: month
+
+ describe ".all" do
+ before do
+ Mousetrap::Plan.stub :build_resources_from
+ end
+
+ it "gets all plans" do
+ Mousetrap::Plan.should_receive(:get_resources).with('plans').and_return('some hash')
+ Mousetrap::Plan.all
+ end
+
+ it "handles no-plans case" do
+ Mousetrap::Plan.stub :get_resources => { 'plans' => nil }
+ Mousetrap::Plan.all.should == []
+ end
+
+ it "builds resources from the response" do
+ Mousetrap::Plan.stub :get_resources => { 'plans' => 'some hash' }
+ Mousetrap::Plan.should_receive(:build_resources_from).with({ 'plans' => 'some hash' })
+ Mousetrap::Plan.all
+ end
+ end
end