richard_iii 0.0.1 → 0.0.2

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
2
  SHA1:
3
- metadata.gz: 65a70f902d9b8500f4db967b05116131a43b41fd
4
- data.tar.gz: c200b5d2b2f1986d985fec79269ae7bec8223914
3
+ metadata.gz: 2778cafda0e669461d11038fb18214895b8718f7
4
+ data.tar.gz: 1011b06506a60f98edaf3d980e37b3d43d143cc6
5
5
  SHA512:
6
- metadata.gz: d032796f39e2951cc73fc5762b04306f3b5d54a9e12e81dce9324d272315fc261c3faf1526404510e352a511a7a75c6b6770aa4a37abb71f588472fea5866c5d
7
- data.tar.gz: 272a14327240bf2257d93ceb0aec27508af754c6670ab809093a49b4a1fe59837ad8016a65a39888e90c3830b710200bff3841e2ebeb199fb204a137777fdc36
6
+ metadata.gz: 547792d0cf8db701e128bd41ea1de9ad9e7b05caa3751d6811a322556cfbe50efa7aa2ee443a6841ae666030f52e7be8e5ad02d494c0206e9a1be9ac77aca85d
7
+ data.tar.gz: aa0bd33e8d43f0116cc838c83f2549c119e3dce4548ac288adf1af9ea07ed42276318d6218495b892e88e0260b6e00626439c524372543ca4932d31f92e74c3a
@@ -1,3 +1,3 @@
1
1
  module RichardIii
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/test/the_basics.rb CHANGED
@@ -1,20 +1,74 @@
1
1
  require 'minitest/autorun'
2
2
  require 'minitest/pride'
3
3
 
4
+ module Richard
5
+ module Internal
6
+ class RequestLineParser
7
+
8
+ end
9
+
10
+ class RequestLine
11
+ attr_reader :method, :uri
12
+
13
+ def initialize(opts = {})
14
+ @method,@uri = opts[:method],opts[:uri]
15
+ end
16
+
17
+ def eql?(other)
18
+ return self.method == other.method && self.uri == other.uri
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ module Richard
25
+ class III
26
+ def initialize(opts={})
27
+ @internet = opts[:internet] || fail("You need to supply :internet")
28
+ end
29
+
30
+ def exec(text)
31
+ lines = text.lines.map(&:chomp)
32
+
33
+ verb = lines.first.match(/^(\w+)/)[1]
34
+ path = lines.first.match(/(\S+)$/)[1]
35
+ host = lines[1].match(/Host: (.+)$/)[1]
36
+
37
+ @internet.execute Request.new(:verb => verb, :uri => "https://#{host}#{path}")
38
+ end
39
+ end
40
+ end
41
+
42
+ class Request
43
+ attr_reader :verb, :uri
44
+
45
+ def initialize(opts={})
46
+ @verb,@uri = opts[:verb],opts[:uri]
47
+ end
48
+
49
+ def eql?(other)
50
+ self.verb.eql?(other.verb) && self.uri.eql?(other.uri)
51
+ end
52
+ end
53
+
4
54
  describe 'The basics of Richard III' do
5
55
  it "can issue a very simple request" do
6
56
  spy_internet = MiniTest::Mock.new
7
57
 
8
- spy_internet.expect :execute, nil, []
58
+ spy_internet.expect :execute, nil do |actual|
59
+ actual.first.eql? Request.new(:verb => 'GET', :uri => 'https://api.twitter.com/1.1/statuses')
60
+ end
9
61
 
10
- richard_iii = Richard::III.new spy_internet
62
+ richard_iii = Richard::III.new :internet => spy_internet
11
63
 
12
64
  richard_iii.exec <<-TEXT
13
- GET /1.1/statuses
14
- Host: api.twitter.com
15
- Accept: application/json
65
+ GET /1.1/statuses
66
+ Host: api.twitter.com
67
+ Accept: application/json
16
68
  TEXT
17
69
 
18
70
  spy_internet.verify
19
71
  end
72
+
73
+ # TEST: where does it read the protocol part (HTTP of HTTPS)
20
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: richard_iii
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Biddington