sinatra-test-helper 0.5.0 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,129 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sinatra-test-helper
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Konstantin Haase
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-07-09 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: monkey-lib
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-10-28 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra-contrib
16
+ requirement: &2154377700 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 11
30
- segments:
31
- - 0
32
- - 5
33
- - 0
34
- version: 0.5.0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: sinatra-sugar
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 11
46
- segments:
47
- - 0
48
- - 5
49
- - 0
50
- version: 0.5.0
51
- type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: sinatra
55
- prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 15
62
- segments:
63
- - 1
64
- - 0
65
- version: "1.0"
66
- type: :runtime
67
- version_requirements: *id003
68
- description: Test helper for Sinatra (part of BigBand).
24
+ version_requirements: *2154377700
25
+ description: ! 'Dummy gem, sinatra-test-helper is now part of sinatra-contrib: http://www.sinatrarb.com/contrib/'
69
26
  email: konstantin.mailinglists@googlemail.com
70
27
  executables: []
71
-
72
28
  extensions: []
73
-
74
29
  extra_rdoc_files: []
75
-
76
- files:
77
- - lib/sinatra/bacon.rb
78
- - lib/sinatra/contest.rb
79
- - lib/sinatra/minitest.rb
80
- - lib/sinatra/mspec.rb
81
- - lib/sinatra/protest.rb
82
- - lib/sinatra/rspec/shared/routing.rb
83
- - lib/sinatra/rspec/shared.rb
84
- - lib/sinatra/rspec.rb
85
- - lib/sinatra/test/spec.rb
86
- - lib/sinatra/test/unit.rb
87
- - lib/sinatra/test_helper.rb
88
- - lib/sinatra/test_spec.rb
89
- - lib/sinatra/test_unit.rb
90
- - spec/sinatra/test_helper_spec.rb
91
- - spec/spec_helper.rb
92
- - README.md
93
- - LICENSE
94
- has_rdoc: yard
95
- homepage: http://github.com/rkh/sinatra-test-helper
30
+ files: []
31
+ homepage: http://github.com/sinatra/sinatra-contrib
96
32
  licenses: []
97
-
98
33
  post_install_message:
99
34
  rdoc_options: []
100
-
101
- require_paths:
35
+ require_paths:
102
36
  - lib
103
- required_ruby_version: !ruby/object:Gem::Requirement
37
+ required_ruby_version: !ruby/object:Gem::Requirement
104
38
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
112
- required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
44
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
119
- - 0
120
- version: "0"
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
121
49
  requirements: []
122
-
123
50
  rubyforge_project:
124
- rubygems_version: 1.3.7
51
+ rubygems_version: 1.8.10
125
52
  signing_key:
126
53
  specification_version: 3
127
- summary: Test helper for Sinatra (part of BigBand).
54
+ summary: Dummy gem, sinatra-test-helper is now part of sinatra-contrib.
128
55
  test_files: []
