Skip to content

Commit

Permalink
Rake feature to ping the ladies
Browse files Browse the repository at this point in the history
  • Loading branch information
Emma Lindsay committed Oct 28, 2010
1 parent b036621 commit 70f6c08
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
18 changes: 18 additions & 0 deletions features/generated_dates.feature
@@ -0,0 +1,18 @@
Feature: Dates generated by instalover

Scenario: Instalover generates dates for users
Given the following users exist:
| Phone Number | Male | Female | Looking For Male | Looking For Female | Dob | Looking For Minimum Age | Looking For Maximum Age | Description | Name |
| 11111111111 | true | false | false | true | 11/06/1989 | 18 | 34 | red hair | Mike |
| 12222222222 | true | false | false | true | 10/20/1989 | 18 | 34 | black shirt | Jason |
| 18004688487 | false| true | true | false | 12/31/1977 | 14 | 22 | super hot | Emma |
| 13333333333 | false| true | true | false | 12/32/1980 | 14 | 30 | super hot | Emma |
And the day and time is "October 16, 2010 8:00pm edt"
And the following date suggestions exist:
| text |
| Silvertone |
| Mike's Apartment |
When I run the rake task "instalover:ping_female_dates"
Then "13333333333" should get a text whose message includes "Should we find you a date "
Then "18004688487" should get a text whose message includes "Should we find you a date "

38 changes: 38 additions & 0 deletions features/step_definitions/rake_steps.rb
@@ -0,0 +1,38 @@
require 'rake'

# Do not re-load the environment task
class Rake::Task
def invoke_prerequisites(task_args, invocation_chain)
@prerequisites.reject{|n| n == "environment"}.each do |n|
prereq = application[n, @scope]
prereq_args = task_args.new_scope(prereq.arg_names)
prereq.invoke_with_call_chain(prereq_args, invocation_chain)
end
end
end

When /^I run the rake task "([^\"]*)"$/ do |task_name|
# Make sure you're in the RAILS_ROOT
oldpwd = Dir.pwd
Dir.chdir(RAILS_ROOT)
old_args = ARGV.dup
ARGV.clear

# Get an instance of rake
rake_app = Rake.application
rake_app.options.silent = true

# Back to where you were
Dir.chdir(oldpwd)

rake_app.init
rake_app.load_rakefile

task = rake_app.tasks.detect {|t| t.name == task_name}
assert_not_nil task, "No rake task defined: #{task_name}"
task.reenable
task.invoke

ARGV.unshift(*old_args)
end

8 changes: 8 additions & 0 deletions lib/tasks/instalover.rake
@@ -0,0 +1,8 @@
namespace :instalover do
desc "Ping women for dates to poke the pot"
task :ping_female_dates => :environment do
User.women.each do |w|
Message.handle_new_date(w)
end
end
end

0 comments on commit 70f6c08

Please sign in to comment.