carbonculture 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +8 -0
- data/carbonculture.gemspec +28 -0
- data/lib/carbonculture/base_url.rb +3 -0
- data/lib/carbonculture/channel.rb +56 -0
- data/lib/carbonculture/organisation.rb +26 -0
- data/lib/carbonculture/place.rb +32 -0
- data/lib/carbonculture/result.rb +12 -0
- data/lib/carbonculture/version.rb +3 -0
- data/lib/carbonculture.rb +7 -0
- data/spec/fixtures/carbonculture_cassettes/channel.yml +313 -0
- data/spec/fixtures/carbonculture_cassettes/organisation.yml +133 -0
- data/spec/fixtures/carbonculture_cassettes/place.yml +529 -0
- data/spec/lib/carbonculture/base_url_spec.rb +7 -0
- data/spec/lib/carbonculture/channel_spec.rb +75 -0
- data/spec/lib/carbonculture/organisation_spec.rb +59 -0
- data/spec/lib/carbonculture/place_spec.rb +73 -0
- data/spec/lib/carbonculture/result_spec.rb +0 -0
- data/spec/spec_helper.rb +10 -0
- metadata +159 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Carbonculture::Channel do
|
4
|
+
|
5
|
+
before do
|
6
|
+
VCR.insert_cassette 'channel', :record => :new_episodes
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
VCR.eject_cassette
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'initialize class' do
|
14
|
+
|
15
|
+
it 'must contain accept valid Channel' do
|
16
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
17
|
+
channel.data.response.code.must_equal '200'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'must raise an error with an invalid Channel' do
|
21
|
+
proc { Carbonculture::Channel.new('fake', '10-downing-street', 'number10') }.must_raise ArgumentError
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'parses the API response from JSON to a hash' do
|
25
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
26
|
+
channel.data.must_be_instance_of Hash
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'must accept points options' do
|
30
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10', { :points => 12 })
|
31
|
+
channel.results.size.must_equal 12
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'Place association' do
|
36
|
+
|
37
|
+
it 'returns a Place' do
|
38
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
39
|
+
channel.place.must_be_kind_of Carbonculture::Place
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns the correct Place' do
|
43
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
44
|
+
channel.place.name.must_equal '10-downing-street'
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#results' do
|
50
|
+
it 'returns an Array' do
|
51
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
52
|
+
channel.results.must_be_kind_of Array
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
it 'returns an Array of Results' do
|
57
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
58
|
+
channel.results.first.must_be_kind_of Carbonculture::Result
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'dynamic attributes' do
|
63
|
+
|
64
|
+
it 'returns the attribute value if present in the profile' do
|
65
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
66
|
+
channel.status.must_equal 'ok'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'raises a NoMethodError if an attribute is not present' do
|
70
|
+
channel = Carbonculture::Channel.new('elec', '10-downing-street', 'number10')
|
71
|
+
lambda { channel.wrong }.must_raise NoMethodError
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Carbonculture::Organisation do
|
4
|
+
|
5
|
+
before do
|
6
|
+
VCR.insert_cassette 'organisation', :record => :new_episodes
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
VCR.eject_cassette
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'initialize class' do
|
14
|
+
|
15
|
+
it 'must contain accept valid Organisation' do
|
16
|
+
org = Carbonculture::Organisation.new('number10')
|
17
|
+
org.data.response.code.must_equal '200'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'must raise an error with an invalid Organisation' do
|
21
|
+
proc { Carbonculture::Organisation.new('unknown') }.must_raise ArgumentError
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'parses the API response from JSON to a hash' do
|
25
|
+
org = Carbonculture::Organisation.new('number10')
|
26
|
+
org.data.must_be_instance_of Hash
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'dynamic attributes' do
|
32
|
+
|
33
|
+
it 'returns the attribute value if present in the profile' do
|
34
|
+
org = Carbonculture::Organisation.new('number10')
|
35
|
+
org.title.must_equal 'Number 10'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raises a NoMethodError if an attribute is not present' do
|
39
|
+
org = Carbonculture::Organisation.new('number10')
|
40
|
+
lambda { org.wrong }.must_raise NoMethodError
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'Places association' do
|
46
|
+
|
47
|
+
it 'returns an Array' do
|
48
|
+
org = Carbonculture::Organisation.new('number10')
|
49
|
+
org.places.must_be_kind_of Array
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns an Array of Places' do
|
53
|
+
org = Carbonculture::Organisation.new('number10')
|
54
|
+
org.places.first.must_be_kind_of Carbonculture::Place
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Carbonculture::Place do
|
4
|
+
|
5
|
+
before do
|
6
|
+
VCR.insert_cassette 'place', :record => :new_episodes
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
VCR.eject_cassette
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'initialize class' do
|
14
|
+
|
15
|
+
it 'must contain accept valid Place' do
|
16
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
17
|
+
place.data.response.code.must_equal '200'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'must raise an error with an invalid Place' do
|
21
|
+
proc { Carbonculture::Place.new('somewhere', 'unknown') }.must_raise ArgumentError
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'parses the API response from JSON to a hash' do
|
25
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
26
|
+
place.data.must_be_instance_of Hash
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'dynamic attributes' do
|
32
|
+
|
33
|
+
it 'returns the attribute value if present in the profile' do
|
34
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
35
|
+
place.title.must_equal '10 Downing Street'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raises a NoMethodError if an attribute is not present' do
|
39
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
40
|
+
lambda { place.wrong }.must_raise NoMethodError
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'Organisation association' do
|
46
|
+
|
47
|
+
it 'returns an Organisation' do
|
48
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
49
|
+
place.organisation.must_be_kind_of Carbonculture::Organisation
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns the correct Organisation' do
|
53
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
54
|
+
place.organisation.name.must_equal 'number10'
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'Channels association' do
|
60
|
+
|
61
|
+
it 'returns an Array' do
|
62
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
63
|
+
place.channels.must_be_kind_of Array
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns an Array of Places' do
|
67
|
+
place = Carbonculture::Place.new('10-downing-street', 'number10')
|
68
|
+
place.channels.first.must_be_kind_of Carbonculture::Channel
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
File without changes
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carbonculture
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sam Knight
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Ruby library to gather energy data from CarbonCulture
|
98
|
+
email:
|
99
|
+
- sam@samknight.co.uk
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- carbonculture.gemspec
|
110
|
+
- lib/carbonculture.rb
|
111
|
+
- lib/carbonculture/base_url.rb
|
112
|
+
- lib/carbonculture/channel.rb
|
113
|
+
- lib/carbonculture/organisation.rb
|
114
|
+
- lib/carbonculture/place.rb
|
115
|
+
- lib/carbonculture/result.rb
|
116
|
+
- lib/carbonculture/version.rb
|
117
|
+
- spec/fixtures/carbonculture_cassettes/channel.yml
|
118
|
+
- spec/fixtures/carbonculture_cassettes/organisation.yml
|
119
|
+
- spec/fixtures/carbonculture_cassettes/place.yml
|
120
|
+
- spec/lib/carbonculture/base_url_spec.rb
|
121
|
+
- spec/lib/carbonculture/channel_spec.rb
|
122
|
+
- spec/lib/carbonculture/organisation_spec.rb
|
123
|
+
- spec/lib/carbonculture/place_spec.rb
|
124
|
+
- spec/lib/carbonculture/result_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
homepage: ''
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.0.0
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Ruby library to gather energy data from CarbonCulture
|
150
|
+
test_files:
|
151
|
+
- spec/fixtures/carbonculture_cassettes/channel.yml
|
152
|
+
- spec/fixtures/carbonculture_cassettes/organisation.yml
|
153
|
+
- spec/fixtures/carbonculture_cassettes/place.yml
|
154
|
+
- spec/lib/carbonculture/base_url_spec.rb
|
155
|
+
- spec/lib/carbonculture/channel_spec.rb
|
156
|
+
- spec/lib/carbonculture/organisation_spec.rb
|
157
|
+
- spec/lib/carbonculture/place_spec.rb
|
158
|
+
- spec/lib/carbonculture/result_spec.rb
|
159
|
+
- spec/spec_helper.rb
|