Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshuaclayton/91261 to your computer and use it in GitHub Desktop.
Save joshuaclayton/91261 to your computer and use it in GitHub Desktop.
# Notes: You NEED to type 'y' and then press enter a few seconds into
# generating the clearance features (to overwrite the features/support/paths.rb).
# no prompt shows up by default.
#
# A few features fail initially; I'm only concerned with the one re: logging
# out (it's looking for a flash that doesn't, for some reason, persist). The
# checking for text with contains can be switched to check for a regex of the text.
# build session store
initializer "session_store.rb", <<-END
ActionController::Base.session = { :session_key => '_clearance_flash_error_session', :secret => '#{ActiveSupport::SecureRandom.hex(32)}' }
END
# gems
gem "thoughtbot-factory_girl", :lib => "factory_girl", :version => "1.2.0", :source => "http://gems.github.com"
gem "thoughtbot-shoulda", :lib => "shoulda", :version => "2.10.1", :source => "http://gems.github.com"
gem "aslakhellesoy-cucumber", :lib => "cucumber", :version => "0.2.3", :source => "http://gems.github.com"
gem "webrat", :lib => "webrat", :version => "0.4.3", :source => "http://gems.github.com"
gem "thoughtbot-clearance", :lib => "clearance", :version => "0.5.4", :source => "http://gems.github.com"
rake('gems:install', :sudo => true) # this shouldn't really be necessary
rake("gems:unpack") # unpack into gems for shoulda macros
rake("db:create")
rake('db:migrate')
# build session store
initializer "session_store.rb", <<-END
ActionController::Base.session = { :session_key => '_clearance_flash_error_session', :secret => '#{ActiveSupport::SecureRandom.hex(32)}' }
ActionController::Base.session_store = :active_record_store
END
rake("rails:freeze:gems RELEASE=2.3.2.1")
rake('db:sessions:create')
rake("db:migrate")
generate("cucumber")
generate("clearance")
run "script/generate clearance_features"
initializer "clearance_constants.rb", <<-END
HOST = "clearance_flash"
DO_NOT_REPLY = "clearance_flash"
END
file "app/controllers/home_controller.rb", <<-END
class HomeController < ApplicationController
end
END
file "app/views/layouts/application.erb", <<-END
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Application</title>
</head>
<body>
<% flash.keys.each do |key| %>
<%= flash[key] %>
<% end %>
<%= yield %>
</body>
</html>
END
file "app/views/home/index.erb", <<-END
<h2>Hello World</h2>
END
route "map.root :controller => 'home'"
# after this is complete, cd into the generated rails directory and run `rake features`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment