Skip to content

Commit

Permalink
setup and populate tasks and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
zflat committed Jan 20, 2013
1 parent 4936cde commit d0d6d67
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
31 changes: 9 additions & 22 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,23 @@
Reproduce all functionality that exists with the current paper bike binder and departed bikes binder system.


## Getting up and running for development
## Install and configuration

### After the first clone
* Setup rake task

Take the following actions to get a cloned/pulled version to run locally for development
bundle exec rake setup

* Rename the database config file (remove ".sample")
* Install gems
* Initialize and populate the database
* Edit the config/database.yml file with correct parameters

cp config/database.yml.sample config/database.yml
bundle install
rake db:populate


### After each time you pull updates
### Prepare the application for development

* Install missing (or out of date) gems
* Reinitialize and repopulate the database (see seeding approaches for details)

bundle install
rake db:populate
* After the first clone and after updates to the database or gems are pulled

## Running tests
bundle exec rake populate

* Create the test database
* Start the autotest
* Running tests

rake db:test_setup
bundle exec guard
bundle exec guard

## Documentation Tasks

Expand Down
2 changes: 2 additions & 0 deletions config/directories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

# config

dirs << CONFIG_DIRECTORY_ROOT = "#{Rails.root}/config"
dirs << APP_CONFIG_DIRECTORY = "#{Rails.root}/config/application"
APP_SECRET_FILE = "#{APP_CONFIG_DIRECTORY}/secret_token.txt"
APP_DB_CONIG_FILE = "#{CONFIG_DIRECTORY_ROOT}/database.yml"

# tmp

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/create_a_secret.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ desc "Install a session secret token for the application"
task :create_a_secret =>:environment do
require File.dirname(__FILE__) + "/../../config/directories.rb"
puts "Writing secret token to #{APP_SECRET_FILE}"
`rake -s secret > #{APP_SECRET_FILE}`
puts `rake -s secret > #{APP_SECRET_FILE}`
end
17 changes: 11 additions & 6 deletions lib/tasks/populate.rake
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
desc "Setup/installation script to prepare applction for develoment after each pull"
task :populate => :environment do
Rake::Task['db:drop'].invoke
Rake::Task['setup'].invoke

Rake::Task['db:populate'].invoke

Rake::Task['db:test_setup'].invoke
end

namespace :db do

desc "Setup the application and fill database with dummy data"
desc "Setup the application and fill database with demo data"
task :populate => :environment do

Rake::Task['db:drop'].invoke
Rake::Task['setup'].invoke

Rake::Task['db:populate_hooks'].invoke
Rake::Task['db:populate_programs'].invoke
Rake::Task['db:populate_bikes'].invoke

# Pass rake argument using ENV hash
ENV['FILE'] = 'surveys/bike_overhaul_inspection.rb'
Rake::Task['surveyor'].invoke

Rake::Task['db:test_setup'].invoke
end

desc "Fill database with initial Hooks"
Expand Down
18 changes: 11 additions & 7 deletions lib/tasks/setup.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
desc "Setup script to run after the first clone"
desc "Setup/installation script to run after the first clone"
task :setup => :environment do

`bundle install`
puts `bundle install`

require File.dirname(__FILE__) + "/../../config/directories.rb"
require 'fileutils'
# Database config file
if !File.exists?(APP_DB_CONIG_FILE)
puts `cp config/database.yml.sample config/database.yml`
end

# Create the secret token
Rake::Task['create_a_secret'].invoke
Expand All @@ -15,15 +22,12 @@ namespace :db do

desc "Prepare test database structure"
task :test_setup => :environment do
#ENV['RAILS_ENV'] = 'test'
#Rake::Task['db:reset'].invoke

# Preparte test db
# http://stackoverflow.com/questions/5264355/rspec-failure-could-not-find-table-after-migration
#Rake::Task['db:test:prepare'].invoke
# http://guides.rubyonrails.org/testing.html#preparing-your-application-for-testing

ENV['RAILS_ENV'] = 'test'
Rake::Task['db:test:load'].invoke
Rake::Task['db:test:clone_structure'].invoke

ENV['FILE'] = 'surveys/bike_overhaul_inspection.rb'
ENV['RAILS_ENV'] = 'test'
Expand Down
2 changes: 2 additions & 0 deletions spec/features/bike_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@new_model_name = 'test_model_123'
@new_brand_name = 'test_brand_123'
end

it "should create and assign the model with correct model name and brand name" do
page.choose('bike_form_brand_action_create')
fill_in 'Brand', :with => @new_brand_name
Expand All @@ -47,6 +48,7 @@
expect(page).to have_content @new_brand_name
expect(page).to have_content @new_model_name
end

end # context "for editing an existing bike" do

context "for creating a new bike" do
Expand Down

0 comments on commit d0d6d67

Please sign in to comment.