tinder 1.3.1 → 1.10.1
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.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/.gitignore +6 -3
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.txt +54 -0
- data/Gemfile +7 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +47 -0
- data/Rakefile +7 -63
- data/init.rb +1 -1
- data/lib/faraday/response/raise_on_authentication_failure.rb +10 -0
- data/lib/faraday/response/remove_whitespace.rb +10 -0
- data/lib/tinder/campfire.rb +28 -51
- data/lib/tinder/connection.rb +108 -9
- data/lib/tinder/room.rb +205 -97
- data/lib/tinder/version.rb +4 -0
- data/lib/tinder.rb +12 -8
- data/site/index.html +7 -7
- data/spec/fixtures/presence.json +26 -0
- data/spec/fixtures/rooms/recent.json +19 -0
- data/spec/fixtures/rooms/room80749.json +21 -0
- data/spec/fixtures/rooms/room80751.json +21 -0
- data/spec/fixtures/rooms/show.json +21 -0
- data/spec/fixtures/rooms.json +18 -0
- data/spec/fixtures/users/me.json +11 -0
- data/spec/spec_helper.rb +26 -2
- data/spec/tinder/campfire_spec.rb +112 -0
- data/spec/tinder/connection_spec.rb +104 -0
- data/spec/tinder/room_spec.rb +364 -0
- data/tinder.gemspec +26 -74
- metadata +206 -82
- data/Manifest.txt +0 -10
- data/README.txt +0 -54
- data/VERSION +0 -1
- data/lib/tinder/multipart.rb +0 -63
- data/spec/campfire_spec.rb +0 -225
- data/spec/html/full_lobby.html +0 -198
- data/spec/html/normal_lobby.html +0 -192
- data/spec/html/transcript.html +0 -133
- data/spec/spec.opts +0 -1
- data/test/remote/credentials.rb.example +0 -4
- data/test/remote/remote_campfire_test.rb +0 -59
- data/test/test_helper.rb +0 -2
metadata
CHANGED
@@ -1,120 +1,244 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinder
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Brandon Keepers
|
8
|
+
- Brian Ryckbost
|
9
|
+
- Tony Coconate
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: eventmachine
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: faraday
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.9.0
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.9.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: faraday_middleware
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.9'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.9'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: hashie
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
21
61
|
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: httparty
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.0'
|
27
64
|
type: :runtime
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
31
68
|
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
|
35
|
-
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '1.0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: json
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.0
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.8.0
|
85
|
+
- !ruby/object:Gem::Dependency
|
36
86
|
name: mime-types
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: multi_json
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.7'
|
106
|
+
type: :runtime
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - "~>"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '1.7'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: twitter-stream
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0.1'
|
37
120
|
type: :runtime
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0.1'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: fakeweb
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
41
131
|
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
|
45
|
-
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: rake
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
- !ruby/object:Gem::Dependency
|
46
156
|
name: rspec
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
47
162
|
type: :development
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
51
166
|
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version:
|
54
|
-
|
55
|
-
|
56
|
-
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
description: A Ruby API for interfacing with Campfire, the 37Signals chat application.
|
170
|
+
email:
|
171
|
+
- brandon@opensoul.org
|
172
|
+
- bryckbost@gmail.com
|
173
|
+
- me@tonycoconate.com
|
57
174
|
executables: []
|
58
|
-
|
59
175
|
extensions: []
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
- .gitignore
|
176
|
+
extra_rdoc_files:
|
177
|
+
- README.markdown
|
178
|
+
files:
|
179
|
+
- ".gemtest"
|
180
|
+
- ".gitignore"
|
181
|
+
- ".rspec"
|
182
|
+
- ".travis.yml"
|
65
183
|
- CHANGELOG.txt
|
66
|
-
-
|
67
|
-
-
|
184
|
+
- Gemfile
|
185
|
+
- MIT-LICENSE
|
186
|
+
- README.markdown
|
68
187
|
- Rakefile
|
69
|
-
- VERSION
|
70
188
|
- init.rb
|
189
|
+
- lib/faraday/response/raise_on_authentication_failure.rb
|
190
|
+
- lib/faraday/response/remove_whitespace.rb
|
71
191
|
- lib/tinder.rb
|
72
192
|
- lib/tinder/campfire.rb
|
73
193
|
- lib/tinder/connection.rb
|
74
|
-
- lib/tinder/multipart.rb
|
75
194
|
- lib/tinder/room.rb
|
195
|
+
- lib/tinder/version.rb
|
76
196
|
- site/index.html
|
77
197
|
- site/stylesheets/style.css
|
78
|
-
- spec/
|
79
|
-
- spec/
|
80
|
-
- spec/
|
81
|
-
- spec/
|
82
|
-
- spec/
|
198
|
+
- spec/fixtures/presence.json
|
199
|
+
- spec/fixtures/rooms.json
|
200
|
+
- spec/fixtures/rooms/recent.json
|
201
|
+
- spec/fixtures/rooms/room80749.json
|
202
|
+
- spec/fixtures/rooms/room80751.json
|
203
|
+
- spec/fixtures/rooms/show.json
|
204
|
+
- spec/fixtures/users/me.json
|
83
205
|
- spec/spec_helper.rb
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
206
|
+
- spec/tinder/campfire_spec.rb
|
207
|
+
- spec/tinder/connection_spec.rb
|
208
|
+
- spec/tinder/room_spec.rb
|
87
209
|
- tinder.gemspec
|
88
|
-
has_rdoc: true
|
89
210
|
homepage: http://github.com/collectiveidea/tinder
|
90
211
|
licenses: []
|
91
|
-
|
212
|
+
metadata: {}
|
92
213
|
post_install_message:
|
93
|
-
rdoc_options:
|
94
|
-
|
95
|
-
require_paths:
|
214
|
+
rdoc_options: []
|
215
|
+
require_paths:
|
96
216
|
- lib
|
97
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
217
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
99
219
|
- - ">="
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version:
|
102
|
-
|
103
|
-
|
104
|
-
requirements:
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
|
+
requirements:
|
105
224
|
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version:
|
108
|
-
version:
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: 1.3.6
|
109
227
|
requirements: []
|
110
|
-
|
111
|
-
|
112
|
-
rubygems_version: 1.3.5
|
228
|
+
rubyforge_project:
|
229
|
+
rubygems_version: 2.2.2
|
113
230
|
signing_key:
|
114
|
-
specification_version:
|
115
|
-
summary:
|
116
|
-
test_files:
|
117
|
-
- spec/
|
231
|
+
specification_version: 4
|
232
|
+
summary: Ruby wrapper for the Campfire API
|
233
|
+
test_files:
|
234
|
+
- spec/fixtures/presence.json
|
235
|
+
- spec/fixtures/rooms.json
|
236
|
+
- spec/fixtures/rooms/recent.json
|
237
|
+
- spec/fixtures/rooms/room80749.json
|
238
|
+
- spec/fixtures/rooms/room80751.json
|
239
|
+
- spec/fixtures/rooms/show.json
|
240
|
+
- spec/fixtures/users/me.json
|
118
241
|
- spec/spec_helper.rb
|
119
|
-
-
|
120
|
-
-
|
242
|
+
- spec/tinder/campfire_spec.rb
|
243
|
+
- spec/tinder/connection_spec.rb
|
244
|
+
- spec/tinder/room_spec.rb
|
data/Manifest.txt
DELETED
data/README.txt
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
= Tinder - get the Campfire started
|
2
|
-
|
3
|
-
|
4
|
-
This branch is a rewrite of Tinder to use the official Campfire API. The API is intended to be backwards compatible so consumers can easily migrate off the HTML API.
|
5
|
-
|
6
|
-
-- Joshua Peek (Programmer, 37signals)
|
7
|
-
|
8
|
-
|
9
|
-
Tinder is a library for interfacing with Campfire, the chat application from 37Signals. Unlike Marshmallow, it is designed to be a full-featured API (since 37Signals doesn't provide a real one), allowing you to programatically manage and speak/listen in chat rooms.
|
10
|
-
|
11
|
-
== Usage
|
12
|
-
|
13
|
-
campfire = Tinder::Campfire.new 'mysubdomain'
|
14
|
-
campfire.login 'myemail@example.com', 'mypassword'
|
15
|
-
|
16
|
-
room = campfire.create_room 'New Room', 'My new campfire room to test tinder'
|
17
|
-
room.rename 'New Room Name'
|
18
|
-
room.speak 'Hello world!'
|
19
|
-
room.paste "my pasted\ncode"
|
20
|
-
room.destroy
|
21
|
-
|
22
|
-
room = campfire.find_room_by_guest_hash 'abc123', 'John Doe'
|
23
|
-
room.speak 'Hello world!'
|
24
|
-
|
25
|
-
See the RDoc for more details.
|
26
|
-
|
27
|
-
== Installation
|
28
|
-
|
29
|
-
Tinder can be installed as a gem or a Rails plugin:
|
30
|
-
|
31
|
-
gem install tinder
|
32
|
-
|
33
|
-
script/plugin install git://github.com/collectiveidea/tinder.git
|
34
|
-
|
35
|
-
== How to contribute
|
36
|
-
|
37
|
-
If you find what looks like a bug:
|
38
|
-
|
39
|
-
1. Check the GitHub issue tracker to see if anyone else has had the same issue.
|
40
|
-
http://github.com/collectiveidea/tinder/issues/
|
41
|
-
2. If you don't see anything, create an issue with information on how to reproduce it.
|
42
|
-
|
43
|
-
If you want to contribute an enhancement or a fix:
|
44
|
-
|
45
|
-
1. Fork the project on github.
|
46
|
-
http://github.com/collectiveidea/tinder
|
47
|
-
2. Make your changes with tests.
|
48
|
-
3. Commit the changes without making changes to the Rakefile, VERSION, or any other files that aren't related to your enhancement or fix
|
49
|
-
4. Send a pull request.
|
50
|
-
|
51
|
-
== ToDo
|
52
|
-
|
53
|
-
* Tests! (unit and remote)
|
54
|
-
* Marshmallow-style integration scripts for exception notification and continuous integration
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.3.1
|
data/lib/tinder/multipart.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'mime/types'
|
2
|
-
require 'net/http'
|
3
|
-
require 'cgi'
|
4
|
-
|
5
|
-
module Multipart #:nodoc:
|
6
|
-
# From: http://deftcode.com/code/flickr_upload/multipartpost.rb
|
7
|
-
## Helper class to prepare an HTTP POST request with a file upload
|
8
|
-
## Mostly taken from
|
9
|
-
#http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/113774
|
10
|
-
### WAS:
|
11
|
-
## Anything that's broken and wrong probably the fault of Bill Stilwell
|
12
|
-
##(bill@marginalia.org)
|
13
|
-
### NOW:
|
14
|
-
## Everything wrong is due to keith@oreilly.com
|
15
|
-
|
16
|
-
class Param #:nodoc:
|
17
|
-
attr_accessor :k, :v
|
18
|
-
def initialize(k, v)
|
19
|
-
@k = k
|
20
|
-
@v = v
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_multipart
|
24
|
-
"Content-Disposition: form-data; name=\"#{k}\"\r\n\r\n#{v}\r\n"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class FileParam #:nodoc:
|
29
|
-
attr_accessor :k, :filename, :content
|
30
|
-
def initialize(k, filename, content)
|
31
|
-
@k = k
|
32
|
-
@filename = filename
|
33
|
-
@content = content
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_multipart
|
37
|
-
"Content-Disposition: form-data; name=\"#{k}\"; filename=\"#{filename}\"\r\n" +
|
38
|
-
"Content-Transfer-Encoding: binary\r\n" +
|
39
|
-
"Content-Type: #{MIME::Types.type_for(@filename)}\r\n\r\n" +
|
40
|
-
@content + "\r\n"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class MultipartPost #:nodoc:
|
45
|
-
BOUNDARY = 'campfire-is-awesome'
|
46
|
-
HEADER = {"Content-type" => "multipart/form-data, boundary=" + BOUNDARY + " "}
|
47
|
-
TIMEOUT_SECONDS = 30
|
48
|
-
|
49
|
-
attr_accessor :params, :query, :headers
|
50
|
-
def initialize(params)
|
51
|
-
@params = params
|
52
|
-
@query = {}
|
53
|
-
self.prepare_query
|
54
|
-
end
|
55
|
-
|
56
|
-
def prepare_query()
|
57
|
-
@query = @params.map do |k,v|
|
58
|
-
param = v.respond_to?(:read) ? FileParam.new(k, v.path, v.read) : Param.new(k, v)
|
59
|
-
"--#{BOUNDARY}\r\n#{param.to_multipart}"
|
60
|
-
end.join("") + "--#{BOUNDARY}--"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/spec/campfire_spec.rb
DELETED
@@ -1,225 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Preparing a campfire request" do
|
4
|
-
before do
|
5
|
-
@campfire = Tinder::Campfire.new("foobar")
|
6
|
-
@request = Net::HTTP::Get.new("does_not_matter")
|
7
|
-
end
|
8
|
-
|
9
|
-
def prepare_request
|
10
|
-
@campfire.send(:prepare_request, @request)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return the request" do
|
14
|
-
prepare_request.should equal(@request)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should set the cookie" do
|
18
|
-
@campfire.instance_variable_set("@cookie", "foobar")
|
19
|
-
prepare_request['Cookie'].should == 'foobar'
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should set the user agent" do
|
23
|
-
prepare_request['User-Agent'].should =~ /^Tinder/
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# describe "Performing a campfire request" do
|
28
|
-
#
|
29
|
-
# before do
|
30
|
-
# @response = mock("response")
|
31
|
-
# Net::HTTP.any_instance.stubs(:request).returns(response)
|
32
|
-
# request = Net::HTTP::Get.new("does_not_matter")
|
33
|
-
# response.expects(:[]).with('set-cookie').and_return('foobar')
|
34
|
-
# @campfire.send(:perform_request) { request }
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# it "should set cookie" do
|
38
|
-
# @campfire.instance_variable_get("@cookie").should == 'foobar'
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# end
|
42
|
-
|
43
|
-
describe "Verifying a 200 response" do
|
44
|
-
|
45
|
-
before do
|
46
|
-
@campfire = Tinder::Campfire.new("foobar")
|
47
|
-
@response = mock("response")
|
48
|
-
@response.should_receive(:code).and_return(200)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should return true when expecting success" do
|
52
|
-
@campfire.send(:verify_response, @response, :success).should equal(true)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should return false when expecting a redirect" do
|
56
|
-
@campfire.send(:verify_response, @response, :redirect).should equal(false)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should return false when expecting a redirect to a specific path" do
|
60
|
-
@campfire.send(:verify_response, @response, :redirect_to => '/foobar').should equal(false)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "Verifying a 302 response" do
|
66
|
-
|
67
|
-
before do
|
68
|
-
@campfire = Tinder::Campfire.new("foobar")
|
69
|
-
@response = mock("response")
|
70
|
-
@response.should_receive(:code).and_return(302)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should return true when expecting redirect" do
|
74
|
-
@campfire.send(:verify_response, @response, :redirect).should equal(true)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should return false when expecting success" do
|
78
|
-
@campfire.send(:verify_response, @response, :success).should equal(false)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should return true when expecting a redirect to a specific path" do
|
82
|
-
@response.should_receive(:[]).with('location').and_return("/foobar")
|
83
|
-
@campfire.send(:verify_response, @response, :redirect_to => '/foobar').should equal(true)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should return false when redirecting to a different path than expected" do
|
87
|
-
@response.should_receive(:[]).with('location').and_return("/baz")
|
88
|
-
@campfire.send(:verify_response, @response, :redirect_to => '/foobar').should equal(false)
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "A failed login" do
|
94
|
-
|
95
|
-
before do
|
96
|
-
@campfire = Tinder::Campfire.new 'foobar'
|
97
|
-
@response = mock("response")
|
98
|
-
@campfire.should_receive(:post).and_return(@response)
|
99
|
-
@response.should_receive(:code).and_return("302")
|
100
|
-
@response.should_receive(:[]).with("location").and_return("/login")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should raise an error" do
|
104
|
-
lambda do
|
105
|
-
@campfire.login "doesn't", "matter"
|
106
|
-
end.should raise_error(Tinder::Error)
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should not set logged in status" do
|
110
|
-
@campfire.login 'foo', 'bar' rescue
|
111
|
-
@campfire.logged_in?.should equal(false)
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "Accessing a room with guest access" do
|
117
|
-
|
118
|
-
before do
|
119
|
-
@room_id = 123
|
120
|
-
@campfire = Tinder::Campfire.new 'foobar'
|
121
|
-
@response = mock("response")
|
122
|
-
@campfire.stub!(:post).and_return(@response)
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should return a room for the public room" do
|
126
|
-
@response.should_receive(:code).and_return(302)
|
127
|
-
@response.should_receive(:[]).with("location").and_return("/rooms/#{@room_id}")
|
128
|
-
|
129
|
-
room = @campfire.find_room_by_guest_hash "valid_hash", "John Doe"
|
130
|
-
room.should be_kind_of(Tinder::Room)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should raise an error if given an invalid room hash" do
|
134
|
-
@response.should_receive(:code).and_return(500)
|
135
|
-
|
136
|
-
room = @campfire.find_room_by_guest_hash "invalid_hash", "John Doe"
|
137
|
-
room.should be_nil
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "Accessing a room" do
|
143
|
-
|
144
|
-
before do
|
145
|
-
@request = mock("request")
|
146
|
-
@response = mock("response")
|
147
|
-
Net::HTTP.stub!(:new).and_return(@request)
|
148
|
-
@request.stub!(:use_ssl=)
|
149
|
-
@request.stub!(:request).and_return(@response)
|
150
|
-
@response.stub!(:[]).and_return(true)
|
151
|
-
end
|
152
|
-
|
153
|
-
describe "when the room is full" do
|
154
|
-
|
155
|
-
before do
|
156
|
-
@html = File.read(File.dirname(__FILE__) + '/html/full_lobby.html')
|
157
|
-
@response.stub!(:body).and_return(@html)
|
158
|
-
@campfire = Tinder::Campfire.new 'foobar'
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should return a room" do
|
162
|
-
@campfire.rooms.should_not be_empty
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should find a room by name" do
|
166
|
-
@campfire.find_room_by_name("Just Fishin").class.should == Tinder::Room
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "when the room is not full" do
|
172
|
-
|
173
|
-
before do
|
174
|
-
@html = File.read(File.dirname(__FILE__) + '/html/normal_lobby.html')
|
175
|
-
@response.stub!(:body).and_return(@html)
|
176
|
-
@campfire = Tinder::Campfire.new 'foobar'
|
177
|
-
end
|
178
|
-
|
179
|
-
it "should return a room" do
|
180
|
-
@campfire.rooms.should_not be_empty
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should find a room by name" do
|
184
|
-
@campfire.find_room_by_name("Just Fishin").class.should == Tinder::Room
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
describe "Accessing a room's transcript" do
|
191
|
-
|
192
|
-
before do
|
193
|
-
@room = Tinder::Room.new nil, 42
|
194
|
-
@html = File.read(File.dirname(__FILE__) + '/html/transcript.html')
|
195
|
-
@response = mock("response")
|
196
|
-
@response.stub!(:body).and_return(@html)
|
197
|
-
@room.stub!(:get).with("room/42/transcript/2009/05/05").
|
198
|
-
and_return(@response)
|
199
|
-
require 'time'
|
200
|
-
@transcript = @room.transcript(Time.parse("2009-05-05"))
|
201
|
-
end
|
202
|
-
|
203
|
-
it "should return some messages" do
|
204
|
-
@transcript.should_not be_empty
|
205
|
-
end
|
206
|
-
|
207
|
-
describe "the first message" do
|
208
|
-
# This is a timestamp message
|
209
|
-
it "should include a timestamp" do
|
210
|
-
@transcript.first[:timestamp].should == Time.parse("2009-05-05 09:35")
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
describe "the second message" do
|
215
|
-
it "should include a timestamp" do
|
216
|
-
@transcript.second[:timestamp].should == Time.parse("2009-05-05 09:35")
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe "when entering the room" do
|
221
|
-
it "a transcript message should include the person who entered" do
|
222
|
-
@transcript.second[:person].should == "Marcel"
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|