Skip to content

Commit

Permalink
Increase code coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jan 6, 2014
1 parent 008c1e8 commit c283eb8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -30,7 +30,7 @@ end

require 'yardstick/rake/verify'
Yardstick::Rake::Verify.new do |verify|
verify.threshold = 61.5
verify.threshold = 60.0
end

task :default => [:spec, :rubocop, :verify_measurements]
13 changes: 8 additions & 5 deletions lib/congress.rb
Expand Up @@ -11,8 +11,9 @@ def configure
# Alias for Congress::Client.new
#
# @return [Congress::Client]
def new
Congress::Client.new
def new(key = key)
return @client if instance_variable_defined?(:@client) && @client.key == key
@client = Congress::Client.new(key)
end

# Delegate to Congress::Client
Expand All @@ -21,7 +22,9 @@ def method_missing(method, *args, &block)
new.send(method, *args, &block)
end

def respond_to?(method, include_private = false)
new.respond_to?(method, include_private) || super(method, include_private)
end
# @return [Boolean]
def respond_to?(method, include_private = false) new.respond_to?(method, include_private) end if RUBY_VERSION < '1.9' # rubocop:disable SingleLineMethods

# @return [Boolean]
def respond_to_missing?(method_name, include_private = false) new.respond_to?(method_name, include_private) end if RUBY_VERSION >= '1.9' # rubocop:disable SingleLineMethods
end
5 changes: 5 additions & 0 deletions lib/congress/client.rb
Expand Up @@ -5,6 +5,11 @@ module Congress
class Client
include Connection
include Request
attr_reader :key

def initialize(key)
@key = key
end

# Current legislators' names, IDs, biography, and social media.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/congress/request.rb
Expand Up @@ -8,7 +8,7 @@ def get(path, options = {})

def request(method, path, options)
response = connection.send(method) do |request|
request.headers[:'X-APIKEY'] = Congress.key
request.headers[:'X-APIKEY'] = key
request.url(path, options)
end
response.body
Expand Down
5 changes: 1 addition & 4 deletions spec/congress/client_spec.rb
Expand Up @@ -2,10 +2,7 @@

describe Congress::Client do
before do
@client = Congress::Client.new
Congress.configure do |config|
config.key = 'abc123'
end
@client = Congress::Client.new('abc123')
end

describe '#legislators' do
Expand Down
13 changes: 13 additions & 0 deletions spec/congress_spec.rb
Expand Up @@ -15,4 +15,17 @@
expect(Congress.key).to eq('abc123')
end
end

describe '.method_missing' do
before do
stub_get('/legislators').
to_return(:status => 200, :body => fixture('legislators.json'))
end
it 'delegates to an instance of Congress::Client' do
Congress.key = 'abc123'
client = Congress.new
expect(client).to receive(:legislators)
Congress.legislators
end
end
end
2 changes: 1 addition & 1 deletion spec/helper.rb
Expand Up @@ -8,7 +8,7 @@

SimpleCov.start do
add_filter '/spec/'
minimum_coverage(95.83)
minimum_coverage(100)
end

require 'congress'
Expand Down

0 comments on commit c283eb8

Please sign in to comment.