Permalink
Browse files

Lots of work on Cucumber features, adding vendored version of webrat …

…(rack branch)
  • Loading branch information...
1 parent 43fa4dc commit 96ad27f116c5eb7f3b048955210f592dfccb4ca3 @winton committed Jul 3, 2009
Showing with 11,499 additions and 67 deletions.
  1. +2 −2 .gitignore
  2. +5 −24 Rakefile
  3. +3 −0 config/externals.yml
  4. +14 −0 features/front_page.feature
  5. +15 −0 features/step_definitions/front_page.rb
  6. +51 −0 features/step_definitions/update_user.rb
  7. +23 −0 features/support/env.rb
  8. +76 −0 features/update_user.feature
  9. +1 −1 lib/sum/boot.rb
  10. +2 −2 lib/sum/model/user.rb
  11. +6 −1 spec/spec_helper.rb
  12. +0 −28 spec/sum/controller/front_spec.rb
  13. +22 −9 spec/sum/model/user_spec.rb
  14. +4 −0 vendor/webrat/.document
  15. +15 −0 vendor/webrat/.gitignore
  16. +358 −0 vendor/webrat/History.txt
  17. +19 −0 vendor/webrat/MIT-LICENSE.txt
  18. +85 −0 vendor/webrat/README.rdoc
  19. +200 −0 vendor/webrat/Rakefile
  20. +1 −0 vendor/webrat/install.rb
  21. +31 −0 vendor/webrat/lib/webrat.rb
  22. +14 −0 vendor/webrat/lib/webrat/core.rb
  23. +102 −0 vendor/webrat/lib/webrat/core/configuration.rb
  24. +31 −0 vendor/webrat/lib/webrat/core/elements/area.rb
  25. +33 −0 vendor/webrat/lib/webrat/core/elements/element.rb
  26. +409 −0 vendor/webrat/lib/webrat/core/elements/field.rb
  27. +103 −0 vendor/webrat/lib/webrat/core/elements/form.rb
  28. +31 −0 vendor/webrat/lib/webrat/core/elements/label.rb
  29. +93 −0 vendor/webrat/lib/webrat/core/elements/link.rb
  30. +35 −0 vendor/webrat/lib/webrat/core/elements/select_option.rb
  31. +20 −0 vendor/webrat/lib/webrat/core/locators.rb
  32. +38 −0 vendor/webrat/lib/webrat/core/locators/area_locator.rb
  33. +54 −0 vendor/webrat/lib/webrat/core/locators/button_locator.rb
  34. +37 −0 vendor/webrat/lib/webrat/core/locators/field_by_id_locator.rb
  35. +56 −0 vendor/webrat/lib/webrat/core/locators/field_labeled_locator.rb
  36. +25 −0 vendor/webrat/lib/webrat/core/locators/field_locator.rb
  37. +41 −0 vendor/webrat/lib/webrat/core/locators/field_named_locator.rb
  38. +19 −0 vendor/webrat/lib/webrat/core/locators/form_locator.rb
  39. +34 −0 vendor/webrat/lib/webrat/core/locators/label_locator.rb
  40. +74 −0 vendor/webrat/lib/webrat/core/locators/link_locator.rb
  41. +20 −0 vendor/webrat/lib/webrat/core/locators/locator.rb
  42. +59 −0 vendor/webrat/lib/webrat/core/locators/select_option_locator.rb
  43. +24 −0 vendor/webrat/lib/webrat/core/logging.rb
  44. +4 −0 vendor/webrat/lib/webrat/core/matchers.rb
  45. +73 −0 vendor/webrat/lib/webrat/core/matchers/have_content.rb
  46. +74 −0 vendor/webrat/lib/webrat/core/matchers/have_selector.rb
  47. +21 −0 vendor/webrat/lib/webrat/core/matchers/have_tag.rb
  48. +147 −0 vendor/webrat/lib/webrat/core/matchers/have_xpath.rb
  49. +63 −0 vendor/webrat/lib/webrat/core/methods.rb
  50. +29 −0 vendor/webrat/lib/webrat/core/mime.rb
  51. +48 −0 vendor/webrat/lib/webrat/core/save_and_open_page.rb
  52. +350 −0 vendor/webrat/lib/webrat/core/scope.rb
  53. +299 −0 vendor/webrat/lib/webrat/core/session.rb
  54. +115 −0 vendor/webrat/lib/webrat/core/xml.rb
  55. +19 −0 vendor/webrat/lib/webrat/core/xml/hpricot.rb
  56. +76 −0 vendor/webrat/lib/webrat/core/xml/nokogiri.rb
  57. +24 −0 vendor/webrat/lib/webrat/core/xml/rexml.rb
  58. +58 −0 vendor/webrat/lib/webrat/core_extensions/blank.rb
  59. +8 −0 vendor/webrat/lib/webrat/core_extensions/deprecate.rb
  60. +12 −0 vendor/webrat/lib/webrat/core_extensions/detect_mapped.rb
  61. +6 −0 vendor/webrat/lib/webrat/core_extensions/meta_class.rb
  62. +5 −0 vendor/webrat/lib/webrat/core_extensions/nil_to_param.rb
  63. +27 −0 vendor/webrat/lib/webrat/core_extensions/tcp_socket.rb
  64. +74 −0 vendor/webrat/lib/webrat/mechanize.rb
  65. +9 −0 vendor/webrat/lib/webrat/merb.rb
  66. +27 −0 vendor/webrat/lib/webrat/merb_multipart_support.rb
  67. +82 −0 vendor/webrat/lib/webrat/merb_session.rb
  68. +25 −0 vendor/webrat/lib/webrat/rack.rb
  69. +106 −0 vendor/webrat/lib/webrat/rails.rb
  70. +10 −0 vendor/webrat/lib/webrat/rspec-rails.rb
  71. +81 −0 vendor/webrat/lib/webrat/selenium.rb
  72. +40 −0 vendor/webrat/lib/webrat/selenium/application_server_factory.rb
  73. +5 −0 vendor/webrat/lib/webrat/selenium/application_servers.rb
  74. +46 −0 vendor/webrat/lib/webrat/selenium/application_servers/base.rb
  75. +26 −0 vendor/webrat/lib/webrat/selenium/application_servers/external.rb
  76. +50 −0 vendor/webrat/lib/webrat/selenium/application_servers/merb.rb
  77. +44 −0 vendor/webrat/lib/webrat/selenium/application_servers/rails.rb
  78. +37 −0 vendor/webrat/lib/webrat/selenium/application_servers/sinatra.rb
  79. +19 −0 vendor/webrat/lib/webrat/selenium/location_strategy_javascript/button.js
  80. +16 −0 vendor/webrat/lib/webrat/selenium/location_strategy_javascript/label.js
  81. +5 −0 vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webrat.js
  82. +12 −0 vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlink.js
  83. +15 −0 vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js
  84. +5 −0 vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js
  85. +4 −0 vendor/webrat/lib/webrat/selenium/matchers.rb
  86. +66 −0 vendor/webrat/lib/webrat/selenium/matchers/have_content.rb
  87. +49 −0 vendor/webrat/lib/webrat/selenium/matchers/have_selector.rb
  88. +72 −0 vendor/webrat/lib/webrat/selenium/matchers/have_tag.rb
  89. +45 −0 vendor/webrat/lib/webrat/selenium/matchers/have_xpath.rb
  90. +6 −0 vendor/webrat/lib/webrat/selenium/selenium_extensions.js
  91. +84 −0 vendor/webrat/lib/webrat/selenium/selenium_rc_server.rb
  92. +248 −0 vendor/webrat/lib/webrat/selenium/selenium_session.rb
  93. +18 −0 vendor/webrat/lib/webrat/selenium/silence_stream.rb
  94. +11 −0 vendor/webrat/lib/webrat/sinatra.rb
  95. +34 −0 vendor/webrat/spec/fakes/test_session.rb
  96. +21 −0 vendor/webrat/spec/integration/merb/.gitignore
  97. +35 −0 vendor/webrat/spec/integration/merb/Rakefile
  98. +2 −0 vendor/webrat/spec/integration/merb/app/controllers/application.rb
  99. +13 −0 vendor/webrat/spec/integration/merb/app/controllers/exceptions.rb
  100. +27 −0 vendor/webrat/spec/integration/merb/app/controllers/testing.rb
  101. +63 −0 vendor/webrat/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb
  102. +47 −0 vendor/webrat/spec/integration/merb/app/views/exceptions/not_found.html.erb
  103. +12 −0 vendor/webrat/spec/integration/merb/app/views/layout/application.html.erb
  104. +27 −0 vendor/webrat/spec/integration/merb/app/views/testing/show_form.html.erb
  105. +9 −0 vendor/webrat/spec/integration/merb/app/views/testing/upload.html.erb
  106. +15 −0 vendor/webrat/spec/integration/merb/config/environments/development.rb
  107. +11 −0 vendor/webrat/spec/integration/merb/config/environments/rake.rb
  108. +14 −0 vendor/webrat/spec/integration/merb/config/environments/test.rb
  109. +25 −0 vendor/webrat/spec/integration/merb/config/init.rb
  110. +11 −0 vendor/webrat/spec/integration/merb/config/rack.rb
  111. +34 −0 vendor/webrat/spec/integration/merb/config/router.rb
  112. +1 −0 vendor/webrat/spec/integration/merb/spec/spec.opts
  113. +24 −0 vendor/webrat/spec/integration/merb/spec/spec_helper.rb
  114. +39 −0 vendor/webrat/spec/integration/merb/spec/webrat_spec.rb
  115. +31 −0 vendor/webrat/spec/integration/merb/tasks/merb.thor/app_script.rb
  116. +64 −0 vendor/webrat/spec/integration/merb/tasks/merb.thor/common.rb
  117. +124 −0 vendor/webrat/spec/integration/merb/tasks/merb.thor/gem_ext.rb
  118. +150 −0 vendor/webrat/spec/integration/merb/tasks/merb.thor/main.thor
  119. +93 −0 vendor/webrat/spec/integration/merb/tasks/merb.thor/ops.rb
  120. +40 −0 vendor/webrat/spec/integration/merb/tasks/merb.thor/utils.rb
  121. +5 −0 vendor/webrat/spec/integration/rack/Rakefile
  122. +73 −0 vendor/webrat/spec/integration/rack/app.rb
  123. +20 −0 vendor/webrat/spec/integration/rack/test/helper.rb
  124. +62 −0 vendor/webrat/spec/integration/rack/test/webrat_rack_test.rb
  125. +3 −0 vendor/webrat/spec/integration/rails/.gitignore
  126. +30 −0 vendor/webrat/spec/integration/rails/Rakefile
  127. +15 −0 vendor/webrat/spec/integration/rails/app/controllers/application.rb
  128. +7 −0 vendor/webrat/spec/integration/rails/app/controllers/buttons_controller.rb
  129. +4 −0 vendor/webrat/spec/integration/rails/app/controllers/fields_controller.rb
  130. +7 −0 vendor/webrat/spec/integration/rails/app/controllers/links_controller.rb
  131. +43 −0 vendor/webrat/spec/integration/rails/app/controllers/webrat_controller.rb
  132. +2 −0 vendor/webrat/spec/integration/rails/app/helpers/buttons_helper.rb
  133. +2 −0 vendor/webrat/spec/integration/rails/app/helpers/fields_helper.rb
  134. +2 −0 vendor/webrat/spec/integration/rails/app/helpers/links_helper.rb
  135. +11 −0 vendor/webrat/spec/integration/rails/app/views/buttons/show.html.erb
  136. +9 −0 vendor/webrat/spec/integration/rails/app/views/fields/show.html.erb
  137. +5 −0 vendor/webrat/spec/integration/rails/app/views/links/show.html.erb
  138. +4 −0 vendor/webrat/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb
  139. +11 −0 vendor/webrat/spec/integration/rails/app/views/webrat/buttons.html.erb
  140. +28 −0 vendor/webrat/spec/integration/rails/app/views/webrat/form.html.erb
  141. +109 −0 vendor/webrat/spec/integration/rails/config/boot.rb
  142. +12 −0 vendor/webrat/spec/integration/rails/config/environment.rb
  143. +17 −0 vendor/webrat/spec/integration/rails/config/environments/development.rb
  144. +22 −0 vendor/webrat/spec/integration/rails/config/environments/selenium.rb
  145. +22 −0 vendor/webrat/spec/integration/rails/config/environments/test.rb
  146. +10 −0 vendor/webrat/spec/integration/rails/config/initializers/inflections.rb
  147. +5 −0 vendor/webrat/spec/integration/rails/config/initializers/mime_types.rb
  148. +17 −0 vendor/webrat/spec/integration/rails/config/initializers/new_rails_defaults.rb
  149. +5 −0 vendor/webrat/spec/integration/rails/config/locales/en.yml
  150. +18 −0 vendor/webrat/spec/integration/rails/config/routes.rb
  151. +30 −0 vendor/webrat/spec/integration/rails/public/404.html
  152. +30 −0 vendor/webrat/spec/integration/rails/public/422.html
  153. +33 −0 vendor/webrat/spec/integration/rails/public/500.html
  154. +4 −0 vendor/webrat/spec/integration/rails/script/about
  155. +3 −0 vendor/webrat/spec/integration/rails/script/console
  156. +3 −0 vendor/webrat/spec/integration/rails/script/dbconsole
  157. +3 −0 vendor/webrat/spec/integration/rails/script/destroy
  158. +3 −0 vendor/webrat/spec/integration/rails/script/generate
  159. +3 −0 vendor/webrat/spec/integration/rails/script/performance/benchmarker
  160. +3 −0 vendor/webrat/spec/integration/rails/script/performance/profiler
  161. +3 −0 vendor/webrat/spec/integration/rails/script/performance/request
  162. +3 −0 vendor/webrat/spec/integration/rails/script/plugin
  163. +3 −0 vendor/webrat/spec/integration/rails/script/process/inspector
  164. +3 −0 vendor/webrat/spec/integration/rails/script/process/reaper
  165. +3 −0 vendor/webrat/spec/integration/rails/script/process/spawner
  166. +3 −0 vendor/webrat/spec/integration/rails/script/runner
  167. +3 −0 vendor/webrat/spec/integration/rails/script/server
  168. +80 −0 vendor/webrat/spec/integration/rails/test/integration/button_click_test.rb
  169. +24 −0 vendor/webrat/spec/integration/rails/test/integration/fill_in_test.rb
  170. +27 −0 vendor/webrat/spec/integration/rails/test/integration/link_click_test.rb
  171. +97 −0 vendor/webrat/spec/integration/rails/test/integration/webrat_test.rb
  172. +25 −0 vendor/webrat/spec/integration/rails/test/test_helper.rb
  173. +5 −0 vendor/webrat/spec/integration/sinatra/Rakefile
  174. +64 −0 vendor/webrat/spec/integration/sinatra/classic_app.rb
  175. +16 −0 vendor/webrat/spec/integration/sinatra/modular_app.rb
  176. +37 −0 vendor/webrat/spec/integration/sinatra/test/classic_app_test.rb
  177. +18 −0 vendor/webrat/spec/integration/sinatra/test/modular_app_test.rb
  178. +16 −0 vendor/webrat/spec/integration/sinatra/test/test_helper.rb
  179. +116 −0 vendor/webrat/spec/private/core/configuration_spec.rb
  180. +85 −0 vendor/webrat/spec/private/core/field_spec.rb
  181. +24 −0 vendor/webrat/spec/private/core/link_spec.rb
  182. +10 −0 vendor/webrat/spec/private/core/logging_spec.rb
  183. +195 −0 vendor/webrat/spec/private/core/session_spec.rb
  184. +81 −0 vendor/webrat/spec/private/mechanize/mechanize_session_spec.rb
  185. +93 −0 vendor/webrat/spec/private/merb/attaches_file_spec.rb
  186. +61 −0 vendor/webrat/spec/private/merb/merb_session_spec.rb
  187. +77 −0 vendor/webrat/spec/private/nokogiri_spec.rb
  188. +81 −0 vendor/webrat/spec/private/rails/attaches_file_spec.rb
  189. +112 −0 vendor/webrat/spec/private/rails/rails_session_spec.rb
  190. +26 −0 vendor/webrat/spec/private/selenium/application_servers/rails_spec.rb
  191. +24 −0 vendor/webrat/spec/public/basic_auth_spec.rb
  192. +191 −0 vendor/webrat/spec/public/check_spec.rb
  193. +118 −0 vendor/webrat/spec/public/choose_spec.rb
  194. +106 −0 vendor/webrat/spec/public/click_area_spec.rb
  195. +496 −0 vendor/webrat/spec/public/click_button_spec.rb
  196. +511 −0 vendor/webrat/spec/public/click_link_spec.rb
  197. +209 −0 vendor/webrat/spec/public/fill_in_spec.rb
  198. +19 −0 vendor/webrat/spec/public/locators/field_by_xpath_spec.rb
  199. +172 −0 vendor/webrat/spec/public/locators/field_labeled_spec.rb
  200. +16 −0 vendor/webrat/spec/public/locators/field_with_id_spec.rb
  201. +114 −0 vendor/webrat/spec/public/matchers/contain_spec.rb
  202. +142 −0 vendor/webrat/spec/public/matchers/have_selector_spec.rb
  203. +39 −0 vendor/webrat/spec/public/matchers/have_tag_spec.rb
  204. +136 −0 vendor/webrat/spec/public/matchers/have_xpath_spec.rb
  205. +10 −0 vendor/webrat/spec/public/reload_spec.rb
  206. +70 −0 vendor/webrat/spec/public/save_and_open_spec.rb
  207. +112 −0 vendor/webrat/spec/public/select_date_spec.rb
  208. +137 −0 vendor/webrat/spec/public/select_datetime_spec.rb
  209. +249 −0 vendor/webrat/spec/public/select_spec.rb
  210. +100 −0 vendor/webrat/spec/public/select_time_spec.rb
  211. +49 −0 vendor/webrat/spec/public/selenium/application_server_factory_spec.rb
  212. +12 −0 vendor/webrat/spec/public/selenium/application_servers/external_spec.rb
  213. +37 −0 vendor/webrat/spec/public/selenium/selenium_session_spec.rb
  214. +5 −0 vendor/webrat/spec/public/set_hidden_field_spec.rb
  215. +5 −0 vendor/webrat/spec/public/submit_form_spec.rb
  216. +58 −0 vendor/webrat/spec/public/visit_spec.rb
  217. +177 −0 vendor/webrat/spec/public/within_spec.rb
  218. +1 −0 vendor/webrat/spec/rcov.opts
  219. +2 −0 vendor/webrat/spec/spec.opts
  220. +50 −0 vendor/webrat/spec/spec_helper.rb
