Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 161 lines (128 sloc) 4.437 kb
beb9ea0 @myronmarston Allow specs to run when the code is not checked out through git.
authored
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
e57ae60 @myronmarston Updated Gemfile/gemspec/Rakefile, etc to use latest best practices based...
authored
8
d2577f7 @myronmarston Initial commit to vcr.
authored
9 require 'rake'
f05cc59 @myronmarston Upgrade to rspec-2.
authored
10 require "rspec/core/rake_task"
d2577f7 @myronmarston Initial commit to vcr.
authored
11
5cdbba3 @myronmarston Improve full build output.
authored
12 RSpec::Core::RakeTask.new(:spec) do |t|
13 t.verbose = false
7f92317 @myronmarston Require spec_helper before the spec files so we don't get an RSpec confi...
authored
14
15 # we require spec_helper so we don't get an RSpec warning about
16 # examples being defined before configuration.
42ec6c3 @myronmarston Fix spec ruby_opts so that the spec_helper file is only loaded once.
authored
17 t.ruby_opts = "-w -I./spec -r./spec/capture_warnings -rspec_helper"
297f028 @myronmarston Setup warnings as part of the build.
authored
18 t.rspec_opts = %w[--format progress] if (ENV['FULL_BUILD'] || !using_git)
5cdbba3 @myronmarston Improve full build output.
authored
19 end
f05cc59 @myronmarston Upgrade to rspec-2.
authored
20
c812e28 @myronmarston Some additional cleanup to remove 1.8.6/1.9.1 support.
authored
21 require 'cucumber/rake/task'
22 Cucumber::Rake::Task.new
7a12870 @myronmarston Remove old cukes. I'm going to rewrite them in a documentation style.
authored
23
4531950 @myronmarston Removed old cucumber rake tasks.
authored
24 task :default => [:spec, :cucumber]
d2577f7 @myronmarston Initial commit to vcr.
authored
25
1837757 @myronmarston Add yard coverage as part of travis build.
authored
26 desc "Ensures we keep up 100% YARD coverage"
27 task :yard_coverage do
28 coverage_stats = `yard stats --list-undoc 2>&1`
29 if coverage_stats.include?('100.00% documented')
30 puts "Nice work! 100% documentation coverage"
31 else
32 puts coverage_stats
33 raise "Documentation coverage is less than 100%"
34 end
35 end
36
bd3dc79 @myronmarston Fail the build if test coverage is too low.
authored
37 desc "Checks the spec coverage and fails if it is less than 100%"
38 task :check_code_coverage do
39 percent = File.read("./coverage/coverage_percent.txt").to_f
40 if percent < 99.0
41 raise "Spec coverage was not high enough: #{percent.round(2)}%"
42 else
43 puts "Nice job! Spec coverage is still above 99%"
44 end
45 end
46
2e37007 @myronmarston Setup build for travis-ci.org.
authored
47 namespace :ci do
48 desc "Sets things up for a ci build on travis-ci.org"
49 task :setup do
364ea9e @myronmarston Don't run em-http-request tests on travis on 1.8.6.
authored
50 ENV['TRAVIS'] = 'true'
2e37007 @myronmarston Setup build for travis-ci.org.
authored
51 sh "git submodule init"
52 sh "git submodule update"
53 end
54
55 RSpec::Core::RakeTask.new(:spec) do |t|
56 t.verbose = true
7f92317 @myronmarston Require spec_helper before the spec files so we don't get an RSpec confi...
authored
57
58 # we require spec_helper so we don't get an RSpec warning about
59 # examples being defined before configuration.
42ec6c3 @myronmarston Fix spec ruby_opts so that the spec_helper file is only loaded once.
authored
60 t.ruby_opts = "-w -I./spec -r./spec/capture_warnings -rspec_helper"
2e37007 @myronmarston Setup build for travis-ci.org.
authored
61 t.rspec_opts = %w[--format progress --backtrace]
62 end
63
64 desc "Run a ci build"
bd3dc79 @myronmarston Fail the build if test coverage is too low.
authored
65 task :build => [:setup, :spec, :cucumber, :yard_coverage, :check_code_coverage]
2e37007 @myronmarston Setup build for travis-ci.org.
authored
66 end
67
284494f @myronmarston Add readme, changelog and license to relish docs.
authored
68 def ensure_relish_doc_symlinked(filename)
5bd3bff @myronmarston Fixes for relish.
authored
69 from_filename = filename.dup
70 from_filename << '.md' unless filename =~ /\.md$/
71 from = File.expand_path("../features/#{from_filename}", __FILE__)
284494f @myronmarston Add readme, changelog and license to relish docs.
authored
72 to = File.expand_path("../#{filename}", __FILE__)
73
74 if File.symlink?(from)
75 return if File.readlink(from) == to
76
77 # delete the old symlink
78 File.unlink(from)
79 end
80
81 FileUtils.ln_s to, from
82 end
83
a7e9528 @myronmarston Add relish task that runs as part of release.
authored
84 desc "Push cukes to relishapp using the relish-client-gem"
85 task :relish do
7b9bf81 @FlaviuSim added the contributing wiki to the project for symlinking with relish
FlaviuSim authored
86 %w[ README.md CHANGELOG.md Upgrade.md LICENSE CONTRIBUTING.md].each do |file|
284494f @myronmarston Add readme, changelog and license to relish docs.
authored
87 ensure_relish_doc_symlinked(file)
88 end
89
84992d2 @myronmarston Updated relish task to push a version.
authored
90 require 'vcr/version'
4db3d6e @myronmarston Allow relish docs to be re-pushed when I run "rake relish".
authored
91 sh "relish versions:add myronmarston/vcr:#{VCR.version}" if ENV['NEW_RELISH_RELEASE']
84992d2 @myronmarston Updated relish task to push a version.
authored
92 sh "relish push vcr:#{VCR.version}"
a7e9528 @myronmarston Add relish task that runs as part of release.
authored
93 end
94
4db3d6e @myronmarston Allow relish docs to be re-pushed when I run "rake relish".
authored
95 task :prep_relish_release do
96 ENV['NEW_RELISH_RELEASE'] = 'true'
97 end
98
c0141b0 @myronmarston Prevent releases on 1.9 as that leads to weird psych/syck errors in the ...
authored
99 task :require_ruby_18 do
100 raise "This must be run on Ruby 1.8" unless RUBY_VERSION =~ /^1\.8/
101 end
102
103 task :release => [:require_ruby_18, :prep_relish_release, :relish]
a7e9528 @myronmarston Add relish task that runs as part of release.
authored
104
1aa5b6d @myronmarston Add support for gem-testers.org.
authored
105 # For gem-test: http://gem-testers.org/
106 task :test => :spec
8fc0f6e @myronmarston Use "should eq(...)" instead of "should ==" to avoid ruby warning.
authored
107
26c1a8a @myronmarston Add a rake task to migrate the cassettes from the 1.x format to the 2.x ...
authored
108 load './lib/vcr/tasks/vcr.rake'
04e2595 @myronmarston Add task to re-migrate spec fixtures.
authored
109 namespace :vcr do
110 task :reset_spec_cassettes do
111 ENV['DIR'] = 'spec/fixtures'
112 def VCR.version; "2.0.0"; end
113 sh "git checkout v2.0.0.beta1 -- spec/fixtures"
114 end
115
116 task :migrate_cassettes => :reset_spec_cassettes
117 end
26c1a8a @myronmarston Add a rake task to migrate the cassettes from the 1.x format to the 2.x ...
authored
118
119 desc "Migrate cucumber cassettes"
120 task :migrate_cucumber_cassettes do
f46cfa5 @myronmarston Update cucumber migration task.
authored
121 sh "git checkout cb3559d6ffcb36cb823ae96a677e380e5b86ed80 -- features"
26c1a8a @myronmarston Add a rake task to migrate the cassettes from the 1.x format to the 2.x ...
authored
122 require 'vcr/cassette/migrator'
123 Dir["features/**/*.feature"].each do |feature_file|
124 puts " - Migrating #{feature_file}"
125 contents = File.read(feature_file)
126
127 # http://rubular.com/r/gjzkoaYX2O
128 contents.scan(/:\n^\s+"""\n([\s\S]+?)"""/).each do |captures|
129 capture = captures.first
130 indentation = capture[/^ +/]
131 cassette_yml = capture.gsub(/^#{indentation}/, '')
132 new_yml = nil
133
134 Dir.mktmpdir do |dir|
135 file_name = "#{dir}/cassette.yml"
136 File.open(file_name, 'w') { |f| f.write(cassette_yml) }
137 VCR::Cassette::Migrator.new(dir, StringIO.new).migrate!
138 new_yml = File.read(file_name)
139 end
140
141 new_yml.gsub!(/^/, indentation)
142 new_yml << indentation
143 contents.gsub!(capture, new_yml)
144 end
145
146 File.open(feature_file, 'w') { |f| f.write(contents) }
147 end
148 end
149
8cefe96 @myronmarston Add rake task to re-run the last cuke.
authored
150 desc "Run the last cuke directly"
151 task :run_last_cuke do
152 command = ENV.fetch('CMD') do
153 raise "Must pass CMD"
154 end
155
156 Dir.chdir("tmp/aruba") do
157 sh "RUBYOPT='-I.:../../lib -r../../features/support/vcr_cucumber_helpers' ruby #{command}"
158 end
159 end
160
Something went wrong with that request. Please try again.