Sfoglia il codice sorgente

Merge pull request #5 from pezholio/initial-tests

Some initial tests
tags/v0.4.5
Adrian Short 6 anni fa
committed by GitHub
parent
commit
93adf1f731
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: 4AEE18F83AFDEB23
6 ha cambiato i file con 69 aggiunte e 3 eliminazioni
  1. +2
    -0
      .rspec
  2. +3
    -0
      lib/uk_planning_scraper.rb
  3. +4
    -3
      lib/uk_planning_scraper/authority.rb
  4. +42
    -0
      spec/authority_spec.rb
  5. +16
    -0
      spec/spec_helper.rb
  6. +2
    -0
      uk_planning_scraper.gemspec

+ 2
- 0
.rspec Vedi File

@@ -0,0 +1,2 @@
--require spec_helper
--format=documentation

+ 3
- 0
lib/uk_planning_scraper.rb Vedi File

@@ -7,4 +7,7 @@ require 'logger'
module UKPlanningScraper
class SystemNotSupportedError < StandardError
end
class AuthorityNotFound < StandardError
end
end

+ 4
- 3
lib/uk_planning_scraper/authority.rb Vedi File

@@ -72,8 +72,9 @@ module UKPlanningScraper
end
def self.named(name)
@@authorities.each { |a| return a if name == a.name }
nil
authority = @@authorities.find { |a| name == a.name }
raise AuthorityNotFound if authority.nil?
authority
end

# Tagged x
@@ -99,7 +100,7 @@ module UKPlanningScraper

def self.load
# Don't run this method more than once
return unless @@authorities.empty?
return unless @@authorities.empty?
# FIXME hardcoded file path
CSV.foreach(File.join(File.dirname(__dir__), 'uk_planning_scraper', 'authorities.csv')) do |line|
@@authorities << Authority.new(


+ 42
- 0
spec/authority_spec.rb Vedi File

@@ -0,0 +1,42 @@
require 'spec_helper'

describe UKPlanningScraper::Authority do
describe '#named' do
let(:authority) { described_class.named(authority_name) }
context 'when authority exists' do
let(:authority_name) { 'Westminster' }
it 'returns an authority' do
expect(authority).to be_a(UKPlanningScraper::Authority)
end
end
context 'when authority does not exist' do
let(:authority_name) { 'Westmonster' }
it 'raises an error' do
expect { authority }.to raise_error(UKPlanningScraper::AuthorityNotFound)
end
end
end
describe '#all' do
let(:all) { described_class.all }
it 'returns all authorities' do
expect(all.count).to eq(48)
end
it 'returns a list of authorities' do
all.each do |authority|
expect(authority).to be_a(UKPlanningScraper::Authority)
end
end
end
end

+ 16
- 0
spec/spec_helper.rb Vedi File

@@ -0,0 +1,16 @@
require 'simplecov'
SimpleCov.start

require 'uk_planning_scraper'

RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
end

+ 2
- 0
uk_planning_scraper.gemspec Vedi File

@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler", "~> 1.15"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.8.0"
spec.add_development_dependency "simplecov", "~> 0.16.1"
spec.add_runtime_dependency "mechanize", "~> 2.7"
spec.add_runtime_dependency "http"


Caricamento…
Annulla
Salva