Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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