Commit 67628f5f683a238e007dee1d61ce781ee5739e77
1 parent
f3d66b48
Exists in
master
and in
1 other branch
added cucumber
Showing
8 changed files
with
320 additions
and
86 deletions
Show diff stats
README.markdown
1 | -This is Heroku Suspenders, the thoughtbot rails template modified to be used for deployment to Heroku. To create a new project, checkout this | |
2 | -repository and run: | |
1 | +Heroku's Suspenders | |
2 | +------------------- | |
3 | 3 | |
4 | - ./script/create_project projectname | |
4 | +A Rails app with intelligent defaults from thoughtbot. | |
5 | 5 | |
6 | -This will create a project in ../projectname. You should then follow the | |
7 | -instructions on Github to upload that project there. This script creates an | |
8 | -entirely new git repository, and is not meant to be used against an existing | |
9 | -repo. | |
6 | +* Rails 2.3.2 | |
7 | +* Clearance for authentication | |
8 | +* Paperclip for file uploads, set for Amazon S3 | |
9 | +* Cucumber, Shoulda, Factory Girl, & Mocha for testing | |
10 | +* Will Paginate for pagination | |
11 | +* RedCloth for Textile formatting | |
12 | +* Hoptoad Notifier for exception notification | |
13 | +* Email defaults configured for Heroku | |
10 | 14 | |
11 | -When making a change to a project that was created via this template, consider | |
12 | -whether it's a change that should be made across all projects. If so, then | |
13 | -make the change in this template, and pull it into your project via: | |
15 | +Get the latest & greatest at anytime with: | |
14 | 16 | |
15 | - git pull heroku_suspenders master | |
17 | + git pull heroku_suspenders master | |
16 | 18 | |
17 | -About Suspenders | |
18 | ----------------- | |
19 | - | |
20 | -Suspenders was created for use at thoughtbot, inc. (http://thoughtbot.com) as a | |
21 | -baseline application setup, with reasonable default plugins that the majority (if not all) | |
22 | -of our applications used, as well as best-practice configuration options. | |
23 | - | |
24 | -Suspenders currently includes Rails 2.3.2 | |
25 | - | |
26 | -Gems (unpacked in vendor/gems): | |
27 | -------------------------------- | |
28 | - | |
29 | -For record pagination: | |
30 | - | |
31 | - will_paginate | |
32 | - | |
33 | -For text formatting: | |
34 | - | |
35 | - RedCloth | |
36 | - | |
37 | -For testing: | |
38 | - | |
39 | - mocha | |
40 | - factory_girl | |
41 | - shoulda | |
42 | - | |
43 | -Plugins (in vendor/plugins): | |
44 | ----------------------------- | |
45 | - | |
46 | - hoptoad_notifier | |
47 | - limerick_rake | |
48 | - | |
49 | -Initializers (in config/initializers) | |
50 | -------------------------------------- | |
51 | - | |
52 | - action_mailer_configs.rb | |
53 | - We use SMTP by default in all applications. | |
54 | - | |
55 | - hoptoad.rb | |
56 | - Get your API key at http://hoptoadapp.com | |
57 | - | |
58 | - requires.rb | |
59 | - Automatically requires everything in | |
60 | - lib/ | |
61 | - lib/extensions | |
62 | - test/mocks/RAILS_ENV (Removed in Rails 2, we decided to keep it) | |
63 | - Add other things you need to require in here. | |
64 | - | |
65 | - time_formats.rb | |
66 | - Two time formats are available by default, :short_date and :long_date. | |
67 | - Add other time formats here. | |
68 | - | |
69 | -Rake Tasks | |
70 | ----------- | |
71 | - | |
72 | -Rake tasks are contained in the limerick_rake gem. | |
73 | - | |
74 | - bootstrap | |
75 | - Provides rake tasks for loading data into the database. These are used for an initial application dataset needed for production. | |
76 | - | |
77 | -Testing | |
78 | -------- | |
79 | - | |
80 | -Testing is done utilizing Test::Unit, Shoulda, factory_girl, and mocha. | |
81 | - | |
82 | -factory_girl is a fixture replacement library, following the factory pattern. Place your | |
83 | -factories in test/factories.rb. The fixture directory has been removed, as fixtures are not | |
84 | -used. | |
85 | - | |
86 | -Shoulda is a pragmatic testing framework for TDD and BDD built on top of Test::Unit. | |
87 | - | |
88 | -jferris-mocha --version '0.9.5.0.1241126838' --source gems.github.com | |
89 | -thoughtbot-factory_girl --version '>= 1.2.0' --source gems.github.com | |
90 | -thoughtbot-shoulda --version '>= 2.10.1' --source gems.github.com | |
19 | +More details available in doc/README_FOR_TEMPLATE. | |
91 | 20 | |
92 | 21 | Mascot |
93 | 22 | ------ |
94 | 23 | |
95 | 24 | The official Suspenders mascot is Suspenders Boy: |
96 | 25 | |
97 | - http://media.tumblr.com/1TEAMALpseh5xzf0Jt6bcwSMo1_400.png | |
26 | + http://media.tumblr.com/1TEAMALpseh5xzf0Jt6bcwSMo1_400.png | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +config.cache_classes = true # This must be true for Cucumber to operate correctly! | |
2 | + | |
3 | +# Log error messages when you accidentally call methods on nil. | |
4 | +config.whiny_nils = true | |
5 | + | |
6 | +# Show full error reports and disable caching | |
7 | +config.action_controller.consider_all_requests_local = true | |
8 | +config.action_controller.perform_caching = false | |
9 | + | |
10 | +# Disable request forgery protection in test environment | |
11 | +config.action_controller.allow_forgery_protection = false | |
12 | + | |
13 | +# Tell Action Mailer not to deliver emails to the real world. | |
14 | +# The :test delivery method accumulates sent emails in the | |
15 | +# ActionMailer::Base.deliveries array. | |
16 | +config.action_mailer.delivery_method = :test | |
17 | + | |
18 | +config.gem "cucumber", :lib => false, :version => ">=0.3.11" unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber')) | |
19 | +config.gem "webrat", :lib => false, :version => ">=0.4.4" unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat')) | |
20 | +config.gem "rspec", :lib => false, :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec')) | |
21 | +config.gem "rspec-rails", :lib => 'spec/rails', :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails')) | ... | ... |
... | ... | @@ -0,0 +1,90 @@ |
1 | +This is Heroku Suspenders, the thoughtbot rails template modified to be used for deployment to Heroku. To create a new project, checkout this | |
2 | +repository and run: | |
3 | + | |
4 | + ./script/create_project projectname | |
5 | + | |
6 | +This will create a project in ../projectname. You should then follow the | |
7 | +instructions on Github to upload that project there. This script creates an | |
8 | +entirely new git repository, and is not meant to be used against an existing | |
9 | +repo. | |
10 | + | |
11 | +When making a change to a project that was created via this template, consider | |
12 | +whether it's a change that should be made across all projects. If so, then | |
13 | +make the change in this template, and pull it into your project via: | |
14 | + | |
15 | + git pull heroku_suspenders master | |
16 | + | |
17 | +About Suspenders | |
18 | +---------------- | |
19 | + | |
20 | +Suspenders was created for use at thoughtbot, inc. (http://thoughtbot.com) as a | |
21 | +baseline application setup, with reasonable default plugins that the majority (if not all) of our applications used, as well as best-practice configuration options. | |
22 | + | |
23 | +Suspenders currently includes Rails 2.3.2 | |
24 | + | |
25 | +Gems (unpacked in vendor/gems): | |
26 | +------------------------------- | |
27 | + | |
28 | +For record pagination: | |
29 | + | |
30 | + will_paginate | |
31 | + | |
32 | +For text formatting: | |
33 | + | |
34 | + RedCloth | |
35 | + | |
36 | +For testing: | |
37 | + | |
38 | + mocha | |
39 | + factory_girl | |
40 | + shoulda | |
41 | + | |
42 | +Plugins (in vendor/plugins): | |
43 | +---------------------------- | |
44 | + | |
45 | + hoptoad_notifier | |
46 | + limerick_rake | |
47 | + | |
48 | +Initializers (in config/initializers) | |
49 | +------------------------------------- | |
50 | + | |
51 | +We use SMTP by default in all applications. | |
52 | + | |
53 | + action_mailer_configs.rb | |
54 | + | |
55 | +Get your API key at http://hoptoadapp.com | |
56 | + | |
57 | + hoptoad.rb | |
58 | + | |
59 | +Two time formats are available by default, :short_date and :long_date. Add other time formats here. | |
60 | + | |
61 | + time_formats.rb | |
62 | + | |
63 | +Rake Tasks | |
64 | +---------- | |
65 | + | |
66 | +Rake tasks are contained in the limerick_rake gem. Provides rake tasks for loading data into the database. These are used for an initial application dataset needed for production. | |
67 | + | |
68 | + bootstrap | |
69 | + | |
70 | +Testing | |
71 | +------- | |
72 | + | |
73 | +Testing is done utilizing Test::Unit, Shoulda, factory_girl, and mocha. | |
74 | + | |
75 | +factory_girl is a fixture replacement library, following the factory pattern. Place your | |
76 | +factories in test/factories.rb. The fixture directory has been removed, as fixtures are not | |
77 | +used. | |
78 | + | |
79 | +Shoulda is a pragmatic testing framework for TDD and BDD built on top of Test::Unit. | |
80 | + | |
81 | + jferris-mocha --version '0.9.5.0.1241126838' --source gems.github.com | |
82 | + thoughtbot-factory_girl --version '>= 1.2.0' --source gems.github.com | |
83 | + thoughtbot-shoulda --version '>= 2.10.1' --source gems.github.com | |
84 | + | |
85 | +Mascot | |
86 | +------ | |
87 | + | |
88 | +The official Suspenders mascot is Suspenders Boy: | |
89 | + | |
90 | + http://media.tumblr.com/1TEAMALpseh5xzf0Jt6bcwSMo1_400.png | ... | ... |
... | ... | @@ -0,0 +1,119 @@ |
1 | +require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) | |
2 | + | |
3 | +# Commonly used webrat steps | |
4 | +# http://github.com/brynary/webrat | |
5 | + | |
6 | +Given /^I am on (.+)$/ do |page_name| | |
7 | + visit path_to(page_name) | |
8 | +end | |
9 | + | |
10 | +When /^I go to (.+)$/ do |page_name| | |
11 | + visit path_to(page_name) | |
12 | +end | |
13 | + | |
14 | +When /^I press "([^\"]*)"$/ do |button| | |
15 | + click_button(button) | |
16 | +end | |
17 | + | |
18 | +When /^I follow "([^\"]*)"$/ do |link| | |
19 | + click_link(link) | |
20 | +end | |
21 | + | |
22 | +When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| | |
23 | + fill_in(field, :with => value) | |
24 | +end | |
25 | + | |
26 | +When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field| | |
27 | + select(value, :from => field) | |
28 | +end | |
29 | + | |
30 | +# Use this step in conjunction with Rail's datetime_select helper. For example: | |
31 | +# When I select "December 25, 2008 10:00" as the date and time | |
32 | +When /^I select "([^\"]*)" as the date and time$/ do |time| | |
33 | + select_datetime(time) | |
34 | +end | |
35 | + | |
36 | +# Use this step when using multiple datetime_select helpers on a page or | |
37 | +# you want to specify which datetime to select. Given the following view: | |
38 | +# <%= f.label :preferred %><br /> | |
39 | +# <%= f.datetime_select :preferred %> | |
40 | +# <%= f.label :alternative %><br /> | |
41 | +# <%= f.datetime_select :alternative %> | |
42 | +# The following steps would fill out the form: | |
43 | +# When I select "November 23, 2004 11:20" as the "Preferred" date and time | |
44 | +# And I select "November 25, 2004 10:30" as the "Alternative" date and time | |
45 | +When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label| | |
46 | + select_datetime(datetime, :from => datetime_label) | |
47 | +end | |
48 | + | |
49 | +# Use this step in conjunction with Rail's time_select helper. For example: | |
50 | +# When I select "2:20PM" as the time | |
51 | +# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat | |
52 | +# will convert the 2:20PM to 14:20 and then select it. | |
53 | +When /^I select "([^\"]*)" as the time$/ do |time| | |
54 | + select_time(time) | |
55 | +end | |
56 | + | |
57 | +# Use this step when using multiple time_select helpers on a page or you want to | |
58 | +# specify the name of the time on the form. For example: | |
59 | +# When I select "7:30AM" as the "Gym" time | |
60 | +When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label| | |
61 | + select_time(time, :from => time_label) | |
62 | +end | |
63 | + | |
64 | +# Use this step in conjunction with Rail's date_select helper. For example: | |
65 | +# When I select "February 20, 1981" as the date | |
66 | +When /^I select "([^\"]*)" as the date$/ do |date| | |
67 | + select_date(date) | |
68 | +end | |
69 | + | |
70 | +# Use this step when using multiple date_select helpers on one page or | |
71 | +# you want to specify the name of the date on the form. For example: | |
72 | +# When I select "April 26, 1982" as the "Date of Birth" date | |
73 | +When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label| | |
74 | + select_date(date, :from => date_label) | |
75 | +end | |
76 | + | |
77 | +When /^I check "([^\"]*)"$/ do |field| | |
78 | + check(field) | |
79 | +end | |
80 | + | |
81 | +When /^I uncheck "([^\"]*)"$/ do |field| | |
82 | + uncheck(field) | |
83 | +end | |
84 | + | |
85 | +When /^I choose "([^\"]*)"$/ do |field| | |
86 | + choose(field) | |
87 | +end | |
88 | + | |
89 | +When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field| | |
90 | + attach_file(field, path) | |
91 | +end | |
92 | + | |
93 | +Then /^I should see "([^\"]*)"$/ do |text| | |
94 | + response.should contain(text) | |
95 | +end | |
96 | + | |
97 | +Then /^I should not see "([^\"]*)"$/ do |text| | |
98 | + response.should_not contain(text) | |
99 | +end | |
100 | + | |
101 | +Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value| | |
102 | + field_labeled(field).value.should =~ /#{value}/ | |
103 | +end | |
104 | + | |
105 | +Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value| | |
106 | + field_labeled(field).value.should_not =~ /#{value}/ | |
107 | +end | |
108 | + | |
109 | +Then /^the "([^\"]*)" checkbox should be checked$/ do |label| | |
110 | + field_labeled(label).should be_checked | |
111 | +end | |
112 | + | |
113 | +Then /^the "([^\"]*)" checkbox should not be checked$/ do |label| | |
114 | + field_labeled(label).should_not be_checked | |
115 | +end | |
116 | + | |
117 | +Then /^I should be on (.+)$/ do |page_name| | |
118 | + URI.parse(current_url).path.should == path_to(page_name) | |
119 | +end | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +# Sets up the Rails environment for Cucumber | |
2 | +ENV["RAILS_ENV"] ||= "cucumber" | |
3 | +require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
4 | +require 'cucumber/rails/world' | |
5 | + | |
6 | +# Comment out the next line if you don't want Cucumber Unicode support | |
7 | +require 'cucumber/formatter/unicode' | |
8 | + | |
9 | +# Comment out the next line if you don't want transactions to | |
10 | +# open/roll back around each scenario | |
11 | +Cucumber::Rails.use_transactional_fixtures | |
12 | + | |
13 | +# Comment out the next line if you want Rails' own error handling | |
14 | +# (e.g. rescue_action_in_public / rescue_responses / rescue_from) | |
15 | +Cucumber::Rails.bypass_rescue | |
16 | + | |
17 | +require 'webrat' | |
18 | + | |
19 | +Webrat.configure do |config| | |
20 | + config.mode = :rails | |
21 | +end | |
22 | + | |
23 | +require 'cucumber/rails/rspec' | |
24 | +require 'webrat/core/matchers' | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +module NavigationHelpers | |
2 | + # Maps a name to a path. Used by the | |
3 | + # | |
4 | + # When /^I go to (.+)$/ do |page_name| | |
5 | + # | |
6 | + # step definition in webrat_steps.rb | |
7 | + # | |
8 | + def path_to(page_name) | |
9 | + case page_name | |
10 | + | |
11 | + when /the homepage/ | |
12 | + '/' | |
13 | + | |
14 | + # Add more mappings here. | |
15 | + # Here is a more fancy example: | |
16 | + # | |
17 | + # when /^(.*)'s profile page$/i | |
18 | + # user_profile_path(User.find_by_login($1)) | |
19 | + | |
20 | + else | |
21 | + raise "Can't find mapping from \"#{page_name}\" to a path.\n" + | |
22 | + "Now, go and add a mapping in #{__FILE__}" | |
23 | + end | |
24 | + end | |
25 | +end | |
26 | + | |
27 | +World(NavigationHelpers) | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') | |
2 | + | |
3 | +begin | |
4 | + require 'cucumber/rake/task' | |
5 | + | |
6 | + Cucumber::Rake::Task.new(:features) do |t| | |
7 | + t.fork = true | |
8 | + t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')] | |
9 | + end | |
10 | + task :features => 'db:test:prepare' | |
11 | +rescue LoadError | |
12 | + desc 'Cucumber rake task not available' | |
13 | + task :features do | |
14 | + abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' | |
15 | + end | |
16 | +end | ... | ... |
... | ... | @@ -0,0 +1,8 @@ |
1 | +#!/usr/bin/env ruby | |
2 | +begin | |
3 | + load File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/cucumber/bin/cucumber") | |
4 | +rescue LoadError => e | |
5 | + raise unless e.to_s =~ /cucumber/ | |
6 | + require "rubygems" | |
7 | + load File.join(Gem.bindir, "cucumber") | |
8 | +end | |
0 | 9 | \ No newline at end of file | ... | ... |