echo_base 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -3
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +51 -2
  6. data/VERSION +1 -0
  7. data/echo_base.gemspec +165 -15
  8. data/lib/echo_base.rb +0 -3
  9. data/lib/generators/echo_base/USAGE +5 -0
  10. data/lib/generators/echo_base/echo_base_generator.rb +44 -0
  11. data/lib/generators/echo_base/templates/.infinity_test +25 -0
  12. data/lib/generators/echo_base/templates/.rspec +1 -0
  13. data/lib/generators/echo_base/templates/.rvmrc +1 -0
  14. data/lib/generators/echo_base/templates/Capfile +4 -0
  15. data/lib/generators/echo_base/templates/Gemfile +37 -0
  16. data/lib/generators/echo_base/templates/Gemfile.lock +235 -0
  17. data/lib/generators/echo_base/templates/app/controllers/application_controller.rb +20 -0
  18. data/lib/generators/echo_base/templates/app/controllers/sessions_controller.rb +15 -0
  19. data/lib/generators/echo_base/templates/app/controllers/users_controller.rb +83 -0
  20. data/lib/generators/echo_base/templates/app/helpers/application_helper.rb +2 -0
  21. data/lib/generators/echo_base/templates/app/helpers/sessions_helper.rb +2 -0
  22. data/lib/generators/echo_base/templates/app/helpers/users_helper.rb +2 -0
  23. data/lib/generators/echo_base/templates/app/models/authorization.rb +14 -0
  24. data/lib/generators/echo_base/templates/app/models/user.rb +11 -0
  25. data/lib/generators/echo_base/templates/app/views/shared/_js.html.erb +14 -0
  26. data/lib/generators/echo_base/templates/app/views/users/_form.html.erb +37 -0
  27. data/lib/generators/echo_base/templates/app/views/users/_sidebar.html.erb +13 -0
  28. data/lib/generators/echo_base/templates/app/views/users/edit.html.erb +19 -0
  29. data/lib/generators/echo_base/templates/app/views/users/index.html.erb +48 -0
  30. data/lib/generators/echo_base/templates/app/views/users/new.html.erb +18 -0
  31. data/lib/generators/echo_base/templates/app/views/users/show.html.erb +44 -0
  32. data/lib/generators/echo_base/templates/application.html.erb +48 -0
  33. data/lib/generators/echo_base/templates/autotest/discover.rb +2 -0
  34. data/lib/generators/echo_base/templates/config/cucumber.yml +8 -0
  35. data/lib/generators/echo_base/templates/config/deploy.rb +24 -0
  36. data/lib/generators/echo_base/templates/config/environments/development.rb +26 -0
  37. data/lib/generators/echo_base/templates/config/environments/production.rb +50 -0
  38. data/lib/generators/echo_base/templates/config/environments/test.rb +35 -0
  39. data/lib/generators/echo_base/templates/config/initializers/hoptoad.rb +4 -0
  40. data/lib/generators/echo_base/templates/config/initializers/omniauth.rb +10 -0
  41. data/lib/generators/echo_base/templates/config/newrelic.yml.example +0 -0
  42. data/lib/generators/echo_base/templates/config/omniauth.yml.example +62 -0
  43. data/lib/generators/echo_base/templates/config/routes.rb +5 -0
  44. data/lib/generators/echo_base/templates/db/migrate/20101008210657_create_authorizations.rb +15 -0
  45. data/lib/generators/echo_base/templates/db/migrate/20101009192412_create_users.rb +17 -0
  46. data/lib/generators/echo_base/templates/features/manage_authentications.feature +45 -0
  47. data/lib/generators/echo_base/templates/features/manage_users.feature +45 -0
  48. data/lib/generators/echo_base/templates/features/step_definitions/authentication_steps.rb +14 -0
  49. data/lib/generators/echo_base/templates/features/step_definitions/users_steps.rb +14 -0
  50. data/lib/generators/echo_base/templates/features/step_definitions/web_steps.rb +219 -0
  51. data/lib/generators/echo_base/templates/features/support/env.rb +57 -0
  52. data/lib/generators/echo_base/templates/features/support/paths.rb +39 -0
  53. data/lib/generators/echo_base/templates/public/404.html +26 -0
  54. data/lib/generators/echo_base/templates/public/422.html +26 -0
  55. data/lib/generators/echo_base/templates/public/500.html +26 -0
  56. data/lib/generators/echo_base/templates/public/favicon.ico +0 -0
  57. data/lib/generators/echo_base/templates/public/images/web-app-theme/arrow.png +0 -0
  58. data/lib/generators/echo_base/templates/public/images/web-app-theme/avatar.png +0 -0
  59. data/lib/generators/echo_base/templates/public/images/web-app-theme/boxbar-background.png +0 -0
  60. data/lib/generators/echo_base/templates/public/images/web-app-theme/breadcrumb.png +0 -0
  61. data/lib/generators/echo_base/templates/public/images/web-app-theme/button-background-active.png +0 -0
  62. data/lib/generators/echo_base/templates/public/images/web-app-theme/button-background.png +0 -0
  63. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/about +12 -0
  64. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/anchor-hover.png +0 -0
  65. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/anchor.png +0 -0
  66. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/cross-hover.png +0 -0
  67. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/cross.png +0 -0
  68. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/download-hover.png +0 -0
  69. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/download.png +0 -0
  70. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/edit-hover.png +0 -0
  71. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/edit.png +0 -0
  72. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/export-hover.png +0 -0
  73. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/export.png +0 -0
  74. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/show-hover.png +0 -0
  75. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/24/show.png +0 -0
  76. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/add.png +0 -0
  77. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/application_edit.png +0 -0
  78. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/calendar-hover.png +0 -0
  79. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/calendar.png +0 -0
  80. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/cross.png +0 -0
  81. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/delete.png +0 -0
  82. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/download.png +0 -0
  83. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/edit.png +0 -0
  84. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/key.png +0 -0
  85. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/pdf.png +0 -0
  86. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/search.png +0 -0
  87. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/see-less.png +0 -0
  88. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/see-more.png +0 -0
  89. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/send-mail.png +0 -0
  90. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/show.png +0 -0
  91. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/source +1 -0
  92. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/tick.png +0 -0
  93. data/lib/generators/echo_base/templates/public/images/web-app-theme/icons/upload.png +0 -0
  94. data/lib/generators/echo_base/templates/public/images/web-app-theme/logo.png +0 -0
  95. data/lib/generators/echo_base/templates/public/images/web-app-theme/menubar-background.png +0 -0
  96. data/lib/generators/echo_base/templates/public/images/web-app-theme/search-button.png +0 -0
  97. data/lib/generators/echo_base/templates/public/images/web-app-theme/session/account.png +0 -0
  98. data/lib/generators/echo_base/templates/public/images/web-app-theme/session/config.png +0 -0
  99. data/lib/generators/echo_base/templates/public/images/web-app-theme/session/home.png +0 -0
  100. data/lib/generators/echo_base/templates/public/images/web-app-theme/session/logout.png +0 -0
  101. data/lib/generators/echo_base/templates/public/images/web-app-theme/tipsy.gif +0 -0
  102. data/lib/generators/echo_base/templates/public/javascripts/application.js +2 -0
  103. data/lib/generators/echo_base/templates/public/javascripts/dd_belatedpng.js +328 -0
  104. data/lib/generators/echo_base/templates/public/javascripts/jquery-1.4.2.min.js +154 -0
  105. data/lib/generators/echo_base/templates/public/javascripts/modernizr-1.5.min.js +28 -0
  106. data/lib/generators/echo_base/templates/public/javascripts/rails.js +132 -0
  107. data/lib/generators/echo_base/templates/public/robots.txt +5 -0
  108. data/lib/generators/echo_base/templates/public/stylesheets/.gitkeep +0 -0
  109. data/lib/generators/echo_base/templates/public/stylesheets/handheld.css +7 -0
  110. data/lib/generators/echo_base/templates/public/stylesheets/style.css +571 -0
  111. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/base.css +397 -0
  112. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/override.css +1 -0
  113. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/themes/default/images/arrow.png +0 -0
  114. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/themes/default/images/boxbar-background.png +0 -0
  115. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/themes/default/images/button-background-active.png +0 -0
  116. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/themes/default/images/button-background.png +0 -0
  117. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/themes/default/images/menubar-background.png +0 -0
  118. data/lib/generators/echo_base/templates/public/stylesheets/web-app-theme/themes/default/style.css +466 -0
  119. data/lib/generators/echo_base/templates/spec/controllers/sessions_controller_spec.rb +5 -0
  120. data/lib/generators/echo_base/templates/spec/controllers/users_controller_spec.rb +125 -0
  121. data/lib/generators/echo_base/templates/spec/helpers/users_helper_spec.rb +15 -0
  122. data/lib/generators/echo_base/templates/spec/models/authorization_spec.rb +5 -0
  123. data/lib/generators/echo_base/templates/spec/models/user_spec.rb +5 -0
  124. data/lib/generators/echo_base/templates/spec/routing/users_routing_spec.rb +35 -0
  125. data/lib/generators/echo_base/templates/spec/spec_helper.rb +16 -0
  126. data/lib/generators/echo_base/templates/spec/views/users/edit.html.erb_spec.rb +27 -0
  127. data/lib/generators/echo_base/templates/spec/views/users/index.html.erb_spec.rb +36 -0
  128. data/lib/generators/echo_base/templates/spec/views/users/new.html.erb_spec.rb +27 -0
  129. data/lib/generators/echo_base/templates/spec/views/users/show.html.erb_spec.rb +27 -0
  130. data/test/helper.rb +10 -0
  131. data/test/test_echo_base.rb +7 -0
  132. metadata +145 -36
  133. data/Gemfile +0 -4
  134. data/lib/echo_base/version.rb +0 -3
