hookercookerman-amee 0.0.2

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.
Files changed (80) hide show
  1. data/History.txt +1 -0
  2. data/LICENSE.txt +20 -0
  3. data/Manifest.txt +79 -0
  4. data/README.rdoc +33 -0
  5. data/Rakefile +29 -0
  6. data/features/config.feature +22 -0
  7. data/features/data/data_category.feature +26 -0
  8. data/features/data/data_item.feature +19 -0
  9. data/features/data/data_item_value.feature +17 -0
  10. data/features/data/drill_down.feature +48 -0
  11. data/features/development.feature +13 -0
  12. data/features/profile/create.profile.feature +15 -0
  13. data/features/profile/create.profile_item.feature +12 -0
  14. data/features/profile/delete.profile.feature +12 -0
  15. data/features/profile/delete.profile_item.feature +13 -0
  16. data/features/profile/get.profile.feature +13 -0
  17. data/features/profile/profile_category.feature +14 -0
  18. data/features/profile/profile_item.feature +15 -0
  19. data/features/profile/profiles.feature +15 -0
  20. data/features/profile/update.profile_item.feature +14 -0
  21. data/features/session/reauthenticate.feature +16 -0
  22. data/features/step_definitions/amee_steps.rb +67 -0
  23. data/features/step_definitions/common_steps.rb +194 -0
  24. data/features/step_definitions/config_steps.rb +13 -0
  25. data/features/step_definitions/data_steps.rb +142 -0
  26. data/features/step_definitions/profile_category_steps.rb +23 -0
  27. data/features/step_definitions/profile_item_steps.rb +62 -0
  28. data/features/step_definitions/profile_steps.rb +41 -0
  29. data/features/support/amee/auth/response.json +11 -0
  30. data/features/support/amee/data.json +84 -0
  31. data/features/support/amee/data/transport/car/generic.json +3 -0
  32. data/features/support/amee/data/transport/car/generic/drill.json +66 -0
  33. data/features/support/amee/data/transport/car/generic/drill?fuel=diesel&size=large.json +55 -0
  34. data/features/support/amee/data/transport/car/generic/drill?fuel=diesel.json +59 -0
  35. data/features/support/amee/data/transport/plane/generic.json +225 -0
  36. data/features/support/amee/data/transport/plane/generic/FFC7A05D54AD.json +224 -0
  37. data/features/support/amee/data/transport/plane/generic/FFC7A05D54AD/kgCO2PerPassengerJourney.json +42 -0
  38. data/features/support/amee/data_category.json +84 -0
  39. data/features/support/amee/data_category_with_data_items.json +225 -0
  40. data/features/support/amee/profiles.json +73 -0
  41. data/features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157.json +190 -0
  42. data/features/support/amee/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157?distance=400&representation=true.json +190 -0
  43. data/features/support/amee/profiles/48B97680BCCF/home/energy/quantity/response.json +9 -0
  44. data/features/support/amee/profiles/7C7D68C2A7CD/home.json +65 -0
  45. data/features/support/amee/profiles/BB1BDB4FDD77/home/energy/quantity/920B54ED665B.json +201 -0
  46. data/features/support/amee/profiles/E0BCB3704D15.json +19 -0
  47. data/features/support/amee/profiles/E0BCB3704D15/Business.json +6 -0
  48. data/features/support/amee/profiles/profile.json +27 -0
  49. data/features/support/env.rb +24 -0
  50. data/init.rb +4 -0
  51. data/lib/amee.rb +37 -0
  52. data/lib/amee/config.rb +59 -0
  53. data/lib/amee/data_api/data_category.rb +50 -0
  54. data/lib/amee/data_api/data_item.rb +28 -0
  55. data/lib/amee/data_api/data_item_value.rb +13 -0
  56. data/lib/amee/data_api/drill_down.rb +23 -0
  57. data/lib/amee/data_api/item_definition.rb +11 -0
  58. data/lib/amee/data_api/item_value_definition.rb +13 -0
  59. data/lib/amee/data_api/value_definition.rb +10 -0
  60. data/lib/amee/logging.rb +43 -0
  61. data/lib/amee/model.rb +128 -0
  62. data/lib/amee/parser.rb +137 -0
  63. data/lib/amee/profile_api/profile.rb +39 -0
  64. data/lib/amee/profile_api/profile_category.rb +42 -0
  65. data/lib/amee/profile_api/profile_item.rb +47 -0
  66. data/lib/amee/service.rb +78 -0
  67. data/lib/amee/session.rb +222 -0
  68. data/lib/amee/utils/string.rb +11 -0
  69. data/script/console +10 -0
  70. data/script/destroy +14 -0
  71. data/script/generate +14 -0
  72. data/script/txt2html +71 -0
  73. data/spec/amee_spec.rb +1 -0
  74. data/spec/service_spec.rb +53 -0
  75. data/spec/session_spec.rb +45 -0
  76. data/spec/spec.opts +1 -0
  77. data/spec/spec_helper.rb +19 -0
  78. data/tasks/rspec.rake +21 -0
  79. data/tasks/yard.rake +4 -0
  80. metadata +184 -0
