Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed task runner as it's no longer needed.

  • Loading branch information...
commit 0289298c86e61808eb9bb3490abf55ae4bdf343c 1 parent 3bcafd9
@myronmarston authored
View
6 CHANGELOG.md
@@ -1,5 +1,11 @@
#Changelog
+## In Git
+
+* Removed VCR::TaskRunner and the corresponding rake task definition. The rake task migrated cassettes from the
+ 0.3.1 format to the 0.4+ format. If you are still on 0.3.1 or earlier, I recommend you upgrade to 0.4.1 first,
+ migrate your cassettes and deal with migration warnings, then upgrade to the current release.
+
## 1.0.3 (August 5, 2010)
* Upgraded VCR specs to RSpec 2.
View
47 lib/vcr/task_runner.rb
@@ -1,47 +0,0 @@
-require 'vcr'
-
-module VCR
- module TaskRunner
- extend self
-
- def migrate_cassettes(dir)
- with_recorded_response_defined do
- FileUtils.cp_r(dir, "#{dir}-backup")
-
- Dir.glob(dir + '/**/*.yml').each do |cassette_file|
- recorded_responses = YAML.load(File.read(cassette_file))
- next unless recorded_responses.is_a?(Enumerable) && recorded_responses.all? { |rr| rr.is_a?(VCR::RecordedResponse) }
-
- interactions = recorded_responses.map do |recorded_response|
- http_interaction(recorded_response)
- end
-
- File.open(cassette_file, 'w') { |f| f.write(interactions.to_yaml) }
- end
- end
- end
-
- private
-
- def http_interaction(recorded_response)
- VCR::HTTPInteraction.new(
- request(recorded_response),
- VCR::Response.from_net_http_response(recorded_response.response)
- )
- end
-
- def request(recorded_response)
- VCR::Request.new(recorded_response.method, recorded_response.uri)
- end
-
- def with_recorded_response_defined
- VCR.const_set(:RecordedResponse, Class.new(Struct.new(:method, :uri, :response, :request_body, :request_headers)))
-
- begin
- yield
- ensure
- VCR.send(:remove_const, :RecordedResponse)
- end
- end
- end
-end
View
9 lib/vcr/tasks/vcr.rake
@@ -1,9 +0,0 @@
-require 'vcr/task_runner'
-
-namespace :vcr do
- desc 'Migrates your VCR cassettes in DIR from the 0.3.1 format to the 0.4+ format'
- task :migrate_cassettes do
- raise "You must pass the cassette library directory as DIR" if ENV['DIR'].to_s == ''
- VCR::TaskRunner.migrate_cassettes(ENV['DIR'])
- end
-end
View
59 spec/task_runner_spec.rb
@@ -1,59 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-require 'vcr/task_runner'
-
-describe VCR::TaskRunner do
- describe '.migrate_cassettes' do
- temp_dir File.expand_path(File.dirname(__FILE__) + '/fixtures/task_runner')
-
- let(:file_name) { '0_3_1_cassette.yml' }
- let(:orig_file_name) { File.dirname(__FILE__) + "/fixtures/#{YAML_SERIALIZATION_VERSION}/#{file_name}" }
- let(:test_dir) { @temp_dir + '/migrate_cassettes' }
-
- def migrate
- VCR::TaskRunner.migrate_cassettes(test_dir)
- end
-
- before(:each) do
- FileUtils.mkdir_p(test_dir)
- FileUtils.cp(orig_file_name, test_dir)
- end
-
- it 'makes a backup of the directory' do
- migrate
- expected_backup_dir_name = test_dir + '-backup'
- expected_backup_file_name = expected_backup_dir_name + "/#{file_name}"
- File.exist?(expected_backup_dir_name).should be_true
- File.file?(expected_backup_file_name).should be_true
- File.read(expected_backup_file_name).should == File.read(orig_file_name)
- end
-
- it 'does not error out on yaml files with individual records' do
- YAML.should_receive(:load).and_return(VCR::Request.new(:get, 'http://example.com'))
- migrate
- end
-
- describe 'the structure serialized in the new 0_3_1_cassette_yml file' do
- subject do
- migrate
- YAML.load(File.read(test_dir + "/#{file_name}")).first
- end
-
- its(:request) { should be_instance_of(VCR::Request) }
-
- describe '.request' do
- def subject; super.request; end
-
- its(:method) { should == :post }
- its(:uri) { should == 'http://example.com:80/' }
- its(:body) { should be_nil }
- its(:headers) { should == {} }
- end
-
- it 'assigns the response using VCR::Response.from_net_http_response' do
- VCR::Response.should respond_to(:from_net_http_response)
- VCR::Response.should_receive(:from_net_http_response).with(an_instance_of(Net::HTTPOK)).and_return(:the_response)
- subject.response.should == :the_response
- end
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.