gopher2000 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,11 +18,11 @@ describe Gopher::Application do
18
18
  describe "find_template" do
19
19
  it "should check in menus" do
20
20
  @s.menus['foo'] = "bar"
21
- @s.find_template('foo').should == ["bar", Gopher::Rendering::Menu]
21
+ expect(@s.find_template('foo')).to eq(["bar", Gopher::Rendering::Menu])
22
22
  end
23
23
  it "should check in text_templates" do
24
24
  @s.text_templates['foo'] = "bar"
25
- @s.find_template('foo').should == ["bar", Gopher::Rendering::Text]
25
+ expect(@s.find_template('foo')).to eq(["bar", Gopher::Rendering::Text])
26
26
  end
27
27
  end
28
28
 
@@ -37,7 +37,7 @@ describe Gopher::Application do
37
37
  @params
38
38
  end
39
39
 
40
- @s.render(:foo).should == "xyz"
40
+ expect(@s.render(:foo)).to eq("xyz")
41
41
  end
42
42
 
43
43
  it "has access to request obj" do
@@ -46,7 +46,7 @@ describe Gopher::Application do
46
46
  @request
47
47
  end
48
48
 
49
- @s.render(:foo).should == "abc"
49
+ expect(@s.render(:foo)).to eq("abc")
50
50
  end
51
51
 
52
52
  it "rendering text access to request obj" do
@@ -55,7 +55,7 @@ describe Gopher::Application do
55
55
  @request
56
56
  end
57
57
 
58
- @s.render(:foo).should == "abc"
58
+ expect(@s.render(:foo)).to eq("abc")
59
59
  end
60
60
  end
61
61
 
@@ -66,11 +66,11 @@ describe Gopher::Application do
66
66
 
67
67
  it "should use custom template if provided" do
68
68
  @s.not_found do ; end
69
- @s.not_found_template.should == :not_found
69
+ expect(@s.not_found_template).to eq(:not_found)
70
70
  end
71
71
 
72
72
  it "should use default otherwise" do
73
- @s.not_found_template.should == :'internal/not_found'
73
+ expect(@s.not_found_template).to eq(:'internal/not_found')
74
74
  end
75
75
  end
76
76
 
data/spec/request_spec.rb CHANGED
@@ -3,33 +3,39 @@ require File.join(File.dirname(__FILE__), '/spec_helper')
3
3
  describe Gopher::Request do
4
4
  it 'should split raw request' do
5
5
  request = Gopher::Request.new("foo\tbar")
6
- request.selector.should == "/foo"
7
- request.input.should == "bar"
6
+ expect(request.selector).to eq("/foo")
7
+ expect(request.input).to eq("bar")
8
8
  end
9
9
 
10
10
  it "normalizes by adding a slash to the front" do
11
11
  request = Gopher::Request.new("foo")
12
- request.selector.should == "/foo"
12
+ expect(request.selector).to eq("/foo")
13
13
  end
14
14
 
15
15
  it "should be ok with just selector" do
16
16
  request = Gopher::Request.new("/foo")
17
- request.selector.should == "/foo"
18
- request.input.should == nil
17
+ expect(request.selector).to eq("/foo")
18
+ expect(request.input).to eq(nil)
19
19
  end
20
20
 
21
21
  it "should accept ip_address" do
22
22
  request = Gopher::Request.new("foo", "bar")
23
- request.ip_address.should == "bar"
23
+ expect(request.ip_address).to eq("bar")
24
24
  end
25
25
 
26
26
  it "valid? == true for valid selectors" do
27
27
  request = Gopher::Request.new("x" * 254, "bar")
28
- request.valid?.should == true
28
+ expect(request.valid?).to eq(true)
29
29
  end
30
30
 
31
31
  it "valid? == false for invalid selectors" do
32
32
  request = Gopher::Request.new("x" * 255, "bar")
