Skip to content

Fix broken specs #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bitbucket_rest_api.gemspec
Original file line number Diff line number Diff line change
@@ -30,5 +30,4 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'rake'
gem.add_development_dependency 'bundler'
gem.add_development_dependency 'pry-byebug'
gem.add_development_dependency 'mocha'
end
30 changes: 18 additions & 12 deletions spec/bitbucket_rest_api/request_spec.rb
Original file line number Diff line number Diff line change
@@ -2,27 +2,33 @@
require 'bitbucket_rest_api/request'

describe BitBucket::Request do
let(:fake_api) { (Class.new { include BitBucket::Request })}
let(:faraday_connection) { Faraday.new(:url => 'https://api.bitbucket.org') }
let(:fake_api) do
Class.new do
include BitBucket::Request

def connection(*args)
Faraday.new(:url => 'https://api.bitbucket.org')
end

def new_access_token
"12345"
end
end
end

describe "request" do
it "raises an ArgumentError if an unsupported HTTP verb is used" do
expect { fake_api.new.request(:i_am_a_teapot, {}, '/') }.to raise_error(ArgumentError)
end

context "with a connection" do
before do
(fake_api).any_instance.stubs(:connection).returns(faraday_connection)
(fake_api).any_instance.stubs(:new_access_token).returns("12345")
end

it "supports get" do
stub_request(:get, "https://api.bitbucket.org/1.0/endpoint").
with(:headers => {
'Accept' => '*/*',
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Authorization' => 'Bearer 12345',
'User-Agent' => 'Faraday v0.9.2'
'User-Agent' => "Faraday v#{Faraday::VERSION}"
})

fake_api.new.request(:get, '/1.0/endpoint', {}, {})
@@ -35,7 +41,7 @@
'Accept' => '*/*',
'Content-Type'=>'application/x-www-form-urlencoded',
'Authorization' => 'Bearer 12345',
'User-Agent' => 'Faraday v0.9.2'
'User-Agent' => "Faraday v#{Faraday::VERSION}"
})

fake_api.new.request(:put, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
@@ -48,7 +54,7 @@
'Accept' => '*/*',
'Content-Type'=>'application/x-www-form-urlencoded',
'Authorization' => 'Bearer 12345',
'User-Agent' => 'Faraday v0.9.2'
'User-Agent' => "Faraday v#{Faraday::VERSION}"
})

fake_api.new.request(:patch, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
@@ -59,7 +65,7 @@
with(:headers => {
'Accept' => '*/*',
'Authorization' => 'Bearer 12345',
'User-Agent' => 'Faraday v0.9.2'
'User-Agent' => "Faraday v#{Faraday::VERSION}"
})
fake_api.new.request(:delete, '/1.0/endpoint', {}, {})
end
@@ -71,7 +77,7 @@
'Accept' => '*/*',
'Content-Type'=>'application/x-www-form-urlencoded',
'Authorization' => 'Bearer 12345',
'User-Agent' => 'Faraday v0.9.2'
'User-Agent' => "Faraday v#{Faraday::VERSION}"
})

fake_api.new.request(:post, '/1.0/endpoint', { 'data' => { 'key' => 'value'} }, {})
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
config.mock_with :mocha
end

config.mock_with :rspec do |mocks|