sinatra-test-helper 0.4.0.a
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +40 -0
- data/lib/sinatra/bacon.rb +10 -0
- data/lib/sinatra/rspec.rb +11 -0
- data/lib/sinatra/test/spec.rb +1 -0
- data/lib/sinatra/test/unit.rb +1 -0
- data/lib/sinatra/test_helper.rb +49 -0
- data/lib/sinatra/test_spec.rb +1 -0
- data/lib/sinatra/test_unit.rb +10 -0
- metadata +80 -0
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Sinatra::TestHelper
|
2
|
+
===================
|
3
|
+
|
4
|
+
Adds helper methods and better integration for various testing frameworks to [Sinatra](http://sinatrarb.com).
|
5
|
+
|
6
|
+
BigBand
|
7
|
+
-------
|
8
|
+
|
9
|
+
Sinatra::TestHelper is part of the [BigBand](http://github.com/rkh/big_band) stack.
|
10
|
+
Check it out if you are looking for other fancy Sinatra extensions.
|
11
|
+
|
12
|
+
Frameworks
|
13
|
+
----------
|
14
|
+
|
15
|
+
Currently Sinatra::TestHelper ships with support for:
|
16
|
+
* Bacon
|
17
|
+
* RSpec
|
18
|
+
* Test::Spec
|
19
|
+
* Test::Unit
|
20
|
+
|
21
|
+
Usage
|
22
|
+
-----
|
23
|
+
|
24
|
+
In you test\_helper.rb or spec\_helper.rb (or your test), place this line:
|
25
|
+
|
26
|
+
require "sinatra/YOUR_FRAMEWORK"
|
27
|
+
|
28
|
+
Example:
|
29
|
+
|
30
|
+
require "sinatra/rspec"
|
31
|
+
require "sinatra/funky_extension"
|
32
|
+
|
33
|
+
describe Sinatra::FunkyExtension do
|
34
|
+
# Let's always start with an empty app, using Sinatra::FunkyExtension
|
35
|
+
before { app :FunkyExtension }
|
36
|
+
it "should do funky thinks" do
|
37
|
+
define_route(:get, '/funky') { "funky" }
|
38
|
+
browse_route(:get, '/funky').body.should == "funky"
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "sinatra/test_spec"
|
@@ -0,0 +1 @@
|
|
1
|
+
require "sinatra/test_unit"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
require "sinatra/sugar"
|
3
|
+
require "rack/test"
|
4
|
+
|
5
|
+
Sinatra::Base.set :environment, :test
|
6
|
+
|
7
|
+
module Sinatra
|
8
|
+
Base.ignore_caller
|
9
|
+
# This encapsulates general test helpers. See Bacon, RSpec, Test::Spec and Test::Unit for examples.
|
10
|
+
module TestHelper
|
11
|
+
include ::Rack::Test::Methods
|
12
|
+
|
13
|
+
attr_writer :app
|
14
|
+
def app(*options, &block)
|
15
|
+
unless block.nil? and options.empty?
|
16
|
+
options.map! do |option|
|
17
|
+
case option
|
18
|
+
when String, Symbol then Sinatra.const_get option
|
19
|
+
when Module, Hash then option
|
20
|
+
else raise ArgumentError, "cannot handle #{option.inspect}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
superclass = options.shift if options.first.is_a? Class
|
24
|
+
superclass ||= Sinatra::Base
|
25
|
+
@app = Class.new(superclass, &block)
|
26
|
+
inspection = "app"
|
27
|
+
inspection << "(" << options.map { |o| o.inspect }.join(", ") << ")" unless options.empty?
|
28
|
+
inspection << " { ... }" if block
|
29
|
+
options.each do |option|
|
30
|
+
if option.is_a? Hash then @app.set option
|
31
|
+
else @app.register option
|
32
|
+
end
|
33
|
+
@app.class_eval "def self.inspect; #{inspection.inspect}; end"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
@app || Sinatra::Application
|
37
|
+
end
|
38
|
+
|
39
|
+
def define_route(verb, *args, &block)
|
40
|
+
app.send(verb, *args, &block)
|
41
|
+
end
|
42
|
+
|
43
|
+
def browse_route(verb, *args, &block)
|
44
|
+
send(verb, *args, &block)
|
45
|
+
last_response
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "sinatra/test_unit"
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-test-helper
|
3
|
+
version: &id001 !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0.a
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Haase
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-15 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: monkey-lib
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- *id001
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: sinatra
|
26
|
+
type: :runtime
|
27
|
+
version_requirement:
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.4
|
33
|
+
version:
|
34
|
+
description: Test helper for Sinatra (part of BigBand).
|
35
|
+
email: konstantin.mailinglists@googlemail.com
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files: []
|
41
|
+
|
42
|
+
files:
|
43
|
+
- lib/sinatra/bacon.rb
|
44
|
+
- lib/sinatra/rspec.rb
|
45
|
+
- lib/sinatra/test/spec.rb
|
46
|
+
- lib/sinatra/test/unit.rb
|
47
|
+
- lib/sinatra/test_helper.rb
|
48
|
+
- lib/sinatra/test_spec.rb
|
49
|
+
- lib/sinatra/test_unit.rb
|
50
|
+
- README.md
|
51
|
+
has_rdoc: yard
|
52
|
+
homepage: http://github.com/rkh/sinatra-test-helper
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.1
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Test helper for Sinatra (part of BigBand).
|
79
|
+
test_files: []
|
80
|
+
|