33
- request.valid?.should == false
33
+ expect(request.valid?).to eq(false)
34
+ end
35
+
36
+ it 'detects urls' do
37
+ request = Gopher::Request.new("URL:http://github.com/muffinista/gopher2000")
38
+ expect(request).to be_url
39
+ expect(request.url).to eql('http://github.com/muffinista/gopher2000')
34
40
  end
35
41
  end
@@ -8,17 +8,17 @@ describe Gopher::Response do
8
8
 
9
9
  it "gets size for string results" do
10
10
  @response.body = "hi"
11
- @response.size.should == 2
11
+ expect(@response.size).to eq(2)
12
12
  end
13
13
 
14
14
  it "gets size for stringio results" do
15
15
  @response.body = StringIO.new("12345")
16
- @response.size.should == 5
16
+ expect(@response.size).to eq(5)
17
17
  end
18
18
 
19
19
  it "defaults to 0 size for weird objects" do
20
- @response.body = mock(Object)
21
- @response.size.should == 0
20
+ @response.body = double(Object)
21
+ expect(@response.size).to eq(0)
22
22
  end
23
23
 
24
24
 
@@ -28,6 +28,6 @@ describe Gopher::Response do
28
28
  temp_file.flush
29
29
 
30
30
  @response.body = File.new(temp_file.path)
31
- @response.size.should == 10
31
+ expect(@response.size).to eq(10)
32
32
  end
33
33
  end
data/spec/routing_spec.rb CHANGED
@@ -16,30 +16,30 @@ describe Gopher::Application do
16
16
  "hi"
17
17
  end
18
18
  junk, block = @router.lookup("sfssfdfsfsd")
19
- block.class.should eql(UnboundMethod)
19
+ expect(block.class).to eql(UnboundMethod)
20
20
  end
21
21
  end
22
22
 
23
23
  describe "globify" do
24
24
  it "should add glob if none yet" do
25
- @router.globify("/foo").should == "/foo/?*"
25
+ expect(@router.globify("/foo")).to eq("/foo/?*")
26
26
  end
27
27
 
28
28
  it "should be ok with trailing slashes" do
29
- @router.globify("/foo/").should == "/foo/?*"
29
+ expect(@router.globify("/foo/")).to eq("/foo/?*")
30
30
  end
31
31
 
32
32
  it "shouldn't add glob if there is one already" do
33
- @router.globify("/foo/*").should == "/foo/*"
33
+ expect(@router.globify("/foo/*")).to eq("/foo/*")
34
34
  end
35
35
  end
36
36
 
37
37
  describe "mount" do
38
38
  before(:each) do
39
- @h = mock(Gopher::Handlers::DirectoryHandler)
40
- @h.should_receive(:application=).with(@router)
39
+ @h = double(Gopher::Handlers::DirectoryHandler)
40
+ expect(@h).to receive(:application=).with(@router)
41
41
 
42
- Gopher::Handlers::DirectoryHandler.should_receive(:new).with({:bar => :baz, :mount_point => "/foo"}).and_return(@h)
42
+ expect(Gopher::Handlers::DirectoryHandler).to receive(:new).with({:bar => :baz, :mount_point => "/foo"}).and_return(@h)
43
43
  end
44
44
 
45
45
  it "should work" do
@@ -50,42 +50,42 @@ describe Gopher::Application do
50
50
  describe "compile" do
51
51
  it "should generate a basic string for routes without keys" do
52
52
  lookup, keys, block = @router.compile! "/foo" do; end
53
- lookup.to_s.should == /^\/foo$/.to_s
54
- keys.should == []
53
+ expect(lookup.to_s).to eq(/^\/foo$/.to_s)
54
+ expect(keys).to eq([])
55
55
  end
56
56
 
57
57
  context "with keys" do
58
58
  it "should generate a lookup and keys for routes with keys" do
59
59
  lookup, keys, block = @router.compile! "/foo/:bar" do; end
60
- lookup.to_s.should == "(?-mix:^\\/foo\\/([^\\/?#]+)$)"
60
+ expect(lookup.to_s).to eq("(?-mix:^\\/foo\\/([^\\/?#]+)$)")
61
61
 
