Permalink
Browse files

Initial homepage

  • Loading branch information...
1 parent 9d637d0 commit 7c29b4a3b2091e0872de123a797b2c214c12a962 @joshuaclayton committed Oct 7, 2009
Showing with 597 additions and 7,701 deletions.
  1. +2 −0 Rakefile
  2. +2 −0 app/models/pea.rb
  3. +19 −0 app/views/layouts/application.html.erb
  4. +1 −0 app/views/pages/index.html.erb
  5. +3 −1 config/environments/test.rb
  6. +1 −41 config/routes.rb
  7. +17 −0 db/migrate/20091006234504_create_peas.rb
  8. +24 −0 db/schema.rb
  9. +8 −0 features/homepage_viewing.feature
  10. +184 −0 features/step_definitions/webrat_steps.rb
  11. +25 −0 features/support/env.rb
  12. +27 −0 features/support/paths.rb
  13. +36 −0 lib/tasks/cucumber.rake
  14. +0 −275 public/index.html
  15. +0 −963 public/javascripts/controls.js
  16. +0 −973 public/javascripts/dragdrop.js
  17. +0 −1,128 public/javascripts/effects.js
  18. +0 −4,320 public/javascripts/prototype.js
  19. +9 −0 script/cucumber
  20. +4 −0 test/unit/pea_test.rb
  21. +20 −0 vendor/plugins/high_voltage/MIT-LICENSE
  22. +75 −0 vendor/plugins/high_voltage/README.markdown
  23. +23 −0 vendor/plugins/high_voltage/Rakefile
  24. +26 −0 vendor/plugins/high_voltage/app/controllers/high_voltage/pages_controller.rb
  25. +5 −0 vendor/plugins/high_voltage/config/high_voltage_routes.rb
  26. +2 −0 vendor/plugins/high_voltage/init.rb
  27. +1 −0 vendor/plugins/high_voltage/install.rb
  28. +5 −0 vendor/plugins/high_voltage/lib/high_voltage.rb
  29. +15 −0 vendor/plugins/high_voltage/lib/high_voltage/extensions/routes.rb
  30. +4 −0 vendor/plugins/high_voltage/tasks/nothing_to_see_here_move_along_tasks.rake
  31. +44 −0 vendor/plugins/high_voltage/test/pages_controller_test.rb
  32. +14 −0 vendor/plugins/high_voltage/test/test_helper.rb
  33. +1 −0 vendor/plugins/high_voltage/uninstall.rb
