cucover 0.1.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.
- data/.gitignore +6 -0
- data/Licence.txt +22 -0
- data/README.markdown +69 -0
- data/Rakefile +86 -0
- data/VERSION +1 -0
- data/bin/cucover +3 -0
- data/cucover.gemspec +182 -0
- data/cucumber.yml +3 -0
- data/examples/self_test/rails/.gitignore +4 -0
- data/examples/self_test/rails/Rakefile +10 -0
- data/examples/self_test/rails/app/controllers/application_controller.rb +2 -0
- data/examples/self_test/rails/app/controllers/widgets_controller.rb +2 -0
- data/examples/self_test/rails/app/helpers/application_helper.rb +3 -0
- data/examples/self_test/rails/app/views/widgets/index.html.erb +1 -0
- data/examples/self_test/rails/config/boot.rb +110 -0
- data/examples/self_test/rails/config/cucumber.yml +7 -0
- data/examples/self_test/rails/config/database.yml +25 -0
- data/examples/self_test/rails/config/environment.rb +41 -0
- data/examples/self_test/rails/config/environments/cucumber.rb +27 -0
- data/examples/self_test/rails/config/environments/development.rb +17 -0
- data/examples/self_test/rails/config/environments/production.rb +28 -0
- data/examples/self_test/rails/config/environments/test.rb +28 -0
- data/examples/self_test/rails/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/self_test/rails/config/initializers/inflections.rb +10 -0
- data/examples/self_test/rails/config/initializers/mime_types.rb +5 -0
- data/examples/self_test/rails/config/initializers/new_rails_defaults.rb +21 -0
- data/examples/self_test/rails/config/initializers/session_store.rb +15 -0
- data/examples/self_test/rails/config/locales/en.yml +5 -0
- data/examples/self_test/rails/config/routes.rb +43 -0
- data/examples/self_test/rails/db/seeds.rb +7 -0
- data/examples/self_test/rails/features/see_widgets.feature +7 -0
- data/examples/self_test/rails/features/step_definitions/web_steps.rb +273 -0
- data/examples/self_test/rails/features/support/env.rb +57 -0
- data/examples/self_test/rails/features/support/paths.rb +29 -0
- data/examples/self_test/rails/lib/tasks/cucumber.rake +47 -0
- data/examples/self_test/rails/public/404.html +30 -0
- data/examples/self_test/rails/public/422.html +30 -0
- data/examples/self_test/rails/public/500.html +30 -0
- data/examples/self_test/rails/public/favicon.ico +0 -0
- data/examples/self_test/rails/public/images/rails.png +0 -0
- data/examples/self_test/rails/public/index.html +275 -0
- data/examples/self_test/rails/public/javascripts/application.js +2 -0
- data/examples/self_test/rails/public/javascripts/controls.js +963 -0
- data/examples/self_test/rails/public/javascripts/dragdrop.js +973 -0
- data/examples/self_test/rails/public/javascripts/effects.js +1128 -0
- data/examples/self_test/rails/public/javascripts/prototype.js +4320 -0
- data/examples/self_test/rails/public/robots.txt +5 -0
- data/examples/self_test/rails/script/about +4 -0
- data/examples/self_test/rails/script/console +3 -0
- data/examples/self_test/rails/script/cucumber +10 -0
- data/examples/self_test/rails/script/dbconsole +3 -0
- data/examples/self_test/rails/script/destroy +3 -0
- data/examples/self_test/rails/script/generate +3 -0
- data/examples/self_test/rails/script/performance/benchmarker +3 -0
- data/examples/self_test/rails/script/performance/profiler +3 -0
- data/examples/self_test/rails/script/plugin +3 -0
- data/examples/self_test/rails/script/runner +3 -0
- data/examples/self_test/rails/script/server +3 -0
- data/examples/self_test/simple/features/call_foo.feature +4 -0
- data/examples/self_test/simple/features/call_foo_and_bar_together.feature +5 -0
- data/examples/self_test/simple/features/call_foo_from_background_then_bar.feature +7 -0
- data/examples/self_test/simple/features/call_foo_from_background_then_bar_then_baz.feature +10 -0
- data/examples/self_test/simple/features/call_foo_then_bar.feature +7 -0
- data/examples/self_test/simple/features/call_foo_then_bar_from_scenario_outline_examples.feature +9 -0
- data/examples/self_test/simple/features/fail.feature +10 -0
- data/examples/self_test/simple/features/step_definitions/main_steps.rb +15 -0
- data/examples/self_test/simple/lib/bar.rb +5 -0
- data/examples/self_test/simple/lib/baz.rb +5 -0
- data/examples/self_test/simple/lib/foo.rb +9 -0
- data/features/call_foo.feature +0 -0
- data/features/coverage_of.feature +81 -0
- data/features/fail.feature +60 -0
- data/features/help.feature +15 -0
- data/features/lazy_run.feature +76 -0
- data/features/lazy_run_per_scenario.feature +108 -0
- data/features/lazy_run_per_scenario_outline_example.feature +29 -0
- data/features/lazy_run_triggered_by_rails_view_change.feature +43 -0
- data/features/run.feature +25 -0
- data/features/show_recordings.feature +28 -0
- data/features/step_definitions/main_steps.rb +41 -0
- data/features/support/env.rb +52 -0
- data/lib/at_exit_hook.rb +3 -0
- data/lib/cucover.rb +65 -0
- data/lib/cucover/cli.rb +50 -0
- data/lib/cucover/cli_commands/coverage_of.rb +44 -0
- data/lib/cucover/cli_commands/cucumber.rb +46 -0
- data/lib/cucover/cli_commands/show_recordings.rb +29 -0
- data/lib/cucover/cli_commands/version.rb +13 -0
- data/lib/cucover/controller.rb +28 -0
- data/lib/cucover/cucumber_hooks.rb +45 -0
- data/lib/cucover/line_numbers.rb +10 -0
- data/lib/cucover/logging_config.rb +16 -0
- data/lib/cucover/monkey.rb +14 -0
- data/lib/cucover/rails.rb +23 -0
- data/lib/cucover/recorder.rb +37 -0
- data/lib/cucover/recording.rb +66 -0
- data/lib/cucover/recording/covered_file.rb +53 -0
- data/lib/cucover/store.rb +70 -0
- data/lib/dependencies.rb +10 -0
- data/spec/cucover/cli_spec.rb +31 -0
- data/spec/cucover/controller_spec.rb +16 -0
- data/spec/cucover/recording/covered_file_spec.rb +20 -0
- data/spec/cucover/store_spec.rb +28 -0
- data/spec/spec_helper.rb +7 -0
- data/tmp/.gitignore +0 -0
- metadata +236 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%
|
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
|
4
|
+
std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
|
|
5
|
+
%>
|
|
6
|
+
default: <%= std_opts %>
|
|
7
|
+
wip: --tags @wip:3 --wip features
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
|
3
|
+
development:
|
|
4
|
+
adapter: sqlite3
|
|
5
|
+
database: db/development.sqlite3
|
|
6
|
+
pool: 5
|
|
7
|
+
timeout: 5000
|
|
8
|
+
|
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
|
10
|
+
# re-generated from your development database when you run "rake".
|
|
11
|
+
# Do not set this db to the same as development or production.
|
|
12
|
+
test: &TEST
|
|
13
|
+
adapter: sqlite3
|
|
14
|
+
database: db/test.sqlite3
|
|
15
|
+
pool: 5
|
|
16
|
+
timeout: 5000
|
|
17
|
+
|
|
18
|
+
production:
|
|
19
|
+
adapter: sqlite3
|
|
20
|
+
database: db/production.sqlite3
|
|
21
|
+
pool: 5
|
|
22
|
+
timeout: 5000
|
|
23
|
+
|
|
24
|
+
cucumber:
|
|
25
|
+
<<: *TEST
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file
|
|
2
|
+
|
|
3
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
|
4
|
+
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
|
|
5
|
+
|
|
6
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
|
7
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
|
8
|
+
|
|
9
|
+
Rails::Initializer.run do |config|
|
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
11
|
+
# Application configuration should go into files in config/initializers
|
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
13
|
+
|
|
14
|
+
# Add additional load paths for your own custom dirs
|
|
15
|
+
# config.load_paths += %W( #{RAILS_ROOT}/extras )
|
|
16
|
+
|
|
17
|
+
# Specify gems that this application depends on and have them installed with rake gems:install
|
|
18
|
+
# config.gem "bj"
|
|
19
|
+
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
|
20
|
+
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
|
21
|
+
# config.gem "aws-s3", :lib => "aws/s3"
|
|
22
|
+
|
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
26
|
+
|
|
27
|
+
# Skip frameworks you're not going to use. To use Rails without a database,
|
|
28
|
+
# you must remove the Active Record framework.
|
|
29
|
+
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
|
30
|
+
|
|
31
|
+
# Activate observers that should always be running
|
|
32
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
33
|
+
|
|
34
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
35
|
+
# Run "rake -D time" for a list of tasks for finding time zone names.
|
|
36
|
+
config.time_zone = 'UTC'
|
|
37
|
+
|
|
38
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
39
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
|
40
|
+
# config.i18n.default_locale = :de
|
|
41
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Edit at your own peril - it's recommended to regenerate this file
|
|
2
|
+
# in the future when you upgrade to a newer version of Cucumber.
|
|
3
|
+
|
|
4
|
+
# IMPORTANT: Setting config.cache_classes to false is known to
|
|
5
|
+
# break Cucumber's use_transactional_fixtures method.
|
|
6
|
+
# For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165
|
|
7
|
+
config.cache_classes = true
|
|
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.action_controller.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Disable request forgery protection in test environment
|
|
17
|
+
config.action_controller.allow_forgery_protection = false
|
|
18
|
+
|
|
19
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
|
20
|
+
# The :test delivery method accumulates sent emails in the
|
|
21
|
+
# ActionMailer::Base.deliveries array.
|
|
22
|
+
config.action_mailer.delivery_method = :test
|
|
23
|
+
|
|
24
|
+
config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
|
|
25
|
+
config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
|
|
26
|
+
config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
|
|
27
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# In the development environment your application's code is reloaded on
|
|
4
|
+
# every request. This slows down response time but is perfect for development
|
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
|
6
|
+
config.cache_classes = false
|
|
7
|
+
|
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
|
9
|
+
config.whiny_nils = true
|
|
10
|
+
|
|
11
|
+
# Show full error reports and disable caching
|
|
12
|
+
config.action_controller.consider_all_requests_local = true
|
|
13
|
+
config.action_view.debug_rjs = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Don't care if the mailer can't send
|
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# The production environment is meant for finished, "live" apps.
|
|
4
|
+
# Code is not reloaded between requests
|
|
5
|
+
config.cache_classes = true
|
|
6
|
+
|
|
7
|
+
# Full error reports are disabled and caching is turned on
|
|
8
|
+
config.action_controller.consider_all_requests_local = false
|
|
9
|
+
config.action_controller.perform_caching = true
|
|
10
|
+
config.action_view.cache_template_loading = true
|
|
11
|
+
|
|
12
|
+
# See everything in the log (default is :info)
|
|
13
|
+
# config.log_level = :debug
|
|
14
|
+
|
|
15
|
+
# Use a different logger for distributed setups
|
|
16
|
+
# config.logger = SyslogLogger.new
|
|
17
|
+
|
|
18
|
+
# Use a different cache store in production
|
|
19
|
+
# config.cache_store = :mem_cache_store
|
|
20
|
+
|
|
21
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
|
22
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
|
23
|
+
|
|
24
|
+
# Disable delivery errors, bad email addresses will be ignored
|
|
25
|
+
# config.action_mailer.raise_delivery_errors = false
|
|
26
|
+
|
|
27
|
+
# Enable threaded mode
|
|
28
|
+
# config.threadsafe!
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# The test environment is used exclusively to run your application's
|
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
7
|
+
config.cache_classes = true
|
|
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.action_controller.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
config.action_view.cache_template_loading = true
|
|
16
|
+
|
|
17
|
+
# Disable request forgery protection in test environment
|
|
18
|
+
config.action_controller.allow_forgery_protection = false
|
|
19
|
+
|
|
20
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
|
21
|
+
# The :test delivery method accumulates sent emails in the
|
|
22
|
+
# ActionMailer::Base.deliveries array.
|
|
23
|
+
config.action_mailer.delivery_method = :test
|
|
24
|
+
|
|
25
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
|
26
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
|
27
|
+
# like if you have constraints or database-specific column types
|
|
28
|
+
# config.active_record.schema_format = :sql
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
|
5
|
+
|
|
6
|
+
# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
|
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Add new inflection rules using the following format
|
|
4
|
+
# (all these examples are active by default):
|
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
|
8
|
+
# inflect.irregular 'person', 'people'
|
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
|
10
|
+
# end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# These settings change the behavior of Rails 2 apps and will be defaults
|
|
4
|
+
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
|
5
|
+
|
|
6
|
+
if defined?(ActiveRecord)
|
|
7
|
+
# Include Active Record class name as root for JSON serialized output.
|
|
8
|
+
ActiveRecord::Base.include_root_in_json = true
|
|
9
|
+
|
|
10
|
+
# Store the full class name (including module namespace) in STI type column.
|
|
11
|
+
ActiveRecord::Base.store_full_sti_class = true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
ActionController::Routing.generate_best_match = false
|
|
15
|
+
|
|
16
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
|
17
|
+
ActiveSupport.use_standard_json_time_format = true
|
|
18
|
+
|
|
19
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
|
20
|
+
# if you're including raw json in an HTML page.
|
|
21
|
+
ActiveSupport.escape_html_entities_in_json = false
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Your secret key for verifying cookie session data integrity.
|
|
4
|
+
# If you change this key, all old sessions will become invalid!
|
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
|
7
|
+
ActionController::Base.session = {
|
|
8
|
+
:key => '_rails_session',
|
|
9
|
+
:secret => '7be52eabeb7c4dc03e39cd81cb0d228ea2335cdf75412658cfdc4924bffc23f6b7ab6f0d4b4a528db79497d982a670deb9f4dffbd3986ab107bebe5305817c31'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
# Use the database for sessions instead of the cookie-based default,
|
|
13
|
+
# which shouldn't be used to store highly confidential information
|
|
14
|
+
# (create the session table with "rake db:sessions:create")
|
|
15
|
+
# ActionController::Base.session_store = :active_record_store
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
|
3
|
+
|
|
4
|
+
# Sample of regular route:
|
|
5
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
|
6
|
+
# Keep in mind you can assign values other than :controller and :action
|
|
7
|
+
|
|
8
|
+
# Sample of named route:
|
|
9
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
|
10
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
|
11
|
+
|
|
12
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
|
13
|
+
# map.resources :products
|
|
14
|
+
|
|
15
|
+
# Sample resource route with options:
|
|
16
|
+
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
|
17
|
+
|
|
18
|
+
# Sample resource route with sub-resources:
|
|
19
|
+
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
|
20
|
+
|
|
21
|
+
# Sample resource route with more complex sub-resources
|
|
22
|
+
# map.resources :products do |products|
|
|
23
|
+
# products.resources :comments
|
|
24
|
+
# products.resources :sales, :collection => { :recent => :get }
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
# Sample resource route within a namespace:
|
|
28
|
+
# map.namespace :admin do |admin|
|
|
29
|
+
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
|
30
|
+
# admin.resources :products
|
|
31
|
+
# end
|
|
32
|
+
|
|
33
|
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
|
34
|
+
# map.root :controller => "welcome"
|
|
35
|
+
|
|
36
|
+
# See how all your routes lay out with "rake routes"
|
|
37
|
+
|
|
38
|
+
# Install the default routes as the lowest priority.
|
|
39
|
+
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
|
40
|
+
# consider removing or commenting them out if you're using named routes and resources.
|
|
41
|
+
map.connect ':controller/:action/:id'
|
|
42
|
+
map.connect ':controller/:action/:id.:format'
|
|
43
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
|
3
|
+
#
|
|
4
|
+
# Examples:
|
|
5
|
+
#
|
|
6
|
+
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
|
7
|
+
# Major.create(:name => 'Daley', :city => cities.first)
|
|
@@ -0,0 +1,273 @@
|
|
|
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 File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
|
10
|
+
|
|
11
|
+
# Commonly used webrat steps
|
|
12
|
+
# http://github.com/brynary/webrat
|
|
13
|
+
|
|
14
|
+
Given /^(?:|I )am on (.+)$/ do |page_name|
|
|
15
|
+
visit path_to(page_name)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
When /^(?:|I )go to (.+)$/ do |page_name|
|
|
19
|
+
visit path_to(page_name)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
When /^(?:|I )press "([^\"]*)"$/ do |button|
|
|
23
|
+
click_button(button)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
When /^(?:|I )follow "([^\"]*)"$/ do |link|
|
|
27
|
+
click_link(link)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
When /^(?:|I )follow "([^\"]*)" within "([^\"]*)"$/ do |link, parent|
|
|
31
|
+
click_link_within(parent, link)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
When /^(?:|I )fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
|
35
|
+
fill_in(field, :with => value)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
When /^(?:|I )fill in "([^\"]*)" for "([^\"]*)"$/ do |value, field|
|
|
39
|
+
fill_in(field, :with => value)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Use this to fill in an entire form with data from a table. Example:
|
|
43
|
+
#
|
|
44
|
+
# When I fill in the following:
|
|
45
|
+
# | Account Number | 5002 |
|
|
46
|
+
# | Expiry date | 2009-11-01 |
|
|
47
|
+
# | Note | Nice guy |
|
|
48
|
+
# | Wants Email? | |
|
|
49
|
+
#
|
|
50
|
+
# TODO: Add support for checkbox, select og option
|
|
51
|
+
# based on naming conventions.
|
|
52
|
+
#
|
|
53
|
+
When /^(?:|I )fill in the following:$/ do |fields|
|
|
54
|
+
fields.rows_hash.each do |name, value|
|
|
55
|
+
When %{I fill in "#{name}" with "#{value}"}
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
When /^(?:|I )select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
|
|
60
|
+
select(value, :from => field)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Use this step in conjunction with Rail's datetime_select helper. For example:
|
|
64
|
+
# When I select "December 25, 2008 10:00" as the date and time
|
|
65
|
+
When /^(?:|I )select "([^\"]*)" as the date and time$/ do |time|
|
|
66
|
+
select_datetime(time)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Use this step when using multiple datetime_select helpers on a page or
|
|
70
|
+
# you want to specify which datetime to select. Given the following view:
|
|
71
|
+
# <%= f.label :preferred %><br />
|
|
72
|
+
# <%= f.datetime_select :preferred %>
|
|
73
|
+
# <%= f.label :alternative %><br />
|
|
74
|
+
# <%= f.datetime_select :alternative %>
|
|
75
|
+
# The following steps would fill out the form:
|
|
76
|
+
# When I select "November 23, 2004 11:20" as the "Preferred" date and time
|
|
77
|
+
# And I select "November 25, 2004 10:30" as the "Alternative" date and time
|
|
78
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
|
|
79
|
+
select_datetime(datetime, :from => datetime_label)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
|
83
|
+
# When I select "2:20PM" as the time
|
|
84
|
+
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
|
85
|
+
# will convert the 2:20PM to 14:20 and then select it.
|
|
86
|
+
When /^(?:|I )select "([^\"]*)" as the time$/ do |time|
|
|
87
|
+
select_time(time)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Use this step when using multiple time_select helpers on a page or you want to
|
|
91
|
+
# specify the name of the time on the form. For example:
|
|
92
|
+
# When I select "7:30AM" as the "Gym" time
|
|
93
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
|
|
94
|
+
select_time(time, :from => time_label)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
|
98
|
+
# When I select "February 20, 1981" as the date
|
|
99
|
+
When /^(?:|I )select "([^\"]*)" as the date$/ do |date|
|
|
100
|
+
select_date(date)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Use this step when using multiple date_select helpers on one page or
|
|
104
|
+
# you want to specify the name of the date on the form. For example:
|
|
105
|
+
# When I select "April 26, 1982" as the "Date of Birth" date
|
|
106
|
+
When /^(?:|I )select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
|
|
107
|
+
select_date(date, :from => date_label)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
When /^(?:|I )check "([^\"]*)"$/ do |field|
|
|
111
|
+
check(field)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
When /^(?:|I )uncheck "([^\"]*)"$/ do |field|
|
|
115
|
+
uncheck(field)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
When /^(?:|I )choose "([^\"]*)"$/ do |field|
|
|
119
|
+
choose(field)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Adds support for validates_attachment_content_type. Without the mime-type getting
|
|
123
|
+
# passed to attach_file() you will get a "Photo file is not one of the allowed file types."
|
|
124
|
+
# error message
|
|
125
|
+
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
|
126
|
+
type = path.split(".")[1]
|
|
127
|
+
|
|
128
|
+
case type
|
|
129
|
+
when "jpg"
|
|
130
|
+
type = "image/jpg"
|
|
131
|
+
when "jpeg"
|
|
132
|
+
type = "image/jpeg"
|
|
133
|
+
when "png"
|
|
134
|
+
type = "image/png"
|
|
135
|
+
when "gif"
|
|
136
|
+
type = "image/gif"
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
attach_file(field, path, type)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
Then /^(?:|I )should see "([^\"]*)"$/ do |text|
|
|
143
|
+
if defined?(Spec::Rails::Matchers)
|
|
144
|
+
response.should contain(text)
|
|
145
|
+
else
|
|
146
|
+
assert_contain text
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
Then /^(?:|I )should see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
|
151
|
+
within(selector) do |content|
|
|
152
|
+
if defined?(Spec::Rails::Matchers)
|
|
153
|
+
content.should contain(text)
|
|
154
|
+
else
|
|
155
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
|
156
|
+
assert hc.matches?(content), hc.failure_message
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
|
162
|
+
regexp = Regexp.new(regexp)
|
|
163
|
+
if defined?(Spec::Rails::Matchers)
|
|
164
|
+
response.should contain(regexp)
|
|
165
|
+
else
|
|
166
|
+
assert_match(regexp, response_body)
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
Then /^(?:|I )should see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
|
171
|
+
within(selector) do |content|
|
|
172
|
+
regexp = Regexp.new(regexp)
|
|
173
|
+
if defined?(Spec::Rails::Matchers)
|
|
174
|
+
content.should contain(regexp)
|
|
175
|
+
else
|
|
176
|
+
assert_match(regexp, content)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
Then /^(?:|I )should not see "([^\"]*)"$/ do |text|
|
|
182
|
+
if defined?(Spec::Rails::Matchers)
|
|
183
|
+
response.should_not contain(text)
|
|
184
|
+
else
|
|
185
|
+
assert_not_contain(text)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
|
|
190
|
+
within(selector) do |content|
|
|
191
|
+
if defined?(Spec::Rails::Matchers)
|
|
192
|
+
content.should_not contain(text)
|
|
193
|
+
else
|
|
194
|
+
hc = Webrat::Matchers::HasContent.new(text)
|
|
195
|
+
assert !hc.matches?(content), hc.negative_failure_message
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
|
201
|
+
regexp = Regexp.new(regexp)
|
|
202
|
+
if defined?(Spec::Rails::Matchers)
|
|
203
|
+
response.should_not contain(regexp)
|
|
204
|
+
else
|
|
205
|
+
assert_not_contain(regexp)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
Then /^(?:|I )should not see \/([^\/]*)\/ within "([^\"]*)"$/ do |regexp, selector|
|
|
210
|
+
within(selector) do |content|
|
|
211
|
+
regexp = Regexp.new(regexp)
|
|
212
|
+
if defined?(Spec::Rails::Matchers)
|
|
213
|
+
content.should_not contain(regexp)
|
|
214
|
+
else
|
|
215
|
+
assert_no_match(regexp, content)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
|
221
|
+
if defined?(Spec::Rails::Matchers)
|
|
222
|
+
field_labeled(field).value.should =~ /#{value}/
|
|
223
|
+
else
|
|
224
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
|
229
|
+
if defined?(Spec::Rails::Matchers)
|
|
230
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
|
231
|
+
else
|
|
232
|
+
assert_no_match(/#{value}/, field_labeled(field).value)
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
|
237
|
+
if defined?(Spec::Rails::Matchers)
|
|
238
|
+
field_labeled(label).should be_checked
|
|
239
|
+
else
|
|
240
|
+
assert field_labeled(label).checked?
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
Then /^the "([^\"]*)" checkbox should not be checked$/ do |label|
|
|
245
|
+
if defined?(Spec::Rails::Matchers)
|
|
246
|
+
field_labeled(label).should_not be_checked
|
|
247
|
+
else
|
|
248
|
+
assert !field_labeled(label).checked?
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
|
253
|
+
if defined?(Spec::Rails::Matchers)
|
|
254
|
+
URI.parse(current_url).path.should == path_to(page_name)
|
|
255
|
+
else
|
|
256
|
+
assert_equal path_to(page_name), URI.parse(current_url).path
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|
261
|
+
actual_params = CGI.parse(URI.parse(current_url).query)
|
|
262
|
+
expected_params = Hash[expected_pairs.rows_hash.map{|k,v| [k,[v]]}]
|
|
263
|
+
|
|
264
|
+
if defined?(Spec::Rails::Matchers)
|
|
265
|
+
actual_params.should == expected_params
|
|
266
|
+
else
|
|
267
|
+
assert_equal expected_params, actual_params
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
Then /^show me the page$/ do
|
|
272
|
+
save_and_open_page
|
|
273
|
+
end
|