mock_server 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,27 +1,34 @@
1
1
  # MockServer
2
2
 
3
- So you have spec for your models and controller for your API.
4
- Now you're building a neat javascript application that consumer that JSON.
3
+ You're building a neat javascript application that consume JSON...
4
+
5
+ So you have spec for your models and controller for your API, you do?
6
+
5
7
  And you're going to test it with something like capybara?
6
- The thing is that its going to be slow! And you're testing testing all you're application logic again!
8
+
9
+ ... The thing is that its going to be slow, and you're testing testing all you're application logic again!
7
10
 
8
11
  MockServer allow you to record your interaction with the server and give you a way to match
9
- the record request with the real request. Its like a rack [VCR](https://github.com/myronmarston/vcr) for your own API!
12
+ the record request with the real request.
13
+
14
+ Its like a rack [VCR](https://github.com/myronmarston/vcr) for your own API!
10
15
 
11
16
  # Recording mode
12
17
 
13
18
  Create mount the rack application, in rails
14
19
 
15
20
  require 'mock_server/record'
16
- config.middleware.use MockServer::Record, { :path => 'fixtures/records', :filename => 'uploads'
17
- :routes => [ '/api/*/**', '/api/*/**' ] }
21
+ config.middleware.use MockServer::Record,
22
+ { :path => 'fixtures/records', :filename => 'uploads'
23
+ :routes => [ '/api/*/**', '/api/*/**' ] }
18
24
 
19
25
  And you're ready to record. Run the test, build so seed by clicking around. whatever.
20
26
 
21
27
  # Playback mode
22
28
 
23
29
  require 'mock_server/playback'
24
- config.middleware.use MockServer::Playback, { :path => 'fixtures/records' ] }
30
+ config.middleware.use MockServer::Playback,
31
+ { :path => 'fixtures/records' }
25
32
 
26
33
  Recording your own playback? Noes, don't use the two Rack middleware at the same time.
27
34
 
@@ -47,9 +54,7 @@ In your spec
47
54
  end
48
55
 
49
56
  after :each do
50
- mock_server_disable_all_routes!
51
- mock_server_clear_matchers!
52
- mock_server_response_stack_clear!
57
+ mock_server_reset!
53
58
  end
54
59
 
55
60
  scenario "Some json api fun" do
@@ -135,6 +135,14 @@ module MockServer
135
135
  mock_server_errors_stack_clear!
136
136
  end
137
137
 
138
+ # Clear all the settings
139
+
140
+ def mock_server_reset!
141
+ mock_server_response_stack_clear!
142
+ mock_server_clear_matchers!
143
+ mock_server_disable_all_routes!
144
+ end
145
+
138
146
  protected
139
147
  # Configuration
140
148
  def mock_server_config_set(key, value)
@@ -6,8 +6,8 @@ module MockServer
6
6
  def lazy_match(strings, path)
7
7
  regexps = strings.map { |str|
8
8
  escaped = Regexp.escape(str)
9
- escaped.gsub!('\\*\\*', '[\w|\/]+')
10
- escaped.gsub!('\\*', '[\w]+')
9
+ escaped.gsub!('\\*\\*', '[\w|.|\-|\/]+')
10
+ escaped.gsub!('\\*', '[\w|.|\-]+')
11
11
  Regexp.new("^#{escaped}$")
12
12
  }
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,30 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-03 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2011-11-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: &70228222928080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70228222928080
25
+ - !ruby/object:Gem::Dependency
26
+ name: hashie
27
+ requirement: &70228222921080 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70228222921080
14
36
  description:
15
37
  email: unixcharles@gmail.com
16
38
  executables: []