Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 196 lines (157 sloc) 5.313 kb
beb9ea0e »
2011-02-28 Allow specs to run when the code is not checked out through git.
1 using_git = File.exist?(File.expand_path('../.git/', __FILE__))
2
3 if using_git
4 require 'bundler'
5 require 'bundler/setup'
6 Bundler::GemHelper.install_tasks
ec845e24 »
2012-10-09 Add back support for Typhoeus 0.4.
7 require 'appraisal'
beb9ea0e »
2011-02-28 Allow specs to run when the code is not checked out through git.
8 end
e57ae60f »
2010-08-26 Updated Gemfile/gemspec/Rakefile, etc to use latest best practices ba…
9
d2577f79 »
2010-02-24 Initial commit to vcr.
10 require 'rake'
f05cc59a »
2010-07-22 Upgrade to rspec-2.
11 require "rspec/core/rake_task"
d2577f79 »
2010-02-24 Initial commit to vcr.
12
5cdbba38 »
2011-01-16 Improve full build output.
13 RSpec::Core::RakeTask.new(:spec) do |t|
14 t.verbose = false
7f92317a »
2011-09-22 Require spec_helper before the spec files so we don't get an RSpec co…
15
16 # we require spec_helper so we don't get an RSpec warning about
17 # examples being defined before configuration.
42ec6c30 »
2011-09-25 Fix spec ruby_opts so that the spec_helper file is only loaded once.
18 t.ruby_opts = "-w -I./spec -r./spec/capture_warnings -rspec_helper"
297f0282 »
2011-08-26 Setup warnings as part of the build.
19 t.rspec_opts = %w[--format progress] if (ENV['FULL_BUILD'] || !using_git)
5cdbba38 »
2011-01-16 Improve full build output.
20 end
f05cc59a »
2010-07-22 Upgrade to rspec-2.
21
c812e281 »
2011-09-10 Some additional cleanup to remove 1.8.6/1.9.1 support.
22 require 'cucumber/rake/task'
23 Cucumber::Rake::Task.new
7a12870a »
2010-11-08 Remove old cukes. I'm going to rewrite them in a documentation style.
24
45319500 »
2010-11-13 Removed old cucumber rake tasks.
25 task :default => [:spec, :cucumber]
d2577f79 »
2010-02-24 Initial commit to vcr.
26
18377570 »
2012-01-25 Add yard coverage as part of travis build.
27 desc "Ensures we keep up 100% YARD coverage"
28 task :yard_coverage do
29 coverage_stats = `yard stats --list-undoc 2>&1`
c0836b65 »
2012-05-01 Print out the yard coverage info (including warnings) even when the t…
30 puts coverage_stats
18377570 »
2012-01-25 Add yard coverage as part of travis build.
31 if coverage_stats.include?('100.00% documented')
c0836b65 »
2012-05-01 Print out the yard coverage info (including warnings) even when the t…
32 puts "\nNice work! 100% documentation coverage"
18377570 »
2012-01-25 Add yard coverage as part of travis build.
33 else
34 raise "Documentation coverage is less than 100%"
35 end
36 end
37
bd3dc792 »
2012-01-27 Fail the build if test coverage is too low.
38 desc "Checks the spec coverage and fails if it is less than 100%"
39 task :check_code_coverage do
9ce3d169 »
2012-01-28 Fix check_code_coverage task.
40 if RUBY_VERSION < '1.9' || RUBY_ENGINE != 'ruby'
41 puts "Cannot check code coverage--simplecov is not supported on this platform"
bd3dc792 »
2012-01-27 Fail the build if test coverage is too low.
42 else
9ce3d169 »
2012-01-28 Fix check_code_coverage task.
43 percent = File.read("./coverage/coverage_percent.txt").to_f
44 if percent < 98.0
45 raise "Spec coverage was not high enough: #{percent.round(2)}%"
46 else
47 puts "Nice job! Spec coverage is still above 98%"
48 end
bd3dc792 »
2012-01-27 Fail the build if test coverage is too low.
49 end
50 end
51
2e370079 »
2011-02-15 Setup build for travis-ci.org.
52 namespace :ci do
53 desc "Sets things up for a ci build on travis-ci.org"
54 task :setup do
364ea9e9 »
2011-04-08 Don't run em-http-request tests on travis on 1.8.6.
55 ENV['TRAVIS'] = 'true'
2e370079 »
2011-02-15 Setup build for travis-ci.org.
56 sh "git submodule init"
57 sh "git submodule update"
58 end
59
60 RSpec::Core::RakeTask.new(:spec) do |t|
61 t.verbose = true
7f92317a »
2011-09-22 Require spec_helper before the spec files so we don't get an RSpec co…
62
63 # we require spec_helper so we don't get an RSpec warning about
64 # examples being defined before configuration.
42ec6c30 »
2011-09-25 Fix spec ruby_opts so that the spec_helper file is only loaded once.
65 t.ruby_opts = "-w -I./spec -r./spec/capture_warnings -rspec_helper"
2e370079 »
2011-02-15 Setup build for travis-ci.org.
66 t.rspec_opts = %w[--format progress --backtrace]
67 end
68
69 desc "Run a ci build"
bd3dc792 »
2012-01-27 Fail the build if test coverage is too low.
70 task :build => [:setup, :spec, :cucumber, :yard_coverage, :check_code_coverage]
2e370079 »
2011-02-15 Setup build for travis-ci.org.
71 end
72
284494fe »
2011-03-01 Add readme, changelog and license to relish docs.
73 def ensure_relish_doc_symlinked(filename)
5bd3bffa »
2011-03-02 Fixes for relish.
74 from_filename = filename.dup
75 from_filename << '.md' unless filename =~ /\.md$/
76 from = File.expand_path("../features/#{from_filename}", __FILE__)
284494fe »
2011-03-01 Add readme, changelog and license to relish docs.
77 to = File.expand_path("../#{filename}", __FILE__)
78
79 if File.symlink?(from)
80 return if File.readlink(from) == to
81
82 # delete the old symlink
83 File.unlink(from)
84 end
85
86 FileUtils.ln_s to, from
87 end
88
a7e95280 »
2010-11-16 Add relish task that runs as part of release.
89 desc "Push cukes to relishapp using the relish-client-gem"
90 task :relish do
7b9bf81a »
2011-11-21 added the contributing wiki to the project for symlinking with relish
91 %w[ README.md CHANGELOG.md Upgrade.md LICENSE CONTRIBUTING.md].each do |file|
284494fe »
2011-03-01 Add readme, changelog and license to relish docs.
92 ensure_relish_doc_symlinked(file)
93 end
94
84992d24 »
2010-11-20 Updated relish task to push a version.
95 require 'vcr/version'
4db3d6eb »
2011-06-03 Allow relish docs to be re-pushed when I run "rake relish".
96 sh "relish versions:add myronmarston/vcr:#{VCR.version}" if ENV['NEW_RELISH_RELEASE']
84992d24 »
2010-11-20 Updated relish task to push a version.
97 sh "relish push vcr:#{VCR.version}"
a7e95280 »
2010-11-16 Add relish task that runs as part of release.
98 end
99
4db3d6eb »
2011-06-03 Allow relish docs to be re-pushed when I run "rake relish".
100 task :prep_relish_release do
101 ENV['NEW_RELISH_RELEASE'] = 'true'
102 end
103
c0141b0a »
2011-08-18 Prevent releases on 1.9 as that leads to weird psych/syck errors in t…
104 task :require_ruby_18 do
105 raise "This must be run on Ruby 1.8" unless RUBY_VERSION =~ /^1\.8/
106 end
107
108 task :release => [:require_ruby_18, :prep_relish_release, :relish]
a7e95280 »
2010-11-16 Add relish task that runs as part of release.
109
1aa5b6d9 »
2011-02-02 Add support for gem-testers.org.
110 # For gem-test: http://gem-testers.org/
111 task :test => :spec
8fc0f6e7 »
2011-08-25 Use "should eq(...)" instead of "should ==" to avoid ruby warning.
112
26c1a8a1 »
2011-10-15 Add a rake task to migrate the cassettes from the 1.x format to the 2…
113 load './lib/vcr/tasks/vcr.rake'
04e25959 »
2011-10-30 Add task to re-migrate spec fixtures.
114 namespace :vcr do
115 task :reset_spec_cassettes do
116 ENV['DIR'] = 'spec/fixtures'
117 def VCR.version; "2.0.0"; end
118 sh "git checkout v2.0.0.beta1 -- spec/fixtures"
119 end
120
121 task :migrate_cassettes => :reset_spec_cassettes
122 end
26c1a8a1 »
2011-10-15 Add a rake task to migrate the cassettes from the 1.x format to the 2…
123
124 desc "Migrate cucumber cassettes"
125 task :migrate_cucumber_cassettes do
531acdf6 »
2012-02-12 Migrate call the cucumber cassettes to updated format.
126 require 'vcr'
127 require 'ruby-debug'
128
129 VCR.configure do |c|
130 c.cassette_library_dir = 'tmp/migrate'
131 c.default_cassette_options = { :serialize_with => :syck }
132 end
133
134 # We want 2.0.0 in the cucumber cassettes instead of 2.0.0.rc1
135 def VCR.version
136 "2.0.0"
137 end
138
26c1a8a1 »
2011-10-15 Add a rake task to migrate the cassettes from the 1.x format to the 2…
139 Dir["features/**/*.feature"].each do |feature_file|
531acdf6 »
2012-02-12 Migrate call the cucumber cassettes to updated format.
140 # The ERB cassettes can't be migrated automatically.
141 next if feature_file.include?('dynamic_erb')
142
26c1a8a1 »
2011-10-15 Add a rake task to migrate the cassettes from the 1.x format to the 2…
143 puts " - Migrating #{feature_file}"
144 contents = File.read(feature_file)
145
146 # http://rubular.com/r/gjzkoaYX2O
147 contents.scan(/:\n^\s+"""\n([\s\S]+?)"""/).each do |captures|
148 capture = captures.first
149 indentation = capture[/^ +/]
150 cassette_yml = capture.gsub(/^#{indentation}/, '')
151 new_yml = nil
152
531acdf6 »
2012-02-12 Migrate call the cucumber cassettes to updated format.
153 file_name = "tmp/migrate/cassette.yml"
154 File.open(file_name, 'w') { |f| f.write(cassette_yml) }
155 cassette = VCR::Cassette.new('cassette')
156
157 hash = begin
158 cassette.serializable_hash
159 rescue => e
160 puts " Skipping #{capture[0, 80]}"
161 next
26c1a8a1 »
2011-10-15 Add a rake task to migrate the cassettes from the 1.x format to the 2…
162 end
163
531acdf6 »
2012-02-12 Migrate call the cucumber cassettes to updated format.
164 new_yml = VCR::Cassette::Serializers::Syck.serialize(hash)
165
26c1a8a1 »
2011-10-15 Add a rake task to migrate the cassettes from the 1.x format to the 2…
166 new_yml.gsub!(/^/, indentation)
167 new_yml << indentation
531acdf6 »
2012-02-12 Migrate call the cucumber cassettes to updated format.
168 new_yml.gsub!(/^\s+\n(\s+response:)/, '\1')
26c1a8a1 »
2011-10-15 Add a rake task to migrate the cassettes from the 1.x format to the 2…
169 contents.gsub!(capture, new_yml)
170 end
171
172 File.open(feature_file, 'w') { |f| f.write(contents) }
173 end
174 end
175
8cefe969 »
2011-11-24 Add rake task to re-run the last cuke.
176 desc "Run the last cuke directly"
177 task :run_last_cuke do
178 command = ENV.fetch('CMD') do
179 raise "Must pass CMD"
180 end
181
182 Dir.chdir("tmp/aruba") do
183 sh "RUBYOPT='-I.:../../lib -r../../features/support/vcr_cucumber_helpers' ruby #{command}"
184 end
185 end
186
283a1bf9 »
2012-02-12 Add rake task to boot the test app.
187 desc "Boot test app"
188 task :boot_test_app do
189 require './spec/support/vcr_localhost_server'
190 require './spec/support/sinatra_app'
191 VCR::SinatraApp.boot
192 puts "Booted sinatra app on port: #{VCR::SinatraApp.port}"
193 loop { }
194 puts "Shutting down."
195 end
Something went wrong with that request. Please try again.