Skip to content

Commit

Permalink
Bump coverage to 100% and fix rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyrjuneja authored and Sunny Juneja committed Mar 3, 2014
1 parent c078980 commit ee36ea9
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 15 deletions.
Empty file added .gemtest
Empty file.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Documentation:
Enabled: false

# Enforce Ruby 1.8-compatible hash syntax
HashSyntax:
EnforcedStyle: hash_rockets
#HashSyntax:
# EnforcedStyle: hash_rockets

# No spaces inside hash literals
SpaceInsideHashLiteralBraces:
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ gem 'yard'

group :test do
gem 'rspec', '>= 2.14'
gem 'rubocop', '>= 0.16', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'rubocop', '>= 0.16', platforms: [:ruby_19, :ruby_20, :ruby_21]
gem 'webmock'
gem 'simplecov', :require => false
gem 'simplecov', require: false
gem 'yardstick'
end

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :test => :spec
task test: :rspec

begin
require 'rubocop/rake_task'
Expand Down Expand Up @@ -33,4 +33,4 @@ Yardstick::Rake::Verify.new do |verify|
verify.threshold = 60.0
end

task :default => [:spec, :rubocop, :verify_measurements]
task default: [:spec, :rubocop, :verify_measurements]
8 changes: 3 additions & 5 deletions lib/open_civic_data.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'open_civic_data/client'

module OpenCivicData
extend self
extend self # rubocop:disable ModuleFunction
attr_accessor :key

def new(key = key)
Expand All @@ -14,8 +14,6 @@ def method_missing(method, *args, &block)
return super unless new.respond_to?(method)
new.send(method, *args, &block)
end

def respond_to_missing?(method_name, include_private = false)
new.respond_to?(method_name, include_private)
end

def respond_to_missing?(method_name, include_private = false) new.respond_to?(method_name, include_private) end # rubocop:disable SingleLineMethods
end
2 changes: 1 addition & 1 deletion lib/open_civic_data/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Connection
ENDPOINT = 'http://api.opencivicdata.org'.freeze

private

def connection
@connection ||= create_connection
end
Expand All @@ -24,4 +25,3 @@ def middlewares
end
end
end

2 changes: 1 addition & 1 deletion lib/open_civic_data/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def get(path, options)
def request(method, path, options)
response = connection.send(method) do |request|
request.params['apikey'] = @key
request.url(path, options)
request.url(path, options)
end
response.body
end
Expand Down
2 changes: 1 addition & 1 deletion spec/helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'simplecov'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter
SimpleCov::Formatter::HTMLFormatter,
]

SimpleCov.start do
Expand Down
2 changes: 1 addition & 1 deletion spec/open_civic_data/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
before do
apikey = 'abcd1234'
@client = OpenCivicData::Client.new(apikey)
@options = { 'apikey' => apikey }
@options = {'apikey' => apikey}
end

describe '#jurisdictions' do
Expand Down
4 changes: 4 additions & 0 deletions spec/open_civic_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
end

describe '.method_missing' do
before do
stub_get('/jurisdictions/', 'apikey' => 'abcd1234').
to_return(status: 200, body: fixture('jurisdictions.json'))
end
it 'delegates to an instance of OpenCivicData::Client' do
client = OpenCivicData.new
expect(client).to receive(:jurisdictions)
Expand Down

0 comments on commit ee36ea9

Please sign in to comment.