Permalink
Browse files

added check for auth routes and bundling

  • Loading branch information...
mattetti committed Nov 7, 2008
1 parent 85df95d commit eb2703bd08e5edcf534e79d86218c345c037c0d3
@@ -1,6 +0,0 @@
-module Step
-
- def ensure_authenticated
- end
-
-end
@@ -0,0 +1,14 @@
+module Step
+ def authenticate_articles_route
+ puts " > authenticating the articles route\n"
+ sentinel = "resources :articles"
+ route_file = "#{path}/config/router.rb"
+ gsub_file route_file, /(#{Regexp.escape(sentinel)})/mi do |match|
+ <<-RUBY
+authenticate do
+ #{sentinel}
+end
+RUBY
+ end
+ end
+end
@@ -0,0 +1,32 @@
+module Step
+
+ def authenticated_articles_route_spec
+
+ spec_file = "#{path}/spec/requests/articles_spec.rb"
+ print " > editing requests spec #{spec_file}\n"
+
+ old_given = <<-RUBY
+ given "a article exists" do
+ Article.all.destroy!
+ request(resource(:articles), :method => "POST",
+ :params => { :article => {:title => 'intro', :author => 'Matt', :created_at => '2008-11-07 10:07:12' }})
+ end
+ RUBY
+
+ gsub_file spec_file, /(#{Regexp.escape(old_given)})/mi do |match|
+ <<-RUBY
+ given "a article exists" do
+ Article.all.destroy!
+ request(resource(:articles), :method => "POST",
+ :params => { :article => {:title => 'intro', :author => 'Matt', :created_at => '2008-11-07 10:07:12' }})
+ User.all.detroy!
+ u = User.new(:login => "mattetti")
+ u.password = u.password_confirmation = "sekrit"
+ u.save
+ end
+ RUBY
+ end
+
+ end
+
+end
@@ -0,0 +1,9 @@
+module Step
+
+ def bundling_merb
+ puts "bundling merb and mongrel.. this is going to take a while :("
+ puts `thor merb:gem:install merb`
+ puts `thor merb:gem:install mongrel`
+ end
+
+end
@@ -1,6 +1,6 @@
module Step
def make_specs_not_pending
- print " > removing the spec pending status\n"
+ puts " > removing the spec pending status\n"
sentinel = "pending"
spec_file = "#{path}/spec/requests/articles_spec.rb"
gsub_file spec_file, /(#{Regexp.escape(sentinel)})/mi do |match|
@@ -1,10 +1,12 @@
#!/usr/bin/env ruby
require 'extlib'
+require 'merb-core'
+
# TODO: move to a gem so I can package the steps easily
#
module Step
-
+
# setter for the app name
#
def self.app_name=(app_name)
@@ -93,6 +95,11 @@ class App < Thor
step :add_model_validation
step :add_model_specs
step :edit_layout
+ step :authenticate_articles_route
+ step :run_app_specs
+ step :authenticated_articles_route_spec
+ step :run_app_specs
+ step :bundling_merb
step :run_app_specs
end

0 comments on commit eb2703b

Please sign in to comment.