View
@@ -1,10 +1,10 @@
.DS_Store
*.gem
+*.log
config/database.yml
config/deploy.rb
config/mail.yml
coverage
log
pkg
-tmp
-vendor
+tmp
View
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake'
+require 'cucumber/rake/task'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require 'gemspec'
@@ -29,34 +30,14 @@ task :install do
`rm -Rf pkg`
end
-desc "Package gem"
-Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
- pkg.gem_spec = GEM_SPEC
+Cucumber::Rake::Task.new do |t|
+ t.cucumber_opts = "--format pretty"
end
-desc "Setup project"
-task :setup do
- name = File.basename(Dir.pwd)
- `rm -Rf .git`
- begin
- dir = Dir['**/gem_template*']
- from = dir.pop
- if from
- rb = from.include?('.rb')
- to = File.dirname(from) + "/#{name}#{'.rb' if rb}"
- FileUtils.mv(from, to)
- end
- end while dir.length > 0
- Dir["**/*"].each do |path|
- next if path.include?('Rakefile')
- if File.file?(path)
- `sed -i "" 's/gem_template/#{name}/g' #{path}`
- end
- end
- `git init`
+Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
+ pkg.gem_spec = GEM_SPEC
end
-desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.rcov = true
t.spec_opts = ["--format", "specdoc", "--colour"]
@@ -7,3 +7,6 @@ fetcher:
sinatra:
repo: git://github.com/sinatra/sinatra.git
path: vendor
+webrat:
+ repo: git://github.com/brynary/webrat.git
+ path: vendor
@@ -0,0 +1,14 @@
+Feature: Front page
+
+ As a user
+ I want to enter my information into a form
+ In order to submit that information
+
+ Scenario: User visits the front page
+ When a user visits the front page
+ Then they should see a form
+ And they should see a "savings" text field
+ And they should see an "income" text field
+ And they should see a "bills" text field
+ And they should see an "email" text field
+ And they should see a submit button
@@ -0,0 +1,15 @@
+When /^a user visits the front page$/ do
+ visit '/'
+end
+
+Then /^they should see a form$/ do
+ assert_have_selector "form[action='/new'][method='post']"
+end
+
+Then /^they should see a.? "([^\"]*)" text field$/ do |field|
+ assert_have_selector "#user_#{field}"
+end
+
+Then /^they should see a submit button$/ do
+ assert_have_selector "input[type=image]"
+end
@@ -0,0 +1,51 @@
+When /^submits a valid form with "([^\"]*)"$/ do |input|
+ fill_all_with_valid_data
+ values = case input
+ when "decimals": [ "1000.00", "5000.00", "2000.00" ]
+ when "numbers only": [ "1000", "5000", "2000" ]
+ when "dollar signs": [ "$1000.00", "$5000.00", "$2000.00" ]
+ end
+ fill_in "user[savings]", :with => values.pop
+ fill_in "user[income]", :with => values.pop
+ fill_in "user[bills]", :with => values.pop
+ click_button
+end
+
+When /^submits an invalid "([^\"]*)".*$/ do |field|
+ fill_all_with_valid_data
+ fill_in "user[#{field}]", :with => "invalid"
+ click_button
+end
+
+When /^submits an empty "([^\"]*)".*$/ do |field|
+ fill_all_with_valid_data
+ fill_in "user[#{field}]", :with => ""
+ click_button
+end
+
+Then /^they should see a success page$/ do
+ assert_contain "Success!"
+end
+
+Then /^the "([^\"]*)" field should have an error$/ do |field|
+ assert_have_selector "#user_#{field}"
+ assert_have_selector ".validation"
+end
+
+Then /^the error should be "([^\"]*)"$/ do |error|
+ within ".validation" do
+ assert_contain error
+ end
+end
+
+def fill_all_with_valid_data
+ valid = {
+ 'savings' => '0',
+ 'income' => '0',
+ 'bills' => '0',
+ 'email' => 'cucumber@sumapp.com'
+ }
+ valid.each do |key, value|
+ fill_in "user[#{key}]", :with => value
+ end
+end
@@ -0,0 +1,23 @@
+$testing = true
+$root = File.expand_path(File.dirname(__FILE__) + "/../../")
+$:.unshift "#{$root}/lib"
+
+require 'sum'
+require 'rack/test'
+require 'test/unit'
+require "#{$root}/vendor/webrat/lib/webrat"
+
+Webrat.configure do |config|
+ config.mode = :rack
+end
+
+World do
+ def app
+ Application
+ end
+
+ include Rack::Test::Methods
+ include Test::Unit::Assertions
+ include Webrat::Matchers
+ include Webrat::Methods
+end
@@ -0,0 +1,76 @@
+Feature: Update user
+
+ As a user
+ I want to submit my information
+ In order to see a success page
+
+ Scenario: User submits a valid form with decimals
+ When a user visits the front page
+ And submits a valid form with "decimals"
+ Then they should see a success page
+
+ Scenario: User submits a valid form with numbers only
+ When a user visits the front page
+ And submits a valid form with "numbers only"
+ Then they should see a success page
+
+ Scenario: User submits a valid form with dollar signs
+ When a user visits the front page
+ And submits a valid form with "dollar signs"
+ Then they should see a success page
+
+ Scenario: User submits an invalid savings amount
+ When a user visits the front page
+ And submits an invalid "savings" amount
+ Then they should see a form
+ And the "savings" field should have an error
+ And the error should be "is not a number"
+
+ Scenario: User submits an empty savings amount
+ When a user visits the front page
+ And submits an empty "savings" amount
+ Then they should see a form
+ And the "savings" field should have an error
+ And the error should be "is not a number"
+
+ Scenario: User submits an invalid income amount
+ When a user visits the front page
+ And submits an invalid "income" amount
+ Then they should see a form
+ And the "income" field should have an error
+ And the error should be "is not a number"
+
+ Scenario: User submits an empty income amount
+ When a user visits the front page
+ And submits an empty "income" amount
+ Then they should see a form
+ And the "income" field should have an error
+ And the error should be "is not a number"
+
+ Scenario: User submits an invalid bills amount
+ When a user visits the front page
+ And submits an invalid "bills" amount
+ Then they should see a form
+ And the "bills" field should have an error
+ And the error should be "is not a number"
+
+ Scenario: User submits an empty bills amount
+ When a user visits the front page
+ And submits an empty "bills" amount
+ Then they should see a form
+ And the "bills" field should have an error
+ And the error should be "is not a number"
+
+ Scenario: User submits an invalid email
+ When a user visits the front page
+ And submits an invalid "email"
+ Then they should see a form
+ And the "email" field should have an error
+ And the error should be "is invalid"
+
+ Scenario: User submits an empty email
+ When a user visits the front page
+ And submits an empty "email"
+ Then they should see a form
+ And the "email" field should have an error
+ And the error should be "can't be blank"
View
@@ -4,7 +4,7 @@
# Sinatra
enable :raise_errors
- set :environment, $TESTING ? :test : environment
+ set :environment, $testing ? :test : environment
set :root, File.expand_path("#{File.dirname(__FILE__)}/../../")
set :public, "#{root}/public"
set :logging, true
@@ -154,7 +154,7 @@ def before_save_spending_goal
end
end
- def local_5am_to_server_time
+ def local_12am_to_server_time
time = to_local_time(Time.now)
time = DateTime.strptime(
time.strftime("%m/%d/%Y 12:00 AM %Z"),
@@ -190,7 +190,7 @@ def update_send_at
if self.send_at
self.send_at = self.send_at + 1.day
else
- self.send_at = local_5am_to_server_time
+ self.send_at = local_12am_to_server_time
end
end
end
View
@@ -1,15 +1,20 @@
-$TESTING=true
+$testing=true
SPEC = File.dirname(__FILE__)
$:.unshift File.expand_path("#{SPEC}/../lib")
require 'sum'
require 'pp'
require 'spec/interop/test'
require 'rack/test'
+require File.expand_path("#{SPEC}/../vendor/webrat/lib/webrat")
Spec::Runner.configure do |config|
end
+Webrat.configure do |config|
+ config.mode = :rack
+end
+
def create_valid_user
User.create(
:email => "test@test.com",
@@ -1,28 +0,0 @@
-require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
-
-describe 'Front Controller' do
- include Rack::Test::Methods
-
- def app
- Application
- end
-
- describe 'get /' do
-
- before(:all) do
- get '/'
- end
-
- it "should respond ok" do
- last_response.should be_ok
- end
-
- it "should contain instructions" do
- last_response.body.include?("class='number'").should == true
- end
-
- it "should contain a form" do
- last_response.body.include?("<form").should == true
- end
- end
-end
Oops, something went wrong.

0 comments on commit 96ad27f

Please sign in to comment.