Commit 463644c8827a6015d9a3669e64ff04683d9f1c3d

Authored by Dmitriy Zaporozhets
1 parent 28ddc152

rspec to capybara-webkit. simplercov now use cucumber

features/support/env.rb
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. 1 +require 'simplecov'
  2 +SimpleCov.start 'rails'
6 3
7 require 'cucumber/rails' 4 require 'cucumber/rails'
8 require 'webmock/cucumber' 5 require 'webmock/cucumber'
@@ -13,16 +10,12 @@ require Rails.root.join 'spec/factories' @@ -13,16 +10,12 @@ require Rails.root.join 'spec/factories'
13 require Rails.root.join 'spec/support/login' 10 require Rails.root.join 'spec/support/login'
14 require Rails.root.join 'spec/support/valid_commit' 11 require Rails.root.join 'spec/support/valid_commit'
15 12
16 -# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In  
17 -# order to ease the transition to Capybara we set the default here. If you'd  
18 -# prefer to use XPath just remove this line and adjust any selectors in your  
19 -# steps to use the XPath syntax.  
20 Capybara.default_selector = :css 13 Capybara.default_selector = :css
21 Capybara.javascript_driver = :webkit 14 Capybara.javascript_driver = :webkit
22 15
23 # By default, any exception happening in your Rails application will bubble up 16 # By default, any exception happening in your Rails application will bubble up
24 -# to Cucumber so that your scenario will fail. This is a different from how  
25 -# your application behaves in the production environment, where an error page will 17 +# to Cucumber so that your scenario will fail. This is a different from how
  18 +# your application behaves in the production environment, where an error page will
26 # be rendered instead. 19 # be rendered instead.
27 # 20 #
28 # Sometimes we want to override this default behaviour and allow Rails to rescue 21 # Sometimes we want to override this default behaviour and allow Rails to rescue
@@ -45,22 +38,4 @@ rescue NameError @@ -45,22 +38,4 @@ rescue NameError
45 raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." 38 raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
46 end 39 end
47 40
48 -# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.  
49 -# See the DatabaseCleaner documentation for details. Example:  
50 -#  
51 -# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do  
52 -# # { :except => [:widgets] } may not do what you expect here  
53 -# # as tCucumber::Rails::Database.javascript_strategy overrides  
54 -# # this setting.  
55 -# DatabaseCleaner.strategy = :truncation  
56 -# end  
57 -#  
58 -# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do  
59 -# DatabaseCleaner.strategy = :transaction  
60 -# end  
61 -#  
62 -  
63 -# Possible values are :truncation and :transaction  
64 -# The :transaction strategy is faster, but might give you threading problems.  
65 -# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature  
66 Cucumber::Rails::Database.javascript_strategy = :truncation 41 Cucumber::Rails::Database.javascript_strategy = :truncation
lib/tasks/dev/tests.rake 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +namespace :dev do
  2 + desc "DEV | Run cucumber and rspec"
  3 + task :tests do
  4 + ["cucumber", "rspec spec"].each do |cmd|
  5 + puts "Starting to run #{cmd}..."
  6 + system("bundle exec #{cmd}")
  7 + raise "#{cmd} failed!" unless $?.exitstatus == 0
  8 + end
  9 + end
  10 +end
spec/monkeypatch.rb
@@ -35,7 +35,7 @@ class UsersProject @@ -35,7 +35,7 @@ class UsersProject
35 end 35 end
36 36
37 class FakeSatellite 37 class FakeSatellite
38 - def exists? 38 + def exists?
39 true 39 true
40 end 40 end
41 41
spec/spec_helper.rb
@@ -17,21 +17,14 @@ require 'email_spec' @@ -17,21 +17,14 @@ require 'email_spec'
17 # in spec/support/ and its subdirectories. 17 # in spec/support/ and its subdirectories.
18 Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} 18 Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
19 19
  20 +# Use capybara-webkit
  21 +Capybara.javascript_driver = :webkit
  22 +
20 RSpec.configure do |config| 23 RSpec.configure do |config|
21 - # == Mock Framework  
22 - #  
23 - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:  
24 - #  
25 - # config.mock_with :mocha  
26 - # config.mock_with :flexmock  
27 - # config.mock_with :rr  
28 config.mock_with :rspec 24 config.mock_with :rspec
29 25
30 config.include LoginMacros 26 config.include LoginMacros
31 27
32 - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures  
33 - config.fixture_path = "#{::Rails.root}/spec/fixtures"  
34 -  
35 # If you're not using ActiveRecord, or you'd prefer not to run each of your 28 # If you're not using ActiveRecord, or you'd prefer not to run each of your
36 # examples within a transaction, remove the following line or assign false 29 # examples within a transaction, remove the following line or assign false
37 # instead of true. 30 # instead of true.
@@ -52,6 +45,12 @@ RSpec.configure do |config| @@ -52,6 +45,12 @@ RSpec.configure do |config|
52 DatabaseCleaner.start 45 DatabaseCleaner.start
53 46
54 WebMock.disable_net_connect!(allow_localhost: true) 47 WebMock.disable_net_connect!(allow_localhost: true)
  48 +
  49 + # !!! Observers disabled by default in tests
  50 + #
  51 + # Use next code to enable observers
  52 + # before(:each) { ActiveRecord::Base.observers.enable(:all) }
  53 + #
55 ActiveRecord::Base.observers.disable :all 54 ActiveRecord::Base.observers.disable :all
56 end 55 end
57 56