From 0a82162802725548f9accd7c1d2583dba51646b3 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 30 Apr 2013 17:09:34 -0700 Subject: [PATCH] add vcr gem, add test helper script for running specific lines --- Gemfile | 3 ++- Gemfile.lock | 4 ++-- script/testing/dtest | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100755 script/testing/dtest diff --git a/Gemfile b/Gemfile index 800c7638f..db4cae472 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,8 @@ group :test do gem "mocha", :require => "mocha/setup" gem "ffaker", :git => "http://github.com/EmmanuelOga/ffaker.git" gem "simplecov", :require => false - gem "testrbl" + gem "pry" + gem "vcr" end group :assets do diff --git a/Gemfile.lock b/Gemfile.lock index 09ff60c5d..d5645fb8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,7 +178,6 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) term-ansicolor (1.1.4) - testrbl (0.2.0) therubyracer (0.11.4) libv8 (~> 3.11.8.12) ref @@ -198,6 +197,7 @@ GEM kgio (~> 2.6) rack raindrops (~> 0.7) + vcr (2.4.0) webrobots (0.1.1) whenever (0.8.2) activesupport (>= 2.3.4) @@ -236,8 +236,8 @@ DEPENDENCIES simple_form simplecov term-ansicolor - testrbl therubyracer uglifier (>= 1.0.3) unicorn + vcr whenever diff --git a/script/testing/dtest b/script/testing/dtest new file mode 100755 index 000000000..79ba2131b --- /dev/null +++ b/script/testing/dtest @@ -0,0 +1,23 @@ +#!/usr/bin/env ruby + +file, line = ARGV[0], nil +test_name_pattern = nil + +if file =~ /:\d+/ + file, line = file.split(/:/) +end + +if line + text = File.read(file).split(/\r\n|\r|\n/)[line.to_i - 1] + if text =~ /(?:context|should) ["'](.+?)["']/ + test_name_pattern = Regexp.escape($1) + end +end + +env_options = { + "TEST" => file +} + +env_options["TESTOPTS"] = "--name='/#{test_name_pattern}/'" if test_name_pattern + +exec(env_options, "bundle exec rake test")