innate 2009.05 → 2009.06

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ require 'spec/helper'
2
+
3
+ class SpecModeDummy
4
+ Innate.node '/'
5
+
6
+ def index
7
+ 'Hello, World!'
8
+ end
9
+
10
+ def random
11
+ rand.to_s
12
+ end
13
+ end
14
+
15
+ describe 'Innate modes' do
16
+ describe 'dev' do
17
+ behaves_like :rack_test
18
+ Innate.options.mode = :dev
19
+
20
+ should 'handle GET request' do
21
+ get('/').status.
22
+ should == 200
23
+ last_response.headers.
24
+ should == {'Content-Length' => '13', 'Content-Type' => 'text/html'}
25
+ last_response.body.
26
+ should == 'Hello, World!'
27
+ end
28
+
29
+ should 'handle HEAD requests by omitting body' do
30
+ head('/').status.
31
+ should == 200
32
+ last_response.headers.
33
+ should == {'Content-Length' => '13', 'Content-Type' => 'text/html'}
34
+ last_response.body.
35
+ should == ''
36
+ end
37
+ end
38
+
39
+ describe 'live' do
40
+ behaves_like :rack_test
41
+ Innate.options.mode = :live
42
+
43
+ should 'handle GET request' do
44
+ get('/').status.
45
+ should == 200
46
+ last_response.headers.
47
+ should == {'Content-Length' => '13', 'Content-Type' => 'text/html'}
48
+ last_response.body.
49
+ should == 'Hello, World!'
50
+ end
51
+
52
+ should 'handle HEAD requests by omitting body' do
53
+ head('/').status.
54
+ should == 200
55
+ last_response.headers.
56
+ should == {'Content-Length' => '13', 'Content-Type' => 'text/html'}
57
+ last_response.body.
58
+ should == ''
59
+ end
60
+ end
61
+ end
@@ -77,7 +77,7 @@ class SpecNodeAliasView < SpecNodeProvideTemplate
77
77
  end
78
78
 
79
79
  describe 'Innate::Node' do
80
- behaves_like :mock
80
+ behaves_like :rack_test
81
81
 
82
82
  should 'respond with 404 if no action was found' do
83
83
  got = Innate::Mock.get('/does_not_exist')
@@ -38,7 +38,7 @@ end
38
38
 
39
39
 
40
40
  describe 'Node#wrap_action_call' do
41
- behaves_like :mock
41
+ behaves_like :rack_test
42
42
 
43
43
  it 'executes our wrapper' do
44
44
  SPEC_WRAP_LOG.clear
@@ -106,7 +106,11 @@ describe Options do
106
106
  require 'pp'
107
107
  p = PP.new
108
108
  @options.pretty_print(p)
109
- p.output.should =~ /:value=>:mom/
109
+ lines = p.output.split(/\n/)
110
+ lines.find_all{|l|
111
+ /:doc/ === l &&
112
+ /:value/ === l
113
+ }.size.should > 3
110
114
  end
111
115
 
112
116
  should 'trigger block when option is changed' do
@@ -49,7 +49,7 @@ end
49
49
 
50
50
  describe 'Content representation' do
51
51
  describe 'without template' do
52
- behaves_like :mock, :assert_wish
52
+ behaves_like :rack_test, :assert_wish
53
53
 
54
54
  it 'provides yaml for an object' do
55
55
  assert_wish('/object.yaml', {'intro' => 'Hello, World!'}.to_yaml, 'text/yaml')
@@ -69,7 +69,7 @@ describe 'Content representation' do
69
69
  end
70
70
 
71
71
  describe 'with templates' do
72
- behaves_like :mock, :assert_wish
72
+ behaves_like :rack_test, :assert_wish
73
73
 
74
74
  it 'defaults to <name>.html.<engine>' do
75
75
  body = '<ul><li>starbucks</li><li>apollo</li><li>athena</li></ul>'
@@ -44,11 +44,13 @@ describe Innate::Request do
44
44
  end
45
45
 
46
46
  should 'provide #subset' do
47
- params = {'a' => 'b', 'c' => 'd', 'e' => 'f'}
48
- env = { 'rack.request.form_hash' => params }
49
- req = request(env)
47
+ require 'stringio'
50
48
 
51
- req.params.should == params
49
+ query = {'a' => 'b', 'c' => 'd', 'e' => 'f'}
50
+ params = StringIO.new(Rack::Utils.build_query(query))
51
+ req = request('rack.request.form_hash' => params, 'rack.input' => params)
52
+
53
+ req.params.should == query
52
54
  req.subset(:a).should == {'a' => 'b'}
