sinatra-test-helper 0.4.0.a → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -2,9 +2,8 @@ require "sinatra/test_helper"
2
2
  require "bacon"
3
3
 
4
4
  module Sinatra
5
- # Some Bacon example and description goes here.
6
5
  module Bacon
7
6
  ::Bacon::Context.send :include, self
8
7
  include Sinatra::TestHelper
9
8
  end
10
- end
9
+ end
@@ -0,0 +1,2 @@
1
+ require "contest"
2
+ require "sinatra/test_unit"
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,9 @@
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
data/lib/sinatra/rspec.rb CHANGED
@@ -2,7 +2,6 @@ require "sinatra/test_helper"
2
2
  require "spec"
3
3
 
4
4
  module Sinatra
5
- # Some RSpec example and description goes here.
6
5
  module RSpec
7
6
  include Sinatra::TestHelper
8
7
  ::Spec::Runner.configure { |c| c.include self }
@@ -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
- superclass = options.shift if options.first.is_a? Class
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
@@ -1 +1,2 @@
1
- require "sinatra/test_unit"
1
+ require "test/spec"
2
+ require "sinatra/test_unit"
@@ -2,7 +2,6 @@ require "sinatra/test_helper"
2
2
  require "test/unit"
3
3
 
4
4
  module Sinatra
5
- # Some TestUnit example and description goes here.
6
5
  module TestUnit
7
6
  ::Test::Unit::TestCase.send :include, self
8
7
  include Sinatra::TestHelper
@@ -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
@@ -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: &id001 !ruby/object:Gem::Version
4
- version: 0.4.0.a
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-02-15 00:00:00 +01:00
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
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
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
- - *id001
23
- version:
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
- type: :runtime
27
- version_requirement:
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
- version:
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
- version: 1.3.1
71
- version:
107
+ segments:
108
+ - 0
109
+ version: "0"
72
110
  requirements: []
73
111
 
74
112
  rubyforge_project:
75
- rubygems_version: 1.3.5
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).