Class: RakeHelpers
- Inherits:
-
Object
- Object
- RakeHelpers
- Defined in:
- lib/tasks/frameworks-tasks.rb
Constant Summary collapse
- INVOKE_CUCUMBER =
"bin/cucumber -r features"
Class Method Summary collapse
- .color(text, options = {}) ⇒ Object
- .install ⇒ Object
- .list_profiles ⇒ Object
- .run_feature(feature, profile = 'default') ⇒ Object
- .run_local ⇒ Object
- .run_profile(profile = 'default') ⇒ Object
- .start_app ⇒ Object
- .update ⇒ Object
Class Method Details
.color(text, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tasks/frameworks-tasks.rb', line 9 def color(text, = {}) #ANSI color codes case [:color] when :red text = "\033[31m#{text}\033[0m" when :green text = "\033[32m#{text}\033[0m" when :yellow text = "\033[33m#{text}\033[0m" end text end |
.install ⇒ Object
5 6 7 |
# File 'lib/tasks/frameworks-tasks.rb', line 5 def install system('bundle install --no-cache --binstubs --path vendor/bundle') end |
.list_profiles ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tasks/frameworks-tasks.rb', line 22 def list_profiles puts 'Available profiles:' f = File.open('config/cucumber.yml', 'r') linenum = 0 @profiles = {} f.readlines.each do |line| line.scan(/.*?: /) do |match| linenum += 1 puts color(linenum.to_s + '. ', :color => :yellow) + color(match.gsub(':',''), :color => :green) @profiles[linenum.to_s] = match.gsub(':','') end end end |
.run_feature(feature, profile = 'default') ⇒ Object
40 41 42 |
# File 'lib/tasks/frameworks-tasks.rb', line 40 def run_feature(feature, profile='default') system("#{INVOKE_CUCUMBER} -p #{profile} features/#{feature}.feature") end |
.run_local ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tasks/frameworks-tasks.rb', line 55 def run_local if(RUBY_PLATFORM == 'java') abort color("This script only works if you are running on MRI ('normal') Ruby....sorry....", :color => :red) end puts color('*********************************************',:color => :green) puts color('* *',:color => :green) puts color('* Cucumber Acceptance Tests *',:color => :green) puts color('* Pre-Requisites: *',:color => :green) puts color('* ruby 1.8.7, bundler, rake *',:color => :green) puts color('* *',:color => :green) puts color('*********************************************',:color => :green) list_profiles puts 'Above is a list of the available profiles, please enter the number of the profile you wish to run: ' profile = STDIN.gets.chomp #TODO: Add some input validation? puts "The profile chosen is: #{color(@profiles[profile], :color => :red)}" puts 'Preparing to bundle required gems...' install puts 'Preparing to run tests...' run_profile(@profiles[profile]) end |
.run_profile(profile = 'default') ⇒ Object
44 45 46 |
# File 'lib/tasks/frameworks-tasks.rb', line 44 def run_profile(profile='default') system("#{INVOKE_CUCUMBER} -p #{profile}") end |
.start_app ⇒ Object
49 50 51 52 53 |
# File 'lib/tasks/frameworks-tasks.rb', line 49 def start_app $: << File.dirname( __FILE__) require 'lib/spec/test_app' Rack::Handler::WEBrick.run TestApp, :Port => 8070 end |
.update ⇒ Object
36 37 38 |
# File 'lib/tasks/frameworks-tasks.rb', line 36 def update system('bundle update') end |