faraday_simulation 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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faraday_simulation (0.0.1)
4
+ faraday_simulation (0.0.2)
5
5
  faraday
6
6
  rake
7
7
 
data/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # FaradaySimulation
2
2
 
3
- A [Faraday]() extension to provide dynamic stubbing. This makes it possible
4
- to simulate more of the behavior of the target service in your tests and when
5
- your app is running in development mode.
3
+ A [Faraday](https://github.com/technoweenie/faraday) extension to provide
4
+ dynamic stubbing. This makes it much easier to simulate the behavior
5
+ of the target service in your tests and when your app is running in
6
+ development mode.
6
7
 
7
8
 
8
9
  ## Usage
9
10
 
10
11
  The `FaradaySimulation::Adapter` class is the equivalent of Faraday's own
11
- test adapter, but you can do a bit more with the stubs:
12
+ test adapter, but the stubbing is more powerful:
12
13
 
13
14
  conn = Faraday::Connection.new { |builder|
14
15
  builder.use(FaradaySimulation::Adapter) { |stub|
@@ -29,8 +30,8 @@ any string, and that string will be the value of `env[:params]['foo']` in
29
30
  your stub block.
30
31
 
31
32
  For more complex routes, you can define the stub with a regular expression.
32
- Any regex group (you know, parenthesized pattern) in the matching regex will
33
- be placed in env[:segments]. For example:
33
+ Any regex group in the matching regex will be placed in `env[:segments]`.
34
+ For example:
34
35
 
35
36
  stub.get(/\/foo\/([A-Z]+)\//) { |env|
36
37
  [200, {}, "Segment is #{env[:segments][0]}"]
@@ -1,6 +1,8 @@
1
+ require 'cgi'
1
2
  require 'faraday'
2
3
 
3
4
  module FaradaySimulation
5
+
4
6
  end
5
7
 
6
8
  require 'faraday_simulation/stub'
@@ -36,7 +36,7 @@ class FaradaySimulation::Stub < Faraday::Adapter::Test::Stub
36
36
  params_match?(request_params) &&
37
37
  (body.to_s.size.zero? || request_body == body)
38
38
  )
39
- self.segments = md.to_a.slice(1, md.size)
39
+ self.segments = md.to_a.slice(1, md.size).collect { |s| CGI.unescape(s) }
40
40
  true
41
41
  else
42
42
  false
@@ -1,5 +1,5 @@
1
1
  module FaradaySimulation
2
2
 
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
 
5
5
  end
@@ -56,6 +56,15 @@ class FaradaySimulation::TestAdapter < Test::Unit::TestCase
56
56
  end
57
57
 
58
58
 
59
+ def test_segment_params_escaped
60
+ @stubs.get(/\/endpoint\/([^\/]+)\//) { |env|
61
+ assert_equal('foo bar', env[:segments][0])
62
+ }
63
+ @conn.get('/endpoint/foo%20bar')
64
+ @conn.get('/endpoint/foo+bar')
65
+ end
66
+
67
+
59
68
  def test_multiple_segment_params
60
69
  @stubs.get(/\/endpoint\/([^\/]+)\/junk\/(.*)/) { |env|
61
70
  assert_equal('slug', env[:segments][0])
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joseph Pearson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-07-09 00:00:00 +10:00
17
+ date: 2012-07-24 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency