riot-rack 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.markdown +13 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/config.ru +3 -0
- data/lib/riot-rack.rb +60 -0
- data/test/autoload_test.rb +26 -0
- data/test/core_test.rb +33 -0
- data/test/teststrap.rb +6 -0
- metadata +97 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 brianc
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Riot-Rack
|
2
|
+
|
3
|
+
## usage
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'riot-rack'
|
7
|
+
context "My application" do
|
8
|
+
app = Proc.new { [200,{"Content-Type"=>"text/html"},["okay!"]] }
|
9
|
+
get "/"
|
10
|
+
asserts("okay") { last_request.status }.equals(200)
|
11
|
+
asserts("correct body") { last_request.body }.equals("okay!")
|
12
|
+
end
|
13
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "riot-rack"
|
8
|
+
gem.summary = %Q{Zero friction, convention based testing for your rack apps}
|
9
|
+
gem.description = %Q{Built on top the riot test framework, adds rack specific helpers and macros}
|
10
|
+
gem.email = "brian.m.carlson@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/brian.carlson/riot-rack"
|
12
|
+
gem.authors = ["brianc"]
|
13
|
+
gem.add_dependency "rack"
|
14
|
+
gem.add_dependency "rack-test"
|
15
|
+
gem.add_dependency "riot"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/*_test.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/*_test.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :test => :check_dependencies
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rake/rdoctask'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "riot-rack #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/config.ru
ADDED
data/lib/riot-rack.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'riot'
|
3
|
+
require 'rack/test'
|
4
|
+
module Riot
|
5
|
+
module Rack
|
6
|
+
module ContextExtensions
|
7
|
+
def app(app)
|
8
|
+
setup do
|
9
|
+
@app = app
|
10
|
+
def app; @app; end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(uri,&context_definition)
|
15
|
+
context("get #{uri}",&context_definition).last.setup do
|
16
|
+
get uri
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
module SituationExtensions
|
22
|
+
|
23
|
+
#the default behavior is to look for
|
24
|
+
#a config.ru file starting with current
|
25
|
+
#directory and working our way back
|
26
|
+
def app
|
27
|
+
file = app_file
|
28
|
+
::Rack::Builder.new {
|
29
|
+
contents = ::File.readlines(file).join("\n")
|
30
|
+
instance_eval(contents)
|
31
|
+
}.to_app
|
32
|
+
end
|
33
|
+
|
34
|
+
def app_file
|
35
|
+
@app_file || find_app_file
|
36
|
+
end
|
37
|
+
|
38
|
+
def app_file=(file)
|
39
|
+
@app_file = file
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def find_app_file
|
44
|
+
if Dir.glob("config.ru").length > 0
|
45
|
+
File.join(Dir.pwd,"config.ru")
|
46
|
+
elsif Dir.pwd != "/"
|
47
|
+
Dir.chdir("..") { find_app_file }
|
48
|
+
else
|
49
|
+
raise "Cannot find config.ru"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
Riot::Context.instance_eval { include Riot::Rack::ContextExtensions }
|
57
|
+
Riot::Situation.instance_eval do
|
58
|
+
include Rack::Test::Methods
|
59
|
+
include Riot::Rack::SituationExtensions
|
60
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__)+"/teststrap.rb"
|
2
|
+
|
3
|
+
context "Autoloading" do
|
4
|
+
|
5
|
+
context "from the test directory" do
|
6
|
+
setup {
|
7
|
+
Dir.chdir(File.dirname(__FILE__))
|
8
|
+
}
|
9
|
+
|
10
|
+
get "/" do
|
11
|
+
asserts('works') { last_response.body }.equals("yo!")
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
context "from the project root directory" do
|
17
|
+
setup {
|
18
|
+
Dir.chdir(File.join(File.dirname(__FILE__)+"/.."))
|
19
|
+
}
|
20
|
+
|
21
|
+
get "/" do
|
22
|
+
should("work") { last_response.body }.equals('yo!')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/test/core_test.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__)+'/teststrap.rb'
|
2
|
+
|
3
|
+
context "My test application" do
|
4
|
+
app Proc.new { [200,{"Content-Type"=>"text/html"},["okay!"]] }
|
5
|
+
|
6
|
+
get "/" do
|
7
|
+
asserts("is okay") { last_response.status }.equals(200)
|
8
|
+
should("has the correct body") { last_response.body }.equals("okay!")
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
context "Situation" do
|
15
|
+
setup { Riot::Situation.new }
|
16
|
+
|
17
|
+
asserts_topic.respond_to :last_response
|
18
|
+
asserts_topic.respond_to :last_response
|
19
|
+
asserts_topic.respond_to :app_file
|
20
|
+
asserts_topic.respond_to :app_file=
|
21
|
+
|
22
|
+
context "finding config.ru" do
|
23
|
+
|
24
|
+
asserts("finds from within test directory") {
|
25
|
+
Dir.chdir(File.dirname(__FILE__)) { topic.app_file }
|
26
|
+
}.matches(/riot-rack\/config.ru/)
|
27
|
+
|
28
|
+
asserts("from within the project directory") {
|
29
|
+
Dir.chdir(File.join(File.dirname(__FILE__),"..")) { topic.app_file }
|
30
|
+
}.matches(/riot-rack\/config.ru/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
data/test/teststrap.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riot-rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- brianc
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-06 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rack
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rack-test
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: riot
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: Built on top the riot test framework, adds rack specific helpers and macros
|
46
|
+
email: brian.m.carlson@gmail.com
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.markdown
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE
|
58
|
+
- README.markdown
|
59
|
+
- Rakefile
|
60
|
+
- VERSION
|
61
|
+
- config.ru
|
62
|
+
- lib/riot-rack.rb
|
63
|
+
- test/autoload_test.rb
|
64
|
+
- test/core_test.rb
|
65
|
+
- test/teststrap.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/brian.carlson/riot-rack
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --charset=UTF-8
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.3.5
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Zero friction, convention based testing for your rack apps
|
94
|
+
test_files:
|
95
|
+
- test/autoload_test.rb
|
96
|
+
- test/core_test.rb
|
97
|
+
- test/teststrap.rb
|