sinatra-test-helper 0.4.0.a → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -0
- data/lib/sinatra/bacon.rb +1 -2
- data/lib/sinatra/contest.rb +2 -0
- data/lib/sinatra/minitest.rb +9 -0
- data/lib/sinatra/mspec.rb +10 -0
- data/lib/sinatra/protest.rb +9 -0
- data/lib/sinatra/rspec.rb +0 -1
- data/lib/sinatra/test_helper.rb +12 -4
- data/lib/sinatra/test_spec.rb +2 -1
- data/lib/sinatra/test_unit.rb +0 -1
- data/spec/sinatra/test_helper_spec.rb +74 -0
- data/spec/spec_helper.rb +1 -0
- metadata +55 -17
data/README.md
CHANGED
@@ -9,11 +9,22 @@ BigBand
|
|
9
9
|
Sinatra::TestHelper is part of the [BigBand](http://github.com/rkh/big_band) stack.
|
10
10
|
Check it out if you are looking for other fancy Sinatra extensions.
|
11
11
|
|
12
|
+
|
13
|
+
Installation
|
14
|
+
------------
|
15
|
+
|
16
|
+
gem install sinatra-test-helper
|
17
|
+
|
12
18
|
Frameworks
|
13
19
|
----------
|
14
20
|
|
15
21
|
Currently Sinatra::TestHelper ships with support for:
|
22
|
+
|
16
23
|
* Bacon
|
24
|
+
* Contest
|
25
|
+
* Minitest
|
26
|
+
* MSpec
|
27
|
+
* Protest
|
17
28
|
* RSpec
|
18
29
|
* Test::Spec
|
19
30
|
* Test::Unit
|
data/lib/sinatra/bacon.rb
CHANGED
data/lib/sinatra/rspec.rb
CHANGED
data/lib/sinatra/test_helper.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "sinatra/base"
|
2
2
|
require "sinatra/sugar"
|
3
3
|
require "rack/test"
|
4
|
+
require "forwardable"
|
5
|
+
require "monkey"
|
4
6
|
|
5
7
|
Sinatra::Base.set :environment, :test
|
6
8
|
|
@@ -9,6 +11,9 @@ module Sinatra
|
|
9
11
|
# This encapsulates general test helpers. See Bacon, RSpec, Test::Spec and Test::Unit for examples.
|
10
12
|
module TestHelper
|
11
13
|
include ::Rack::Test::Methods
|
14
|
+
extend Forwardable
|
15
|
+
|
16
|
+
def_delegators :app, :configure, :set, :enable, :disable, :use, :helpers, :register
|
12
17
|
|
13
18
|
attr_writer :app
|
14
19
|
def app(*options, &block)
|
@@ -20,12 +25,15 @@ module Sinatra
|
|
20
25
|
else raise ArgumentError, "cannot handle #{option.inspect}"
|
21
26
|
end
|
22
27
|
end
|
23
|
-
|
24
|
-
superclass ||= Sinatra::Base
|
25
|
-
@app = Class.new(superclass, &block)
|
26
|
-
inspection = "app"
|
28
|
+
inspection = "app"
|
27
29
|
inspection << "(" << options.map { |o| o.inspect }.join(", ") << ")" unless options.empty?
|
28
30
|
inspection << " { ... }" if block
|
31
|
+
if options.first.is_a? Class
|
32
|
+
@app = options.shift
|
33
|
+
@app.class_eval(&block) if block
|
34
|
+
else
|
35
|
+
@app = Class.new(Sinatra::Base, &block)
|
36
|
+
end
|
29
37
|
options.each do |option|
|
30
38
|
if option.is_a? Hash then @app.set option
|
31
39
|
else @app.register option
|
data/lib/sinatra/test_spec.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require "
|
1
|
+
require "test/spec"
|
2
|
+
require "sinatra/test_unit"
|
data/lib/sinatra/test_unit.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe Sinatra::TestHelper do
|
4
|
+
describe :app do
|
5
|
+
before { @app = nil }
|
6
|
+
|
7
|
+
it "should use Sinatra::Application if app is not set" do
|
8
|
+
app.should == Sinatra::Application
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should use another app if passed directly" do
|
12
|
+
some_app = Class.new Sinatra::Base
|
13
|
+
app(some_app).should == some_app
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should register a mixin that is passed in" do
|
17
|
+
mod = Module.new
|
18
|
+
app(mod).should be_a(mod)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "takes an option hash" do
|
22
|
+
app(:foo => 42).foo.should == 42
|
23
|
+
end
|
24
|
+
|
25
|
+
it "does no modify Sinatra::Application" do
|
26
|
+
app { set :foo, 42 }
|
27
|
+
app.should_not == Sinatra::Application
|
28
|
+
end
|
29
|
+
|
30
|
+
it "does no modify Sinatra::Base" do
|
31
|
+
app :foo => 42
|
32
|
+
app.should_not == Sinatra::Base
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should register a mixin from the Sinatra module if a symbol is given" do
|
36
|
+
module ::Sinatra::Foo; end
|
37
|
+
app(:Foo).should be_a(::Sinatra::Foo)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should take both a class an mixins" do
|
41
|
+
some_app, mod = Class.new(Sinatra::Base), Module.new
|
42
|
+
module ::Sinatra::Foo; end
|
43
|
+
app(some_app, mod, :Foo)
|
44
|
+
app.should == some_app
|
45
|
+
app.should be_a(mod)
|
46
|
+
app.should be_a(::Sinatra::Foo)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should use the given block for setting up app" do
|
50
|
+
app { set :foo, 42 }.foo.should == 42
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe :define_route do
|
55
|
+
before { app {} }
|
56
|
+
%w[get head post put delete].each do |verb|
|
57
|
+
it "defines #{verb} routes" do
|
58
|
+
define_route(verb, %r{^/foo$}) { "bar" }
|
59
|
+
app.routes[verb.upcase].last.first.should == %r{^/foo$}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe :browse_route do
|
65
|
+
before { app {} }
|
66
|
+
%w[get head post put delete].each do |verb|
|
67
|
+
it "able to browse #{verb} routes" do
|
68
|
+
define_route(verb, "/foo") { "bar" }
|
69
|
+
browse_route(verb, "/foo").should be_ok
|
70
|
+
browse_route(verb, "/foo").body.should == "bar" unless verb == "head"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "sinatra/rspec"
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-test-helper
|
3
|
-
version:
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Konstantin Haase
|
@@ -9,28 +14,53 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-13 00:00:00 +02:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: monkey-lib
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 4
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 0.4.0.0
|
17
33
|
type: :runtime
|
18
|
-
|
19
|
-
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sinatra-sugar
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
20
39
|
requirements:
|
21
|
-
- -
|
22
|
-
-
|
23
|
-
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 4
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
version: 0.4.0.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
24
50
|
- !ruby/object:Gem::Dependency
|
25
51
|
name: sinatra
|
26
|
-
|
27
|
-
|
28
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
29
54
|
requirements:
|
30
55
|
- - ">="
|
31
56
|
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
- 9
|
60
|
+
- 4
|
32
61
|
version: 0.9.4
|
33
|
-
|
62
|
+
type: :runtime
|
63
|
+
version_requirements: *id003
|
34
64
|
description: Test helper for Sinatra (part of BigBand).
|
35
65
|
email: konstantin.mailinglists@googlemail.com
|
36
66
|
executables: []
|
@@ -41,12 +71,18 @@ extra_rdoc_files: []
|
|
41
71
|
|
42
72
|
files:
|
43
73
|
- lib/sinatra/bacon.rb
|
74
|
+
- lib/sinatra/contest.rb
|
75
|
+
- lib/sinatra/minitest.rb
|
76
|
+
- lib/sinatra/mspec.rb
|
77
|
+
- lib/sinatra/protest.rb
|
44
78
|
- lib/sinatra/rspec.rb
|
45
79
|
- lib/sinatra/test/spec.rb
|
46
80
|
- lib/sinatra/test/unit.rb
|
47
81
|
- lib/sinatra/test_helper.rb
|
48
82
|
- lib/sinatra/test_spec.rb
|
49
83
|
- lib/sinatra/test_unit.rb
|
84
|
+
- spec/sinatra/test_helper_spec.rb
|
85
|
+
- spec/spec_helper.rb
|
50
86
|
- README.md
|
51
87
|
has_rdoc: yard
|
52
88
|
homepage: http://github.com/rkh/sinatra-test-helper
|
@@ -61,18 +97,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
97
|
requirements:
|
62
98
|
- - ">="
|
63
99
|
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
64
102
|
version: "0"
|
65
|
-
version:
|
66
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
104
|
requirements:
|
68
|
-
- - "
|
105
|
+
- - ">="
|
69
106
|
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
72
110
|
requirements: []
|
73
111
|
|
74
112
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.3.
|
113
|
+
rubygems_version: 1.3.6
|
76
114
|
signing_key:
|
77
115
|
specification_version: 3
|
78
116
|
summary: Test helper for Sinatra (part of BigBand).
|