ramaze 0.1.3 → 0.1.4
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.
- data/bin/ramaze +58 -26
- data/doc/AUTHORS +2 -0
- data/doc/CHANGELOG +401 -0
- data/doc/README +14 -9
- data/doc/README.html +737 -0
- data/doc/TODO +14 -14
- data/doc/changes.txt +401 -0
- data/doc/changes.xml +401 -0
- data/doc/meta/announcement.txt +28 -15
- data/doc/meta/configuration.txt +3 -3
- data/doc/meta/internals.txt +2 -2
- data/doc/meta/users.kml +62 -0
- data/doc/readme_chunks/examples.txt +1 -1
- data/doc/readme_chunks/features.txt +13 -8
- data/doc/tutorial/todolist.html +2 -2
- data/doc/tutorial/todolist.mkd +2 -2
- data/examples/blog/README +3 -0
- data/examples/blog/spec/blog.rb +101 -0
- data/examples/blog/{main.rb → start.rb} +0 -0
- data/examples/caching.rb +16 -5
- data/examples/layout.rb +41 -0
- data/examples/templates/template_amrita2.rb +1 -1
- data/examples/templates/template_erubis.rb +1 -1
- data/examples/templates/template_ezamar.rb +1 -1
- data/examples/templates/template_haml.rb +1 -1
- data/examples/templates/template_liquid.rb +1 -1
- data/examples/templates/template_markaby.rb +1 -1
- data/examples/templates/template_remarkably.rb +1 -1
- data/examples/todolist/README +1 -0
- data/{spec/examples → examples/todolist/spec}/todolist.rb +3 -3
- data/examples/todolist/{main.rb → start.rb} +0 -0
- data/examples/whywiki/{main.rb → start.rb} +0 -0
- data/examples/wiktacular/README +2 -0
- data/examples/wiktacular/spec/wiktacular.rb +146 -0
- data/examples/wiktacular/src/controller.rb +11 -0
- data/examples/wiktacular/src/model.rb +5 -1
- data/examples/wiktacular/{main.rb → start.rb} +0 -1
- data/examples/wiktacular/template/edit.xhtml +1 -2
- data/examples/wiktacular/template/html_layout.xhtml +27 -0
- data/examples/wiktacular/template/index.xhtml +8 -10
- data/examples/wiktacular/template/new.xhtml +1 -2
- data/lib/proto/{main.rb → start.rb} +0 -0
- data/lib/proto/template/index.xhtml +1 -1
- data/lib/ramaze/action/render.rb +58 -4
- data/lib/ramaze/action.rb +20 -0
- data/lib/ramaze/adapter/cgi.rb +7 -4
- data/lib/ramaze/adapter/fcgi.rb +6 -4
- data/lib/ramaze/adapter/mongrel.rb +4 -0
- data/lib/ramaze/adapter/webrick.rb +20 -9
- data/lib/ramaze/adapter.rb +3 -1
- data/lib/ramaze/cache/memcached.rb +2 -26
- data/lib/ramaze/cache.rb +8 -4
- data/lib/ramaze/controller/resolve.rb +26 -8
- data/lib/ramaze/controller.rb +44 -7
- data/lib/ramaze/dispatcher/action.rb +5 -1
- data/lib/ramaze/dispatcher/directory.rb +115 -0
- data/lib/ramaze/dispatcher/error.rb +19 -5
- data/lib/ramaze/dispatcher/file.rb +2 -2
- data/lib/ramaze/dispatcher.rb +52 -39
- data/lib/ramaze/global/dsl.rb +3 -2
- data/lib/ramaze/global/globalstruct.rb +26 -4
- data/lib/ramaze/global.rb +20 -11
- data/lib/ramaze/helper/aspect.rb +29 -11
- data/lib/ramaze/helper/auth.rb +2 -2
- data/lib/ramaze/helper/cache.rb +2 -0
- data/lib/ramaze/helper/identity.rb +21 -6
- data/lib/ramaze/helper/link.rb +1 -1
- data/lib/ramaze/helper/pager.rb +158 -100
- data/lib/ramaze/helper/partial.rb +22 -0
- data/lib/ramaze/helper/redirect.rb +1 -2
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/inform/informer.rb +20 -0
- data/lib/ramaze/inform/syslog.rb +5 -0
- data/lib/ramaze/snippets/kernel/__dir__.rb +21 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +22 -12
- data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +33 -0
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
- data/lib/ramaze/snippets/struct/values_at.rb +11 -4
- data/lib/ramaze/sourcereload.rb +29 -1
- data/{spec → lib/ramaze/spec}/helper/context.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/layout.rb +1 -1
- data/{spec → lib/ramaze/spec}/helper/minimal.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/mock_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/requester.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/simple_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/wrap.rb +0 -0
- data/lib/ramaze/spec/helper.rb +60 -0
- data/lib/ramaze/store/default.rb +3 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +3 -0
- data/lib/ramaze/template/sass.rb +45 -0
- data/lib/ramaze/template.rb +1 -1
- data/lib/ramaze/tool/create.rb +5 -5
- data/lib/ramaze/tool/localize.rb +26 -5
- data/lib/ramaze/tool/mime.rb +7 -0
- data/lib/ramaze/trinity/response.rb +15 -0
- data/lib/ramaze/trinity/session.rb +1 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze.rb +5 -0
- data/rake_tasks/conf.rake +4 -4
- data/rake_tasks/maintaince.rake +12 -7
- data/rake_tasks/spec.rake +7 -4
- data/spec/examples/caching.rb +6 -8
- data/spec/helper.rb +3 -60
- data/spec/ramaze/action/basics.rb +17 -0
- data/spec/ramaze/action/cache.rb +28 -0
- data/spec/ramaze/action/layout.rb +110 -0
- data/spec/ramaze/action/render.rb +14 -0
- data/spec/ramaze/action/template/bar.xhtml +1 -0
- data/spec/ramaze/action/template/other_wrapper.xhtml +1 -0
- data/spec/ramaze/action/template/single_wrapper.xhtml +1 -0
- data/spec/ramaze/controller/template/edit/content.xhtml +1 -0
- data/spec/ramaze/controller/template/edit.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +2 -2
- data/spec/ramaze/dispatcher/directory.rb +53 -0
- data/spec/ramaze/dispatcher/file.rb +0 -3
- data/spec/ramaze/error.rb +17 -2
- data/spec/ramaze/helper/aspect.rb +14 -20
- data/spec/ramaze/helper/pager.rb +83 -1
- data/spec/ramaze/helper/partial.rb +1 -1
- data/spec/ramaze/helper/template/test_template.xhtml +1 -0
- data/spec/ramaze/inform/informer.rb +37 -5
- data/spec/ramaze/localize.rb +1 -1
- data/spec/ramaze/template/haml.rb +5 -5
- data/spec/ramaze/template/sass/file.css.sass +5 -0
- data/spec/ramaze/template/sass.rb +46 -0
- data/spec/ramaze/template.rb +1 -1
- data/spec/ramaze/trinity/session.rb +27 -0
- data/spec/snippets/kernel/__dir__.rb +8 -0
- data/spec/snippets/kernel/aquire.rb +71 -0
- data/spec/snippets/kernel/constant.rb +27 -0
- data/spec/snippets/numeric/human_readable_filesize_format.rb +11 -0
- data/spec/snippets/ramaze/caller_info.rb +39 -0
- data/spec/snippets/ramaze/caller_lines.rb +27 -0
- data/spec/snippets/string/DIVIDE.rb +18 -0
- data/spec/snippets/string/camel_case.rb +25 -0
- data/spec/snippets/string/color.rb +11 -0
- data/spec/snippets/string/snake_case.rb +17 -0
- data/spec/snippets/struct/fill.rb +27 -0
- data/spec/snippets/struct/values_at.rb +39 -0
- metadata +71 -31
- data/examples/todolist/todolist.db +0 -5
- data/examples/wiktacular/src/page.rb +0 -66
- data/lib/ramaze/helper/feed.rb +0 -135
- data/lib/ramaze/helper/form.rb +0 -204
- data/lib/ramaze/snippets/openstruct/temp.rb +0 -13
- data/lib/ramaze/store/yaml.rb +0 -170
- data/spec/ramaze/helper/feed.rb +0 -127
- data/spec/ramaze/helper/form.rb +0 -146
- data/spec/ramaze/store/yaml.rb +0 -76
|
@@ -6,7 +6,7 @@ require 'spec/helper'
|
|
|
6
6
|
class TCPartialHelperController < Ramaze::Controller
|
|
7
7
|
map '/'
|
|
8
8
|
helper :partial
|
|
9
|
-
template_root(
|
|
9
|
+
template_root(__DIR__/:template)
|
|
10
10
|
|
|
11
11
|
def index
|
|
12
12
|
'<html><head><title>#{render_partial("/title")}</title></head></html>'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
I am a template.
|
|
@@ -9,23 +9,23 @@ describe 'Informer' do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def format(tag, string)
|
|
12
|
-
|
|
12
|
+
/\[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\] #{tag.to_s.upcase.ljust(5)} #{Regexp.escape(string)}/
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'info' do
|
|
16
16
|
@inform.info('Some Info')
|
|
17
|
-
@out.first.should
|
|
17
|
+
@out.first.should =~ format(:info, 'Some Info')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'debug' do
|
|
21
21
|
arr = [:some, :stuff]
|
|
22
22
|
@inform.debug(arr)
|
|
23
|
-
@out.first.should
|
|
23
|
+
@out.first.should =~ format(:debug, arr.inspect)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it 'warn' do
|
|
27
27
|
@inform.warn('More things')
|
|
28
|
-
@out.first.should
|
|
28
|
+
@out.first.should =~ format(:warn, 'More things')
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it 'error' do
|
|
@@ -35,6 +35,38 @@ describe 'Informer' do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
@inform.error(ex)
|
|
38
|
-
@out.first.should
|
|
38
|
+
@out.first.should =~ format(:error, ex.inspect)
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
it 'should choose stdout on init(stdout,:stdout,STDOUT)' do
|
|
42
|
+
a = Ramaze::Informer.new(STDOUT)
|
|
43
|
+
b = Ramaze::Informer.new(:stdout)
|
|
44
|
+
c = Ramaze::Informer.new('stdout')
|
|
45
|
+
[a,b,c].each { |x| x.out.should == $stdout}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'should choose stderr on init(stderr,:stderr,STDERR)' do
|
|
49
|
+
a = Ramaze::Informer.new(STDERR)
|
|
50
|
+
b = Ramaze::Informer.new(:stderr)
|
|
51
|
+
c = Ramaze::Informer.new('stderr')
|
|
52
|
+
[a,b,c].each { |x| x.out.should == $stderr}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'should use IO when supplied' do
|
|
56
|
+
i = Ramaze::Informer.new(s = StringIO.new)
|
|
57
|
+
i.out.should == s
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'should open file otherwise' do
|
|
61
|
+
begin
|
|
62
|
+
i = Ramaze::Informer.new('tmp.dummy')
|
|
63
|
+
out = i.out
|
|
64
|
+
out.should be_an_instance_of(File)
|
|
65
|
+
out.path.should == 'tmp.dummy'
|
|
66
|
+
ensure
|
|
67
|
+
out.close
|
|
68
|
+
File.delete('tmp.dummy')
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
40
72
|
end
|
data/spec/ramaze/localize.rb
CHANGED
|
@@ -20,21 +20,21 @@ class TCTemplateHamlController < Ramaze::Controller
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
describe "
|
|
23
|
+
describe "Haml templates" do
|
|
24
24
|
ramaze(:compile => true)
|
|
25
25
|
|
|
26
|
-
it "
|
|
26
|
+
it "should render" do
|
|
27
27
|
get('/').body.strip.should ==
|
|
28
|
-
|
|
28
|
+
%{<div id='contact'>
|
|
29
29
|
<h1>Eugene Mumbai</h1>
|
|
30
30
|
<ul class='info'>
|
|
31
31
|
<li class='login'>eugene</li>
|
|
32
32
|
<li class='email'>eugene@example.com</li>
|
|
33
33
|
</ul>
|
|
34
|
-
</div>
|
|
34
|
+
</div>}
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
it "variables in controller" do
|
|
37
|
+
it "should have access to variables defined in controller" do
|
|
38
38
|
get('/with_vars').body.strip.should ==
|
|
39
39
|
%{<div id='content'>
|
|
40
40
|
<div class='title'>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require 'spec/helper'
|
|
5
|
+
|
|
6
|
+
testcase_requires 'sass/engine'
|
|
7
|
+
|
|
8
|
+
class TCTemplateSassController < Ramaze::Controller
|
|
9
|
+
map '/'
|
|
10
|
+
template_root 'spec/ramaze/template/sass/'
|
|
11
|
+
trait :engine => Ramaze::Template::Sass
|
|
12
|
+
|
|
13
|
+
define_method('style.css') do
|
|
14
|
+
%{
|
|
15
|
+
body
|
|
16
|
+
:margin 1em
|
|
17
|
+
|
|
18
|
+
#content
|
|
19
|
+
:text-align center
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "Sass templates" do
|
|
25
|
+
ramaze(:compile => true)
|
|
26
|
+
|
|
27
|
+
it "should render inline" do
|
|
28
|
+
r = get('/style.css')
|
|
29
|
+
r.headers['Content-Type'].should == "text/css"
|
|
30
|
+
r.body.strip.should ==
|
|
31
|
+
"body {
|
|
32
|
+
margin: 1em; }
|
|
33
|
+
body #content {
|
|
34
|
+
text-align: center; }"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should render from file" do
|
|
38
|
+
r = get('/file.css')
|
|
39
|
+
r.headers['Content-Type'].should == "text/css"
|
|
40
|
+
r.body.strip.should ==
|
|
41
|
+
"body {
|
|
42
|
+
margin: 1em; }
|
|
43
|
+
body #content {
|
|
44
|
+
text-align: center; }"
|
|
45
|
+
end
|
|
46
|
+
end
|
data/spec/ramaze/template.rb
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require 'spec/helper'
|
|
5
|
+
|
|
6
|
+
class TrinitySessionController < Ramaze::Controller
|
|
7
|
+
map :/
|
|
8
|
+
|
|
9
|
+
def index
|
|
10
|
+
"nothing"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "Session" do
|
|
15
|
+
before(:all){
|
|
16
|
+
Ramaze::Global.sessions = false
|
|
17
|
+
ramaze
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
it 'should work without sessions' do
|
|
21
|
+
(Ramaze::Session::IP_COUNT_LIMIT + 2).times do
|
|
22
|
+
r = get('/')
|
|
23
|
+
r.body.should == "nothing"
|
|
24
|
+
r.headers.should == {'Content-Type' => 'text/html'}
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
describe 'aquire' do
|
|
4
|
+
def require(name)
|
|
5
|
+
@required << name
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
before :all do
|
|
9
|
+
FileUtils.mkdir_p 'tmp_dir_for_aquire/sub'
|
|
10
|
+
FileUtils.touch 'tmp_dir_for_aquire/foo.rb'
|
|
11
|
+
FileUtils.touch 'tmp_dir_for_aquire/bar.rb'
|
|
12
|
+
FileUtils.touch 'tmp_dir_for_aquire/baz.so'
|
|
13
|
+
FileUtils.touch 'tmp_dir_for_aquire/baz.yml'
|
|
14
|
+
FileUtils.touch 'tmp_dir_for_aquire/sub/baz.rb'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
before do
|
|
18
|
+
@required = []
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should not load a single file' do
|
|
22
|
+
aquire 'tmp_dir_for_aquire/foo'
|
|
23
|
+
@required.should == []
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should load dir' do
|
|
27
|
+
aquire 'tmp_dir_for_aquire/sub/*'
|
|
28
|
+
@required.should == ['tmp_dir_for_aquire/sub/baz.rb']
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should load {so,rb}, not others' do
|
|
32
|
+
aquire 'tmp_dir_for_aquire/*'
|
|
33
|
+
@required.sort.should == %w{
|
|
34
|
+
tmp_dir_for_aquire/bar.rb
|
|
35
|
+
tmp_dir_for_aquire/baz.so
|
|
36
|
+
tmp_dir_for_aquire/foo.rb}
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should use globbing' do
|
|
41
|
+
aquire 'tmp_dir_for_aquire/ba*'
|
|
42
|
+
@required.sort.should == %w{
|
|
43
|
+
tmp_dir_for_aquire/bar.rb
|
|
44
|
+
tmp_dir_for_aquire/baz.so}
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'should use recursive globbing' do
|
|
49
|
+
aquire 'tmp_dir_for_aquire/**/*'
|
|
50
|
+
@required.sort.should == %w{
|
|
51
|
+
tmp_dir_for_aquire/bar.rb
|
|
52
|
+
tmp_dir_for_aquire/baz.so
|
|
53
|
+
tmp_dir_for_aquire/foo.rb
|
|
54
|
+
tmp_dir_for_aquire/sub/baz.rb}
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'should accept multiple arguments' do
|
|
59
|
+
aquire 'tmp_dir_for_aquire/*', 'tmp_dir_for_aquire/sub/*'
|
|
60
|
+
@required.sort.should == %w{
|
|
61
|
+
tmp_dir_for_aquire/bar.rb
|
|
62
|
+
tmp_dir_for_aquire/baz.so
|
|
63
|
+
tmp_dir_for_aquire/foo.rb
|
|
64
|
+
tmp_dir_for_aquire/sub/baz.rb}
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
after :all do
|
|
69
|
+
FileUtils.rm_rf('tmp_dir_for_aquire')
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
describe 'constant' do
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
it 'should load from string' do
|
|
7
|
+
constant('Fixnum').should == Fixnum
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should load from symbol' do
|
|
11
|
+
constant(:Fixnum).should == Fixnum
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should handle hierarchy' do
|
|
15
|
+
constant('Ramaze::Inform').should == Ramaze::Inform
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should be callable with explicit self' do
|
|
19
|
+
Ramaze.constant('Inform').should == Ramaze::Inform
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'should be callable with explicit self' do
|
|
23
|
+
Ramaze.constant('::Ramaze').should == Ramaze
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
describe "Numeric#human_readable_filesize_format" do
|
|
4
|
+
it 'it should convert filesizes to human readable format' do
|
|
5
|
+
1.human_readable_filesize_format.should == '1'
|
|
6
|
+
1024.human_readable_filesize_format.should == '1.0K'
|
|
7
|
+
(1 << 20).human_readable_filesize_format.should == '1.0M'
|
|
8
|
+
(1 << 30).human_readable_filesize_format.should == '1.0G'
|
|
9
|
+
(1 << 40).human_readable_filesize_format.should == '1.0T'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
#TODO test parse_backtrace explicitly
|
|
4
|
+
describe "Ramaze#caller_info" do
|
|
5
|
+
|
|
6
|
+
def foo(n=0)
|
|
7
|
+
Ramaze.caller_info(n)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def bar
|
|
11
|
+
foo
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def baz
|
|
15
|
+
foo(1)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should report correct informations" do
|
|
19
|
+
file,line,meth=foo()
|
|
20
|
+
file.should == __FILE__
|
|
21
|
+
line.should match(/\d+/)
|
|
22
|
+
meth.should == 'foo'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should report correct informations on nested defs" do
|
|
26
|
+
file,line,meth=bar()
|
|
27
|
+
file.should == __FILE__
|
|
28
|
+
line.should match(/\d+/)
|
|
29
|
+
meth.should == 'foo'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should report correct informations on other callers" do
|
|
33
|
+
file,line,meth=baz()
|
|
34
|
+
file.should == __FILE__
|
|
35
|
+
line.should match(/\d+/)
|
|
36
|
+
meth.should == 'baz'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
describe "Ramaze#caller_info" do
|
|
4
|
+
|
|
5
|
+
it 'should show line numbers' do
|
|
6
|
+
res = Ramaze.caller_lines('/usr/lib/ruby/1.8/debug.rb', 122, 2)
|
|
7
|
+
res.size.should == 5
|
|
8
|
+
res.map {|e| e[0]}.should == (120..124).to_a
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should show which line we asked for' do
|
|
12
|
+
res = Ramaze.caller_lines('/usr/lib/ruby/1.8/debug.rb', 122, 2)
|
|
13
|
+
res.size.should == 5
|
|
14
|
+
res.map {|e| e[2]}.should == [false,false,true,false,false]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should show the code' do
|
|
18
|
+
res = Ramaze.caller_lines(__FILE__, __LINE__, 1)
|
|
19
|
+
res.size.should == 3
|
|
20
|
+
res.map {|e| e[1].strip}.should == [
|
|
21
|
+
"it 'should show the code' do",
|
|
22
|
+
"res = Ramaze.caller_lines(__FILE__, __LINE__, 1)",
|
|
23
|
+
"res.size.should == 3"
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
describe 'String#/' do
|
|
4
|
+
|
|
5
|
+
# check if this is ok in win32
|
|
6
|
+
it 'should join two strings' do
|
|
7
|
+
('a' / 'b').should == 'a/b'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should join a string and a symbol' do
|
|
11
|
+
('a' / :b).should == 'a/b'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should be usable in concatenation' do
|
|
15
|
+
('a' / :b / :c).should == 'a/b/c'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec/helper'
|
|
2
|
+
|
|
3
|
+
describe "String#camel_case" do
|
|
4
|
+
|
|
5
|
+
it 'should camelize snake_case' do
|
|
6
|
+
'foo_bar'.camel_case.should == 'FooBar'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'should camelize snake_case_long' do
|
|
10
|
+
'foo_bar_baz'.camel_case.should == 'FooBarBaz'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should ignore starting _' do
|
|
14
|
+
'_foo_bar_baz'.camel_case.should == 'FooBarBaz'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should ignore trailing _' do
|
|
18
|
+
'foo_bar_baz_'.camel_case.should == 'FooBarBaz'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'messes up existing CamelCase' do
|
|
22
|
+
'foo_barBaz'.camel_case.should == 'FooBarbaz'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|