public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
Search Repo:
reorganized with cascading helpers
automatthew (author)
Fri May 30 10:20:56 -0700 2008
commit  714726e17b6749587ad4b717cc19def531c2aeb3
tree    96c43b5b7f802ec86b40c387e0866545fda31d4d
parent  1ca657edeb9c7f9ae01a1404c3f61f5517dd17e6
...
71
72
73
74
75
76
77
78
79
...
71
72
73
 
 
 
74
75
76
0
@@ -71,9 +71,6 @@ require 'renderers/mixin'
0
 require 'renderers/erubis'
0
 require 'renderers/markaby'
0
 
0
-# waves test support
0
-require 'verify/mapping.rb'
0
-require 'verify/request.rb'
0
 
0
 # waves foundations / layers
0
 require 'layers/simple'
...
1
2
3
4
5
6
7
8
9
10
11
12
 
...
 
 
 
 
 
 
 
 
 
 
 
 
1
0
@@ -1,12 +1 @@
0
-%w( rubygems bacon extensions/all).each { |f| require f }
0
-
0
-Bacon.extend Bacon::TestUnitOutput
0
-Bacon.summary_on_exit
0
-
0
-# Prepend the framework lib to the loadpath
0
-$:.unshift( File.join(File.dirname(__FILE__), "..", "..", "lib") )
0
-require 'waves'
0
-
0
-def defined
0
- lambda { |obj| defined?(obj) }
0
-end
0
+require File.join(File.dirname(__FILE__) , "..", "helpers")
...
22
23
24
25
26
...
22
23
24
 
25
0
@@ -22,5 +22,4 @@ describe "An application module which includes the Simple foundation" do
0
     SimpleApplication::Configurations.should.respond_to :[]
0
   end
0
 
0
-
0
 end
...
1
2
3
4
 
5
6
7
8
9
10
11
12
13
14
 
 
15
16
17
18
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
 
 
 
 
 
 
 
 
 
25
 
 
 
...
 
 
 
 
1
2
3
4
5
6
 
 
 
 
 
7
8
9
10
11
12
13
14
 
 
 
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
0
@@ -1,25 +1,75 @@
0
-%w( rubygems bacon ).each { |f| require f }
0
-
0
-Bacon.extend Bacon::TestUnitOutput
0
-Bacon.summary_on_exit
0
+%w( rubygems bacon facon ).each { |f| require f }
0
 
0
 # Prepend the framework lib to the loadpath
0
 $:.unshift( File.join(File.dirname(__FILE__), "..", "lib") )
0
 require 'waves'
0
 
0
-# define basic app for use in testing
0
-# before methods may add to it using helper methods
0
-module Test ; include Waves::Foundations::Simple ; end
0
-Waves << Test
0
-Waves::Console.load( :mode => :development )
0
+Bacon.extend Bacon::TestUnitOutput
0
+Bacon.summary_on_exit
0
 
0
 module Kernel
0
   private
0
   def specification(name, &block) Bacon::Context.new(name, &block) end
0
 end
0
 
0
-Bacon::Context.instance_eval do
0
- include ::Waves::Verify::Helpers::Mapping
0
- include ::Waves::Verify::Helpers::Request
0
+
0
+Bacon::Context.module_eval do
0
+
0
+ # Mapping helpers
0
+ def mapping
0
+ ::Waves::Application.instance.mapping
0
+ end
0
+
0
+ %w{ path url always handle threaded generator}.each do |method|
0
+ module_eval "def #{method}(*args,&block); mapping.#{method}(*args,&block);end"
0
+ end
0
+
0
+ # Rack request helpers
0
+ ::Rack::MockRequest::DEFAULT_ENV.merge!(
0
+ 'REMOTE_ADDR' => '127.0.0.1',
0
+ 'REMOTE_HOST' => 'localhost',
0
+ 'SERVER_NAME' => 'localhost',
0
+ 'SERVER_PORT' => '3000',
0
+ 'SERVER_PORT_SECURE' => '0',
0
+ 'SERVER_PROTOCOL' => 'HTTP/1.1',
0
+ 'SERVER_SOFTWARE' => 'Waves 1.0',
0
+ 'HTTP_HOST' => 'localhost',
0
+ 'HTTP_VERSION' => 'HTTP/1.1',
0
+ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14',
0
+ 'HTTP_CACHE_CONTROL' => 'max-age=0',
0
+ 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
0
+ 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
0
+ 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
0
+ 'HTTP_ACCEPT_ENCODING' => 'gzip,compress;q=0.5,*;q=0.0,',
0
+ 'HTTP_CONNECTION' => 'keep-alive',
0
+ 'HTTP_KEEP_ALIVE' => '300',
0
+ 'HTTP_REFERER' => 'http://localhost/',
0
+ 'GATEWAY_INTERFACE' => 'CGI/1.1'
0
+ )
0
+
0
+ def request
0
+ @request ||= ::Rack::MockRequest.new( ::Waves::Dispatchers::Default.new )
0
+ end
0
+
0
+ def get(uri, opts={}) request.get(uri, opts) end
0
+ def post(uri, opts={}) request.post(uri, opts) end
0
+ def put(uri, opts={}) request.put(uri, opts) end
0
+ def delete(uri, opts={}) request.delete(uri, opts) end
0
+
0
+
0
+ # Testing helpers
0
   alias_method :specify, :it
