hobby-test 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: 6630ab85ce09d1fbd6661bd8ec6201e66a73c197
4
- data.tar.gz: 7547c087095c379e16aafe99a62fb72dddedfba6
3
+ metadata.gz: 4a384dfdc98bfcbaf05e4d60a9555ecad3ad1ed1
4
+ data.tar.gz: ad4976cbbf499a72cc67adcc8e02044869ce2e44
5
5
  SHA512:
6
- metadata.gz: 4f2d0e876e7b6e10990418aa0318aeca79189b30f9953eb24c50fe2d212110a0c4603e5d00a5d061bb9a01f3f18219c11a07369dbbd91c6fcbb7149c3b745fa7
7
- data.tar.gz: 6f4c9b2756eb6fd613ed6ef211a208f5ef78eb74aa81312f81da11e0d5715dc8b86da986ab0aa2cd745e3a2d4ecc6bc1f27c14d2eff4bdc92a86083d9502d141
6
+ metadata.gz: b3836b972568d143e1713e720f93dab9fa04cb8cdc710e66b4ddb87b9dff865ec5eea9a98a8dd7f61d377c2959d25d4e2389071aac6d0caf96bd377f229345b1
7
+ data.tar.gz: 7abdd424b0b9b2ef3e0f27f9a218a1b21b54ceec6c868193fd778733de94141348c282995e04da3d9137705b61396b70cd2c4e359d7f75273f7ecc8154783a7f
data/hobby-test.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |g|
2
2
  g.name = 'hobby-test'
3
3
  g.files = `git ls-files`.split($/)
4
- g.version = '0.0.1'
4
+ g.version = '0.0.2'
5
5
  g.summary = 'A way to test HTTP exchanges via YAML specifications'
6
6
  g.authors = ['Anatoly Chernow']
7
7
 
@@ -18,6 +18,14 @@ class Hobby::Test::Exchange
18
18
  dup.assert response
19
19
  end
20
20
 
21
+ def compare_chain
22
+ if chain.end_with? '>', '=', '<'
23
+ actual_value.instance_eval "#{chain}(#{specified_value})"
24
+ else
25
+ (actual_value.instance_eval chain) == specified_value
26
+ end
27
+ end
28
+
21
29
  attr_reader :actual_value, :specified_value, :chain, :key
22
30
 
23
31
  class Status
@@ -30,6 +38,16 @@ class Hobby::Test::Exchange
30
38
  end
31
39
  end
32
40
 
41
+ class Headers
42
+ include Assert
43
+
44
+ def assert response
45
+ @actual_value = response.public_send key
46
+ @ok = chain.empty? ? actual_value == specified_value : compare_chain
47
+ self
48
+ end
49
+ end
50
+
33
51
  class Body
34
52
  include Assert
35
53
 
@@ -49,14 +67,6 @@ class Hobby::Test::Exchange
49
67
 
50
68
  self
51
69
  end
52
-
53
- def compare_chain
54
- if chain.end_with? '>', '=', '<'
55
- actual_value.instance_eval "#{chain}(#{specified_value})"
56
- else
57
- (actual_value.instance_eval chain) == specified_value
58
- end
59
- end
60
70
  end
61
71
  end
62
72
  end
data/spec/apps/main.rb CHANGED
@@ -3,7 +3,7 @@ require 'hobby/json'
3
3
 
4
4
  class MainApp
5
5
  include Hobby::App
6
- get { 'root-only app' }
6
+ get { 'root' }
7
7
 
8
8
  class Counter
9
9
  include Hobby::App
@@ -3,7 +3,7 @@
3
3
 
4
4
  response:
5
5
  status: 200
6
- body: root-only app
6
+ body: root
7
7
 
8
8
  - get:
9
9
  path: /non-existent
@@ -0,0 +1,10 @@
1
+ - get:
2
+ path: /hash
3
+
4
+ response:
5
+ status: 200
6
+ headers:
7
+ Content-Length: "19"
8
+ Content-Type: application/json
9
+ headers.>:
10
+ Content-Type: application/json
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobby-test
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
  - Anatoly Chernow
@@ -68,6 +68,7 @@ files:
68
68
  - spec/yml/passing/chain_assertions.yml
69
69
  - spec/yml/passing/counter.yml
70
70
  - spec/yml/passing/echo.yml
71
+ - spec/yml/passing/headers.yml
71
72
  - spec/yml/passing/query.yml
72
73
  - useful_links
73
74
  homepage: