ns-yapi 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe NSClient do
4
+
5
+ before :each do
6
+ @nsclient = NSClient.new("username", "password")
7
+ end
8
+
9
+ context "Fetching stations from NS" do
10
+
11
+ before :each do
12
+ stub_ns_client_request "http://username:password@webservices.ns.nl/ns-api-stations-v2", load_fixture('ns_stations.xml')
13
+ end
14
+
15
+ it "should return all stations" do
16
+ stations = @nsclient.stations
17
+ stations.size.should == 620
18
+ end
19
+
20
+ it "should return expected first station from list" do
21
+ stations = @nsclient.stations
22
+ first_station = stations.first
23
+ first_station.class.should == NSClient::Station
24
+ first_station.type.should == "knooppuntIntercitystation"
25
+ first_station.code.should == "HT"
26
+ first_station.short_name.should == "H'bosch"
27
+ first_station.name.should == "'s-Hertogenbosch"
28
+ first_station.long_name.should == "'s-Hertogenbosch"
29
+ first_station.land.should == "NL"
30
+ first_station.uiccode.should == "8400319"
31
+ first_station.lat.should == "51.69048"
32
+ first_station.long.should == "5.29362"
33
+ end
34
+
35
+ end
36
+
37
+ def stub_ns_client_request(url, response)
38
+ # headers based on "username", "password"
39
+ stub_request(:get, url).
40
+ with(:headers => {'Authorization' => 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='}).
41
+ to_return(:status => 200, :body => response, :headers => {})
42
+ end
43
+
44
+ end
@@ -0,0 +1,25 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ require 'httpclient'
8
+
9
+ require 'mocha/api'
10
+ require 'webmock/rspec'
11
+
12
+
13
+ spec_helper = Pathname.new(__FILE__).realpath
14
+ lib_path = File.expand_path("../../lib", spec_helper)
15
+ $:.unshift(lib_path)
16
+
17
+ $ROOT = File.expand_path("../", lib_path)
18
+
19
+ Dir.glob(File.join(lib_path, '/**/*.rb')).each do |file|
20
+ require file
21
+ end
22
+
23
+ def load_fixture(filename)
24
+ File.read(File.join($ROOT, "spec/fixtures/#{filename}"))
25
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ns-yapi
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stefan Hendriks
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httpi
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: nori
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: nokogiri
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A Ruby client for the NS (Dutch Railways) API
63
+ email:
64
+ - stefanhen83@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rvmrc
71
+ - .travis.yml
72
+ - Gemfile
73
+ - Gemfile.lock
74
+ - README.md
75
+ - lib/ns_client.rb
76
+ - ns.gemspec
77
+ - rakefile.rb
78
+ - spec/fixtures/ns_stations.xml
79
+ - spec/ns_client_spec.rb
80
+ - spec/spec_helper.rb
81
+ homepage: https://github.com/stefanhendriks/ns-api
82
+ licenses: []
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.24
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: A Ruby client for the NS (Dutch Railways) API
105
+ test_files:
106
+ - spec/fixtures/ns_stations.xml
107
+ - spec/ns_client_spec.rb
108
+ - spec/spec_helper.rb