true-web 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'superhash'
5
+
6
+ class Test_SuperHash < Test::Unit::TestCase
7
+
8
+ def setup
9
+ ## should have an assortment of possibilties
10
+ p0 = { 1=>2, 2=>3, 3=>4 }
11
+ p1 = { 1=>3, 2=>4, 3=>5, 4=>6 }
12
+
13
+ @inherited = p1.dup.update(p0)
14
+
15
+ @sh = SuperHash.new [p0, p1], :zip
16
+
17
+ @own = { 0=>0, 1=>1 }
18
+ @sh.own.update @own
19
+
20
+ @expected = p1.dup.update(p0.dup.update(@own))
21
+
22
+ @missing = "foo" # just an example of a missing key
23
+ end
24
+ alias set_up setup # just for earlier versions of Test::Unit
25
+
26
+ def test_inherits_key
27
+ assert(@sh.inherits_key?(2))
28
+ assert(@sh.inherits_key?(4))
29
+ assert(! @sh.inherits_key?(0))
30
+ assert(! @sh.inherits_key?(1))
31
+ end
32
+
33
+ def test_to_h
34
+ assert_equal(@expected, @sh.to_hash)
35
+ end
36
+
37
+ def test_each
38
+ @sh.each { |k, v|
39
+ @expected.delete(k) {
40
+ flunk("Unexpected key #{k} found in superhash.")
41
+ }
42
+ }
43
+ assert(@expected.empty?,
44
+ "Keys #{@expected.keys.inspect} were not traversed during each.")
45
+ end
46
+
47
+ def test_fetch
48
+ assert_raises IndexError do
49
+ @sh.fetch @missing
50
+ end
51
+ assert_equal(:worked, @sh.fetch(@missing) {:worked})
52
+ assert_equal(:worked, @sh.fetch(@missing, :worked))
53
+ end
54
+
55
+ def test_has_value?
56
+ assert(@sh.has_value?(0))
57
+ assert(@sh.has_value?(6))
58
+ assert(!@sh.has_value?(5))
59
+ end
60
+
61
+ def test_index
62
+ assert_equal(1, @sh.index(1))
63
+ assert_equal(2, @sh.index(3))
64
+ end
65
+
66
+ def test_invert
67
+ assert_equal(@expected.invert, @sh.invert)
68
+ end
69
+
70
+ def test_has_key?
71
+ assert(@sh.has_key?(1))
72
+ assert(@sh.has_key?(4))
73
+ assert(!@sh.has_key?(7))
74
+ end
75
+
76
+ def test_keys
77
+ assert_equal(@expected.keys, @sh.keys)
78
+ end
79
+
80
+ def test_size
81
+ assert_equal(@expected.size, @sh.size)
82
+ end
83
+
84
+ def test_store
85
+ @sh[4] = 40
86
+ @expected[4] = 40
87
+ assert_equal(@expected, @sh.to_hash)
88
+ end
89
+
90
+ def test_clear
91
+ @sh.clear
92
+ assert_equal(:zip, @sh[0])
93
+ assert_equal(:zip, @sh[2])
94
+ assert_equal(:zip, @sh[4])
95
+ end
96
+
97
+ def test_delete
98
+ assert_equal(6, @sh.delete(4))
99
+ assert_equal(@missing, @sh.delete(@missing) { |k| k })
100
+
101
+ assert_equal(0, @sh.delete(0))
102
+ assert_raises IndexError do
103
+ @sh.fetch 0
104
+ end
105
+ end
106
+
107
+ # def test_delete_if
108
+ #
109
+ # end
110
+ #
111
+ # def test_reject!
112
+ #
113
+ # end
114
+
115
+ def test_update
116
+ h = {2=>20, 30=>300}
117
+ assert_equal(@expected.update(h), @sh.update(h).to_hash)
118
+ end
119
+
120
+ def test_values
121
+ assert_equal(@expected.values, @sh.values)
122
+ end
123
+
124
+ end
metadata ADDED
@@ -0,0 +1,242 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: true-web
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Brian Takita
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-16 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activesupport
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 3.0.0
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: honkster-addressable
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 2.2.3
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: i18n
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.5.0
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: mustache
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 0.99.2
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: named-routes
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.5
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: sinatra
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.2.0
80
+ type: :runtime
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: yajl-ruby
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 0.8.1
91
+ type: :runtime
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: capybara
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 0.4.0
102
+ type: :development
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: nokogiri
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.4.4
113
+ type: :development
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: rack-test
117
+ prerelease: false
118
+ requirement: &id010 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 0.5.6
124
+ type: :development
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: rr
128
+ prerelease: false
129
+ requirement: &id011 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.0.2
135
+ type: :development
136
+ version_requirements: *id011
137
+ - !ruby/object:Gem::Dependency
138
+ name: rspec
139
+ prerelease: false
140
+ requirement: &id012 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 2.2.0
146
+ type: :development
147
+ version_requirements: *id012
148
+ - !ruby/object:Gem::Dependency
149
+ name: ruby-debug19
150
+ prerelease: false
151
+ requirement: &id013 !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: 0.11.6
157
+ type: :development
158
+ version_requirements: *id013
159
+ - !ruby/object:Gem::Dependency
160
+ name: webmock
161
+ prerelease: false
162
+ requirement: &id014 !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: 1.6.2
168
+ type: :development
169
+ version_requirements: *id014
170
+ description: A lightweight Sinatra web MVC stack
171
+ email:
172
+ - btakita@truecar.com
173
+ executables: []
174
+
175
+ extensions: []
176
+
177
+ extra_rdoc_files: []
178
+
179
+ files:
180
+ - .gitignore
181
+ - .rvmrc
182
+ - Gemfile
183
+ - Gemfile.lock
184
+ - README
185
+ - Rakefile
186
+ - lib/true-web.rb
187
+ - lib/true-web/controller.rb
188
+ - lib/true-web/env_methods.rb
189
+ - lib/true-web/plugins.rb
190
+ - lib/true-web/plugins/directory_first_sort.rb
191
+ - lib/true-web/service.rb
192
+ - lib/true-web/version.rb
193
+ - lib/true-web/views.rb
194
+ - spec/fixture-app/app.rb
195
+ - spec/fixture-app/services/authentication/app/templates/index.html.ms
196
+ - spec/fixture-app/services/authentication/init.rb
197
+ - spec/fixture-app/services/authentication/public/javascripts/foo.js
198
+ - spec/spec_helper.rb
199
+ - spec/spec_suite.rb
200
+ - spec/true-web/service_spec.rb
201
+ - spec/true-web/views_spec.rb
202
+ - true-web.gemspec
203
+ - vendor/superhash/InstalledFiles
204
+ - vendor/superhash/README
205
+ - vendor/superhash/RELEASE-NOTES
206
+ - vendor/superhash/config.save
207
+ - vendor/superhash/examples/attributed-node.rb
208
+ - vendor/superhash/examples/class-superhash.rb
209
+ - vendor/superhash/examples/state-object.rb
210
+ - vendor/superhash/install.rb
211
+ - vendor/superhash/lib/superhash.rb
212
+ - vendor/superhash/test/test.rb
213
+ has_rdoc: true
214
+ homepage: https://github.com/TrueCar/true-web
215
+ licenses: []
216
+
217
+ post_install_message:
218
+ rdoc_options: []
219
+
220
+ require_paths:
221
+ - lib
222
+ required_ruby_version: !ruby/object:Gem::Requirement
223
+ none: false
224
+ requirements:
225
+ - - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: "0"
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ none: false
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ version: 1.3.6
234
+ requirements: []
235
+
236
+ rubyforge_project:
237
+ rubygems_version: 1.5.2
238
+ signing_key:
239
+ specification_version: 3
240
+ summary: A lightweight Sinatra web MVC stack
241
+ test_files: []
242
+