README.md in rack-vcr-0.1.4 vs README.md in rack-vcr-0.1.5
- old
+ new
@@ -20,11 +20,11 @@
## Usage
### Capturing in Rails
-In `config/initializer/rack_vcr.rb`:
+In `config/initializers/rack_vcr.rb`:
```ruby
if Rails.env.test?
Rails.configuration.middleware.insert(0, Rack::VCR)
end
@@ -36,20 +36,36 @@
VCR.configure do |config|
config.cassette_library_dir = 'doc/cassettes'
end
RSpec.configure do |config|
+ config.around(:each, type: :request) do |example|
+ host! "yourapp.hostname"
+ name = example.full_description.gsub /[^\w\-]/, '_'
+ VCR.use_cassette(name, record: :all) do
+ example.run
+ end
+ end
+end
+```
+
+The above example might not work if you were using RSpec 2.x, in which case you might need to write as follows:
+
+```ruby
+RSpec.configure do |config|
config.around(:each, type: :request) do |ex|
host! "yourapp.hostname"
name = example.full_description.gsub /[^\w\-]/, '_'
VCR.use_cassette(name, record: :all) do
ex.run
end
end
end
```
+Read more about the changes around `example` on [RSpec blog post](http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/).
+
### Capturing in Sinatra/Rack
In `spec/spec_helper.rb`:
@@ -109,10 +125,10 @@
@app = app
end
def call(env)
cassette = ... # determine cassette from env
- VCR.use_cassette(casssette, record: :none) do
+ VCR.use_cassette(cassette, record: :none) do
@app.call(env)
end
end
end