netrecorder 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +39 -0
  2. data/Rakefile +1 -1
  3. data/netrecorder.gemspec +2 -2
  4. metadata +2 -2
@@ -33,6 +33,27 @@ Use recorded cache with fakeweb:
33
33
  config.cache_file = File.join(RAILS_ROOT, 'features', 'support', 'fakeweb')
34
34
  config.fakeweb = true
35
35
  end
36
+
37
+ == Scopes
38
+
39
+ Net recorder makes it easy to add a 'scope' to your recordings. Fakeweb doesn't have a way to name a response. If you make a request to the same url twice and get a different response both times, fakeweb just stores the responses in an array and returns them in order. This means that whatever you are testing will have to maintain the order or else you won't get the correct mocked data for your tests. So netrecorder allows you to set a scope that can be used when registering with fakeweb.
40
+
41
+ To record using scopes:
42
+
43
+ if NetRecorder.recording?
44
+ NetRecorder.scope = 'first request'
45
+ # request www.something.com
46
+ # make a change that alters the return value from www.something.com
47
+ NetRecorder.scope = "second request"
48
+ # request www.something.com
49
+ end
50
+
51
+ To register the scoped cache with fakeweb:
52
+
53
+ if !NetRecorder.recording?
54
+ FakeWeb.clean_registry # This will clear out any previous registrations so that our scope will not be added to the array of reponses
55
+ NetRecorder.register_scope(scenario.name)
56
+ end
36
57
 
37
58
  == Cucumber Example
38
59
 
@@ -54,9 +75,27 @@ see http://cukes.info for more info on testing with Cucumber
54
75
  NetRecorder.cache!
55
76
  end
56
77
  end
78
+
79
+ # Scope all the recordings to the scenario name!
80
+ Before do |scenario|
81
+ if NetRecorder.recording?
82
+ NetRecorder.scope = scenario.name
83
+ else
84
+ FakeWeb.clean_registry
85
+ NetRecorder.register_scope(scenario.name)
86
+ end
87
+ end
57
88
 
58
89
  record mode (command line)
59
90
  >> rake features RECORD_NET_CALLS=true
60
91
 
61
92
  cache mode (command line)
62
93
  >> rake features
94
+
95
+ == Similar projects
96
+
97
+ *StaleFish*[http://github.com/jsmestad/stale_fish]
98
+
99
+ * Uses fixtures to store netrequests
100
+ * More configuration options
101
+ * Configure fixtures to atomically refresh themselves at an interval
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('netrecorder', '0.2.0') do |p|
5
+ Echoe.new('netrecorder', '0.2.1') do |p|
6
6
  p.description = "Record network responses for easy stubbing of external calls"
7
7
  p.url = "http://github.com/chrisyoung/netrecorder"
8
8
  p.author = "Chris Young"
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{netrecorder}
5
- s.version = "0.2.0"
5
+ s.version = "0.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chris Young"]
9
- s.date = %q{2010-01-24}
9
+ s.date = %q{2010-04-13}
10
10
  s.description = %q{Record network responses for easy stubbing of external calls}
11
11
  s.email = %q{beesucker@gmail.com}
12
12
  s.extra_rdoc_files = ["README.rdoc", "lib/config.rb", "lib/http.rb", "lib/http_header.rb", "lib/netrecorder.rb"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netrecorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Young
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-24 00:00:00 -07:00
12
+ date: 2010-04-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency