tcr 0.2.2 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6c3b335b522930e2cda40cc99bacc68109e13189
4
- data.tar.gz: 25d3fe32caf69278fc4753763e1c1ba84640a5c1
2
+ SHA256:
3
+ metadata.gz: ab0a471bccd0a80a5d75bec6909dc521072b2ad666af34935f1d6ab596d9f2b4
4
+ data.tar.gz: eb6d9817d928173edd5354dc206fe7dd3e35a0f38ffde356e0e6e233e0a58431
5
5
  SHA512:
6
- metadata.gz: ee2afda4d4a575fee8d988d12a56b1bfe27f30dac317776232fddc019499addec91348d8c3545fbf0cccdfef0c3153b5016f66a21e8767d9e7b345fe1f7f59f9
7
- data.tar.gz: 7cc411a8feb6d80c3ee2b4541141d90e0d47845853474a69255a6b0773b683d1b2e417dc7539013adb059c5d5abc94464b4825a2e3948b2ebd212747886dfc98
6
+ metadata.gz: cedcebdd9373876a73534581ef013945ab20912ba86b71375b14de26043c135420f5140a2c1cf9d920afc9eacaa9b2f567d173c5d2525aa60db19ac97f43f606
7
+ data.tar.gz: d41afdda3c2d24c85e461db3247fed88ed5c9019e0929251c03b199b37dc3dc7a261796c3266041aea90ffbdf9b0c6053a2e627a9e7b7258382430db85df66a9
@@ -0,0 +1,47 @@
1
+ name: TCR Spec Suite
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ name: Test
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ ruby:
16
+ - "2.0.0"
17
+ - "2.1.9"
18
+ - "2.2.10"
19
+ - "2.3.7"
20
+ - "2.4.4"
21
+ - "2.5.1"
22
+ - "2.7.3"
23
+ - "3.0.1"
24
+
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+
28
+ - name: Initial setup
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+
33
+ - name: Install dependencies
34
+ run: bundle install
35
+
36
+ - name: Run tests
37
+ run: bundle exec rspec
38
+
39
+ testall:
40
+ if: ${{ always() }}
41
+ runs-on: ubuntu-latest
42
+ name: Test (matrix)
43
+ needs: [test]
44
+ steps:
45
+ - name: Check status of all test runs
46
+ if: ${{ needs.test.result != 'success' }}
47
+ run: exit 1
@@ -27,28 +27,33 @@ module TCR
27
27
  end
28
28
  end
29
29
 
30
- def read(bytes)
31
- _read(:read, bytes)
30
+ def read(*args)
31
+ _read(:read, args)
32
32
  end
33
33
 
34
34
  def getc(*args)
35
- _read(:getc, *args)
35
+ _read(:getc, args)
36
36
  end
37
37
 
38
38
  def gets(*args)
39
- _read(:gets, *args)
39
+ _read(:gets, args)
40
40
  end
41
41
 
42
42
  def read_nonblock(*args)
43
- _read(:read_nonblock, *args, blocking: false)
43
+ _read(:read_nonblock, args, blocking: false)
44
44
  end
45
45
 
46
- def print(str)
47
- _write(:print, str)
46
+ def print(str, *args)
47
+ _write(:print, str, args)
48
48
  end
49
49
 
50
- def write(str)
51
- _write(:write, str)
50
+ def write(str, *args)
51
+ _write(:write, str, args)
52
+ str.length
53
+ end
54
+
55
+ def write_nonblock(str, *args)
56
+ _write(:write_nonblock, str, args)
52
57
  str.length
53
58
  end
54
59
 
@@ -99,10 +104,10 @@ module TCR
99
104
  @read_lock << 1
100
105
  end
101
106
 
102
- def _write(method, data)
107
+ def _write(method, data, args)
103
108
  if live
104
109
  payload = data.dup if !data.is_a?(Symbol)
105
- @socket.__send__(method, payload)
110
+ _delegate_call(method, args.unshift(payload))
106
111
  recording << ["write", data.dup]
107
112
  else
108
113
  direction, data = recording.shift
@@ -111,14 +116,11 @@ module TCR
111
116
  end
112
117
  end
113
118
 
114
- def _read(method, *args)
115
- blocking = true
116
- if args.last.is_a?(::Hash)
117
- blocking = args.pop.fetch(:blocking, true)
118
- end
119
+ def _read(method, args, opts = {})
120
+ blocking = opts.fetch(:blocking, true)
119
121
 
120
122
  if live
121
- data = @socket.__send__(method, *args)
123
+ data = _delegate_call(method, args)
122
124
  payload = data.dup if !data.is_a?(Symbol)
123
125
  recording << ["read", payload]