@@ -0,0 +1,24 @@
1
+ set :application, "set your application name here"
2
+ set :repository, "set your repository location here"
3
+
4
+ set :scm, :subversion
5
+ # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
6
+
7
+ role :web, "your web-server here" # Your HTTP server, Apache/etc
8
+ role :app, "your app-server here" # This may be the same as your `Web` server
9
+ role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
10
+ role :db, "your slave db-server here"
11
+
12
+ # If you are using Passenger mod_rails uncomment this:
13
+ # if you're still using the script/reapear helper you will need
14
+ # these http://github.com/rails/irs_process_scripts
15
+
16
+ # namespace :deploy do
17
+ # task :start do ; end
18
+ # task :stop do ; end
19
+ # task :restart, :roles => :app, :except => { :no_release => true } do
20
+ # run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
21
+ # end
22
+ # end
23
+ require 'config/boot'
24
+ require 'hoptoad_notifier/capistrano'
@@ -0,0 +1,26 @@
1
+ EchoBase::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,50 @@
1
+ EchoBase::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ #config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ config.cache_store = :mem_cache_store
29
+ config.middleware.use Rack::Cache, :metastore => 'file:tmp/cache/meta', :entitystore => 'file:tmp/cache/entity'
30
+
31
+ # Disable Rails's static asset server
32
+ # In production, Apache or nginx will already do this
33
+ config.serve_static_assets = false
34
+
35
+ # Enable serving of images, stylesheets, and javascripts from an asset server
36
+ # config.action_controller.asset_host = "http://assets.example.com"
37
+
38
+ # Disable delivery errors, bad email addresses will be ignored
39
+ # config.action_mailer.raise_delivery_errors = false
40
+
41
+ # Enable threaded mode
42
+ # config.threadsafe!
43
+
44
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
45
+ # the I18n.default_locale when a translation can not be found)
46
+ config.i18n.fallbacks = true
47
+
48
+ # Send deprecation notices to registered listeners
49
+ config.active_support.deprecation = :notify
50
+ end
@@ -0,0 +1,35 @@
1
+ EchoBase::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,4 @@
1
+ HoptoadNotifier.configure do |config|
2
+ config.api_key = 'HOPTOAD_API_KEY'
3
+ config.js_notifier = true
4
+ end
@@ -0,0 +1,10 @@
1
+ omni_auth = YAML.load_file(Rails.root.join("config", "omniauth.yml"))[Rails.env]
2
+
3
+ Rails.application.config.middleware.use OmniAuth::Builder do
4
+ provider :twitter, omni_auth["twitter"]["key"], omni_auth["twitter"]["secret"] if omni_auth["twitter"]
5
+ provider :facebook, omni_auth["facebook"]["key"], omni_auth["twitter"]["secret"] if omni_auth["twitter"]
6
+ provider :linked_in, omni_auth["linked_in"]["key"], omni_auth["linked_in"]["secret"] if omni_auth["linked_in"]
7
+ provider :foursquare, omni_auth["foursquare"]["key"], omni_auth["foursquare"]["secret"] if omni_auth["foursquare"]
8
+ provider :github, omni_auth["github"]["key"], omni_auth["github"]["secret"] if omni_auth["github"]
9
+ provider :thirty_seven_signals, omni_auth["thirty_seven_signals"]["key"], omni_auth["thirty_seven_signals"]["secret"] if omni_auth["thirty_seven_signals"]
10
+ end
@@ -0,0 +1,62 @@
1
+ development:
2
+ twitter:
3
+ key:
4
+ secret:
5
+ facebook:
6
+ key:
7
+ secret:
8
+ linked:
9
+ key:
10
+ secret:
11
+ foursquare:
12
+ key:
13
+ secret:
14
+ github:
15
+ key:
16
+ secret:
17
+ thirty_seven_signals:
18
+ key:
19
+ secret:
20
+
21
+ test: &test
22
+ twitter:
23
+ key:
24
+ secret:
25
+ facebook:
26
+ key:
27
+ secret:
28
+ linked:
29
+ key:
30
+ secret:
31
+ foursquare:
32
+ key:
33
+ secret:
34
+ github:
35
+ key:
36
+ secret:
37
+ thirty_seven_signals:
38
+ key:
39
+ secret:
40
+
41
+ cucumber:
42
+ <<: *test
43
+
44
+ production:
45
+ twitter:
46
+ key:
47
+ secret:
48
+ facebook:
49
+ key:
50
+ secret:
51
+ linked:
52
+ key:
53
+ secret:
54
+ foursquare:
55
+ key:
56
+ secret:
57
+ github:
58
+ key:
59
+ secret:
60
+ thirty_seven_signals:
61
+ key:
62
+ secret:
@@ -0,0 +1,5 @@
1
+ EchoBase::Application.routes.draw do
2
+ resources :users
3
+ match '/auth/:provider/callback', :to => 'sessions#create'
4
+ root :to => 'users#index'
5
+ end
@@ -0,0 +1,15 @@
1
+ class CreateAuthorizations < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :authorizations do |t|
4
+ t.string :provider
5
+ t.string :uid
6
+ t.integer :user_id
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :authorizations
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :name
5
+ t.string :nickname
6
+ t.string :image
7
+ t.string :description
8
+ t.string :location
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ drop_table :users
16
+ end
17
+ end
@@ -0,0 +1,45 @@
1
+ Feature: Manage authentications
2
+ In order to [goal]
3
+ [stakeholder]
4
+ wants [behaviour]
5
+
6
+ Scenario: Register new authentication
7
+ Given I am on the new authentication page
8
+ And I press "Create"
9
+
10
+ # Rails generates Delete links that use Javascript to pop up a confirmation
11
+ # dialog and then do a HTTP POST request (emulated DELETE request).
12
+ #
13
+ # Capybara must use Culerity/Celerity or Selenium2 (webdriver) when pages rely
14
+ # on Javascript events. Only Culerity/Celerity supports clicking on confirmation
15
+ # dialogs.
16
+ #
17
+ # Since Culerity/Celerity and Selenium2 has some overhead, Cucumber-Rails will
18
+ # detect the presence of Javascript behind Delete links and issue a DELETE request
19
+ # instead of a GET request.
20
+ #
21
+ # You can turn this emulation off by tagging your scenario with @no-js-emulation.
22
+ # Turning on browser testing with @selenium, @culerity, @celerity or @javascript
23
+ # will also turn off the emulation. (See the Capybara documentation for
24
+ # details about those tags). If any of the browser tags are present, Cucumber-Rails
25
+ # will also turn off transactions and clean the database with DatabaseCleaner
26
+ # after the scenario has finished. This is to prevent data from leaking into
27
+ # the next scenario.
28
+ #
29
+ # Another way to avoid Cucumber-Rails' javascript emulation without using any
30
+ # of the tags above is to modify your views to use <button> instead. You can
31
+ # see how in http://github.com/jnicklas/capybara/issues#issue/12
32
+ #
33
+ Scenario: Delete authentication
34
+ Given the following authentications:
35
+ ||
36
+ ||
37
+ ||
38
+ ||
39
+ ||
40
+ When I delete the 3rd authentication
41
+ Then I should see the following authentications:
42
+ ||
43
+ ||
44
+ ||
45
+ ||
@@ -0,0 +1,45 @@
1
+ Feature: Manage users
2
+ In order to [goal]
3
+ [stakeholder]
4
+ wants [behaviour]
5
+
6
+ Scenario: Register new users
7
+ Given I am on the new user page
8
+ And I press "Create"
9
+
10
+ # Rails generates Delete links that use Javascript to pop up a confirmation
11
+ # dialog and then do a HTTP POST request (emulated DELETE request).
12
+ #
13
+ # Capybara must use Culerity/Celerity or Selenium2 (webdriver) when pages rely
14
+ # on Javascript events. Only Culerity/Celerity supports clicking on confirmation
15
+ # dialogs.
16
+ #
17
+ # Since Culerity/Celerity and Selenium2 has some overhead, Cucumber-Rails will
18
+ # detect the presence of Javascript behind Delete links and issue a DELETE request
19
+ # instead of a GET request.
20
+ #
21
+ # You can turn this emulation off by tagging your scenario with @no-js-emulation.
22
+ # Turning on browser testing with @selenium, @culerity, @celerity or @javascript
23
+ # will also turn off the emulation. (See the Capybara documentation for
24
+ # details about those tags). If any of the browser tags are present, Cucumber-Rails
25
+ # will also turn off transactions and clean the database with DatabaseCleaner
26
+ # after the scenario has finished. This is to prevent data from leaking into
27
+ # the next scenario.
28
+ #
29
+ # Another way to avoid Cucumber-Rails' javascript emulation without using any
30
+ # of the tags above is to modify your views to use <button> instead. You can
31
+ # see how in http://github.com/jnicklas/capybara/issues#issue/12
32
+ #
33
+ Scenario: Delete users
34
+ Given the following users:
35
+ ||
36
+ ||
37
+ ||
38
+ ||
39
+ ||
40
+ When I delete the 3rd users
41
+ Then I should see the following users:
42
+ ||
43
+ ||
44
+ ||
45
+ ||
@@ -0,0 +1,14 @@
1
+ Given /^the following authentications:$/ do |authentications|
2
+ Authentication.create!(authentications.hashes)
3
+ end
4
+
5
+ When /^I delete the (\d+)(?:st|nd|rd|th) authentication$/ do |pos|
6
+ visit authentications_path
7
+ within("table tr:nth-child(#{pos.to_i+1})") do
8
+ click_link "Destroy"
9
+ end
10
+ end
11
+
12
+ Then /^I should see the following authentications:$/ do |expected_authentications_table|
13
+ expected_authentications_table.diff!(tableish('table tr', 'td,th'))
14
+ end
@@ -0,0 +1,14 @@
1
+ Given /^the following users:$/ do |users|
2
+ Users.create!(users.hashes)
3
+ end
4
+
5
+ When /^I delete the (\d+)(?:st|nd|rd|th) users$/ do |pos|
6
+ visit users_path
7
+ within("table tr:nth-child(#{pos.to_i+1})") do
8
+ click_link "Destroy"
9
+ end
10
+ end
11
+
12
+ Then /^I should see the following users:$/ do |expected_users_table|
13
+ expected_users_table.diff!(tableish('table tr', 'td,th'))
14
+ end
@@ -0,0 +1,219 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require 'uri'
9
+ require 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end
@@ -0,0 +1,57 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ ENV["RAILS_ENV"] ||= "test"
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
9
+
10
+ require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
11
+ require 'cucumber/rails/world'
12
+ require 'cucumber/rails/active_record'
13
+ require 'cucumber/web/tableish'
14
+
15
+ require 'capybara/rails'
16
+ require 'capybara/cucumber'
17
+ require 'capybara/session'
18
+ require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
19
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
20
+ # order to ease the transition to Capybara we set the default here. If you'd
21
+ # prefer to use XPath just remove this line and adjust any selectors in your
22
+ # steps to use the XPath syntax.
23
+ Capybara.default_selector = :css
24
+
25
+ # If you set this to false, any error raised from within your app will bubble
26
+ # up to your step definition and out to cucumber unless you catch it somewhere
27
+ # on the way. You can make Rails rescue errors and render error pages on a
28
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
29
+ #
30
+ # If you set this to true, Rails will rescue all errors and render error
31
+ # pages, more or less in the same way your application would behave in the
32
+ # default production environment. It's not recommended to do this for all
33
+ # of your scenarios, as this makes it hard to discover errors in your application.
34
+ ActionController::Base.allow_rescue = false
35
+
36
+ # If you set this to true, each scenario will run in a database transaction.
37
+ # You can still turn off transactions on a per-scenario basis, simply tagging
38
+ # a feature or scenario with the @no-txn tag. If you are using Capybara,
39
+ # tagging with @culerity or @javascript will also turn transactions off.
40
+ #
41
+ # If you set this to false, transactions will be off for all scenarios,
42
+ # regardless of whether you use @no-txn or not.
43
+ #
44
+ # Beware that turning transactions off will leave data in your database
45
+ # after each scenario, which can lead to hard-to-debug failures in
46
+ # subsequent scenarios. If you do this, we recommend you create a Before
47
+ # block that will explicitly put your database in a known state.
48
+ Cucumber::Rails::World.use_transactional_fixtures = true
49
+ # How to clean your database when transactions are turned off. See
50
+ # http://github.com/bmabey/database_cleaner for more info.
51
+ if defined?(ActiveRecord::Base)
52
+ begin
53
+ require 'database_cleaner'
54
+ DatabaseCleaner.strategy = :truncation
55
+ rescue LoadError => ignore_if_database_cleaner_not_present
56
+ end
57
+ end