cuba-sugar 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +9 -9
- data/Rakefile +2 -1
- data/cuba-sugar.gemspec +4 -4
- data/test/as.rb +24 -2
- data/test/content_for.rb +3 -3
- data/test/csrf.rb +10 -6
- data/test/helpers.rb +2 -2
- data/test/{subdomain.rb → routes.rb} +3 -3
- data/test/test_helper.rb +6 -0
- metadata +17 -31
- data/test/as_json.rb +0 -24
- data/test/helper.rb +0 -5
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6047fb996178f2829795a95ed0d4611217980051
|
4
|
+
data.tar.gz: c45ec2bd00c39666c58e5b43cd527ff600a11208
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1812df535d51f437ef7497157cace9ae295a4d981f2e235463f9cbf37c2cc2c4fc3c6ff9013504a9e1c2d07e08e2520bad29757929e0b78849606263b4a2272d
|
7
|
+
data.tar.gz: 6b37a6d2f5a15b79e37be32cfc7e601202fe5cf48af783bdd61c4b761f58abae1ad0684690ecc0585f589bcaf2085eed7ffc06eab1f2b1d735c03a7d03aab512
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cuba-sugar (0.3.
|
5
|
-
cuba (~> 3.
|
6
|
-
json (~> 1.7
|
7
|
-
rack_csrf (~> 2.4
|
4
|
+
cuba-sugar (0.3.1)
|
5
|
+
cuba (~> 3.3)
|
6
|
+
json (~> 1.7)
|
7
|
+
rack_csrf (~> 2.4)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
cuba (3.
|
12
|
+
cuba (3.4.0)
|
13
13
|
rack
|
14
14
|
cutest (1.1.3)
|
15
|
-
json (1.
|
16
|
-
rack (1.
|
17
|
-
rack_csrf (2.
|
18
|
-
rack (>= 0
|
15
|
+
json (1.8.2)
|
16
|
+
rack (1.6.1)
|
17
|
+
rack_csrf (2.5.0)
|
18
|
+
rack (>= 1.1.0)
|
19
19
|
rake (0.9.2.2)
|
20
20
|
tilt (1.3.3)
|
21
21
|
|
data/Rakefile
CHANGED
data/cuba-sugar.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cuba-sugar"
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.1"
|
4
4
|
s.summary = "Give Cuba some Sugar!"
|
5
5
|
s.description = "Useful stuff to use with cuba"
|
6
6
|
s.authors = ["elcuervo"]
|
@@ -9,9 +9,9 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.files = `git ls-files`.split("\n")
|
10
10
|
s.test_files = `git ls-files test`.split("\n")
|
11
11
|
|
12
|
-
s.add_dependency("cuba", "~> 3.
|
13
|
-
s.add_dependency("json", "~> 1.7
|
14
|
-
s.add_dependency("rack_csrf", "~> 2.4
|
12
|
+
s.add_dependency("cuba", "~> 3.3")
|
13
|
+
s.add_dependency("json", "~> 1.7")
|
14
|
+
s.add_dependency("rack_csrf", "~> 2.4")
|
15
15
|
|
16
16
|
s.add_development_dependency("cutest", "~> 1.1.3")
|
17
17
|
s.add_development_dependency("tilt", "~> 1.3.3")
|
data/test/as.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require_relative "test_helper"
|
2
|
+
require "cuba/sugar/as"
|
3
3
|
|
4
4
|
test "set status and headers through helper" do
|
5
5
|
Cuba.plugin Cuba::Sugar::As
|
@@ -19,3 +19,25 @@ test "set status and headers through helper" do
|
|
19
19
|
assert_equal ["User Created"], resp
|
20
20
|
assert_equal "http://somewhere.com/users/705", headers["Content-Location"]
|
21
21
|
end
|
22
|
+
|
23
|
+
test "set a block to return json" do
|
24
|
+
rum_and_coke = { "rum" => "hot", "coke" => "sweet" }
|
25
|
+
|
26
|
+
Cuba.plugin Cuba::Sugar::As
|
27
|
+
Cuba.define do
|
28
|
+
on "drinks" do
|
29
|
+
as_json 201, {"Content-Location" => "http://somewhere.com/drinks/42"} do
|
30
|
+
rum_and_coke
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/drinks" }
|
36
|
+
|
37
|
+
code, headers, resp = Cuba.call(env)
|
38
|
+
|
39
|
+
assert_equal 201, code
|
40
|
+
assert_equal "application/json", headers["Content-Type"]
|
41
|
+
assert_equal [rum_and_coke.to_json], resp
|
42
|
+
assert_equal "http://somewhere.com/drinks/42", headers["Content-Location"]
|
43
|
+
end
|
data/test/content_for.rb
CHANGED
data/test/csrf.rb
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require_relative "test_helper"
|
2
|
+
require "cuba/render"
|
3
|
+
require "cuba/sugar/as"
|
4
|
+
require "cuba/sugar/csrf"
|
5
5
|
|
6
6
|
test "set status and headers through helper" do
|
7
7
|
Cuba.plugin Cuba::Sugar::As
|
8
8
|
Cuba.plugin Cuba::Sugar::Csrf
|
9
9
|
Cuba.plugin Cuba::Render
|
10
|
+
|
11
|
+
Cuba.settings[:render][:views] = "./test/fixtures"
|
12
|
+
Cuba.settings[:render][:template_engine] = "erb"
|
13
|
+
|
10
14
|
Cuba.define do
|
11
15
|
on "users" do
|
12
16
|
as do
|
13
|
-
|
17
|
+
partial "csrf"
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
|
-
env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/users",
|
22
|
+
env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/users", "rack.session" => {} }
|
19
23
|
|
20
24
|
code, headers, resp = Cuba.call(env)
|
21
25
|
|
data/test/helpers.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require_relative "test_helper"
|
2
|
+
require "cuba/sugar/as"
|
3
|
+
require "cuba/sugar/routes"
|
4
4
|
|
5
5
|
test "eval only in a given subdomain" do
|
6
6
|
Cuba.plugin Cuba::Sugar::As
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,68 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuba-sugar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- elcuervo
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: cuba
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.
|
19
|
+
version: '3.3'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.
|
26
|
+
version: '3.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: json
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.7
|
33
|
+
version: '1.7'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.7
|
40
|
+
version: '1.7'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rack_csrf
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.4
|
47
|
+
version: '2.4'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.4
|
54
|
+
version: '2.4'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: cutest
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: tilt
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -111,47 +100,44 @@ files:
|
|
111
100
|
- lib/cuba/sugar/csrf.rb
|
112
101
|
- lib/cuba/sugar/routes.rb
|
113
102
|
- test/as.rb
|
114
|
-
- test/as_json.rb
|
115
103
|
- test/content_for.rb
|
116
104
|
- test/csrf.rb
|
117
105
|
- test/fixtures/csrf.erb
|
118
|
-
- test/helper.rb
|
119
106
|
- test/helpers.rb
|
120
|
-
- test/
|
107
|
+
- test/routes.rb
|
108
|
+
- test/test_helper.rb
|
121
109
|
- test/views/home.erb
|
122
110
|
- test/views/layout.erb
|
123
111
|
homepage: http://github.com/elcuervo/cuba-sugar
|
124
112
|
licenses: []
|
113
|
+
metadata: {}
|
125
114
|
post_install_message:
|
126
115
|
rdoc_options: []
|
127
116
|
require_paths:
|
128
117
|
- lib
|
129
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
119
|
requirements:
|
132
|
-
- -
|
120
|
+
- - '>='
|
133
121
|
- !ruby/object:Gem::Version
|
134
122
|
version: '0'
|
135
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
124
|
requirements:
|
138
|
-
- -
|
125
|
+
- - '>='
|
139
126
|
- !ruby/object:Gem::Version
|
140
127
|
version: '0'
|
141
128
|
requirements: []
|
142
129
|
rubyforge_project:
|
143
|
-
rubygems_version:
|
130
|
+
rubygems_version: 2.0.14
|
144
131
|
signing_key:
|
145
|
-
specification_version:
|
132
|
+
specification_version: 4
|
146
133
|
summary: Give Cuba some Sugar!
|
147
134
|
test_files:
|
148
135
|
- test/as.rb
|
149
|
-
- test/as_json.rb
|
150
136
|
- test/content_for.rb
|
151
137
|
- test/csrf.rb
|
152
138
|
- test/fixtures/csrf.erb
|
153
|
-
- test/helper.rb
|
154
139
|
- test/helpers.rb
|
155
|
-
- test/
|
140
|
+
- test/routes.rb
|
141
|
+
- test/test_helper.rb
|
156
142
|
- test/views/home.erb
|
157
143
|
- test/views/layout.erb
|
data/test/as_json.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
2
|
-
require 'cuba/sugar/as'
|
3
|
-
|
4
|
-
test "set a block to return json" do
|
5
|
-
rum_and_coke = { "rum" => "hot", "coke" => "sweet" }
|
6
|
-
|
7
|
-
Cuba.plugin Cuba::Sugar::As
|
8
|
-
Cuba.define do
|
9
|
-
on "drinks" do
|
10
|
-
as_json 201, {"Content-Location" => "http://somewhere.com/drinks/42"} do
|
11
|
-
rum_and_coke
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/drinks" }
|
17
|
-
|
18
|
-
code, headers, resp = Cuba.call(env)
|
19
|
-
|
20
|
-
assert_equal 201, code
|
21
|
-
assert_equal "application/json", headers["Content-Type"]
|
22
|
-
assert_equal [rum_and_coke.to_json], resp
|
23
|
-
assert_equal "http://somewhere.com/drinks/42", headers["Content-Location"]
|
24
|
-
end
|