hookercookerman-amee 0.2.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.yardoc +0 -0
- data/{LICENSE.txt → LICENSE} +0 -0
- data/Rakefile +41 -24
- data/VERSION +1 -0
- data/amee.gemspec +156 -36
- data/features/step_definitions/amee_steps.rb +5 -5
- data/features/step_definitions/data_steps.rb +5 -5
- data/features/step_definitions/profile_item_steps.rb +5 -5
- data/features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/{D47C465B8157?distance=400&representation=true.json → D47C465B8157?distance=400&representation=full.json} +0 -0
- data/lib/amee/profile_api/profile_item.rb +2 -2
- data/spec/service_spec.rb +5 -5
- metadata +116 -81
- data/History.txt +0 -4
- data/Manifest.txt +0 -82
- data/features/development.feature +0 -13
- data/features/step_definitions/common_steps.rb +0 -194
- data/spec/spec.opts +0 -1
data/.gitignore
ADDED
data/.yardoc
ADDED
Binary file
|
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/Rakefile
CHANGED
@@ -1,32 +1,49 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "amee"
|
8
|
+
gem.summary = %Q{Its a gem to interact with the amee api}
|
9
|
+
gem.description = %Q{Amee}
|
10
|
+
gem.email = "hookercookerman@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/hookercookerman/amee"
|
12
|
+
gem.authors = ["Richard Hooker"]
|
13
|
+
gem.test_files.include "features/**/*"
|
14
|
+
gem.files.exclude "spec/**/*"
|
15
|
+
gem.files.exclude "features/**/*"
|
16
|
+
gem.add_development_dependency "rspec", ">=1.2.6"
|
17
|
+
gem.add_development_dependency "cucumber", ">=0.3.94"
|
18
|
+
gem.add_development_dependency "fakeweb", ">=1.2.5"
|
19
|
+
|
20
|
+
gem.add_dependency('httparty', '>=0.4.3')
|
21
|
+
gem.add_dependency('wycats-moneta', '>=0.5.0')
|
22
|
+
gem.add_dependency('crack', '>=0.1.3')
|
23
|
+
gem.add_dependency('validatable', '>=1.6.7')
|
24
|
+
end
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
21
27
|
end
|
22
28
|
|
23
|
-
require 'newgem/tasks' # load /tasks/*.rake
|
24
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
25
|
-
|
26
29
|
# TODO - want other tests/tasks run by default? Add them to the list
|
27
|
-
|
28
|
-
|
30
|
+
task :default => [:spec, :features]
|
31
|
+
|
32
|
+
require 'spec/rake/spectask'
|
33
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
34
|
+
spec.libs << 'lib' << 'spec'
|
35
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
36
|
+
end
|
37
|
+
|
38
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
39
|
+
spec.libs << 'lib' << 'spec'
|
40
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
41
|
+
spec.rcov = true
|
42
|
+
end
|
29
43
|
|
44
|
+
task :spec => :check_dependencies
|
45
|
+
|
46
|
+
require 'cucumber/rake/task'
|
30
47
|
namespace :features do
|
31
48
|
Cucumber::Rake::Task.new(:all) do |t|
|
32
49
|
t.cucumber_opts = "--format pretty"
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.6.0
|
data/amee.gemspec
CHANGED
@@ -1,54 +1,174 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
7
|
s.name = %q{amee}
|
5
|
-
s.version =
|
6
|
-
|
7
|
-
s.homepage = 'http://github.com/hookercookerman/amee/tree/master'
|
8
|
-
s.description = %q{Its a gem to interact with the amee api}
|
9
|
-
s.summary = %q{Amee}
|
8
|
+
s.version = "0.6.0"
|
10
9
|
|
11
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
11
|
s.authors = ["Richard Hooker"]
|
13
|
-
s.date = %q{2009-
|
14
|
-
|
15
|
-
s.email =
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
s.
|
21
|
-
|
12
|
+
s.date = %q{2009-08-13}
|
13
|
+
s.description = %q{Amee}
|
14
|
+
s.email = %q{hookercookerman@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
".yardoc",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"amee.gemspec",
|
27
|
+
"init.rb",
|
28
|
+
"lib/amee.rb",
|
29
|
+
"lib/amee/config.rb",
|
30
|
+
"lib/amee/data_api/data_category.rb",
|
31
|
+
"lib/amee/data_api/data_item.rb",
|
32
|
+
"lib/amee/data_api/data_item_value.rb",
|
33
|
+
"lib/amee/data_api/drill_down.rb",
|
34
|
+
"lib/amee/data_api/item_definition.rb",
|
35
|
+
"lib/amee/data_api/item_value_definition.rb",
|
36
|
+
"lib/amee/data_api/value_definition.rb",
|
37
|
+
"lib/amee/logging.rb",
|
38
|
+
"lib/amee/model.rb",
|
39
|
+
"lib/amee/parser.rb",
|
40
|
+
"lib/amee/profile_api/profile.rb",
|
41
|
+
"lib/amee/profile_api/profile_category.rb",
|
42
|
+
"lib/amee/profile_api/profile_item.rb",
|
43
|
+
"lib/amee/service.rb",
|
44
|
+
"lib/amee/session.rb",
|
45
|
+
"lib/amee/utils/string.rb",
|
46
|
+
"script/console",
|
47
|
+
"script/destroy",
|
48
|
+
"script/generate",
|
49
|
+
"script/txt2html",
|
50
|
+
"tasks/rspec.rake",
|
51
|
+
"tasks/yard.rake"
|
52
|
+
]
|
53
|
+
s.homepage = %q{http://github.com/hookercookerman/amee}
|
54
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
22
55
|
s.require_paths = ["lib"]
|
23
|
-
s.
|
24
|
-
s.
|
25
|
-
|
56
|
+
s.rubygems_version = %q{1.3.5}
|
57
|
+
s.summary = %q{Its a gem to interact with the amee api}
|
58
|
+
s.test_files = [
|
59
|
+
"spec/amee_spec.rb",
|
60
|
+
"spec/service_spec.rb",
|
61
|
+
"spec/session_spec.rb",
|
62
|
+
"spec/spec_helper.rb",
|
63
|
+
"features/config.feature",
|
64
|
+
"features/data",
|
65
|
+
"features/data/data_category.feature",
|
66
|
+
"features/data/data_item.feature",
|
67
|
+
"features/data/data_item_value.feature",
|
68
|
+
"features/data/drill_down.feature",
|
69
|
+
"features/profile",
|
70
|
+
"features/profile/create.profile.feature",
|
71
|
+
"features/profile/create.profile_item.feature",
|
72
|
+
"features/profile/delete.profile.feature",
|
73
|
+
"features/profile/delete.profile_item.feature",
|
74
|
+
"features/profile/get.profile.feature",
|
75
|
+
"features/profile/profile_category.feature",
|
76
|
+
"features/profile/profile_item.feature",
|
77
|
+
"features/profile/profiles.feature",
|
78
|
+
"features/profile/update.profile_item.feature",
|
79
|
+
"features/session",
|
80
|
+
"features/session/reauthenticate.feature",
|
81
|
+
"features/step_definitions",
|
82
|
+
"features/step_definitions/amee_steps.rb",
|
83
|
+
"features/step_definitions/config_steps.rb",
|
84
|
+
"features/step_definitions/data_steps.rb",
|
85
|
+
"features/step_definitions/profile_category_steps.rb",
|
86
|
+
"features/step_definitions/profile_item_steps.rb",
|
87
|
+
"features/step_definitions/profile_steps.rb",
|
88
|
+
"features/support",
|
89
|
+
"features/support/amee",
|
90
|
+
"features/support/amee/auth",
|
91
|
+
"features/support/amee/auth/response.json",
|
92
|
+
"features/support/amee/data",
|
93
|
+
"features/support/amee/data/transport",
|
94
|
+
"features/support/amee/data/transport/car",
|
95
|
+
"features/support/amee/data/transport/car/generic",
|
96
|
+
"features/support/amee/data/transport/car/generic/drill.json",
|
97
|
+
"features/support/amee/data/transport/car/generic/drill?fuel=diesel&size=large.json",
|
98
|
+
"features/support/amee/data/transport/car/generic/drill?fuel=diesel.json",
|
99
|
+
"features/support/amee/data/transport/car/generic/E57D6E2828EB.json",
|
100
|
+
"features/support/amee/data/transport/car/generic.json",
|
101
|
+
"features/support/amee/data/transport/plane",
|
102
|
+
"features/support/amee/data/transport/plane/generic",
|
103
|
+
"features/support/amee/data/transport/plane/generic/FFC7A05D54AD",
|
104
|
+
"features/support/amee/data/transport/plane/generic/FFC7A05D54AD/kgCO2PerPassengerJourney.json",
|
105
|
+
"features/support/amee/data/transport/plane/generic/FFC7A05D54AD.json",
|
106
|
+
"features/support/amee/data/transport/plane/generic.json",
|
107
|
+
"features/support/amee/data.json",
|
108
|
+
"features/support/amee/data_category.json",
|
109
|
+
"features/support/amee/data_category_with_data_items.json",
|
110
|
+
"features/support/amee/profiles",
|
111
|
+
"features/support/amee/profiles/155DD3C63646",
|
112
|
+
"features/support/amee/profiles/155DD3C63646/transport",
|
113
|
+
"features/support/amee/profiles/155DD3C63646/transport/motorcycle",
|
114
|
+
"features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic",
|
115
|
+
"features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157.json",
|
116
|
+
"features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157?distance=400&representation=full.json",
|
117
|
+
"features/support/amee/profiles/180D73DA5229",
|
118
|
+
"features/support/amee/profiles/180D73DA5229/home.json",
|
119
|
+
"features/support/amee/profiles/48B97680BCCF",
|
120
|
+
"features/support/amee/profiles/48B97680BCCF/home",
|
121
|
+
"features/support/amee/profiles/48B97680BCCF/home/energy",
|
122
|
+
"features/support/amee/profiles/48B97680BCCF/home/energy/quantity",
|
123
|
+
"features/support/amee/profiles/48B97680BCCF/home/energy/quantity/response.json",
|
124
|
+
"features/support/amee/profiles/7C7D68C2A7CD",
|
125
|
+
"features/support/amee/profiles/7C7D68C2A7CD/home.json",
|
126
|
+
"features/support/amee/profiles/BB1BDB4FDD77",
|
127
|
+
"features/support/amee/profiles/BB1BDB4FDD77/home",
|
128
|
+
"features/support/amee/profiles/BB1BDB4FDD77/home/energy",
|
129
|
+
"features/support/amee/profiles/BB1BDB4FDD77/home/energy/quantity",
|
130
|
+
"features/support/amee/profiles/BB1BDB4FDD77/home/energy/quantity/response.json",
|
131
|
+
"features/support/amee/profiles/E0BCB3704D15",
|
132
|
+
"features/support/amee/profiles/E0BCB3704D15/Business.json",
|
133
|
+
"features/support/amee/profiles/E0BCB3704D15.json",
|
134
|
+
"features/support/amee/profiles/F38ECBD56D59",
|
135
|
+
"features/support/amee/profiles/F38ECBD56D59/home",
|
136
|
+
"features/support/amee/profiles/F38ECBD56D59/home/energy",
|
137
|
+
"features/support/amee/profiles/F38ECBD56D59/home/energy/quantity",
|
138
|
+
"features/support/amee/profiles/F38ECBD56D59/home/energy/quantity/5891C88F29FA.json",
|
139
|
+
"features/support/amee/profiles/profile.json",
|
140
|
+
"features/support/amee/profiles.json",
|
141
|
+
"features/support/env.rb"
|
142
|
+
]
|
26
143
|
|
27
144
|
if s.respond_to? :specification_version then
|
28
145
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
29
146
|
s.specification_version = 3
|
30
147
|
|
31
148
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
32
|
-
s.add_development_dependency(%q<
|
33
|
-
s.add_development_dependency(%q<
|
34
|
-
s.add_development_dependency(%q<fakeweb>, [">=
|
35
|
-
s.add_runtime_dependency(%q<httparty>, ["
|
36
|
-
s.add_runtime_dependency(%q<wycats-moneta>, [">= 0"])
|
37
|
-
s.add_runtime_dependency(%q<
|
149
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.6"])
|
150
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.3.94"])
|
151
|
+
s.add_development_dependency(%q<fakeweb>, [">= 1.2.5"])
|
152
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.4.3"])
|
153
|
+
s.add_runtime_dependency(%q<wycats-moneta>, [">= 0.5.0"])
|
154
|
+
s.add_runtime_dependency(%q<crack>, [">= 0.1.3"])
|
155
|
+
s.add_runtime_dependency(%q<validatable>, [">= 1.6.7"])
|
38
156
|
else
|
39
|
-
s.add_dependency(%q<
|
40
|
-
s.add_dependency(%q<
|
41
|
-
s.add_dependency(%q<
|
42
|
-
s.add_dependency(%q<httparty>, ["
|
43
|
-
s.add_dependency(%q<wycats-moneta>, [">= 0"])
|
44
|
-
s.add_dependency(%q<
|
157
|
+
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
158
|
+
s.add_dependency(%q<cucumber>, [">= 0.3.94"])
|
159
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.5"])
|
160
|
+
s.add_dependency(%q<httparty>, [">= 0.4.3"])
|
161
|
+
s.add_dependency(%q<wycats-moneta>, [">= 0.5.0"])
|
162
|
+
s.add_dependency(%q<crack>, [">= 0.1.3"])
|
163
|
+
s.add_dependency(%q<validatable>, [">= 1.6.7"])
|
45
164
|
end
|
46
165
|
else
|
47
|
-
s.add_dependency(%q<
|
48
|
-
s.add_dependency(%q<
|
49
|
-
s.add_dependency(%q<
|
50
|
-
s.add_dependency(%q<
|
51
|
-
s.add_dependency(%q<
|
52
|
-
s.add_dependency(%q<
|
166
|
+
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
167
|
+
s.add_dependency(%q<cucumber>, [">= 0.3.94"])
|
168
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.5"])
|
169
|
+
s.add_dependency(%q<httparty>, [">= 0.4.3"])
|
170
|
+
s.add_dependency(%q<wycats-moneta>, [">= 0.5.0"])
|
171
|
+
s.add_dependency(%q<crack>, [">= 0.1.3"])
|
172
|
+
s.add_dependency(%q<validatable>, [">= 1.6.7"])
|
53
173
|
end
|
54
|
-
end
|
174
|
+
end
|
@@ -9,7 +9,7 @@ end
|
|
9
9
|
# Profiles
|
10
10
|
When(/^I ask the session for: profiles$/) do
|
11
11
|
FakeWeb.register_uri(:get, "http://stage.amee.com/profiles",
|
12
|
-
:
|
12
|
+
:body => "#{File.read(File.join(AMEE_FIXTURE_PATH, "profiles.json"))}"
|
13
13
|
)
|
14
14
|
@models["profiles"] = @amee_session.profiles
|
15
15
|
end
|
@@ -17,7 +17,7 @@ end
|
|
17
17
|
# Profile
|
18
18
|
When(/^I ask the session for: profile with: \"(\S+)\"/) do |param|
|
19
19
|
FakeWeb.register_uri(:get, "http://stage.amee.com/profiles/#{param}",
|
20
|
-
:
|
20
|
+
:body => File.join(AMEE_FIXTURE_PATH, "profiles/#{param}.json")
|
21
21
|
)
|
22
22
|
@models["profile"] = @amee_session.get_profile(param)
|
23
23
|
end
|
@@ -25,7 +25,7 @@ end
|
|
25
25
|
# Profile Category
|
26
26
|
When(/^I ask the session for: get_profile_category with path: \"(\S+)\"$/) do |path|
|
27
27
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
|
28
|
-
:
|
28
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
|
29
29
|
)
|
30
30
|
@models["profile_category"] = @amee_session.get_profile_category(path)
|
31
31
|
end
|
@@ -34,7 +34,7 @@ end
|
|
34
34
|
# Profile Category
|
35
35
|
When(/^I ask the session for: get_profile_item with path: \"(\S+)\"$/) do |path|
|
36
36
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
|
37
|
-
:
|
37
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
|
38
38
|
)
|
39
39
|
@models["profile_item"] = @amee_session.get_profile_item(path)
|
40
40
|
end
|
@@ -57,7 +57,7 @@ end
|
|
57
57
|
Given(/^the session is stale for path: \"(\S+)\"$/) do |path|
|
58
58
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
|
59
59
|
[{:status => ["401", "NOT COOL"]},
|
60
|
-
{:
|
60
|
+
{:body => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")}
|
61
61
|
])
|
62
62
|
end
|
63
63
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# AMEE DATA CATEGORY
|
2
2
|
When(/^I ask the session for: get_data_category with path: \"(.*)\"$/) do |path|
|
3
3
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
|
4
|
-
:
|
4
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
|
5
5
|
)
|
6
6
|
@models["data_category"] = @amee_session.get_data_category(path)
|
7
7
|
end
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
# AMEE DATA ITEM YES COULD REFACTOR
|
34
34
|
When(/^I ask the session for: get_data_item with path: \"(.*)\"$/) do |path|
|
35
35
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
|
36
|
-
:
|
36
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
|
37
37
|
)
|
38
38
|
@models["data_item"] = @amee_session.get_data_item(path)
|
39
39
|
end
|
@@ -71,7 +71,7 @@ end
|
|
71
71
|
# AMEE DATA ITEM YES COULD REFACTOR
|
72
72
|
When(/^I ask the session for: get_data_item_value with path: \"(.*)\"$/) do |path|
|
73
73
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
|
74
|
-
:
|
74
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
|
75
75
|
)
|
76
76
|
@models["data_item_value"] = @amee_session.get_data_item_value(path)
|
77
77
|
end
|
@@ -107,13 +107,13 @@ end
|
|
107
107
|
# DRILL DOWNS
|
108
108
|
Given(/I drill down with params: \"(.*)\"/) do |params|
|
109
109
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{@models["data_category"].full_path}/drill#{params}",
|
110
|
-
:
|
110
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{@models["data_category"].full_path.gsub(/^\//, "")}/drill#{params}.json")
|
111
111
|
)
|
112
112
|
# what a wicked line hmmmm
|
113
113
|
input = params.gsub("?", "").split("&").map{|a| a.split("=")}.flatten
|
114
114
|
selection = Hash[*input.flatten]
|
115
115
|
|
116
|
-
@models["drill_down"] = @models["data_category"].drill(selection)
|
116
|
+
@models["drill_down"] = @models["data_category"].drill(:query => selection)
|
117
117
|
end
|
118
118
|
|
119
119
|
|
@@ -20,16 +20,16 @@ end
|
|
20
20
|
|
21
21
|
When(/^I create a profile item with data_item_uid: \"(\S+)\" the path: \"(.*)\"/) do |uid, path|
|
22
22
|
FakeWeb.register_uri(:post, "http://stage.amee.com#{path}?kWhPerMonth=10&dataItemUid=66056991EE23&representation=full",
|
23
|
-
:
|
23
|
+
:body => File.join(AMEE_FIXTURE_PATH, "/profiles/BB1BDB4FDD77/home/energy/quantity/response.json")
|
24
24
|
)
|
25
25
|
@models["profile_category"] = @amee_session.create_profile_item(path, uid, :representation => true, :query => {:kWhPerMonth => "10"})
|
26
26
|
end
|
27
27
|
|
28
28
|
When(/^I update the profile item with: distance=400$/) do
|
29
|
-
FakeWeb.register_uri(:put, "http://stage.amee.com#{@models["profile_item"].full_path}?distance=400&representation=
|
30
|
-
:
|
29
|
+
FakeWeb.register_uri(:put, "http://stage.amee.com#{@models["profile_item"].full_path}?distance=400&representation=full",
|
30
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{@models["profile_item"].full_path.gsub(/^\//, "")}?distance=400&representation=full.json")
|
31
31
|
)
|
32
|
-
@models["profile_item"].update(:distance => 400)
|
32
|
+
@models["profile_item"].update({:distance => 400}, true)
|
33
33
|
end
|
34
34
|
|
35
35
|
Then(/^the profile item item_value: with name: \"Distance\" should have value: \"400\"$/) do
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
|
39
39
|
Given(/I profile exists with path \"(\S+)\"/) do |path|
|
40
40
|
FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
|
41
|
-
:
|
41
|
+
:body => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
|
42
42
|
)
|
43
43
|
@models["profile_item"] = @amee_session.get_profile_item(path)
|
44
44
|
end
|
File without changes
|
@@ -21,9 +21,9 @@ module Amee
|
|
21
21
|
self.from_hash(hash, session)
|
22
22
|
end
|
23
23
|
|
24
|
-
def update(fields = {})
|
24
|
+
def update(fields = {}, representation = false)
|
25
25
|
session.api_call(:put, "profile_item", self.full_path,
|
26
|
-
:query => fields) do |response|
|
26
|
+
:query => fields.merge(:representation => representation ? "full" : "")) do |response|
|
27
27
|
populate_from_hash!(response)
|
28
28
|
self
|
29
29
|
end
|
data/spec/service_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe "Given FakeRequests Are Setup" do
|
|
5
5
|
before(:each) do
|
6
6
|
|
7
7
|
FakeWeb.register_uri(:get, "http://stage.amee.com/path",
|
8
|
-
{:
|
8
|
+
{:body => "{}", :status => [200, "OK"]})
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "Service", "when performing a request" do
|
@@ -28,25 +28,25 @@ describe "Given FakeRequests Are Setup" do
|
|
28
28
|
|
29
29
|
it "should raise Amee::Session::PermissionDenied if status code is 403" do
|
30
30
|
FakeWeb.register_uri(:get, "http://stage.amee.com/path",
|
31
|
-
{:
|
31
|
+
{:body => "{}", :status => [403, "Permission denied"]})
|
32
32
|
lambda{@service.get("raw", "/path")}.should raise_error(Amee::Session::PermissionDenied )
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should raise Amee::Session::Expired if status code is 401" do
|
36
36
|
FakeWeb.register_uri(:get, "http://stage.amee.com/path",
|
37
|
-
{:
|
37
|
+
{:body => "{}", :status => [401, "Permission denied"]})
|
38
38
|
lambda{@service.get("raw", "/path")}.should raise_error(Amee::Session::Expired )
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should raise Amee::Session::UnknownError if status code is 609" do
|
42
42
|
FakeWeb.register_uri(:get, "http://stage.amee.com/path",
|
43
|
-
{:
|
43
|
+
{:body => "{}", :status => [609, "Permission denied"]})
|
44
44
|
lambda{@service.get("raw", "/path")}.should raise_error(Amee::Session::UnknownError )
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should raise Amee::NotFound::Expired if status code is 404" do
|
48
48
|
FakeWeb.register_uri(:get, "http://stage.amee.com/path",
|
49
|
-
{:
|
49
|
+
{:body => "{}", :status => [404, "Permission denied"]})
|
50
50
|
lambda{@service.get("raw", "/path")}.should raise_error(Amee::Session::NotFound )
|
51
51
|
end
|
52
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hookercookerman-amee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Hooker
|
@@ -9,28 +9,28 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: rspec
|
17
17
|
type: :development
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
23
|
+
version: 1.2.6
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: cucumber
|
27
27
|
type: :development
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.3.94
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: fakeweb
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 1.2.5
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: httparty
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
version_requirement:
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 0.4.3
|
54
54
|
version:
|
@@ -60,84 +60,45 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
63
|
+
version: 0.5.0
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: crack
|
67
|
+
type: :runtime
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.1.3
|
64
74
|
version:
|
65
75
|
- !ruby/object:Gem::Dependency
|
66
|
-
name:
|
76
|
+
name: validatable
|
67
77
|
type: :runtime
|
68
78
|
version_requirement:
|
69
79
|
version_requirements: !ruby/object:Gem::Requirement
|
70
80
|
requirements:
|
71
81
|
- - ">="
|
72
82
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
83
|
+
version: 1.6.7
|
74
84
|
version:
|
75
|
-
description:
|
76
|
-
email:
|
77
|
-
- richard.hooker@dynamic50.com
|
85
|
+
description: Amee
|
86
|
+
email: hookercookerman@gmail.com
|
78
87
|
executables: []
|
79
88
|
|
80
89
|
extensions: []
|
81
90
|
|
82
91
|
extra_rdoc_files:
|
83
|
-
-
|
84
|
-
- LICENSE.txt
|
85
|
-
- Manifest.txt
|
92
|
+
- LICENSE
|
86
93
|
- README.rdoc
|
87
94
|
files:
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
95
|
+
- .gitignore
|
96
|
+
- .yardoc
|
97
|
+
- LICENSE
|
91
98
|
- README.rdoc
|
92
99
|
- Rakefile
|
100
|
+
- VERSION
|
93
101
|
- amee.gemspec
|
94
|
-
- features/config.feature
|
95
|
-
- features/support/amee/profiles/BB1BDB4FDD77/home/energy/quantity/response.json
|
96
|
-
- features/data/data_category.feature
|
97
|
-
- features/data/data_item.feature
|
98
|
-
- features/data/data_item_value.feature
|
99
|
-
- features/data/drill_down.feature
|
100
|
-
- features/development.feature
|
101
|
-
- features/profile/create.profile.feature
|
102
|
-
- features/profile/create.profile_item.feature
|
103
|
-
- features/profile/delete.profile.feature
|
104
|
-
- features/profile/delete.profile_item.feature
|
105
|
-
- features/profile/get.profile.feature
|
106
|
-
- features/profile/profile_category.feature
|
107
|
-
- features/profile/profile_item.feature
|
108
|
-
- features/profile/profiles.feature
|
109
|
-
- features/profile/update.profile_item.feature
|
110
|
-
- features/session/reauthenticate.feature
|
111
|
-
- features/step_definitions/amee_steps.rb
|
112
|
-
- features/step_definitions/common_steps.rb
|
113
|
-
- features/step_definitions/config_steps.rb
|
114
|
-
- features/step_definitions/data_steps.rb
|
115
|
-
- features/step_definitions/profile_category_steps.rb
|
116
|
-
- features/step_definitions/profile_item_steps.rb
|
117
|
-
- features/step_definitions/profile_steps.rb
|
118
|
-
- features/support/amee/auth/response.json
|
119
|
-
- features/support/amee/data.json
|
120
|
-
- features/support/amee/data/transport/car/generic.json
|
121
|
-
- features/support/amee/data/transport/car/generic/E57D6E2828EB.json
|
122
|
-
- features/support/amee/data/transport/car/generic/drill.json
|
123
|
-
- features/support/amee/data/transport/car/generic/drill?fuel=diesel&size=large.json
|
124
|
-
- features/support/amee/data/transport/car/generic/drill?fuel=diesel.json
|
125
|
-
- features/support/amee/data/transport/plane/generic.json
|
126
|
-
- features/support/amee/data/transport/plane/generic/FFC7A05D54AD.json
|
127
|
-
- features/support/amee/data/transport/plane/generic/FFC7A05D54AD/kgCO2PerPassengerJourney.json
|
128
|
-
- features/support/amee/data_category.json
|
129
|
-
- features/support/amee/data_category_with_data_items.json
|
130
|
-
- features/support/amee/profiles.json
|
131
|
-
- features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157.json
|
132
|
-
- features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157?distance=400&representation=true.json
|
133
|
-
- features/support/amee/profiles/180D73DA5229/home.json
|
134
|
-
- features/support/amee/profiles/48B97680BCCF/home/energy/quantity/response.json
|
135
|
-
- features/support/amee/profiles/7C7D68C2A7CD/home.json
|
136
|
-
- features/support/amee/profiles/E0BCB3704D15.json
|
137
|
-
- features/support/amee/profiles/E0BCB3704D15/Business.json
|
138
|
-
- features/support/amee/profiles/F38ECBD56D59/home/energy/quantity/5891C88F29FA.json
|
139
|
-
- features/support/amee/profiles/profile.json
|
140
|
-
- features/support/env.rb
|
141
102
|
- init.rb
|
142
103
|
- lib/amee.rb
|
143
104
|
- lib/amee/config.rb
|
@@ -161,21 +122,13 @@ files:
|
|
161
122
|
- script/destroy
|
162
123
|
- script/generate
|
163
124
|
- script/txt2html
|
164
|
-
- spec/amee_spec.rb
|
165
|
-
- spec/service_spec.rb
|
166
|
-
- spec/session_spec.rb
|
167
|
-
- spec/spec.opts
|
168
|
-
- spec/spec_helper.rb
|
169
125
|
- tasks/rspec.rake
|
170
126
|
- tasks/yard.rake
|
171
|
-
has_rdoc:
|
172
|
-
homepage: http://github.com/hookercookerman/amee
|
127
|
+
has_rdoc: false
|
128
|
+
homepage: http://github.com/hookercookerman/amee
|
173
129
|
licenses:
|
174
130
|
post_install_message:
|
175
131
|
rdoc_options:
|
176
|
-
- --main
|
177
|
-
- README.rdoc
|
178
|
-
- --inline-source
|
179
132
|
- --charset=UTF-8
|
180
133
|
require_paths:
|
181
134
|
- lib
|
@@ -193,10 +146,92 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
146
|
version:
|
194
147
|
requirements: []
|
195
148
|
|
196
|
-
rubyforge_project:
|
149
|
+
rubyforge_project:
|
197
150
|
rubygems_version: 1.3.5
|
198
151
|
signing_key:
|
199
152
|
specification_version: 3
|
200
|
-
summary:
|
201
|
-
test_files:
|
202
|
-
|
153
|
+
summary: Its a gem to interact with the amee api
|
154
|
+
test_files:
|
155
|
+
- spec/amee_spec.rb
|
156
|
+
- spec/service_spec.rb
|
157
|
+
- spec/session_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- features/config.feature
|
160
|
+
- features/data
|
161
|
+
- features/data/data_category.feature
|
162
|
+
- features/data/data_item.feature
|
163
|
+
- features/data/data_item_value.feature
|
164
|
+
- features/data/drill_down.feature
|
165
|
+
- features/profile
|
166
|
+
- features/profile/create.profile.feature
|
167
|
+
- features/profile/create.profile_item.feature
|
168
|
+
- features/profile/delete.profile.feature
|
169
|
+
- features/profile/delete.profile_item.feature
|
170
|
+
- features/profile/get.profile.feature
|
171
|
+
- features/profile/profile_category.feature
|
172
|
+
- features/profile/profile_item.feature
|
173
|
+
- features/profile/profiles.feature
|
174
|
+
- features/profile/update.profile_item.feature
|
175
|
+
- features/session
|
176
|
+
- features/session/reauthenticate.feature
|
177
|
+
- features/step_definitions
|
178
|
+
- features/step_definitions/amee_steps.rb
|
179
|
+
- features/step_definitions/config_steps.rb
|
180
|
+
- features/step_definitions/data_steps.rb
|
181
|
+
- features/step_definitions/profile_category_steps.rb
|
182
|
+
- features/step_definitions/profile_item_steps.rb
|
183
|
+
- features/step_definitions/profile_steps.rb
|
184
|
+
- features/support
|
185
|
+
- features/support/amee
|
186
|
+
- features/support/amee/auth
|
187
|
+
- features/support/amee/auth/response.json
|
188
|
+
- features/support/amee/data
|
189
|
+
- features/support/amee/data/transport
|
190
|
+
- features/support/amee/data/transport/car
|
191
|
+
- features/support/amee/data/transport/car/generic
|
192
|
+
- features/support/amee/data/transport/car/generic/drill.json
|
193
|
+
- features/support/amee/data/transport/car/generic/drill?fuel=diesel&size=large.json
|
194
|
+
- features/support/amee/data/transport/car/generic/drill?fuel=diesel.json
|
195
|
+
- features/support/amee/data/transport/car/generic/E57D6E2828EB.json
|
196
|
+
- features/support/amee/data/transport/car/generic.json
|
197
|
+
- features/support/amee/data/transport/plane
|
198
|
+
- features/support/amee/data/transport/plane/generic
|
199
|
+
- features/support/amee/data/transport/plane/generic/FFC7A05D54AD
|
200
|
+
- features/support/amee/data/transport/plane/generic/FFC7A05D54AD/kgCO2PerPassengerJourney.json
|
201
|
+
- features/support/amee/data/transport/plane/generic/FFC7A05D54AD.json
|
202
|
+
- features/support/amee/data/transport/plane/generic.json
|
203
|
+
- features/support/amee/data.json
|
204
|
+
- features/support/amee/data_category.json
|
205
|
+
- features/support/amee/data_category_with_data_items.json
|
206
|
+
- features/support/amee/profiles
|
207
|
+
- features/support/amee/profiles/155DD3C63646
|
208
|
+
- features/support/amee/profiles/155DD3C63646/transport
|
209
|
+
- features/support/amee/profiles/155DD3C63646/transport/motorcycle
|
210
|
+
- features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic
|
211
|
+
- features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157.json
|
212
|
+
- features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157?distance=400&representation=full.json
|
213
|
+
- features/support/amee/profiles/180D73DA5229
|
214
|
+
- features/support/amee/profiles/180D73DA5229/home.json
|
215
|
+
- features/support/amee/profiles/48B97680BCCF
|
216
|
+
- features/support/amee/profiles/48B97680BCCF/home
|
217
|
+
- features/support/amee/profiles/48B97680BCCF/home/energy
|
218
|
+
- features/support/amee/profiles/48B97680BCCF/home/energy/quantity
|
219
|
+
- features/support/amee/profiles/48B97680BCCF/home/energy/quantity/response.json
|
220
|
+
- features/support/amee/profiles/7C7D68C2A7CD
|
221
|
+
- features/support/amee/profiles/7C7D68C2A7CD/home.json
|
222
|
+
- features/support/amee/profiles/BB1BDB4FDD77
|
223
|
+
- features/support/amee/profiles/BB1BDB4FDD77/home
|
224
|
+
- features/support/amee/profiles/BB1BDB4FDD77/home/energy
|
225
|
+
- features/support/amee/profiles/BB1BDB4FDD77/home/energy/quantity
|
226
|
+
- features/support/amee/profiles/BB1BDB4FDD77/home/energy/quantity/response.json
|
227
|
+
- features/support/amee/profiles/E0BCB3704D15
|
228
|
+
- features/support/amee/profiles/E0BCB3704D15/Business.json
|
229
|
+
- features/support/amee/profiles/E0BCB3704D15.json
|
230
|
+
- features/support/amee/profiles/F38ECBD56D59
|
231
|
+
- features/support/amee/profiles/F38ECBD56D59/home
|
232
|
+
- features/support/amee/profiles/F38ECBD56D59/home/energy
|
233
|
+
- features/support/amee/profiles/F38ECBD56D59/home/energy/quantity
|
234
|
+
- features/support/amee/profiles/F38ECBD56D59/home/energy/quantity/5891C88F29FA.json
|
235
|
+
- features/support/amee/profiles/profile.json
|
236
|
+
- features/support/amee/profiles.json
|
237
|
+
- features/support/env.rb
|
data/History.txt
DELETED
data/Manifest.txt
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
LICENSE.txt
|
3
|
-
Manifest.txt
|
4
|
-
README.rdoc
|
5
|
-
Rakefile
|
6
|
-
features/config.feature
|
7
|
-
features/data/data_category.feature
|
8
|
-
features/data/data_item.feature
|
9
|
-
features/data/data_item_value.feature
|
10
|
-
features/data/drill_down.feature
|
11
|
-
features/development.feature
|
12
|
-
features/profile/create.profile.feature
|
13
|
-
features/profile/create.profile_item.feature
|
14
|
-
features/profile/delete.profile.feature
|
15
|
-
features/profile/delete.profile_item.feature
|
16
|
-
features/profile/get.profile.feature
|
17
|
-
features/profile/profile_category.feature
|
18
|
-
features/profile/profile_item.feature
|
19
|
-
features/profile/profiles.feature
|
20
|
-
features/profile/update.profile_item.feature
|
21
|
-
features/session/reauthenticate.feature
|
22
|
-
features/step_definitions/amee_steps.rb
|
23
|
-
features/step_definitions/common_steps.rb
|
24
|
-
features/step_definitions/config_steps.rb
|
25
|
-
features/step_definitions/data_steps.rb
|
26
|
-
features/step_definitions/profile_category_steps.rb
|
27
|
-
features/step_definitions/profile_item_steps.rb
|
28
|
-
features/step_definitions/profile_steps.rb
|
29
|
-
features/support/amee/auth/response.json
|
30
|
-
features/support/amee/data.json
|
31
|
-
features/support/amee/data/transport/car/generic.json
|
32
|
-
features/support/amee/data/transport/car/generic/E57D6E2828EB.json
|
33
|
-
features/support/amee/data/transport/car/generic/drill.json
|
34
|
-
features/support/amee/data/transport/car/generic/drill?fuel=diesel&size=large.json
|
35
|
-
features/support/amee/data/transport/car/generic/drill?fuel=diesel.json
|
36
|
-
features/support/amee/data/transport/plane/generic.json
|
37
|
-
features/support/amee/data/transport/plane/generic/FFC7A05D54AD.json
|
38
|
-
features/support/amee/data/transport/plane/generic/FFC7A05D54AD/kgCO2PerPassengerJourney.json
|
39
|
-
features/support/amee/data_category.json
|
40
|
-
features/support/amee/data_category_with_data_items.json
|
41
|
-
features/support/amee/profiles.json
|
42
|
-
features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157.json
|
43
|
-
features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157?distance=400&representation=true.json
|
44
|
-
features/support/amee/profiles/180D73DA5229/home.json
|
45
|
-
features/support/amee/profiles/48B97680BCCF/home/energy/quantity/response.json
|
46
|
-
features/support/amee/profiles/7C7D68C2A7CD/home.json
|
47
|
-
features/support/amee/profiles/BB1BDB4FDD77/home/energy/quantity/response.json
|
48
|
-
features/support/amee/profiles/E0BCB3704D15.json
|
49
|
-
features/support/amee/profiles/E0BCB3704D15/Business.json
|
50
|
-
features/support/amee/profiles/F38ECBD56D59/home/energy/quantity/5891C88F29FA.json
|
51
|
-
features/support/amee/profiles/profile.json
|
52
|
-
features/support/env.rb
|
53
|
-
init.rb
|
54
|
-
lib/amee.rb
|
55
|
-
lib/amee/config.rb
|
56
|
-
lib/amee/data_api/data_category.rb
|
57
|
-
lib/amee/data_api/data_item.rb
|
58
|
-
lib/amee/data_api/data_item_value.rb
|
59
|
-
lib/amee/data_api/drill_down.rb
|
60
|
-
lib/amee/data_api/item_definition.rb
|
61
|
-
lib/amee/data_api/item_value_definition.rb
|
62
|
-
lib/amee/data_api/value_definition.rb
|
63
|
-
lib/amee/logging.rb
|
64
|
-
lib/amee/model.rb
|
65
|
-
lib/amee/parser.rb
|
66
|
-
lib/amee/profile_api/profile.rb
|
67
|
-
lib/amee/profile_api/profile_category.rb
|
68
|
-
lib/amee/profile_api/profile_item.rb
|
69
|
-
lib/amee/service.rb
|
70
|
-
lib/amee/session.rb
|
71
|
-
lib/amee/utils/string.rb
|
72
|
-
script/console
|
73
|
-
script/destroy
|
74
|
-
script/generate
|
75
|
-
script/txt2html
|
76
|
-
spec/amee_spec.rb
|
77
|
-
spec/service_spec.rb
|
78
|
-
spec/session_spec.rb
|
79
|
-
spec/spec.opts
|
80
|
-
spec/spec_helper.rb
|
81
|
-
tasks/rspec.rake
|
82
|
-
tasks/yard.rake
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Feature: Development processes of newgem itself (rake tasks)
|
2
|
-
|
3
|
-
As a Newgem maintainer or contributor
|
4
|
-
I want rake tasks to maintain and release the gem
|
5
|
-
So that I can spend time on the tests and code, and not excessive time on maintenance processes
|
6
|
-
|
7
|
-
Scenario: Generate RubyGem
|
8
|
-
Given this project is active project folder
|
9
|
-
And 'pkg' folder is deleted
|
10
|
-
When task 'rake gem' is invoked
|
11
|
-
Then folder 'pkg' is created
|
12
|
-
And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
|
13
|
-
And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
|
@@ -1,194 +0,0 @@
|
|
1
|
-
def in_project_folder(&block)
|
2
|
-
project_folder = @active_project_folder || @tmp_root
|
3
|
-
FileUtils.chdir(project_folder, &block)
|
4
|
-
end
|
5
|
-
|
6
|
-
def in_home_folder(&block)
|
7
|
-
FileUtils.chdir(@home_path, &block)
|
8
|
-
end
|
9
|
-
|
10
|
-
Given %r{^a safe folder} do
|
11
|
-
FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
12
|
-
FileUtils.mkdir_p @tmp_root
|
13
|
-
FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
|
14
|
-
@lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
15
|
-
Given "env variable $HOME set to '#{@home_path}'"
|
16
|
-
end
|
17
|
-
|
18
|
-
Given %r{^this project is active project folder} do
|
19
|
-
Given "a safe folder"
|
20
|
-
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
21
|
-
end
|
22
|
-
|
23
|
-
Given %r{^env variable \$([\w_]+) set to '(.*)'} do |env_var, value|
|
24
|
-
ENV[env_var] = value
|
25
|
-
end
|
26
|
-
|
27
|
-
def force_local_lib_override(project_name = @project_name)
|
28
|
-
rakefile = File.read(File.join(project_name, 'Rakefile'))
|
29
|
-
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
30
|
-
f << "$:.unshift('#{@lib_path}')\n"
|
31
|
-
f << rakefile
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def setup_active_project_folder project_name
|
36
|
-
@active_project_folder = File.join(@tmp_root, project_name)
|
37
|
-
@project_name = project_name
|
38
|
-
end
|
39
|
-
|
40
|
-
Given %r{'(.*)' folder is deleted} do |folder|
|
41
|
-
in_project_folder do
|
42
|
-
FileUtils.rm_rf folder
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
|
47
|
-
@stdout = StringIO.new
|
48
|
-
FileUtils.chdir(@active_project_folder) do
|
49
|
-
if Object.const_defined?("APP_ROOT")
|
50
|
-
APP_ROOT.replace(FileUtils.pwd)
|
51
|
-
else
|
52
|
-
APP_ROOT = FileUtils.pwd
|
53
|
-
end
|
54
|
-
run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
|
55
|
-
end
|
56
|
-
File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
|
57
|
-
@stdout.rewind
|
58
|
-
f << @stdout.read
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
When %r{run executable '(.*)' with arguments '(.*)'} do |executable, arguments|
|
63
|
-
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
64
|
-
in_project_folder do
|
65
|
-
system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
When %r{run project executable '(.*)' with arguments '(.*)'} do |executable, arguments|
|
70
|
-
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
71
|
-
in_project_folder do
|
72
|
-
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
When %r{run local executable '(.*)' with arguments '(.*)'} do |executable, arguments|
|
77
|
-
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
78
|
-
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
79
|
-
in_project_folder do
|
80
|
-
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
When %r{^task 'rake (.*)' is invoked$} do |task|
|
85
|
-
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
86
|
-
FileUtils.chdir(@active_project_folder) do
|
87
|
-
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
Then %r{^folder '(.*)' (is|is not) created} do |folder, is|
|
92
|
-
in_project_folder do
|
93
|
-
File.exists?(folder).should(is == 'is' ? be_true : be_false)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
Then %r{^file '(.*)' (is|is not) created} do |file, is|
|
98
|
-
in_project_folder do
|
99
|
-
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
Then %r{^file with name matching '(.*)' is created} do |pattern|
|
104
|
-
in_project_folder do
|
105
|
-
Dir[pattern].should_not be_empty
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file|
|
110
|
-
File.exists?(gem_file).should be_true
|
111
|
-
File.exists?(project_file).should be_true
|
112
|
-
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
113
|
-
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
114
|
-
project_file_contents.should == gem_file_contents
|
115
|
-
end
|
116
|
-
|
117
|
-
Then %r{^output same as contents of '(.*)'$} do |file|
|
118
|
-
expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
|
119
|
-
actual_output = File.read(@stdout)
|
120
|
-
actual_output.should == expected_output
|
121
|
-
end
|
122
|
-
|
123
|
-
Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
|
124
|
-
actual_output = File.read(@stdout)
|
125
|
-
does_invoke == "does" ?
|
126
|
-
actual_output.should(match(/dependency\s+#{generator}/)) :
|
127
|
-
actual_output.should_not(match(/dependency\s+#{generator}/))
|
128
|
-
end
|
129
|
-
|
130
|
-
Then %r{help options '(.*)' and '(.*)' are displayed} do |opt1, opt2|
|
131
|
-
actual_output = File.read(@stdout)
|
132
|
-
actual_output.should match(/#{opt1}/)
|
133
|
-
actual_output.should match(/#{opt2}/)
|
134
|
-
end
|
135
|
-
|
136
|
-
Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
|
137
|
-
actual_output = File.read(@stdout)
|
138
|
-
(does == 'does') ?
|
139
|
-
actual_output.should(match(/#{regex}/)) :
|
140
|
-
actual_output.should_not(match(/#{regex}/))
|
141
|
-
end
|
142
|
-
|
143
|
-
Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
|
144
|
-
in_project_folder do
|
145
|
-
actual_output = File.read(file)
|
146
|
-
(does == 'does') ?
|
147
|
-
actual_output.should(match(/#{regex}/)) :
|
148
|
-
actual_output.should_not(match(/#{regex}/))
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
Then %r{^all (\d+) tests pass} do |expected_test_count|
|
153
|
-
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
154
|
-
actual_output = File.read(@stdout)
|
155
|
-
actual_output.should match(expected)
|
156
|
-
end
|
157
|
-
|
158
|
-
Then %r{^all (\d+) examples pass} do |expected_test_count|
|
159
|
-
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
160
|
-
actual_output = File.read(@stdout)
|
161
|
-
actual_output.should match(expected)
|
162
|
-
end
|
163
|
-
|
164
|
-
Then %r{^yaml file '(.*)' contains (\{.*\})} do |file, yaml|
|
165
|
-
in_project_folder do
|
166
|
-
yaml = eval yaml
|
167
|
-
YAML.load(File.read(file)).should == yaml
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
Then %r{^Rakefile can display tasks successfully} do
|
172
|
-
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
173
|
-
FileUtils.chdir(@active_project_folder) do
|
174
|
-
system "rake -T > #{@stdout} 2> #{@stdout}"
|
175
|
-
end
|
176
|
-
actual_output = File.read(@stdout)
|
177
|
-
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
178
|
-
end
|
179
|
-
|
180
|
-
Then %r{^task 'rake (.*)' is executed successfully} do |task|
|
181
|
-
@stdout.should_not be_nil
|
182
|
-
actual_output = File.read(@stdout)
|
183
|
-
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
184
|
-
actual_output.should_not match(/Error/i)
|
185
|
-
end
|
186
|
-
|
187
|
-
Then %r{^gem spec key '(.*)' contains \/(.*)\/} do |key, regex|
|
188
|
-
in_project_folder do
|
189
|
-
gem_file = Dir["pkg/*.gem"].first
|
190
|
-
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
191
|
-
spec_value = gem_spec.send(key.to_sym)
|
192
|
-
spec_value.to_s.should match(/#{regex}/)
|
193
|
-
end
|
194
|
-
end
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour
|