0
+
0
+ def wrap(&block)
0
+ @before << block
0
+ @after << block
0
+ end
0
+
0
+ def rm_if_exist(name)
0
+ FileUtils.rm name if File.exist? name
0
+ end
0
+
0
 end
0
+
0
+
0
+
...
1
2
3
4
5
6
 
7
8
9
...
17
18
19
20
 
21
22
23
24
25
...
1
2
3
 
 
 
4
5
6
7
...
15
16
17
 
18
19
 
20
21
22
0
@@ -1,9 +1,7 @@
0
 # require 'test_helper' because RubyMate needs help
0
 require File.join(File.dirname(__FILE__) , "helpers")
0
 
0
-include ::Waves::Verify::Helpers::Request
0
-
0
-module DEApplication
0
+module DefaultErrorsApp
0
   include Waves::Foundations::Simple
0
   include Waves::Layers::DefaultErrors
0
   module Views
0
@@ -17,9 +15,8 @@ module DEApplication
0
   stub!(:views).and_return(Views)
0
 end
0
 
0
-Waves << DEApplication
0
+Waves << DefaultErrorsApp
0
 Waves::Console.load( :mode => :development )
0
-DEA = DEApplication
0
 
0
 
0
 describe "An application which includes the DefaultErrors layer" do
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
0
@@ -1,18 +1 @@
0
-%w( rubygems bacon facon extensions/all).each { |f| require f }
0
-
0
-Bacon.extend Bacon::TestUnitOutput
0
-Bacon.summary_on_exit
0
-
0
-# Prepend the framework lib to the loadpath
0
-$:.unshift( File.join(File.dirname(__FILE__), "..", "..", "lib") )
0
-require 'waves'
0
-
0
-def rm_if_exist(name)
0
- FileUtils.rm name if File.exist? name
0
-end
0
-
0
-# add block to Bacon's before and after blocks
0
-def wrap(&block)
0
- @before << block
0
- @after << block
0
-end
0
+require File.join(File.dirname(__FILE__) , "..", "helpers")
...
1
2
3
4
 
 
5
6
7
...
1
 
 
 
2
3
4
5
6
0
@@ -1,7 +1,6 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
-
0
-require 'facon'
0
+require File.join(File.dirname(__FILE__), "helpers")
0
+::TEST_VALUE = 'foo'
0
 
0
 specification "A developer can ensure" do
0
 
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 describe "A developer can map requests to filters." do
0
 
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 specification "A developer can register exception handlers" do
0
 
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 specification "A developer can extract parameters from a request path or URL." do
0
 
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 specification "A developer can register named mappings" do
0
 
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 specification "A developer can map requests with options." do
0
 
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 specification "A developer can map requests using the request path." do
0
 
...
1
2
 
3
4
5
6
7
 
8
9
10
11
 
12
13
14
15
16
17
18
 
19
20
21
...
1
 
2
3
4
5
6
 
7
8
9
10
 
11
12
13
14
15
16
17
 
18
19
20
21
0
@@ -1,21 +1,21 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 # Note: you have to define the resource classes using module_eval here, because otherwise
0
 # the auto_create code never gets triggered in the application.
0
 
0
-module Test
0
+module MappingApp
0
   include Waves::Layers::MVC
0
 end
0
 
0
-Test::Controllers.module_eval do
0
+MappingApp::Controllers.module_eval do
0
   class Animal
0
     include Waves::Controllers::Mixin
0
     def cow() 'Moo!' end
0
   end
0
 end
0
 
0
-Test::Views.module_eval do
0
+MappingApp::Views.module_eval do
0
   class Animal
0
     include Waves::Views::Mixin
0
     def say( says ) "This animal says: '#{says}'" end
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 # require 'test_helper' because RubyMate needs help
0
-require File.join(File.dirname(__FILE__), "..", "helpers")
0
+require File.join(File.dirname(__FILE__), "helpers")
0
 
0
 specification "Requests can be made threaded for event driven servers" do
0
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
20
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
0
@@ -1,18 +1 @@
0
-%w( rubygems bacon facon extensions/all).each { |f| require f }
0
-
0
-Bacon.extend Bacon::TestUnitOutput
0
-Bacon.summary_on_exit
0
-
0
-# Prepend the framework lib to the loadpath
0
-$:.unshift( File.join(File.dirname(__FILE__), "..", "..", "lib") )
0
-require 'waves'
0
-
0
-def rm_if_exist(name)
0
- FileUtils.rm name if File.exist? name
0
-end
0
-
0
-# add block to Bacon's before and after blocks
0
-def wrap(&block)
0
- @before << block
0
- @after << block
0
-end
0
\ No newline at end of file
0
+require File.join(File.dirname(__FILE__) , "..", "helpers")
0
\ No newline at end of file

Comments

    No one has commented yet.