diff options
-rw-r--r-- | features/support/env.rb | 33 | ||||
-rw-r--r-- | lib/tasks/dev/tests.rake | 10 | ||||
-rw-r--r-- | spec/monkeypatch.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 19 |
4 files changed, 24 insertions, 40 deletions
diff --git a/features/support/env.rb b/features/support/env.rb index 498072a3d28..b47349c8ea7 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,8 +1,5 @@ -# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. -# It is recommended to regenerate this file in the future when you upgrade to a -# newer version of cucumber-rails. Consider adding your own code to a new file -# instead of editing this one. Cucumber will automatically load all features/**/*.rb -# files. +require 'simplecov' +SimpleCov.start 'rails' require 'cucumber/rails' require 'webmock/cucumber' @@ -13,16 +10,12 @@ require Rails.root.join 'spec/factories' require Rails.root.join 'spec/support/login' require Rails.root.join 'spec/support/valid_commit' -# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In -# order to ease the transition to Capybara we set the default here. If you'd -# prefer to use XPath just remove this line and adjust any selectors in your -# steps to use the XPath syntax. Capybara.default_selector = :css Capybara.javascript_driver = :webkit # By default, any exception happening in your Rails application will bubble up -# to Cucumber so that your scenario will fail. This is a different from how -# your application behaves in the production environment, where an error page will +# to Cucumber so that your scenario will fail. This is a different from how +# your application behaves in the production environment, where an error page will # be rendered instead. # # Sometimes we want to override this default behaviour and allow Rails to rescue @@ -45,22 +38,4 @@ rescue NameError raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." end -# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. -# See the DatabaseCleaner documentation for details. Example: -# -# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do -# # { :except => [:widgets] } may not do what you expect here -# # as tCucumber::Rails::Database.javascript_strategy overrides -# # this setting. -# DatabaseCleaner.strategy = :truncation -# end -# -# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do -# DatabaseCleaner.strategy = :transaction -# end -# - -# Possible values are :truncation and :transaction -# The :transaction strategy is faster, but might give you threading problems. -# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature Cucumber::Rails::Database.javascript_strategy = :truncation diff --git a/lib/tasks/dev/tests.rake b/lib/tasks/dev/tests.rake new file mode 100644 index 00000000000..f91320ebdd2 --- /dev/null +++ b/lib/tasks/dev/tests.rake @@ -0,0 +1,10 @@ +namespace :dev do + desc "DEV | Run cucumber and rspec" + task :tests do + ["cucumber", "rspec spec"].each do |cmd| + puts "Starting to run #{cmd}..." + system("bundle exec #{cmd}") + raise "#{cmd} failed!" unless $?.exitstatus == 0 + end + end +end diff --git a/spec/monkeypatch.rb b/spec/monkeypatch.rb index 93dda0174c6..855a31f06de 100644 --- a/spec/monkeypatch.rb +++ b/spec/monkeypatch.rb @@ -35,7 +35,7 @@ class UsersProject end class FakeSatellite - def exists? + def exists? true end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 31ca2a2b64e..f87c9a50f86 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,21 +17,14 @@ require 'email_spec' # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} +# Use capybara-webkit +Capybara.javascript_driver = :webkit + RSpec.configure do |config| - # == Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr config.mock_with :rspec config.include LoginMacros - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" - # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. @@ -52,6 +45,12 @@ RSpec.configure do |config| DatabaseCleaner.start WebMock.disable_net_connect!(allow_localhost: true) + + # !!! Observers disabled by default in tests + # + # Use next code to enable observers + # before(:each) { ActiveRecord::Base.observers.enable(:all) } + # ActiveRecord::Base.observers.disable :all end |