View
@@ -8,3 +8,5 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
+
+task :default => [:test, :cucumber]
View
@@ -0,0 +1,2 @@
+class Pea < ActiveRecord::Base
+end
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Peas</title>
+ <%= yield :head %>
+ </head>
+ <body>
+ <div class="container content">
+ <div class="header group">
+ <h1 class="col-24">Peas</h1>
+ </div>
+ <%= yield %>
+ <div class="footer">
+ <p>Copyright &copy;2009</p>
+ </div>
+ </div>
+ </body>
+</html>
@@ -0,0 +1 @@
+<h1>Peas</h1>
@@ -25,4 +25,6 @@
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
-# config.active_record.schema_format = :sql
+# config.active_record.schema_format = :sql
+
+config.gem "cucumber"
View
@@ -1,43 +1,3 @@
ActionController::Routing::Routes.draw do |map|
- # The priority is based upon order of creation: first created -> highest priority.
-
- # Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # map.resources :products
-
- # Sample resource route with options:
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
-
- # Sample resource route with sub-resources:
- # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
-
- # Sample resource route with more complex sub-resources
- # map.resources :products do |products|
- # products.resources :comments
- # products.resources :sales, :collection => { :recent => :get }
- # end
-
- # Sample resource route within a namespace:
- # map.namespace :admin do |admin|
- # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
- # admin.resources :products
- # end
-
- # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- # map.root :controller => "welcome"
-
- # See how all your routes lay out with "rake routes"
-
- # Install the default routes as the lowest priority.
- # Note: These default routes make all actions in every controller accessible via GET requests. You should
- # consider removing or commenting them out if you're using named routes and resources.
- map.connect ':controller/:action/:id'
- map.connect ':controller/:action/:id.:format'
+ map.root :controller => "high_voltage/pages", :action => "show", :id => "index"
end
@@ -0,0 +1,17 @@
+class CreatePeas < ActiveRecord::Migration
+ def self.up
+ create_table :peas do |table|
+ table.string :long_url, :key
+ table.timestamps
+ end
+
+ change_table :peas do |table|
+ table.index :long_url
+ table.index :key
+ end
+ end
+
+ def self.down
+ drop_table :peas
+ end
+end
View
@@ -0,0 +1,24 @@
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
+# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20091006234504) do
+
+ create_table "peas", :force => true do |t|
+ t.string "long_url"
+ t.string "key"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "peas", ["key"], :name => "index_peas_on_key"
+ add_index "peas", ["long_url"], :name => "index_peas_on_long_url"
+
+end
@@ -0,0 +1,8 @@
+Feature: View the homepage
+ In order to see what the website is about
+ As a visitor
+ I want to read about "Peas"
+
+ Scenario: View the homepage
+ When I go to the homepage
+ Then I should see "Peas"
@@ -0,0 +1,184 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
+
+# Commonly used webrat steps
+# http://github.com/brynary/webrat
+
+Given /^I am on (.+)$/ do |page_name|
+ visit path_to(page_name)
+end
+
+When /^I go to (.+)$/ do |page_name|
+ visit path_to(page_name)
+end
+
+When /^I press "([^\"]*)"$/ do |button|
+ click_button(button)
+end
+
+When /^I follow "([^\"]*)"$/ do |link|
+ click_link(link)
+end
+
+When /^I follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
+ click_link_within(parent, link)
+end
+
+When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
+ fill_in(field, :with => value)
+end
+
+When /^I fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
+ fill_in(field, :with => value)
+end
+
+# Use this to fill in an entire form with data from a table. Example:
+#
+# When I fill in the following:
+# | Account Number | 5002 |
+# | Expiry date | 2009-11-01 |
+# | Note | Nice guy |
+# | Wants Email? | |
+#
+# TODO: Add support for checkbox, select og option
+# based on naming conventions.
+#
+When /^I fill in the following:$/ do |fields|
+ fields.rows_hash.each do |name, value|
+ When %{I fill in "#{name}" with "#{value}"}
+ end
+end
+
+When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
+ select(value, :from => field)
+end
+
+# Use this step in conjunction with Rail's datetime_select helper. For example:
+# When I select "December 25, 2008 10:00" as the date and time
+When /^I select "([^\"]*)" as the date and time$/ do |time|
+ select_datetime(time)
+end
+
+# Use this step when using multiple datetime_select helpers on a page or
+# you want to specify which datetime to select. Given the following view:
+# <%= f.label :preferred %><br />
+# <%= f.datetime_select :preferred %>
+# <%= f.label :alternative %><br />
+# <%= f.datetime_select :alternative %>
+# The following steps would fill out the form:
+# When I select "November 23, 2004 11:20" as the "Preferred" date and time
+# And I select "November 25, 2004 10:30" as the "Alternative" date and time
+When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
+ select_datetime(datetime, :from => datetime_label)
+end
+
+# Use this step in conjunction with Rail's time_select helper. For example:
+# When I select "2:20PM" as the time
+# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
+# will convert the 2:20PM to 14:20 and then select it.
+When /^I select "([^\"]*)" as the time$/ do |time|
+ select_time(time)
+end
+
+# Use this step when using multiple time_select helpers on a page or you want to
+# specify the name of the time on the form. For example:
+# When I select "7:30AM" as the "Gym" time
+When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
+ select_time(time, :from => time_label)
+end
+
+# Use this step in conjunction with Rail's date_select helper. For example:
+# When I select "February 20, 1981" as the date
+When /^I select "([^\"]*)" as the date$/ do |date|
+ select_date(date)
+end
+
+# Use this step when using multiple date_select helpers on one page or
+# you want to specify the name of the date on the form. For example:
+# When I select "April 26, 1982" as the "Date of Birth" date
+When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
+ select_date(date, :from => date_label)
+end
+
+When /^I check "([^\"]*)"$/ do |field|
+ check(field)
+end
+
+When /^I uncheck "([^\"]*)"$/ do |field|
+ uncheck(field)
+end
+
+When /^I choose "([^\"]*)"$/ do |field|
+ choose(field)
+end
+
+When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
+ attach_file(field, path)
+end
+
+Then /^I should see "([^\"]*)"$/ do |text|
+ response.should contain(text)
+end
+
+Then /^I should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
+ within(selector) do |content|
+ content.should contain(text)
+ end
+end
+
+Then /^I should see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+ response.should contain(regexp)
+end
+
+Then /^I should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
+ within(selector) do |content|
+ regexp = Regexp.new(regexp)
+ content.should contain(regexp)
+ end
+end
+
+Then /^I should not see "([^\"]*)"$/ do |text|
+ response.should_not contain(text)
+end
+
+Then /^I should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
+ within(selector) do |content|
+ content.should_not contain(text)
+ end
+end
+
+Then /^I should not see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+ response.should_not contain(regexp)
+end
+
+Then /^I should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
+ within(selector) do |content|
+ regexp = Regexp.new(regexp)
+ content.should_not contain(regexp)
+ end
+end
+
+Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
+ field_labeled(field).value.should =~ /#{value}/
+end
+
+Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
+ field_labeled(field).value.should_not =~ /#{value}/
+end
+
+Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
+ field_labeled(label).should be_checked
+end
+
+Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
+ field_labeled(label).should_not be_checked
+end
+
+Then /^I should be on (.+)$/ do |page_name|
+ URI.parse(current_url).path.should == path_to(page_name)
+end
+
+Then /^show me the page$/ do
+ save_and_open_page
+end
View
@@ -0,0 +1,25 @@
+# Sets up the Rails environment for Cucumber
+ENV["RAILS_ENV"] ||= "test"
+require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
+require 'cucumber/rails/world'
+
+# Comment out the next line if you don't want Cucumber Unicode support
+require 'cucumber/formatter/unicode'
+
+# Comment out the next line if you don't want transactions to
+# open/roll back around each scenario
+Cucumber::Rails.use_transactional_fixtures
+
+# Comment out the next line if you want Rails' own error handling
+# (e.g. rescue_action_in_public / rescue_responses / rescue_from)
+Cucumber::Rails.bypass_rescue
+
+require 'webrat'
+require 'cucumber/webrat/element_locator' # Lets you do table.diff!(element_at('#my_table_or_dl_or_ul_or_ol').to_table)
+
+Webrat.configure do |config|
+ config.mode = :rails
+end
+
+require 'cucumber/rails/rspec'
+require 'webrat/core/matchers'
View
@@ -0,0 +1,27 @@
+module NavigationHelpers
+ # Maps a name to a path. Used by the
+ #
+ # When /^I go to (.+)$/ do |page_name|
+ #
+ # step definition in webrat_steps.rb
+ #
+ def path_to(page_name)
+ case page_name
+
+ when /the homepage/
+ '/'
+
+ # Add more mappings here.
+ # Here is a more fancy example:
+ #
+ # when /^(.*)'s profile page$/i
+ # user_profile_path(User.find_by_login($1))
+
+ else
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
+ "Now, go and add a mapping in #{__FILE__}"
+ end
+ end
+end
+
+World(NavigationHelpers)
Oops, something went wrong.

0 comments on commit 7c29b4a

Please sign in to comment.