Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions lib/fbe/octo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ def with_disable_auto_paginate # rubocop:disable Layout/EmptyLineBetweenDefs
o =
intercepted(o) do |e, m, args, _r|
next unless e == :before
unless client.respond_to?(m)
kind = options.testing.nil? ? Octokit::Client : Fbe::FakeOctokit
raise(NoMethodError.new("undefined method '#{m}' for an instance of #{kind}", m, args))
end
next if %i[off_quota? print_trace! rate_limit rate_limit!].include?(m)
next if m == :get && %w[/rate_limit rate_limit].include?(args.first)
if Fbe::SEARCH_METHODS.include?(m)
Expand Down
16 changes: 16 additions & 0 deletions test/fbe/test_octo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ def test_fails_user_request_when_off_quota
assert_raises(StandardError) { o.user(42) }
end

def test_raises_no_method_error_for_a_missing_method
WebMock.disable_net_connect!
stub_request(:get, 'https://api.github.com/rate_limit').to_return(
{ body: '{}', headers: { 'X-RateLimit-Remaining' => '4000' } }
)
{
{ 'testing' => true } => 'Fbe::FakeOctokit',
{ 'github_token' => 'fake-token' } => 'Octokit::Client'
}.each do |opts, kind|
o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new(opts))
e = assert_raises(NoMethodError) { o.no_such_method('foo/bar') }
assert_equal(:no_such_method, e.name, "wrong method name in #{e.message.inspect}")
assert_includes(e.message, kind, "the client class is not named in #{e.message.inspect}")
end
end

def test_rate_limit_bang_works_when_off_quota
WebMock.disable_net_connect!
stub_request(:get, 'https://api.github.com/rate_limit').to_return(
Expand Down
Loading