sads_xml 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.
Files changed (62) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +8 -0
  3. data/Rakefile +38 -0
  4. data/app/views/layouts/sads_xml.html.erb +9 -0
  5. data/app/views/sads_xml/sads.html.erb +126 -0
  6. data/lib/sads_xml/controller_additions.rb +61 -0
  7. data/lib/sads_xml/sads.rb +166 -0
  8. data/lib/sads_xml/version.rb +3 -0
  9. data/lib/sads_xml.rb +9 -0
  10. data/test/dummy/README.rdoc +261 -0
  11. data/test/dummy/Rakefile +7 -0
  12. data/test/dummy/app/assets/javascripts/application.js +15 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/test/dummy/app/controllers/application_controller.rb +3 -0
  15. data/test/dummy/app/controllers/ussd/default_controller.rb +9 -0
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/helpers/ussd/default_helper.rb +2 -0
  18. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  19. data/test/dummy/config/application.rb +56 -0
  20. data/test/dummy/config/boot.rb +10 -0
  21. data/test/dummy/config/database.yml +25 -0
  22. data/test/dummy/config/environment.rb +5 -0
  23. data/test/dummy/config/environments/development.rb +37 -0
  24. data/test/dummy/config/environments/production.rb +67 -0
  25. data/test/dummy/config/environments/test.rb +37 -0
  26. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  27. data/test/dummy/config/initializers/inflections.rb +15 -0
  28. data/test/dummy/config/initializers/mime_types.rb +5 -0
  29. data/test/dummy/config/initializers/secret_token.rb +7 -0
  30. data/test/dummy/config/initializers/session_store.rb +8 -0
  31. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  32. data/test/dummy/config/locales/en.yml +5 -0
  33. data/test/dummy/config/routes.rb +62 -0
  34. data/test/dummy/config.ru +4 -0
  35. data/test/dummy/db/development.sqlite3 +0 -0
  36. data/test/dummy/db/test.sqlite3 +0 -0
  37. data/test/dummy/log/development.log +337 -0
  38. data/test/dummy/log/test.log +133 -0
  39. data/test/dummy/public/404.html +26 -0
  40. data/test/dummy/public/422.html +26 -0
  41. data/test/dummy/public/500.html +25 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/dummy/script/rails +6 -0
  44. data/test/dummy/test/functional/ussd/default_controller_test.rb +9 -0
  45. data/test/dummy/test/unit/helpers/ussd/default_helper_test.rb +4 -0
  46. data/test/dummy/tmp/cache/assets/CB1/D30/sprockets%2F7b6a97d2209a681f2bebe34655163319 +0 -0
  47. data/test/dummy/tmp/cache/assets/CBF/3F0/sprockets%2F7bd700995054fc7f6e3dd46729840f41 +0 -0
  48. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  49. data/test/dummy/tmp/cache/assets/CF8/240/sprockets%2Fa77e8c483f757a8dde25486509c30e49 +0 -0
  50. data/test/dummy/tmp/cache/assets/CFA/270/sprockets%2Fd02325a0101297b802b9d58bf528daad +0 -0
  51. data/test/dummy/tmp/cache/assets/D15/F00/sprockets%2Fecc50cf25fa3f5a19523f1167447499e +0 -0
  52. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  53. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  54. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  55. data/test/dummy/tmp/cache/assets/D87/660/sprockets%2F1ae8d4faaefc28a0e004e1363156a41f +0 -0
  56. data/test/dummy/tmp/cache/assets/D9D/DE0/sprockets%2Fa9c151cfd3ded7726c52d078c35ac71f +0 -0
  57. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  58. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  59. data/test/dummy/tmp/cache/assets/E43/620/sprockets%2Fa1fde4a5eaab0961220acbd9def065aa +0 -0
  60. data/test/sads_xml_test.rb +108 -0
  61. data/test/test_helper.rb +14 -0
  62. metadata +186 -0