53
55
  req.subset(:a, :c).should == {'a' => 'b', 'c' => 'd'}
54
56
  end
@@ -29,7 +29,7 @@ class SpecSession
29
29
  end
30
30
 
31
31
  describe Innate::Session do
32
- behaves_like :mock
32
+ behaves_like :rack_test
33
33
 
34
34
  should 'initiate session as needed' do
35
35
  get '/'
@@ -51,4 +51,8 @@ describe Innate::Session do
51
51
  get('/decrement').body.should == n.to_s
52
52
  end
53
53
  end
54
+
55
+ should 'expose sid method' do
56
+ Innate::Current.session.sid.should.not.be.empty
57
+ end
54
58
  end
@@ -1,14 +1,17 @@
1
- task :gem_installer do
2
- class GemInstaller
1
+ task :gem_setup do
2
+ class GemSetup
3
3
  def initialize(options = {}, &block)
4
4
  @gems = []
5
- @options = options
5
+ @options = options.dup
6
+ @verbose = @options.delete(:verbose)
6
7
 
7
8
  run(&block)
8
9
  end
9
10
 
10
11
  def run(&block)
11
- instance_eval(&block) if block_given?
12
+ return unless block_given?
13
+ instance_eval(&block)
14
+ setup
12
15
  end
13
16
 
14
17
  def gem(name, version = nil, options = {})
@@ -21,6 +24,16 @@ task :gem_installer do
21
24
  @gems << [name, options]
22
25
  end
23
26
 
27
+ # all gems defined, let's try to load/install them
28
+ def setup
29
+ require 'rubygems'
30
+ require 'rubygems/dependency_installer'
31
+
32
+ @gems.each do |name, options|
33
+ setup_gem(name, options)
34
+ end
35
+ end
36
+
24
37
  def setup_gemspec(gemspec)
25
38
  gemspec.dependencies.each do |dependency|
26
39
  dependency.version_requirements.as_list.each do |version|
@@ -31,36 +44,31 @@ task :gem_installer do
31
44
  setup
32
45
  end
33
46
 
34
- def setup
35
- require 'rubygems'
36
- require 'rubygems/dependency_installer'
47
+ # first try to activate, install and try to activate again if activation
48
+ # fails the first time
49
+ def setup_gem(name, options)
50
+ version = [options[:version]].compact
51
+ lib_name = options[:lib] || name
37
52
 
38
- @gems.each do |name, options|
39
- setup_gem(name, options)
40
- end
41
- end
53
+ log "activating #{name}"
42
54
 
43
- def setup_gem(name, options, try_install = true)
44
- print "activating #{name} ... "
45
- Gem.activate(name, *[options[:version]].compact)
46
- require(options[:lib] || name)
47
- puts "success."
48
- rescue LoadError => error
49
- puts error
50
- install_gem(name, options) if try_install
51
- setup_gem(name, options, try_install = false)
55
+ Gem.activate(name, *version)
56
+ rescue LoadError
57
+ install_gem(name, options)
58
+ Gem.activate(name, *version)
52
59
  end
53
60
 
61
+ # tell rubygems to install a gem
54
62
  def install_gem(name, options)
55
63
  installer = Gem::DependencyInstaller.new(options)
56
64
 
57
65
  temp_argv(options[:extconf]) do
58
- print "Installing #{name} ... "
66
+ log "Installing #{name}"
59
67
  installer.install(name, options[:version])
60
- puts "done."
61
68
  end
62
69
  end
63
70
 
71
+ # prepare ARGV for rubygems installer
64
72
  def temp_argv(extconf)
65
73
  if extconf ||= @options[:extconf]
66
74
  old_argv = ARGV.clone
@@ -72,5 +80,20 @@ task :gem_installer do
72
80
  ensure
73
81
  ARGV.replace(old_argv) if extconf
74
82
  end
83
+
84
+ private
85
+
86
+ def log(msg)
87
+ return unless @verbose
88
+
89
+ if defined?(Log)
90
+ Log.info(msg)
91
+ else
92
+ puts(msg)
93
+ end
94
+ end
95
+
96
+ def rubyforge; 'http://gems.rubyforge.org/' end
97
+ def github; 'http://gems.github.com/' end
75
98
  end
76
99
  end
data/tasks/release.rake CHANGED
@@ -29,7 +29,8 @@ INSTRUCTIONS
29
29
  To publish to rubyforge do following:
30
30
 
31
31
  rubyforge login
