Sha256: 6f4ada413d5589a8fea64dc23e84b404fea8863ea1b6a5a0229d00cf8e4b037a
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
require 'minitest/autorun' require 'coder_wally/api' describe 'api' do describe 'memoize result' do before do @accept_encoding = 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3' @success_fixture = File.dirname(__FILE__) + '/./fixtures/200.json' @success_response = open(File.expand_path(@success_fixture)).read stub_request(:get, 'https://coderwall.com/me.json') .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => @accept_encoding, 'User-Agent' => 'Ruby' }) .to_return(status: 200, body: @success_response, headers: {}) end it 'calls the send_request method only the first time for any given username' do api = CoderWally::API.new api.fetch('me') api.fetch('me') api.response.count.must_equal 1 stub_request(:get, 'https://coderwall.com/foo.json') .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => @accept_encoding, 'User-Agent' => 'Ruby' }) .to_return(status: 200, body: @success_response, headers: {}) api.fetch('foo') api.response.count.must_equal 2 end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
coder_wally-1.0.2 | test/api_test.rb |
coder_wally-1.0.1 | test/api_test.rb |
coder_wally-1.0.0 | test/api_test.rb |
coder_wally-0.1.2 | test/api_test.rb |