124
126
  else
@@ -130,6 +132,15 @@ module TCR
130
132
  data
131
133
  end
132
134
 
135
+ def _delegate_call(method, args)
136
+ if RUBY_VERSION >= "2.7" && Hash === args.last
137
+ kwargs = args.pop
138
+ @socket.__send__(method, *args, **kwargs)
139
+ else
140
+ @socket.__send__(method, *args)
141
+ end
142
+ end
143
+
133
144
  def _ensure_direction(desired, actual)
134
145
  raise TCR::DirectionMismatchError.new("Expected to '#{desired}' but next in recording was '#{actual}'") unless desired == actual
135
146
  end
@@ -146,6 +157,14 @@ module TCR
146
157
  end
147
158
  end
148
159
 
160
+ def ssl_version
161
+ ""
162
+ end
163
+
164
+ def cipher
165
+ []
166
+ end
167
+
149
168
  def sync_close=(arg)
150
169
  true
151
170
  end
@@ -169,6 +188,9 @@ module TCR
169
188
  def session=(args)
170
189
  end
171
190
 
191
+ def hostname=(args)
192
+ end
193
+
172
194
  def io
173
195
  self
174
196
  end
data/lib/tcr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TCR
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -19,7 +19,6 @@ end
19
19
 
20
20
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
21
  RSpec.configure do |config|
22
- config.treat_symbols_as_metadata_keys_with_true_values = true
23
22
  config.run_all_when_everything_filtered = true
24
23
  config.filter_run :focus
25
24
 
data/spec/tcr_spec.rb CHANGED
@@ -422,9 +422,9 @@ RSpec.describe TCR do
422
422
  it "raises an error if you try to playback more sessions than you previously recorded" do
423
423
  expect {
424
424
  TCR.use_cassette("spec/fixtures/multitest-smtp") do
425
- smtp = Net::SMTP.start("smtp.mandrillapp.com", 2525)
426
- smtp = Net::SMTP.start("mail.smtp2go.com", 2525)
427
- smtp = Net::SMTP.start("mail.smtp2go.com", 2525)
425
+ smtp = Net::SMTP.start("smtp.mandrillapp.com", 2525, starttls: false)
426
+ smtp = Net::SMTP.start("mail.smtp2go.com", 2525, starttls: false)
427
+ smtp = Net::SMTP.start("mail.smtp2go.com", 2525, starttls: false)
428
428
  end
429
429
  }.to raise_error(TCR::NoMoreSessionsError)
430
430
  end
@@ -432,7 +432,7 @@ RSpec.describe TCR do
432
432
  it "raises an error if you try to playback less sessions than you previously recorded" do
433
433
  expect {
434
434
  TCR.use_cassette("spec/fixtures/multitest-extra-smtp", hit_all: true) do
435
- smtp = Net::SMTP.start("smtp.mandrillapp.com", 2525)
435
+ smtp = Net::SMTP.start("smtp.mandrillapp.com", 2525, starttls: false)
436
436
  end
437
437
  }.to raise_error(TCR::ExtraSessionsError)
438
438
  end
@@ -467,12 +467,12 @@ RSpec.describe TCR do
467
467
 
468
468
  it "replaces sockets created with Socket.tcp" do
469
469
  TCR.configure { |c|
470
- c.hook_tcp_ports = [23]
470
+ c.hook_tcp_ports = [80]
471
471
  c.cassette_library_dir = "."
472
472
  }
473
473
 
474
474
  TCR.use_cassette("test") do
475
- sock = Socket.tcp("towel.blinkenlights.nl", 23)
475
+ sock = Socket.tcp("google.com", 80)
476
476
  expect(sock).to be_a(TCR::RecordableTCPSocket)
477
477
  end
478
478
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Forman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-22 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -87,9 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/tcr.yml"
90
91
  - ".gitignore"
91
92
  - ".rvmrc"
92
- - ".travis.yml"
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
@@ -118,7 +118,7 @@ files:
118
118
  homepage: ''
119
119
  licenses: []
120
120
  metadata: {}
121
- post_install_message:
121
+ post_install_message:
122
122
  rdoc_options: []
123
123
  require_paths:
124
124
  - lib
@@ -133,9 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.4.5
138
- signing_key:
136
+ rubygems_version: 3.4.7
137
+ signing_key:
139
138
  specification_version: 4
140
139
  summary: TCR is a lightweight VCR for TCP sockets.
141
140
  test_files:
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "2.0.0"
4
- - "2.1.10"
5
- - "2.2.10"
6
- - "2.3.7"
7
- - "2.4.4"
8
- - "2.5.1"
9
- before_install:
10
- - gem install bundler
11
- script: bundle exec rspec