32
- rubyforge add_release #{name} '#{version}' pkg/#{name}-#{version}.gem
32
+ rubyforge add_release #{name} #{name} '#{version}' pkg/#{name}-#{version}.gem
33
+
33
34
 
34
35
  After you have done these steps, see:
35
36
 
@@ -41,8 +42,9 @@ INSTRUCTIONS
41
42
  desc 'Display instructions to add archives after release:rubyforge'
42
43
  task :rubyforge_archives do
43
44
  puts "Adding archives for distro packagers is:", ""
45
+ name, version = GEMSPEC.name, GEMSPEC.version
44
46
 
45
- Dir["pkg/#{name}-#{version}.{gz,zip}"].each do |file|
47
+ Dir["pkg/#{name}-#{version}.{tgz,zip}"].each do |file|
46
48
  puts "rubyforge add_file #{name} #{name} '#{version}' '#{file}'"
47
49
  end
48
50
 
data/tasks/setup.rake CHANGED
@@ -1,28 +1,6 @@
1
- # Currently, Innate is not usable without Rack from the master branch head.
2
- # Also, our specs now depend on the latest rack-test.
3
- #
4
- # In order to make setup simpler for folks, I'll put up some gemspecs on github
5
- # and use their automatic building to provide development versions of these
6
- # libraries as gems for easier deployment.
7
- #
8
- # Once the libraries are officially released in a usable state I'll switch
9
- # dependencies to the official ones again.
10
- #
11
- # Please note that this makes running in environments that enforce their own
12
- # Rack (like jruby-rack) still quite difficult, but should allow for easier
13
- # development.
14
- #
15
- # Please be patient.
16
-
17
- desc 'install dependencies'
18
- task :setup do
19
- GemInstaller.new do
20
- gem 'bacon', '>= 1.0'
21
- gem 'json', '~> 1.1.3'
22
-
23
- gem 'manveru-rack-test', '> 0.1.0', :lib => 'rack-test'
24
- gem 'manveru-rack', '>= 0.9.9', :lib => 'rack'
25
-
26
- setup
1
+ desc 'install dependencies from gemspec'
2
+ task :setup => [:gem_setup] do
3
+ GemSetup.new :verbose => true do
4
+ setup_gemspec GEMSPEC
27
5
  end
28
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: innate
3
3
  version: !ruby/object:Gem::Version
4
- version: "2009.05"
4
+ version: "2009.06"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael 'manveru' Fellinger
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-07 00:00:00 +09:00
12
+ date: 2009-06-02 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,36 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.0.0
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: bacon
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.0
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: json
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.6
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: rack-test
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.0
54
+ version:
25
55
  description: Simple, straight-forward base for web-frameworks.
26
56
  email: m.fellinger@gmail.com
27
57
  executables: []
@@ -89,6 +119,7 @@ files:
89
119
  - lib/innate/session.rb
90
120
  - lib/innate/session/flash.rb
91
121
  - lib/innate/spec.rb
122
+ - lib/innate/spec/bacon.rb
92
123
  - lib/innate/state.rb
93
124
  - lib/innate/state/accessor.rb
94
125
  - lib/innate/traited.rb
@@ -126,6 +157,7 @@ files:
126
157
  - spec/innate/helper/view/partial.xhtml
127
158
  - spec/innate/helper/view/recursive.xhtml
128
159
  - spec/innate/mock.rb
160
+ - spec/innate/modes.rb
129
161
  - spec/innate/node/mapping.rb
130
162
  - spec/innate/node/node.rb
131
163
  - spec/innate/node/resolve.rb
@@ -148,9 +180,8 @@ files:
148
180
  - tasks/bacon.rake
149
181
  - tasks/changelog.rake
150
182
  - tasks/gem.rake
151
- - tasks/gem_installer.rake
183
+ - tasks/gem_setup.rake
152
184
  - tasks/grancher.rake
153
- - tasks/install_dependencies.rake
154
185
  - tasks/manifest.rake
155
186
  - tasks/rcov.rake
156
187
  - tasks/release.rake
@@ -181,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
212
  requirements: []
182
213
 
183
214
  rubyforge_project: innate
184
- rubygems_version: 1.3.2
215
+ rubygems_version: 1.3.3
185
216
  signing_key:
186
217
  specification_version: 3
187
218
  summary: Powerful web-framework wrapper for Rack.
@@ -1,4 +0,0 @@
1
- desc 'install dependencies from gemspec'
2
- task :install_dependencies => [:gem_installer] do
3
- GemInstaller.new{ setup_gemspec(GEMSPEC) }
4
- end