From 5281ccda543f7dd0c616f4fd11d4df47551d9b2e Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Fri, 10 Jul 2015 01:59:40 -0300 Subject: [PATCH] rails4: fix remaining cucumber tests --- Gemfile | 2 +- config/environments/cucumber.rb | 5 ++--- features/delete_profile.feature | 4 ++++ features/edit_article.feature | 1 + features/members_block.feature | 1 + features/register_enterprise.feature | 6 ++++-- features/step_definitions/noosfero_steps.rb | 15 ++++----------- features/support/database_cleaner.rb | 16 ++++++++++++++++ features/support/paths.rb | 2 +- features/support/selenium.rb | 16 ---------------- test/support/noosfero_doc_test.rb | 1 + 11 files changed, 35 insertions(+), 34 deletions(-) create mode 100644 features/support/database_cleaner.rb diff --git a/Gemfile b/Gemfile index 7c097b1..4b8655e 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem 'exception_notification', '~> 4.0.1' gem 'gettext', '~> 2.2.1', :require => false gem 'locale', '~> 2.0.5' gem 'whenever', :require => false -gem 'eita-jrails', '>= 0.10.0', require: 'jrails' +gem 'eita-jrails', '~> 0.10.0', require: 'jrails' # asset pipeline gem 'uglifier', '>= 1.0.3' diff --git a/config/environments/cucumber.rb b/config/environments/cucumber.rb index 8db9555..8b3974f 100644 --- a/config/environments/cucumber.rb +++ b/config/environments/cucumber.rb @@ -7,6 +7,8 @@ Noosfero::Application.configure do # For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165 config.cache_classes = true + config.assets.debug = false + config.eager_load = false config.active_support.deprecation = :log @@ -22,7 +24,4 @@ Noosfero::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.2' unless File.directory?(Rails.root.join('vendor/plugins/cucumber-rails')) - config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(Rails.root.join('vendor/plugins/database_cleaner')) - config.gem 'capybara', :lib => false, :version => '>=0.3.5' unless File.directory?(Rails.root.join('vendor/plugins/capybara')) end diff --git a/features/delete_profile.feature b/features/delete_profile.feature index c263473..806233f 100644 --- a/features/delete_profile.feature +++ b/features/delete_profile.feature @@ -13,6 +13,7 @@ Feature: delete profile | sample-community | Sample Community | And "Maria Silva" is a member of "Sample Community" + @selenium Scenario: deleting profile Given I am logged in as "joaosilva" And I am on joaosilva's control panel @@ -45,6 +46,7 @@ Feature: delete profile When I follow "Community Info and settings" Then I should see "Delete profile" + @selenium Scenario: community admin deletes the community Given "Joao Silva" is admin of "Sample Community" And I am logged in as "joaosilva" @@ -73,6 +75,7 @@ Feature: delete profile When I follow "Enterprise Info and settings" Then I should see "Delete profile" + @selenium Scenario: enterprise admin deletes the enterprise Given the following enterprise | identifier | name | @@ -98,6 +101,7 @@ Feature: delete profile And I go to /myprofile/sample-enterprise/profile_editor/destroy_profile Then I should see "Access denied" + @selenium Scenario: environment admin deletes profile Given I am logged in as admin And I am on joaosilva's control panel diff --git a/features/edit_article.feature b/features/edit_article.feature index 4da2e8b..c5f4f52 100644 --- a/features/edit_article.feature +++ b/features/edit_article.feature @@ -20,6 +20,7 @@ Feature: edit article And I fill in "Title" with "My Folder" And I press "Save" And I go to joaosilva's control panel + And I follow "Manage Content" Then I should see "My Folder" @selenium diff --git a/features/members_block.feature b/features/members_block.feature index b595d5c..d624cb8 100644 --- a/features/members_block.feature +++ b/features/members_block.feature @@ -29,6 +29,7 @@ Feature: And I follow "Manage my groups" Then I should see "Sample Community" + @selenium Scenario: a user can leave a community by members block's button Given "Maria Silva" is a member of "Sample Community" And I am logged in as "mariasilva" diff --git a/features/register_enterprise.feature b/features/register_enterprise.feature index 556c747..f374afd 100644 --- a/features/register_enterprise.feature +++ b/features/register_enterprise.feature @@ -77,6 +77,7 @@ Feature: register enterprise Then I should see "Contact person can't be blank" Then I should see "Contact email can't be blank" + @selenium Scenario: a user register an enterprise successfully through the admin validator method and the admin accepts Given organization_approval_method is "admin" on environment @@ -133,8 +134,9 @@ Feature: register enterprise When I follow "Manage my groups" Then I should not see "My Enterprise" - Scenario: a user register an enterprise successfully through the region - validator method and the validator accepts + @selenium + Scenario: a user register an enterprise successfully through the region + validator method and the validator accepts Given organization_approval_method is "region" on environment And I follow "Manage my groups" And the following enterprise diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index bda4d53..fe920b3 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -435,20 +435,13 @@ Given /^the mailbox is empty$/ do end Given /^the (.+) mail (?:is|has) (.+) (.+)$/ do |position, field, value| - if(/^[0-9]+$/ =~ position) - ActionMailer::Base.deliveries[position.to_i][field].to_s == value - else - ActionMailer::Base.deliveries.send(position)[field].to_s == value - end + mail = if /^[0-9]+$/ =~ position then ActionMailer::Base.deliveries[position.to_i] else ActionMailer::Base.deliveries.send position end + mail and mail[field].to_s == value end Given /^the (.+) mail (.+) is like (.+)$/ do |position, field, regexp| - re = Regexp.new(regexp) - if(/^[0-9]+$/ =~ position) - re =~ ActionMailer::Base.deliveries[position.to_i][field.to_sym] - else - re =~ ActionMailer::Base.deliveries.send(position)[field.to_sym] - end + mail = if /^[0-9]+$/ =~ position then ActionMailer::Base.deliveries[position.to_i] else ActionMailer::Base.deliveries.send position end + mail and Regexp.new(regexp) =~ mail[field.to_sym] end Given /^the following environment configuration$/ do |table| diff --git a/features/support/database_cleaner.rb b/features/support/database_cleaner.rb new file mode 100644 index 0000000..8068e91 --- /dev/null +++ b/features/support/database_cleaner.rb @@ -0,0 +1,16 @@ +require 'database_cleaner' +require 'database_cleaner/cucumber' + +Cucumber::Rails::World.use_transactional_fixtures = false +# FIXME: 'DELETE FROM ...' is being ran 3x - see cucumber.log +DatabaseCleaner.clean_with :truncation +DatabaseCleaner.strategy = :truncation, {:pre_count => true, :reset_ids => false} + +Before do + DatabaseCleaner.start +end + +After do + DatabaseCleaner.clean +end + diff --git a/features/support/paths.rb b/features/support/paths.rb index ea524b5..7ce77ac 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -40,7 +40,7 @@ module NavigationHelpers "/myprofile/#{$2}/profile_design/edit/#{block.id}" when /^(.*)'s homepage$/ - '/' + profile_identifier($1) + '/' + '/' + profile_identifier($1) when /^(.*)'s blog$/ '/%s/blog' % profile_identifier($1) diff --git a/features/support/selenium.rb b/features/support/selenium.rb index 66682db..5a7316d 100644 --- a/features/support/selenium.rb +++ b/features/support/selenium.rb @@ -1,21 +1,9 @@ -require 'database_cleaner' -require 'database_cleaner/cucumber' - -Cucumber::Rails::World.use_transactional_fixtures = false Capybara.default_driver = :selenium Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new(app, :browser => :firefox) end -# FIXME: 'DELETE FROM ...' is being ran 3x - see cucumber.log -DatabaseCleaner.clean_with :truncation -DatabaseCleaner.strategy = :truncation, {:pre_count => true, :reset_ids => false} - -Before do - DatabaseCleaner.start -end - Before('@ignore-hidden-elements') do Capybara.ignore_hidden_elements = true end @@ -23,8 +11,4 @@ end Capybara.default_wait_time = 30 Capybara.server_host = "localhost" -After do - DatabaseCleaner.clean -end - World(Capybara) diff --git a/test/support/noosfero_doc_test.rb b/test/support/noosfero_doc_test.rb index b7235c0..5e19fd0 100644 --- a/test/support/noosfero_doc_test.rb +++ b/test/support/noosfero_doc_test.rb @@ -1,5 +1,6 @@ # encoding: UTF-8 require 'mocha' +require 'mocha/mini_test' module Noosfero::DocTest -- libgit2 0.21.2