RubyApp 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/.gitignore +3 -3
  2. data/Gemfile.lock +1 -1
  3. data/features/default.feature +2 -2
  4. data/features/elements/button.feature +9 -0
  5. data/features/{dialog.feature → elements/dialog.feature} +19 -13
  6. data/features/elements/input.feature +20 -0
  7. data/features/elements/link.feature +9 -0
  8. data/features/elements/list.feature +19 -0
  9. data/features/elements/markdown.feature +9 -0
  10. data/features/elements/page.feature +10 -0
  11. data/features/elements/pages/exception_page.feature +10 -0
  12. data/features/step_definitions/default_macros.rb +1 -1
  13. data/features/step_definitions/default_steps.rb +7 -3
  14. data/features/support/env.rb +1 -1
  15. data/lib/ruby_app/application.rb +16 -41
  16. data/lib/ruby_app/configuration.rb +9 -17
  17. data/lib/ruby_app/element.rb +27 -23
  18. data/lib/ruby_app/elements/base/base_page.js.haml +1 -1
  19. data/lib/ruby_app/elements/base/base_page.rb +5 -5
  20. data/lib/ruby_app/elements/list.js.haml +1 -1
  21. data/lib/ruby_app/elements/list.rb +5 -5
  22. data/lib/ruby_app/elements/lists/select.js.haml +1 -1
  23. data/lib/ruby_app/elements/lists/select.rb +1 -3
  24. data/lib/ruby_app/elements/markdown.js.haml +1 -1
  25. data/lib/ruby_app/elements/markdown.rb +5 -5
  26. data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.js.haml +1 -1
  27. data/lib/ruby_app/elements/navigation/base/base_breadcrumbs.rb +3 -3
  28. data/lib/ruby_app/elements/navigation/page_link.js.haml +1 -1
  29. data/lib/ruby_app/elements/navigation/page_link.rb +3 -3
  30. data/lib/ruby_app/elements/navigation/page_menu.js.haml +1 -1
  31. data/lib/ruby_app/elements/navigation/page_menu.rb +3 -3
  32. data/lib/ruby_app/elements/pages/authentication/open_id/authentication_page.rb +2 -2
  33. data/lib/ruby_app/elements/pages/authentication/open_id/ax_authentication_page.rb +2 -2
  34. data/lib/ruby_app/elements/pages/authentication/open_id/google_authentication_page.rb +1 -1
  35. data/lib/ruby_app/elements/pages/authentication/open_id/my_open_id_authentication_page.rb +1 -1
  36. data/lib/ruby_app/elements/pages/authentication/open_id/yahoo_authentication_page.rb +1 -1
  37. data/lib/ruby_app/elements/pages/default_page.rb +1 -1
  38. data/lib/ruby_app/elements/pages/exception_page.html.haml +0 -2
  39. data/lib/ruby_app/elements/pages/settings_page.rb +2 -2
  40. data/lib/ruby_app/elements/pages/test_pages/button_test_page.css.haml +3 -0
  41. data/lib/ruby_app/elements/pages/test_pages/button_test_page.html.haml +7 -0
  42. data/lib/ruby_app/elements/pages/test_pages/button_test_page.js.haml +3 -0
  43. data/lib/ruby_app/elements/pages/test_pages/button_test_page.rb +39 -0
  44. data/lib/ruby_app/elements/pages/test_pages/default_test_page.rb +8 -15
  45. data/lib/ruby_app/elements/pages/test_pages/dialog_test_page.rb +1 -1
  46. data/lib/ruby_app/elements/pages/test_pages/exception_test_page.html.haml +5 -0
  47. data/lib/ruby_app/elements/pages/test_pages/exception_test_page.rb +33 -0
  48. data/lib/ruby_app/elements/pages/test_pages/input_test_page.css.haml +1 -0
  49. data/lib/ruby_app/elements/pages/test_pages/input_test_page.html.haml +3 -0
  50. data/lib/ruby_app/elements/pages/test_pages/input_test_page.js.haml +1 -0
  51. data/lib/ruby_app/elements/pages/test_pages/input_test_page.rb +2 -0
  52. data/lib/ruby_app/elements/pages/test_pages/link_test_page.css.haml +3 -0
  53. data/lib/ruby_app/elements/pages/test_pages/link_test_page.html.haml +7 -0
  54. data/lib/ruby_app/elements/pages/test_pages/link_test_page.js.haml +3 -0
  55. data/lib/ruby_app/elements/pages/test_pages/link_test_page.rb +39 -0
  56. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.css.haml +2 -0
  57. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.html.haml +5 -0
  58. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.js.haml +2 -0
  59. data/lib/ruby_app/elements/pages/test_pages/linked_test_page.rb +30 -0
  60. data/lib/ruby_app/elements/pages/test_pages/list_test_page.css.haml +1 -0
  61. data/lib/ruby_app/elements/pages/test_pages/list_test_page.html.haml +2 -1
  62. data/lib/ruby_app/elements/pages/test_pages/list_test_page.js.haml +1 -0
  63. data/lib/ruby_app/elements/pages/test_pages/list_test_page.rb +16 -11
  64. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.css.haml +2 -0
  65. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.html.haml +5 -0
  66. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.js.haml +2 -0
  67. data/lib/ruby_app/elements/pages/test_pages/markdown_test_page.rb +38 -0
  68. data/lib/ruby_app/elements/pages/test_pages/select_test_page.rb +44 -0
  69. data/lib/ruby_app/elements/pages/test_pages/test_page.html.haml +14 -0
  70. data/lib/ruby_app/elements/pages/test_pages/test_page.rb +42 -0
  71. data/lib/ruby_app/language.rb +9 -12
  72. data/lib/ruby_app/log.rb +19 -9
  73. data/lib/ruby_app/mixins/{configuration.rb → configure_mixin.rb} +2 -2
  74. data/lib/ruby_app/mixins/{delegate.rb → delegate_mixin.rb} +1 -1
  75. data/lib/ruby_app/mixins/{hash.rb → hash_mixin.rb} +5 -1
  76. data/lib/ruby_app/mixins/{render.rb → render_mixin.rb} +2 -2
  77. data/lib/ruby_app/mixins/{route.rb → route_mixin.rb} +5 -5
  78. data/lib/ruby_app/mixins/{template.rb → template_mixin.rb} +11 -11
  79. data/lib/ruby_app/mixins/{translate.rb → translate_mixin.rb} +1 -1
  80. data/lib/ruby_app/rack/application.rb +3 -3
  81. data/lib/ruby_app/rack/route.rb +14 -30
  82. data/lib/ruby_app/request.rb +36 -13
  83. data/lib/ruby_app/session.rb +17 -23
  84. data/lib/ruby_app/translations/en.yml +77 -15
  85. data/lib/ruby_app/version.rb +1 -1
  86. data/rakefile +1 -12
  87. data/spec/application_spec.rb +25 -0
  88. data/spec/configuration_spec.rb +25 -0
  89. data/spec/element_spec.rb +54 -5
  90. data/spec/elements/navigation/breadcrumbs_spec.rb +17 -25
  91. data/spec/elements/page_spec.rb +2 -13
  92. data/spec/language_spec.rb +25 -0
  93. data/spec/log_spec.rb +25 -0
  94. data/spec/mixins/configure_mixin_spec.rb +24 -0
  95. data/spec/mixins/delegate_mixin_spec.rb +28 -0
  96. data/spec/mixins/hash_mixin_spec.rb +39 -0
  97. data/spec/mixins/render_mixin_spec.rb +127 -0
  98. data/spec/mixins/route_mixin_spec.rb +60 -0
  99. data/spec/mixins/{template_spec.rb → template_mixin_spec.rb} +3 -3
  100. data/spec/mixins/test_a.css.haml +4 -3
  101. data/spec/mixins/test_a.html.haml +0 -1
  102. data/spec/mixins/test_a.js.haml +4 -3
  103. data/spec/mixins/test_b.css.haml +4 -4
  104. data/spec/mixins/test_b.js.haml +2 -2
  105. data/spec/mixins/test_c.css.haml +4 -4
  106. data/spec/mixins/test_c.js.haml +2 -2
  107. data/spec/mixins/translate_mixin_spec.rb +25 -0
  108. data/spec/request_spec.rb +25 -0
  109. data/spec/session_spec.rb +39 -0
  110. data/spec/spec_helper.rb +7 -0
  111. data/spec/support/shared.rb +19 -5
  112. metadata +75 -38
  113. data/features/breadcrumbs.feature +0 -11
  114. data/features/content.feature +0 -16
  115. data/features/exception.feature +0 -53
  116. data/features/input.feature +0 -13
  117. data/features/list.feature +0 -12
  118. data/features/month.feature +0 -14
  119. data/spec/mixins/render_spec.rb +0 -191
  120. data/spec/mixins/route_spec.rb +0 -60
  121. data/spec/mixins/test_e.html.haml +0 -2
  122. data/spec/mixins/test_f.html.haml +0 -2
  123. data/spec/mixins/test_g.css.haml +0 -4
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ require 'ruby_app/mixins/configure_mixin'
4
+
5
+ describe RubyApp::Mixins::ConfigureMixin do
6
+ include_context 'RubyApp::Request'
7
+
8
+ describe 'positive' do
9
+
10
+ before(:all) do
11
+
12
+ class TestConfigureMixin
13
+ include RubyApp::Mixins::ConfigureMixin
14
+ end
15
+
16
+ end
17
+
18
+ let(:instance_a) { TestConfigureMixin.new }
19
+
20
+ specify { instance_a.should respond_to(:configure) }
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,28 @@
1
+ require 'ruby_app/mixins/delegate_mixin'
2
+
3
+ describe RubyApp::Mixins::DelegateMixin do
4
+
5
+ describe 'positive' do
6
+
7
+ before(:all) do
8
+
9
+ class TestDelegateMixin
10
+ extend RubyApp::Mixins::DelegateMixin
11
+
12
+ def get_a
13
+ return TestDelegateMixin
14
+ end
15
+
16
+ def self.get
17
+ TestDelegateMixin.new
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ specify { TestDelegateMixin.get_a.should == TestDelegateMixin }
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,39 @@
1
+ require 'ruby_app/mixins/hash_mixin'
2
+
3
+ describe RubyApp::Mixins::HashMixin do
4
+
5
+ describe 'positive' do
6
+
7
+ before(:all) do
8
+
9
+ class TestHashMixin
10
+ include RubyApp::Mixins::HashMixin
11
+
12
+ def initialize
13
+ @data = { :get_a => TestHashMixin }
14
+ end
15
+
16
+ def [](key)
17
+ @data[key]
18
+ end
19
+
20
+ def []=(key, value)
21
+ @data[key] = value
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
28
+ let(:instance_a) { TestHashMixin.new }
29
+
30
+ specify { instance_a.get_a.should == TestHashMixin }
31
+
32
+ specify do
33
+ instance_a.get_a = RubyApp::Mixins::HashMixin
34
+ instance_a.get_a.should == RubyApp::Mixins::HashMixin
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,127 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'haml'
5
+
6
+ require 'spec_helper'
7
+
8
+ require 'ruby_app/mixins/render_mixin'
9
+ require 'ruby_app/mixins/template_mixin'
10
+
11
+ describe RubyApp::Mixins::RenderMixin do
12
+ include_context 'RubyApp::Request'
13
+
14
+ before(:all) do
15
+
16
+ class TestA
17
+ extend RubyApp::Mixins::TemplateMixin
18
+ extend Haml::Helpers
19
+ include Haml::Helpers
20
+ extend RubyApp::Mixins::RenderMixin
21
+ include RubyApp::Mixins::RenderMixin
22
+ template_path(:all, File.dirname(__FILE__))
23
+ end
24
+
25
+ class TestB < TestA
26
+ template_path(:all, File.dirname(__FILE__))
27
+ end
28
+
29
+ class TestC < TestA
30
+ template_path(:all, File.dirname(__FILE__))
31
+ exclude_parent_template(:html)
32
+ end
33
+
34
+ class TestD < TestC
35
+ template_path(:all, File.dirname(__FILE__))
36
+ end
37
+
38
+ end
39
+
40
+ describe 'positive' do
41
+
42
+ describe 'class' do
43
+
44
+ specify { TestA.render(:css).should include('/* TestA */') }
45
+ specify { TestA.render(:css).scan(/TestA/).length.should == 1 }
46
+ specify { TestA.render(:js).should include('// TestA') }
47
+ specify { TestA.render(:js).scan(/TestA/).length.should == 1 }
48
+
49
+ describe 'including all derived class' do
50
+
51
+ specify { TestB.render(:css).should include('/* TestA */') }
52
+ specify { TestB.render(:css).should include('/* TestB */') }
53
+ specify { TestB.render(:js).should include('// TestA') }
54
+ specify { TestB.render(:js).should include('// TestB') }
55
+
56
+ end
57
+
58
+ describe 'including some derived class' do
59
+
60
+ specify { TestC.render(:css).should include('/* TestA */') }
61
+ specify { TestC.render(:css).should include('/* TestC */') }
62
+ specify { TestC.render(:js).should include('// TestA') }
63
+ specify { TestC.render(:js).should include('// TestC') }
64
+
65
+ end
66
+
67
+ describe 'render a derived class with no templates' do
68
+
69
+ specify { TestD.render(:css).should include('/* TestA */') }
70
+ specify { TestD.render(:css).should include('/* TestC */') }
71
+ specify { TestD.render(:js).should include('// TestA') }
72
+ specify { TestD.render(:js).should include('// TestC') }
73
+
74
+ end
75
+
76
+ end
77
+
78
+ describe 'instance' do
79
+
80
+ let(:instance_a) { TestA.new }
81
+ let(:instance_b) { TestB.new }
82
+ let(:instance_c) { TestC.new }
83
+ let(:instance_d) { TestD.new }
84
+
85
+ specify { instance_a.render(:html).should include('<!-- TestA -->') }
86
+ specify { instance_a.render(:html).scan(/TestA/).length.should == 1 }
87
+
88
+ describe 'include all derived instance' do
89
+
90
+ specify { instance_b.render(:html).should include('<!-- TestA -->') }
91
+ specify { instance_b.render(:html).should include('<!-- TestB -->') }
92
+
93
+ end
94
+
95
+ describe 'include some derived instance' do
96
+
97
+ specify { instance_c.render(:html).should include('<!-- TestC -->') }
98
+
99
+ end
100
+
101
+ describe 'render a derived instance with no templates' do
102
+
103
+ specify { instance_d.render(:html).should include('<!-- TestC -->') }
104
+
105
+ end
106
+
107
+ end
108
+
109
+ end
110
+
111
+ describe 'negative' do
112
+
113
+ describe 'instance' do
114
+
115
+ describe 'should not include some derived instance' do
116
+
117
+ let(:instance_c) { TestC.new }
118
+
119
+ specify { instance_c.render(:html).should_not include('<!-- TestA -->') }
120
+
121
+ end
122
+
123
+ end
124
+
125
+ end
126
+
127
+ end
@@ -0,0 +1,60 @@
1
+ require 'ruby_app/mixins/route_mixin'
2
+
3
+ describe RubyApp::Mixins::RouteMixin do
4
+
5
+ before(:all) do
6
+ Object.extend RubyApp::Mixins::RouteMixin
7
+ end
8
+
9
+ before(:each) do
10
+ @value = false
11
+ @parameters = nil
12
+ Object.clear_routes
13
+ end
14
+
15
+ describe 'positive' do
16
+
17
+ it 'should match a blank pattern on GET' do
18
+ Object.route(RubyApp::Mixins::RouteMixin::GET, /^$/) { @value = true }
19
+ @value.should be_false
20
+ Object.do_route(RubyApp::Mixins::RouteMixin::GET, '')
21
+ @value.should be_true
22
+ end
23
+
24
+ it 'should match a pattern on GET' do
25
+ Object.route(RubyApp::Mixins::RouteMixin::GET, /^pattern$/) { @value = true }
26
+ @value.should be_false
27
+ Object.do_route(RubyApp::Mixins::RouteMixin::GET, 'pattern')
28
+ @value.should be_true
29
+ end
30
+
31
+ it 'should match a pattern on POST' do
32
+ Object.route(RubyApp::Mixins::RouteMixin::POST, /^pattern$/) { @value = true }
33
+ @value.should be_false
34
+ Object.do_route(RubyApp::Mixins::RouteMixin::POST, 'pattern')
35
+ @value.should be_true
36
+ end
37
+
38
+ it 'should match a pattern on GET with a parameter' do
39
+ Object.route(RubyApp::Mixins::RouteMixin::GET, /^pattern (.*)$/) { |method, path, parameter| @value, @parameters = true, parameter }
40
+ @value.should be_false
41
+ @parameter.should be_nil
42
+ Object.do_route(RubyApp::Mixins::RouteMixin::GET, 'pattern parameter')
43
+ @value.should be_true
44
+ @parameters.should == 'parameter'
45
+ end
46
+
47
+ end
48
+
49
+ describe 'negative' do
50
+
51
+ it 'should not match a not matching pattern on GET' do
52
+ Object.route(RubyApp::Mixins::RouteMixin::GET, /^pattern$/) { @value = true }
53
+ @value.should be_false
54
+ Object.do_route(RubyApp::Mixins::RouteMixin::GET, 'not matching pattern')
55
+ @value.should be_false
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -1,11 +1,11 @@
1
- require 'ruby_app/mixins/template'
1
+ require 'ruby_app/mixins/template_mixin'
2
2
 