62
- keys.should == ["bar"]
62
+ expect(keys).to eq(["bar"])
63
63
  end
64
64
 
65
65
  it "should match correctly" do
66
66
  lookup, keys, block = @router.compile! "/foo/:bar" do; end
67
- lookup.to_s.should == "(?-mix:^\\/foo\\/([^\\/?#]+)$)"
67
+ expect(lookup.to_s).to eq("(?-mix:^\\/foo\\/([^\\/?#]+)$)")
68
68
 
69
- lookup.match("/foo/baz").should_not be_nil
70
- lookup.match("/foo2/baz").should be_nil
71
- lookup.match("/baz/foo/baz").should be_nil
72
- lookup.match("/foo/baz/bar").should be_nil
69
+ expect(lookup.match("/foo/baz")).not_to be_nil
70
+ expect(lookup.match("/foo2/baz")).to be_nil
71
+ expect(lookup.match("/baz/foo/baz")).to be_nil
72
+ expect(lookup.match("/foo/baz/bar")).to be_nil
73
73
  end
74
74
  end
75
75
 
76
76
  context "with splat" do
77
77
  it "should work with splats" do
78
78
  lookup, keys, block = @router.compile! "/foo/*" do; end
79
- lookup.to_s.should == "(?-mix:^\\/foo\\/(.*?)$)"
80
- keys.should == ["splat"]
79
+ expect(lookup.to_s).to eq("(?-mix:^\\/foo\\/(.*?)$)")
80
+ expect(keys).to eq(["splat"])
81
81
  end
82
82
 
83
83
  it "should match correctly" do
84
84
  lookup, keys, block = @router.compile! "/foo/*" do; end
85
85
 
86
- lookup.match("/foo/baz/bar/bam").should_not be_nil
87
- lookup.match("/foo2/baz").should be_nil
88
- lookup.match("/baz/foo/baz").should be_nil
86
+ expect(lookup.match("/foo/baz/bar/bam")).not_to be_nil
87
+ expect(lookup.match("/foo2/baz")).to be_nil
88
+ expect(lookup.match("/baz/foo/baz")).to be_nil
89
89
  end
90
90
  end
91
91
  end
data/spec/server_spec.rb CHANGED
@@ -18,20 +18,36 @@ if ENV["WITH_SERVER_SPECS"].to_i == 1
18
18
 
19
19
  @host = "0.0.0.0"
20
20
  @port = 12345
21
+ @environment = 'test'
21
22
 
22
23
  @application.config[:host] = @host
23
24
  @application.config[:port] = @port
25
+ @application.config[:env] = @environment
24
26
 
25
27
  @request = Gopher::Request.new("foo", "bar")
26
28
 
27
- @response = Gopher::Response.new(@request)
29
+ @response = Gopher::Response.new
28
30
  @response.code = :success
29
31
  @response.body = "hi"
30
32
  end
31
33
 
34
+ it "returns host" do
35
+ @application.config[:host] = 'gopher-site.test'
36
+ expect(@application.host).to eql('gopher-site.test')
37
+ end
38
+
39
+ it "returns port" do
40
+ expect(@application.port).to eql(@port)
41
+ end
42
+
43
+ it "returns environment" do
44
+ expect(@application.env).to eql(@environment)
45
+ end
46
+
47
+
32
48
  it "should work in non-blocking mode" do
33
49
  @application.fake_response = @response
34
- @application.stub!(:non_blocking?).and_return(false)
50
+ allow(@application).to receive(:non_blocking?).and_return(false)
35
51
 
36
52
  ::EM.run {
37
53
  server = Gopher::Server.new(@application)
@@ -42,7 +58,7 @@ if ENV["WITH_SERVER_SPECS"].to_i == 1
42
58
  socket.send_data("123\n")
43
59
 
44
60
  socket.onopen = lambda {
45
- socket.data.last.chomp.should == "hi\r\n."
61
+ expect(socket.data.last.chomp).to eq("hi\r\n.")
46
62
  EM.stop
47
63
  }
48
64
  }