@@ -0,0 +1,14 @@
1
+ Feature: Update Amee Profile Item
2
+ In order to update profile item information which means we can keep
3
+ In order co2 histroy and calcuations and profit big time
4
+ As a amee developer
5
+ I want to be able to update a profile items
6
+
7
+ Scenario: Update Amee profile item with path /profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157
8
+ Given I have a valid amee session
9
+ When I ask the session for: get_profile_item with path: "/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157"
10
+
11
+
12
+ And I update the profile item with: distance=400
13
+
14
+ Then the profile item item_value: with name: "Distance" should have value: "400"
@@ -0,0 +1,16 @@
1
+ Feature: ReAuthenticate the session
2
+ In order to keep make stale session fresh so we dont lose money from broken calculators
3
+ As a amee developer
4
+ I want to keep my session fresh
5
+
6
+ Scenario: Keep session fresh
7
+ Given I have a valid amee session
8
+ And the session is stale for path: "/profiles/E0BCB3704D15"
9
+
10
+ When when I try to get the profile with id: "E0BCB3704D15" the session should be refreshed
11
+ And the amee profile should have: "uid" with: "E0BCB3704D15"
12
+
13
+
14
+
15
+
16
+
@@ -0,0 +1,67 @@
1
+ # AMEE SESSION
2
+ Given(/^I have a valid amee session$/) do
3
+ @models ||= {}
4
+ Amee::Service.stub!(:auth_token).and_return("random auth token")
5
+ @amee_session = Amee::Session.create("datest", "datest")
6
+ end
7
+
8
+
9
+ # Profiles
10
+ When(/^I ask the session for: profiles$/) do
11
+ FakeWeb.register_uri(:get, "http://stage.amee.com/profiles",
12
+ :string => "#{File.read(File.join(AMEE_FIXTURE_PATH, "profiles.json"))}"
13
+ )
14
+ @models["profiles"] = @amee_session.profiles
15
+ end
16
+
17
+ # Profile
18
+ When(/^I ask the session for: profile with: \"(\S+)\"/) do |param|
19
+ FakeWeb.register_uri(:get, "http://stage.amee.com/profiles/#{param}",
20
+ :file => File.join(AMEE_FIXTURE_PATH, "profiles/#{param}.json")
21
+ )
22
+ @models["profile"] = @amee_session.get_profile(param)
23
+ end
24
+
25
+ # Profile Category
26
+ When(/^I ask the session for: get_profile_category with path: \"(\S+)\"$/) do |path|
27
+ FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
28
+ :file => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
29
+ )
30
+ @models["profile_category"] = @amee_session.get_profile_category(path)
31
+ end
32
+
33
+ # PROFILE ITEM
34
+ # Profile Category
35
+ When(/^I ask the session for: get_profile_item with path: \"(\S+)\"$/) do |path|
36
+ FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
37
+ :file => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
38
+ )
39
+ @models["profile_item"] = @amee_session.get_profile_item(path)
40
+ end
41
+
42
+
43
+ Then(/^there should be an amee profile with the uid of \"(\S+)\"$/) do |uid|
44
+ @models["profiles"].map{|profile| profile.uid}.should include(uid)
45
+ end
46
+
47
+ Then(/^each amee profile should have a path, name, created, modified and uid$/) do
48
+ @models["profiles"].each do |profile|
49
+ profile.path.should_not be_nil
50
+ profile.name.should_not be_nil
51
+ profile.uid.should_not be_nil
52
+ profile.created.should_not be_nil
53
+ profile.modified.should_not be_nil
54
+ end
55
+ end
56
+
57
+ Given(/^the session is stale for path: \"(\S+)\"$/) do |path|
58
+ FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
59
+ [{:status => ["401", "NOT COOL"]},
60
+ {:file => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")}
61
+ ])
62
+ end
63
+
64
+ When(/^when I try to get the profile with id: \"(\S+)\" the session should be refreshed/) do |id|
65
+ @amess_sessino.should_receive(:authenticate!)
66
+ @models["profile"] = @amee_session.get_profile(id)
67
+ end
@@ -0,0 +1,194 @@
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
@@ -0,0 +1,13 @@
1
+ When "I do not create a config" do
2
+ # do nothing
3
+ end
4
+
5
+ Then(/^the amee config: \"(\w+)\" should be: \"(.*)\"$/) do |key, value|
6
+ Amee::Config[key.intern].to_s.should == value
7
+ end
8
+
9
+ When(/I set the: \"(\w+)\" on the amee config with: \"(.*)\"$/) do |key, value|
10
+ Amee::Config.set do |config|
11
+ config[key.intern] = value
12
+ end
13
+ end
@@ -0,0 +1,142 @@
1
+ # AMEE DATA CATEGORY
2
+ When(/^I ask the session for: get_data_category with path: \"(.*)\"$/) do |path|
3
+ FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
4
+ :file => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
5
+ )
6
+ @models["data_category"] = @amee_session.get_data_category(path)
7
+ end
8
+
9
+ When(/^I ask the data category for its: \"(\S+)\"$/) do |method|
10
+ @models[method] = @models["data_category"].send(method)
11
+ end
12
+
13
+ Then(/^the data category should have: \"(.*)\" with: \"(.*)\"$/) do |attribute, value|
14
+ @models["data_category"].send(attribute).should == value
15
+ end
16
+
17
+ Then(/^the data category should (?:be|have) (?:an? )?(.*)/) do |predicate|
18
+ @models["data_category"].should send("be_#{predicate.gsub(' ', '_')}")
19
+ end
20
+
21
+ Then(/^the data category should not (?:be|have) (?:an? )?(.*)/) do |predicate|
22
+ @models["data_category"].should_not send("be_#{predicate.gsub(' ', '_')}")
23
+ end
24
+
25
+ Then(/^the data category's (.*) should (?:be|have) (?:an? )?(.*)/) do |method, predicate|
26
+ @models["data_category"].send(method).should send("be_#{predicate.gsub(' ', '_')}")
27
+ end
28
+
29
+ Then(/^the data category's (.*) should not (?:be|have) (?:an? )?(.*)/) do |method, predicate|
30
+ @models["data_category"].send(method).should_not send("be_#{predicate.gsub(' ', '_')}")
31
+ end
32
+
33
+ # AMEE DATA ITEM YES COULD REFACTOR
34
+ When(/^I ask the session for: get_data_item with path: \"(.*)\"$/) do |path|
35
+ FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
36
+ :file => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
37
+ )
38
+ @models["data_item"] = @amee_session.get_data_item(path)
39
+ end
40
+
41
+ When(/^I ask the data item for its: \"(\S+)\"$/) do |method|
42
+ @models[method] = @models["data_item"].send(method)
43
+ end
44
+
45
+ Then(/^the data item should have: \"(.*)\" with: \"(.*)\"$/) do |attribute, value|
46
+ @models["data_item"].send(attribute).should == value
47
+ end
48
+
49
+ Then(/^the data item should (?:be|have) (?:an? )?(.*)/) do |predicate|
50
+ @models["data_item"].should send("be_#{predicate.gsub(' ', '_')}")
51
+ end
52
+
53
+ Then(/^the data item should not (?:be|have) (?:an? )?(.*)/) do |predicate|
54
+ @models["data_item"].should_not send("be_#{predicate.gsub(' ', '_')}")
55
+ end
56
+
57
+ Then(/^the data item's (\S+) should (?:be|have) (?:an? )?(.*)/) do |method, predicate|
58
+ @models["data_item"].send(method).should send("be_#{predicate.gsub(' ', '_')}")
59
+ end
60
+
61
+ Then(/^the data item's (\S+) should not (?:be|have) (?:an? )?(.*)/) do |method, predicate|
62
+ @models["data_item"].send(method).should_not send("be_#{predicate.gsub(' ', '_')}")
63
+ end
64
+
65
+ Then(/^the data item's item_definition: (\S+) should be \"(.*)\"/) do |method ,value|
66
+ @models["data_item"].item_definition.send(method).should == value
67
+ end
68
+
69
+
70
+ # YES COULD REFACTOR DATA ITEM VALUE
71
+ # AMEE DATA ITEM YES COULD REFACTOR
72
+ When(/^I ask the session for: get_data_item_value with path: \"(.*)\"$/) do |path|
73
+ FakeWeb.register_uri(:get, "http://stage.amee.com#{path}",
74
+ :file => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}.json")
75
+ )
76
+ @models["data_item_value"] = @amee_session.get_data_item_value(path)
77
+ end
78
+
79
+ When(/^I ask the data item value for its: \"(\S+)\"$/) do |method|
80
+ @models[method] = @models["data_item_value"].send(method)
81
+ end
82
+
83
+ Then(/^the data item value should have: \"(.*)\" with: \"(.*)\"$/) do |attribute, value|
84
+ @models["data_item_value"].send(attribute).should == value
85
+ end
86
+
87
+ Then(/^the data item value should (?:be|have) (?:an? )?(.*)/) do |predicate|
88
+ @models["data_item_value"].should send("be_#{predicate.gsub(' ', '_')}")
89
+ end
90
+
91
+ Then(/^the data item value should not (?:be|have) (?:an? )?(.*)/) do |predicate|
92
+ @models["data_item_value"].should_not send("be_#{predicate.gsub(' ', '_')}")
93
+ end
94
+
95
+ Then(/^the data item value's (\S+) should (?:be|have) (?:an? )?(.*)/) do |method, predicate|
96
+ @models["data_item_value"].send(method).should send("be_#{predicate.gsub(' ', '_')}")
97
+ end
98
+
99
+ Then(/^the data item value's (\S+) should not (?:be|have) (?:an? )?(.*)/) do |method, predicate|
100
+ @models["data_item_value"].send(method).should_not send("be_#{predicate.gsub(' ', '_')}")
101
+ end
102
+
103
+ Then(/^the data item value's item_value_definition: (\S+) should be \"(.*)\"/) do |method ,value|
104
+ @models["data_item_value"].item_value_definition.send(method).should == value
105
+ end
106
+
107
+ # DRILL DOWNS
108
+ Given(/I drill down with params: \"(.*)\"/) do |params|
109
+ FakeWeb.register_uri(:get, "http://stage.amee.com#{@models["data_category"].full_path}/drill#{params}",
110
+ :file => File.join(AMEE_FIXTURE_PATH, "#{@models["data_category"].full_path.gsub(/^\//, "")}/drill#{params}.json")
111
+ )
112
+ # what a wicked line hmmmm
113
+ input = params.gsub("?", "").split("&").map{|a| a.split("=")}.flatten
114
+ selection = Hash[*input.flatten]
115
+
116
+ @models["drill_down"] = @models["data_category"].drill(selection)
117
+ end
118
+
119
+
120
+ Then(/^the drill down should have: \"(.*)\" with: \"(.*)\"$/) do |attribute, value|
121
+ @models["drill_down"].send(attribute).should == value
122
+ end
123
+
124
+ Then(/^the drill down should (?:be|have) (?:an? )?(.*)/) do |predicate|
125
+ @models["drill_down"].should send("be_#{predicate.gsub(' ', '_')}")
126
+ end
127
+
128
+ Then(/^the drill down should not (?:be|have) (?:an? )?(.*)/) do |predicate|
129
+ @models["drill_down"].should_not send("be_#{predicate.gsub(' ', '_')}")
130
+ end
131
+
132
+ Then(/^the drill down's (\S+) should (?:be|have) (?:an? )?(.*)/) do |method, predicate|
133
+ @models["drill_down"].send(method).should send("be_#{predicate.gsub(' ', '_')}")
134
+ end
135
+
136
+ Then(/^the drill down's (\S+) should not (?:be|have) (?:an? )?(.*)/) do |method, predicate|
137
+ @models["drill_down"].send(method).should_not send("be_#{predicate.gsub(' ', '_')}")
138
+ end
139
+
140
+ Then(/^the drill down data category's should have: \"(\S+)\" with: \"(\S+)\"/) do |method, value|
141
+ @models["drill_down"].data_category.send(method).should == value
142
+ end