129
-
data/LICENSE DELETED
@@ -1,27 +0,0 @@
1
- copyright (c) 2010 Konstantin Haase. All rights reserved.
2
-
3
- Developed by: Konstantin Haase
4
- http://github.com/rkh/big_band
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to
8
- deal with the Software without restriction, including without limitation the
9
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
- sell copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
- 1. Redistributions of source code must retain the above copyright notice,
13
- this list of conditions and the following disclaimers.
14
- 2. Redistributions in binary form must reproduce the above copyright
15
- notice, this list of conditions and the following disclaimers in the
16
- documentation and/or other materials provided with the distribution.
17
- 3. Neither the name of Konstantin Haase, nor the names of other contributors
18
- may be used to endorse or promote products derived from this Software without
19
- specific prior written permission.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27
- WITH THE SOFTWARE.
data/README.md DELETED
@@ -1,51 +0,0 @@
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
-
13
- Installation
14
- ------------
15
-
16
- gem install sinatra-test-helper
17
-
18
- Frameworks
19
- ----------
20
-
21
- Currently Sinatra::TestHelper ships with support for:
22
-
23
- * Bacon
24
- * Contest
25
- * Minitest
26
- * MSpec
27
- * Protest
28
- * RSpec
29
- * Test::Spec
30
- * Test::Unit
31
-
32
- Usage
33
- -----
34
-
35
- In you test\_helper.rb or spec\_helper.rb (or your test), place this line:
36
-
37
- require "sinatra/YOUR_FRAMEWORK"
38
-
39
- Example:
40
-
41
- require "sinatra/rspec"
42
- require "sinatra/funky_extension"
43
-
44
- describe Sinatra::FunkyExtension do
45
- # Let's always start with an empty app, using Sinatra::FunkyExtension
46
- before { app :FunkyExtension }
47
- it "should do funky thinks" do
48
- define_route(:get, '/funky') { "funky" }
49
- browse_route(:get, '/funky').body.should == "funky"
50
- end
51
- end
@@ -1,9 +0,0 @@
1
- require "sinatra/test_helper"
2
- require "bacon"
3
-
4
- module Sinatra
5
- module Bacon
6
- ::Bacon::Context.send :include, self
7
- include Sinatra::TestHelper
8
- end
9
- end
@@ -1,2 +0,0 @@
1
- require "contest"
2
- require "sinatra/test_unit"
@@ -1,9 +0,0 @@
1
- require "sinatra/test_helper"
2
- require "minitest/unit"
3
-
4
- module Sinatra
5
- module Minitest
6
- ::Minitest::Unit.send :include, self
7
- include Sinatra::TestHelper
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- require "sinatra/test_helper"
2
- require "mspec"
3
-
4
- module Sinatra
5
- # Some Bacon example and description goes here.
6
- module MSpec
7
- ::Object.send :include, self
8
- include Sinatra::TestHelper
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- require "sinatra/test_helper"
2
- require "protest"
3
-
4
- module Sinatra
5
- module Protest
6
- ::Protest::TestCase.send :include, self
7
- include Sinatra::TestHelper
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- require "sinatra/test_helper"
2
- require "spec"
3
-
4
- module Sinatra
5
- module RSpec
6
- include Sinatra::TestHelper
7
- ::Spec::Runner.configure { |c| c.include self }
8
- end
9
- Rspec = RSpec
10
- end
@@ -1,6 +0,0 @@
1
- require 'sinatra/rspec'
2
- require 'sinatra/rspec/shared/routing'
3
-
4
- shared_examples_for 'sinatra' do
5
- it_should_behave_like 'sinatra routing'
6
- end
@@ -1,61 +0,0 @@
1
- require 'sinatra/rspec/shared'
2
-
3
- shared_examples_for 'sinatra routing' do
4
- %w[get head post put delete].each do |verb|
5
- describe verb.upcase do
6
- it "should route matching patterns" do
7
- app.routes.clear
8
- define_route(verb, '/foo') { 'bar' }
9
- result = browse_route(verb, '/foo')
10
- result.should be_ok
11
- result.body.should == 'bar' unless verb == 'head'
12
- end
13
-
14
- it "404s when no route satisfies the request" do
15
- app.routes.clear
16
- define_route(verb, '/foo') { }
17
- browse_route(verb, '/bar').status.should == 404
18
- end
19
-
20
- it "404s and sets X-Cascade header when no route satisfies the request" do
21
- app.routes.clear
22
- define_route(verb, '/foo') { }
23
- result = browse_route(verb, '/bar')
24
- result.status.should == 404
25
- result.headers['X-Cascade'].should == 'pass'
26
- end
27
-
28
- it "overrides the content-type in error handlers" do
29
- app.routes.clear
30
- app.before { content_type 'text/plain' }
31
- app.error Sinatra::NotFound do
32
- content_type "text/html"
33
- "<h1>Not Found</h1>"
34
- end
35
- result = browse_route(verb, '/bar')
36
- result.status.should == 404
37
- result["Content-Type"].should include('text/html')
38
- result.body.should == "<h1>Not Found</h1>" unless verb == 'head'
39
- end
40
-
41
- it 'takes multiple definitions of a route' do
42
- app.routes.clear
43
- app.send(:user_agent, /Foo/)
44
- define_route(verb, '/foo') { 'foo' }
45
- define_route(verb, '/foo') { 'not foo' }
46
- browse_route verb, '/foo', {}, 'HTTP_USER_AGENT' => 'Foo'
47
- last_response.should be_ok
48
- last_response.body.should == 'foo' unless verb == 'head'
49
- last_response.should be_ok
50
- browse_route verb, '/foo'
51
- last_response.body.should == 'not foo' unless verb == 'head'
52
- end
53
- end
54
- end
55
-
56
- it "defines HEAD request handlers with HEAD" do
57
- app.routes.clear
58
- define_route(:head, '/hello') { response['X-Hello'] = 'World!' }
59
- head('/hello')['X-Hello'].should == 'World!'
60
- end
61
- end
@@ -1 +0,0 @@
1
- require "sinatra/test_spec"
@@ -1 +0,0 @@
1
- require "sinatra/test_unit"
@@ -1,100 +0,0 @@
1
- require "sinatra/base"
2
- require "sinatra/sugar"
3
- require "rack/test"
4
- require "forwardable"
5
- require "monkey-lib"
6
-
7
- Sinatra::Base.set :environment, :test
8
-
9
- module Sinatra
10
- Base.ignore_caller
11
- # This encapsulates general test helpers. See Bacon, RSpec, Test::Spec and Test::Unit for examples.
12
- module TestHelper
13
- module AppMixin
14
- def call!(env)
15
- env['sinatra.test_helper'].last_sinatra_instance = self if env['sinatra.test_helper']
16
- super
17
- end
18
- end
19
-
20
- class Session < Rack::Test::Session
21
- def global_env
22
- @global_env ||= {}
23
- end
24
- private
25
- def default_env
26
- super.merge global_env
27
- end
28
- end
29
-
30
- include ::Rack::Test::Methods
31
- extend Forwardable
32
-
33
- def build_rack_test_session(name) # :nodoc:
34
- Session.new(rack_mock_session(name)).tap do |s|
35
- s.global_env['sinatra.test_helper'] = self
36
- end
37
- end
38
-
39
- def_delegators :app, :configure, :set, :enable, :disable, :use, :helpers, :register
40
- attr_writer :last_sinatra_instance
41
-
42
- attr_writer :app
43
- def app(*options, &block)
44
- unless block.nil? and options.empty?
45
- options.map! do |option|
46
- case option
47
- when String, Symbol then Sinatra.const_get option
48
- when Module, Hash then option
49
- else raise ArgumentError, "cannot handle #{option.inspect}"
50
- end
51
- end
52
- inspection = "app"
53
- inspection << "(" << options.map { |o| o.inspect }.join(", ") << ")" unless options.empty?
54
- inspection << " { ... }" if block
55
- if options.first.is_a? Class
56
- @app = options.shift
57
- @app.class_eval(&block) if block
58
- else
59
- @app = Class.new(Sinatra::Base, &block)
60
- end
61
- options.each do |option|
62
- if option.is_a? Hash then @app.set option
63
- else @app.register option
64
- end
65
- @app.class_eval "def self.inspect; #{inspection.inspect}; end"
66
- end
67
- end
68
- @app ||= Sinatra::Application
69
- @app.extend AppMixin unless @app.is_a? AppMixin
70
- @app
71
- end
72
-
73
- def last_request?
74
- last_request
75
- true
76
- rescue Rack::Test::Error
77
- false
78
- end
79
-
80
- def session
81
- return {} unless last_request?
82
- raise Rack::Test:Error, "session not enabled for app" unless last_env["rack.session"] or app.session?
83
- last_request.session
84
- end
85
-
86
- def last_env
87
- last_request.env
88
- end
89
-
90
- def define_route(verb, *args, &block)
91
- app.send(verb, *args, &block)
92
- end
93
-
94
- def browse_route(verb, *args, &block)
95
- send(verb, *args, &block)
96
- last_response
97
- end
98
-
99
- end
100
- end
@@ -1,2 +0,0 @@
1
- require "test/spec"
2
- require "sinatra/test_unit"
@@ -1,9 +0,0 @@
1
- require "sinatra/test_helper"
2
- require "test/unit"
3
-
4
- module Sinatra
5
- module TestUnit
6
- ::Test::Unit::TestCase.send :include, self
7
- include Sinatra::TestHelper
8
- end
9
- end
@@ -1,76 +0,0 @@
1
- require File.expand_path("../../spec_helper", __FILE__)
2
-
3
- describe Sinatra::TestHelper do
4
- it_should_behave_like 'sinatra'
5
-
6
- describe :app do
7
- before { @app = nil }
8
-
9
- it "should use Sinatra::Application if app is not set" do
10
- app.should == Sinatra::Application
11
- end
12
-
13
- it "should use another app if passed directly" do
14
- some_app = Class.new Sinatra::Base
15
- app(some_app).should == some_app
16
- end
17
-
18
- it "should register a mixin that is passed in" do
19
- mod = Module.new
20
- app(mod).should be_a(mod)
21
- end
22
-
23
- it "takes an option hash" do
24
- app(:foo => 42).foo.should == 42
25
- end
26
-
27
- it "does no modify Sinatra::Application" do
28
- app { set :foo, 42 }
29
- app.should_not == Sinatra::Application
30
- end
31
-
32
- it "does no modify Sinatra::Base" do
33
- app :foo => 42
34
- app.should_not == Sinatra::Base
35
- end
36
-
37
- it "should register a mixin from the Sinatra module if a symbol is given" do
38
- module ::Sinatra::Foo; end
39
- app(:Foo).should be_a(::Sinatra::Foo)
40
- end
41
-
42
- it "should take both a class an mixins" do
43
- some_app, mod = Class.new(Sinatra::Base), Module.new
44
- module ::Sinatra::Foo; end
45
- app(some_app, mod, :Foo)
46
- app.should == some_app
47
- app.should be_a(mod)
48
- app.should be_a(::Sinatra::Foo)
49
- end
50
-
51
- it "should use the given block for setting up app" do
52
- app { set :foo, 42 }.foo.should == 42
53
- end
54
- end
55
-
56
- describe :define_route do
57
- before { app {} }
58
- %w[get head post put delete].each do |verb|
59
- it "defines #{verb} routes" do
60
- define_route(verb, %r{^/foo$}) { "bar" }
61
- app.routes[verb.upcase].last.first.should == %r{^/foo$}
62
- end
63
- end
64
- end
65
-
66
- describe :browse_route do
67
- before { app {} }
68
- %w[get head post put delete].each do |verb|
69
- it "able to browse #{verb} routes" do
70
- define_route(verb, "/foo") { "bar" }
71
- browse_route(verb, "/foo").should be_ok
72
- browse_route(verb, "/foo").body.should == "bar" unless verb == "head"
73
- end
74
- end
75
- end
76
- end
@@ -1 +0,0 @@
1
- require "sinatra/rspec/shared"