Sha256: 4c3f5adc57dc46d8dbea1438ff1118c625476569e7150aeb8b510c349b997f5e
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' describe CrystalApi::StoreEndpoint do let(:user) { 'username' } let(:pass) { 'licensekey' } subject { CrystalApi::StoreEndpoint.new(base_url: "https://api.crystalcommerce.com/v1/stores/arux", username: user, license: pass) } it "requests and accepts json" do expect(subject.headers).to include({ "Accept" => "application/json", "Content-Type" => "application/json", }) end describe "#get" do context "/prefs/store", :vcr do it "makes the request to the endpoint" do subject.get("/prefs/store") a_request(:get, "https://#{user}:#{pass}@api.crystalcommerce.com/v1/stores/arux/prefs/store"). should have_been_made end it "parses the returned a store pref" do subject.get("/prefs/store").parsed.should be_a(CrystalApi::StorePrefs) end end context "csv parsing" do before do stub_request(:get, "https://#{user}:#{pass}@api.crystalcommerce.com/v1/stores/arux/reports/1234/download"). to_return(:body => "id,name\n1,Fred", :headers => {:content_type => "text/csv"}) end it "parses the response as a CSV" do response = subject.get("/reports/1234/download") response.parsed.should be_a(CSV::Table) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crystal_api-0.1.0 | spec/crystal_api/store_endpoint_spec.rb |