@@ -60,7 +76,7 @@ if ENV["WITH_SERVER_SPECS"].to_i == 1
60
76
  socket.send_data("123\n")
61
77
 
62
78
  socket.onopen = lambda {
63
- socket.data.last.chomp.should == "hi\r\n."
79
+ expect(socket.data.last.chomp).to eq("hi\r\n.")
64
80
  EM.stop
65
81
  }
66
82
  }
@@ -78,7 +94,7 @@ if ENV["WITH_SERVER_SPECS"].to_i == 1
78
94
  socket.send_data("123\n")
79
95
 
80
96
  socket.onopen = lambda {
81
- socket.data.last.chomp.should == "hi\r\n."
97
+ expect(socket.data.last.chomp).to eq("hi\r\n.")
82
98
  EM.stop
83
99
  }
84
100
  }
@@ -100,7 +116,7 @@ if ENV["WITH_SERVER_SPECS"].to_i == 1
100
116
  socket.send_data("123\n")
101
117
 
102
118
  socket.onopen = lambda {
103
- socket.data.last.chomp.should == "hi"
119
+ expect(socket.data.last.chomp).to eq("hi")
104
120
  EM.stop
105
121
  }
106
122
  }
@@ -118,7 +134,7 @@ if ENV["WITH_SERVER_SPECS"].to_i == 1
118
134
  socket.send_data("123\n")
119
135
 
120
136
  socket.onopen = lambda {
121
- socket.data.last.chomp.should == "hi\r\n."
137
+ expect(socket.data.last.chomp).to eq("hi\r\n.")
122
138
  EM.stop
123
139
  }
124
140
  }
metadata CHANGED
@@ -1,126 +1,169 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gopher2000
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Colin Mitchell
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-05-02 00:00:00.000000000Z
11
+ date: 2021-06-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
- requirement: &18116460 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *18116460
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: redcarpet
27
- requirement: &18115520 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *18115520
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: yard
38
- requirement: &18114820 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *18114820
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: shoulda
49
- requirement: &18113580 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ! '>='
59
+ - - ">="
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *18113580
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rdoc
60
- requirement: &18093380 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ! '>='
73
+ - - ">="
64
74
  - !ruby/object:Gem::Version
65
75
  version: '0'
66
76
  type: :development
67
77
  prerelease: false
68
- version_requirements: *18093380
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: simplecov
71
- requirement: &18092340 !ruby/object:Gem::Requirement
72
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
- - - ! '>='
87
+ - - "~>"
75
88
  - !ruby/object:Gem::Version
76
- version: '0'
89
+ version: 0.16.1
77
90
  type: :development
78
91
  prerelease: false
79
- version_requirements: *18092340
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.16.1
80
97
  - !ruby/object:Gem::Dependency
81
98
  name: watchr
82
- requirement: &18086720 !ruby/object:Gem::Requirement
83
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
84
100
  requirements:
85
- - - ! '>='
101
+ - - ">="
86
102
  - !ruby/object:Gem::Version
87
103
  version: '0'
88
104
  type: :development
89
105
  prerelease: false
90
- version_requirements: *18086720
91
- - !ruby/object:Gem::Dependency
92
- name: eventmachine
93
- requirement: &18032500 !ruby/object:Gem::Requirement
94
- none: false
106
+ version_requirements: !ruby/object:Gem::Requirement
95
107
  requirements:
96
- - - ! '>='
108
+ - - ">="
97
109
  - !ruby/object:Gem::Version
98
110
  version: '0'
99
- type: :development
111
+ - !ruby/object:Gem::Dependency
112
+ name: artii
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.0.1
118
+ type: :runtime
100
119
  prerelease: false
101
- version_requirements: *18032500
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 2.0.1
102
125
  - !ruby/object:Gem::Dependency
103
126
  name: eventmachine