3
- describe RubyApp::Mixins::Template do
3
+ describe RubyApp::Mixins::TemplateMixin do
4
4
 
5
5
  before(:all) do
6
6
 
7
7
  class TestA
8
- extend RubyApp::Mixins::Template
8
+ extend RubyApp::Mixins::TemplateMixin
9
9
  template_path(:all, File.dirname(__FILE__))
10
10
  end
11
11
 
@@ -1,3 +1,4 @@
1
- :plain
2
- /* TestA */
3
- = yield :next_1
1
+ - self.rendered?(__FILE__) do
2
+ :sass
3
+ /* TestA
4
+ = yield
@@ -1,3 +1,2 @@
1
1
  / TestA
2
2
  = yield :next_1
3
- = yield
@@ -1,3 +1,4 @@
1
- :plain
2
- // TestA
3
- = yield :next_1
1
+ - self.rendered?(__FILE__) do
2
+ :plain
3
+ // TestA
4
+ = yield
@@ -1,4 +1,4 @@
1
- - self.content_for(:next_1) do
2
- :plain
3
- /* TestB */
4
- = yield :next_2
1
+ - self.rendered?(__FILE__) do
2
+ :sass
3
+ /* TestB
4
+ = yield
@@ -1,4 +1,4 @@
1
- - self.content_for(:next_1) do
1
+ - self.rendered?(__FILE__) do
2
2
  :plain
3
3
  // TestB
4
- = yield :next_2
4
+ = yield
@@ -1,4 +1,4 @@
1
- - self.content_for(:next_1) do
2
- :plain
3
- /* TestC */
4
- = yield :next_2
1
+ - self.rendered?(__FILE__) do
2
+ :sass
3
+ /* TestC
4
+ = yield
@@ -1,4 +1,4 @@
1
- - self.content_for(:next_1) do
1
+ - self.rendered?(__FILE__) do
2
2
  :plain
3
3
  // TestC
4
- = yield :next_2
4
+ = yield
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ require 'ruby_app/mixins/translate_mixin'
4
+
5
+ describe RubyApp::Mixins::TranslateMixin do
6
+ include_context 'RubyApp::Request'
7
+
8
+ describe 'positive' do
9
+
10
+ before(:all) do
11
+
12
+ class TestTranslateMixin
13
+ include RubyApp::Mixins::TranslateMixin
14
+ end
15
+
16
+ end
17
+
18
+ let(:instance_a) { TestTranslateMixin.new }
19
+
20
+ specify { instance_a.should respond_to(:translate) }
21
+ specify { instance_a.should respond_to(:localize) }
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ require 'ruby_app/request'
4
+
5
+ describe RubyApp::Request do
6
+ include_context 'RubyApp::Request'
7
+
8
+ describe 'positive' do
9
+
10
+ describe 'class' do
11
+
12
+ specify { RubyApp::Request.should respond_to('create!') }
13
+ specify { RubyApp::Request.should respond_to('get') }
14
+ specify { RubyApp::Request.should respond_to('destroy!') }
15
+
16
+ specify { RubyApp::Request.get.should_not be_nil }
17
+
18
+ end
19
+
20
+ end
21
+
22
+ describe 'negative' do
23
+ end
24
+
25
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ require 'ruby_app/session'
4
+
5
+ describe RubyApp::Session do
6
+ include_context 'RubyApp::Request'
7
+
8
+ describe 'positive' do
9
+
10
+ describe 'class' do
11
+
12
+ specify { RubyApp::Session.should respond_to('create!') }
13
+ specify { RubyApp::Session.should respond_to('get') }
14
+ specify { RubyApp::Session.should respond_to('destroy!') }
15
+
16
+ specify { RubyApp::Session.get.should_not be_nil }
17
+
18
+ end
19
+
20
+ describe 'instance' do
21
+
22
+ let(:session) { RubyApp::Session.get }
23
+
24
+ specify { session.should respond_to('pages') }
25
+ specify { session.should respond_to('[]') }
26
+ specify { session.should respond_to('[]=') }
27
+ specify { session.should respond_to('identity') }
28
+ specify { session.should respond_to('identity=') }
29
+ specify { session.should respond_to('show') }
30
+ specify { session.should respond_to('quit') }
31
+
32
+ end
33
+
34
+ end
35
+
36
+ describe 'negative' do
37
+ end
38
+
39
+ end