@@ -0,0 +1,108 @@
1
+ require 'test_helper'
2
+
3
+ class SadsXmlTest < ActiveSupport::TestCase
4
+ def setup
5
+ @sads = SadsXml::Sads.new
6
+ end
7
+
8
+ test "must have default title" do
9
+ assert !@sads.title.nil?
10
+ end
11
+
12
+ test "must have default navigations" do
13
+ assert_equal Array, @sads.navigations[:default].class
14
+ end
15
+
16
+ test "must be able to add new set of navigations" do
17
+ @sads.add_navigation :title => 'Main Menu', :accesskey => "00", :pageId => '/'
18
+ @sads.add_navigation :title => 'Back', :accesskey => "07", :pageId => '/'
19
+ @sads.add_navigation :title => 'Next', :accesskey => "09", :pageId => '/'
20
+
21
+ assert_equal Array, @sads.navigations[:default].class
22
+ assert_equal 3, @sads.navigations[:default].length
23
+
24
+ @sads.add_navigation({ :title => 'Food', :accesskey => '1', :pageId => 'food/' }, :categories)
25
+ @sads.add_navigation({ :title => 'Shops', :accesskey => '2', :pageId => 'shops/' }, :categories)
26
+ assert_equal Array, @sads.navigations[:categories].class
27
+ assert_equal 2, @sads.navigations[:categories].length
28
+ end
29
+
30
+ test "xml must have id for the title attribute even if blank" do
31
+ assert !@sads.to_sads.match(/<title id=""><\/title>/).nil?
32
+
33
+ @sads.title = 'A Crappy Title'
34
+ assert !@sads.to_sads.match(/<title id="">A Crappy Title<\/title>/).nil?
35
+ end
36
+
37
+ test "must render input elements" do
38
+ @sads.add_input :navigationId => 'submit', :name => 'username', :title => 'Username'
39
+ @sads.submit_page = 'search_by_person_submit'
40
+
41
+ assert_equal true, (not @sads.submit_page.nil?)
42
+ assert_equal 'search_by_person_submit', @sads.submit_page
43
+
44
+ assert_equal Array, @sads.inputs.class
45
+ assert_equal 1, @sads.inputs.length
46
+
47
+ xml = @sads.to_sads
48
+
49
+ assert !xml.match(/<navigation id="submit">/).nil?
50
+
51
+ # Must find a way to verify codes below. XML Builder doesn't have order of creating the attributes
52
+ # Research on this one please
53
+ #assert !xml.match(/<input title="Username" navigationId="submit" name="username"\/>/).nil?
54
+ #assert !xml.match(/<link pageId="search_by_person_submit" accesskey="1"\/>/).nil?
55
+ end
56
+
57
+ test "ussd_length must count the length of the message" do
58
+ title = "This is title"
59
+ message = "This is a message"
60
+
61
+ @sads.title = title
62
+ @sads.message = message
63
+ @sads.add_navigation :title => 'Main Menu', :accesskey => "00", :pageId => '/'
64
+ @sads.add_navigation({ :title => 'Food', :accesskey => '1', :pageId => 'food/' }, :categories)
65
+ @sads.add_navigation({ :title => 'Shops', :accesskey => '2', :pageId => 'shops/' }, :categories)
66
+
67
+ assert_equal (title.length + 2) +
68
+ (message.length + 1) +
69
+ ('Main Menu'.length + "00".length + 2) +
70
+ ('Food'.length + "1".length + 2) +
71
+ ('Shops'.length + "2".length + 2) - 1,
72
+ @sads.ussd_length
73
+
74
+ @sads = SadsXml::Sads.new
75
+ @sads.title = "DPC Mobile: Search by Person"
76
+ @sads.add_input :navigationId => 'submit', :name => 'person_name', :title => 'Please enter name of Person'
77
+ @sads.submit_page = 'whatever_path'
78
+
79
+ assert_equal 58, @sads.ussd_length
80
+ end
81
+
82
+ test "must be able to add messages" do
83
+ title = "This is title"
84
+ message = "This is a message"
85
+
86
+ @sads.title = title
87
+ @sads.message = message
88
+ @sads.set_message :bottom, "bottom message"
89
+
90
+ xml = @sads.to_sads
91
+
92
+ assert !xml.match(/<div id="bottom">bottom message<\/div>/).nil?
93
+ assert !xml.match(/<div>This is a message<\/div>/).nil?
94
+ end
95
+
96
+ test "must not render banners if banner_targets is empty" do
97
+ xml = @sads.to_sads
98
+ assert xml.match(/<meta:banner/).nil?
99
+ end
100
+
101
+ test "must render banners if banner_targets is not empty" do
102
+ @sads.banner_targets<< "female"
103
+ xml = @sads.to_sads
104
+ assert !xml.match(/<meta:banner target="female"\/>/).nil?
105
+ end
106
+
107
+
108
+ end
@@ -0,0 +1,14 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require "rails/test_help"
5
+
6
+ Rails.backtrace_cleaner.remove_silencers!
7
+
8
+ # Load support files
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
+
11
+ # Load fixtures from the engine
12
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
13
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
14
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sads_xml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Angelo Ang
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-09 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70345148188860 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70345148188860
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &70345148186580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70345148186580
36
+ description: Helpers for implenting services on Rails using Eyeline's Mobilizer product.
37
+ email:
38
+ - dev@innohub.ph
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - app/views/layouts/sads_xml.html.erb
44
+ - app/views/sads_xml/sads.html.erb
45
+ - lib/sads_xml/controller_additions.rb
46
+ - lib/sads_xml/sads.rb
47
+ - lib/sads_xml/version.rb
48
+ - lib/sads_xml.rb
49
+ - MIT-LICENSE
50
+ - Rakefile
51
+ - README
52
+ - test/dummy/app/assets/javascripts/application.js
53
+ - test/dummy/app/assets/stylesheets/application.css
54
+ - test/dummy/app/controllers/application_controller.rb
55
+ - test/dummy/app/controllers/ussd/default_controller.rb
56
+ - test/dummy/app/helpers/application_helper.rb
57
+ - test/dummy/app/helpers/ussd/default_helper.rb
58
+ - test/dummy/app/views/layouts/application.html.erb
59
+ - test/dummy/config/application.rb
60
+ - test/dummy/config/boot.rb
61
+ - test/dummy/config/database.yml
62
+ - test/dummy/config/environment.rb
63
+ - test/dummy/config/environments/development.rb
64
+ - test/dummy/config/environments/production.rb
65
+ - test/dummy/config/environments/test.rb
66
+ - test/dummy/config/initializers/backtrace_silencers.rb
67
+ - test/dummy/config/initializers/inflections.rb
68
+ - test/dummy/config/initializers/mime_types.rb
69
+ - test/dummy/config/initializers/secret_token.rb
70
+ - test/dummy/config/initializers/session_store.rb
71
+ - test/dummy/config/initializers/wrap_parameters.rb
72
+ - test/dummy/config/locales/en.yml
73
+ - test/dummy/config/routes.rb
74
+ - test/dummy/config.ru
75
+ - test/dummy/db/development.sqlite3
76
+ - test/dummy/db/test.sqlite3
77
+ - test/dummy/log/development.log
78
+ - test/dummy/log/test.log
79
+ - test/dummy/public/404.html
80
+ - test/dummy/public/422.html
81
+ - test/dummy/public/500.html
82
+ - test/dummy/public/favicon.ico
83
+ - test/dummy/Rakefile
84
+ - test/dummy/README.rdoc
85
+ - test/dummy/script/rails
86
+ - test/dummy/test/functional/ussd/default_controller_test.rb
87
+ - test/dummy/test/unit/helpers/ussd/default_helper_test.rb
88
+ - test/dummy/tmp/cache/assets/CB1/D30/sprockets%2F7b6a97d2209a681f2bebe34655163319
89
+ - test/dummy/tmp/cache/assets/CBF/3F0/sprockets%2F7bd700995054fc7f6e3dd46729840f41
90
+ - test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953
91
+ - test/dummy/tmp/cache/assets/CF8/240/sprockets%2Fa77e8c483f757a8dde25486509c30e49
92
+ - test/dummy/tmp/cache/assets/CFA/270/sprockets%2Fd02325a0101297b802b9d58bf528daad
93
+ - test/dummy/tmp/cache/assets/D15/F00/sprockets%2Fecc50cf25fa3f5a19523f1167447499e
94
+ - test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705
95
+ - test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655
96
+ - test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6
97
+ - test/dummy/tmp/cache/assets/D87/660/sprockets%2F1ae8d4faaefc28a0e004e1363156a41f
98
+ - test/dummy/tmp/cache/assets/D9D/DE0/sprockets%2Fa9c151cfd3ded7726c52d078c35ac71f
99
+ - test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994
100
+ - test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
101
+ - test/dummy/tmp/cache/assets/E43/620/sprockets%2Fa1fde4a5eaab0961220acbd9def065aa
102
+ - test/sads_xml_test.rb
103
+ - test/test_helper.rb
104
+ homepage: http://github.com/InnoHub/sads_xml
105
+ licenses: []
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ segments:
117
+ - 0
118
+ hash: 3417546636344553107
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ segments:
126
+ - 0
127
+ hash: 3417546636344553107
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.10
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Helpers for implenting services on Rails using Eyeline's Mobilizer product.
134
+ test_files:
135
+ - test/dummy/app/assets/javascripts/application.js
136
+ - test/dummy/app/assets/stylesheets/application.css
137
+ - test/dummy/app/controllers/application_controller.rb
138
+ - test/dummy/app/controllers/ussd/default_controller.rb
139
+ - test/dummy/app/helpers/application_helper.rb
140
+ - test/dummy/app/helpers/ussd/default_helper.rb
141
+ - test/dummy/app/views/layouts/application.html.erb
142
+ - test/dummy/config/application.rb
143
+ - test/dummy/config/boot.rb
144
+ - test/dummy/config/database.yml
145
+ - test/dummy/config/environment.rb
146
+ - test/dummy/config/environments/development.rb
147
+ - test/dummy/config/environments/production.rb
148
+ - test/dummy/config/environments/test.rb
149
+ - test/dummy/config/initializers/backtrace_silencers.rb
150
+ - test/dummy/config/initializers/inflections.rb
151
+ - test/dummy/config/initializers/mime_types.rb
152
+ - test/dummy/config/initializers/secret_token.rb
153
+ - test/dummy/config/initializers/session_store.rb
154
+ - test/dummy/config/initializers/wrap_parameters.rb
155
+ - test/dummy/config/locales/en.yml
156
+ - test/dummy/config/routes.rb
157
+ - test/dummy/config.ru
158
+ - test/dummy/db/development.sqlite3
159
+ - test/dummy/db/test.sqlite3
160
+ - test/dummy/log/development.log
161
+ - test/dummy/log/test.log
162
+ - test/dummy/public/404.html
163
+ - test/dummy/public/422.html
164
+ - test/dummy/public/500.html
165
+ - test/dummy/public/favicon.ico
166
+ - test/dummy/Rakefile
167
+ - test/dummy/README.rdoc
168
+ - test/dummy/script/rails
169
+ - test/dummy/test/functional/ussd/default_controller_test.rb
170
+ - test/dummy/test/unit/helpers/ussd/default_helper_test.rb
171
+ - test/dummy/tmp/cache/assets/CB1/D30/sprockets%2F7b6a97d2209a681f2bebe34655163319
172
+ - test/dummy/tmp/cache/assets/CBF/3F0/sprockets%2F7bd700995054fc7f6e3dd46729840f41
173
+ - test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953
174
+ - test/dummy/tmp/cache/assets/CF8/240/sprockets%2Fa77e8c483f757a8dde25486509c30e49
175
+ - test/dummy/tmp/cache/assets/CFA/270/sprockets%2Fd02325a0101297b802b9d58bf528daad
176
+ - test/dummy/tmp/cache/assets/D15/F00/sprockets%2Fecc50cf25fa3f5a19523f1167447499e
177
+ - test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705
178
+ - test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655
179
+ - test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6
180
+ - test/dummy/tmp/cache/assets/D87/660/sprockets%2F1ae8d4faaefc28a0e004e1363156a41f
181
+ - test/dummy/tmp/cache/assets/D9D/DE0/sprockets%2Fa9c151cfd3ded7726c52d078c35ac71f
182
+ - test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994
183
+ - test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
184
+ - test/dummy/tmp/cache/assets/E43/620/sprockets%2Fa1fde4a5eaab0961220acbd9def065aa
185
+ - test/sads_xml_test.rb
186
+ - test/test_helper.rb