104
- requirement: &18031440 !ruby/object:Gem::Requirement
105
- none: false
127
+ requirement: !ruby/object:Gem::Requirement
106
128
  requirements:
107
- - - ! '>='
129
+ - - "~>"
108
130
  - !ruby/object:Gem::Version
109
- version: '0'
131
+ version: 1.2.5
110
132
  type: :runtime
111
133
  prerelease: false
112
- version_requirements: *18031440
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.2.5
113
139
  - !ruby/object:Gem::Dependency
114
140
  name: logging
115
- requirement: &18029980 !ruby/object:Gem::Requirement
116
- none: false
141
+ requirement: !ruby/object:Gem::Requirement
117
142
  requirements:
118
- - - ! '>='
143
+ - - ">="
119
144
  - !ruby/object:Gem::Version
120
145
  version: '0'
121
146
  type: :runtime
122
147
  prerelease: false
123
- version_requirements: *18029980
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: mimemagic
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
124
167
  description: Gopher2000 is a ruby-based Gopher server. It is built for speedy, enjoyable
125
168
  development of all sorts of gopher sites.
126
169
  email:
@@ -130,14 +173,17 @@ executables:
130
173
  extensions: []
131
174
  extra_rdoc_files: []
132
175
  files:
133
- - .gitignore
134
- - .rvmrc
176
+ - ".github/workflows/ci.yml"
177
+ - ".gitignore"
178
+ - ".ruby-version"
179
+ - Dockerfile
135
180
  - Gemfile
136
181
  - LICENSE.txt
137
182
  - README.markdown
138
183
  - Rakefile
139
184
  - bin/gopher2000
140
185
  - examples/default_route.rb
186
+ - examples/figlet.rb
141
187
  - examples/nyan.rb
142
188
  - examples/simple.rb
143
189
  - examples/twitter.rb
@@ -179,33 +225,40 @@ files:
179
225
  homepage: https://github.com/muffinista/gopher2000
180
226
  licenses:
181
227
  - WTFPL
182
- post_install_message:
228
+ metadata: {}
229
+ post_install_message:
183
230
  rdoc_options: []
184
231
  require_paths:
185
232
  - lib
186
233
  required_ruby_version: !ruby/object:Gem::Requirement
187
- none: false
188
234
  requirements:
189
- - - ! '>='
235
+ - - ">="
190
236
  - !ruby/object:Gem::Version
191
237
  version: '0'
192
- segments:
193
- - 0
194
- hash: -579980991170337830
195
238
  required_rubygems_version: !ruby/object:Gem::Requirement
196
- none: false
197
239
  requirements:
198
- - - ! '>='
240
+ - - ">="
199
241
  - !ruby/object:Gem::Version
200
242
  version: '0'
201
- segments:
202
- - 0
203
- hash: -579980991170337830
204
243
  requirements: []
205
- rubyforge_project: gopher2000
206
- rubygems_version: 1.8.17
207
- signing_key:
208
- specification_version: 3
244
+ rubygems_version: 3.0.8
245
+ signing_key:
246
+ specification_version: 4
209
247
  summary: Gopher2000 - A Gopher server for the next millenium
210
- test_files: []
211
- has_rdoc:
248
+ test_files:
249
+ - spec/application_spec.rb
250
+ - spec/dispatching_spec.rb
251
+ - spec/dsl_spec.rb
252
+ - spec/gopher_spec.rb
253
+ - spec/handlers/directory_handler_spec.rb
254
+ - spec/helpers_spec.rb
255
+ - spec/rendering/base_spec.rb
256
+ - spec/rendering/menu_spec.rb
257
+ - spec/rendering_spec.rb
258
+ - spec/request_spec.rb
259
+ - spec/response_spec.rb
260
+ - spec/routing_spec.rb
261
+ - spec/sandbox/old/socks.txt
262
+ - spec/sandbox/socks.txt
263
+ - spec/server_spec.rb
264
+ - spec/spec_helper.rb