Commit c5ec52ba905945019b2bc9179d06e858e5c9c532

Authored by Daniela Feitosa
1 parent ac8c3207

Fixing cucumber tests

features/browse.feature
@@ -4,6 +4,7 @@ Feature: browse @@ -4,6 +4,7 @@ Feature: browse
4 4
5 Background: 5 Background:
6 Given I am on the homepage 6 Given I am on the homepage
  7 + And the search index is empty
7 And the following users 8 And the following users
8 | login | name | 9 | login | name |
9 | joaosilva | Joao Silva | 10 | joaosilva | Joao Silva |
features/profile_search.feature
@@ -4,7 +4,8 @@ Feature: search inside a profile @@ -4,7 +4,8 @@ Feature: search inside a profile
4 In order to find stuff from a profile 4 In order to find stuff from a profile
5 5
6 Background: 6 Background:
7 - Given the following users 7 + Given the search index is empty
  8 + And the following users
8 | login | name | 9 | login | name |
9 | joaosilva | Joao Silva | 10 | joaosilva | Joao Silva |
10 And the following articles 11 And the following articles
features/search.feature
@@ -3,6 +3,9 @@ Feature: search @@ -3,6 +3,9 @@ Feature: search
3 I want to search 3 I want to search
4 In order to find stuff 4 In order to find stuff
5 5
  6 + Background:
  7 + Given the search index is empty
  8 +
6 Scenario: simple search for person 9 Scenario: simple search for person
7 Given the following users 10 Given the following users
8 | login | name | 11 | login | name |
features/step_definitions/noosfero_steps.rb
@@ -411,3 +411,9 @@ Given /^the environment domain is "([^\"]*)"$/ do |domain| @@ -411,3 +411,9 @@ Given /^the environment domain is "([^\"]*)"$/ do |domain|
411 d = Domain.new :name => domain, :owner => Environment.default 411 d = Domain.new :name => domain, :owner => Environment.default
412 d.save(false) 412 d.save(false)
413 end 413 end
  414 +
  415 +Given /^the search index is empty$/ do
  416 + ActsAsSolr::Post.execute(Solr::Request::Delete.new(:query => '*:*'))
  417 +end
  418 +
  419 +
lib/tasks/cucumber.rake
@@ -11,6 +11,11 @@ begin @@ -11,6 +11,11 @@ begin
11 vendored_cucumber_binary = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first 11 vendored_cucumber_binary = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
12 12
13 namespace :cucumber do 13 namespace :cucumber do
  14 + Cucumber::Rake::Task.new({:solr_start => 'solr:start'}, 'Run solr before') do |t|
  15 + Rake::Task['solr:start'].invoke
  16 +# ENV['RAILS_ENV'] = 'cucumber'
  17 + end
  18 +
14 Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t| 19 Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
15 t.binary = vendored_cucumber_binary 20 t.binary = vendored_cucumber_binary
16 t.fork = true # You may get faster startup if you set this to false 21 t.fork = true # You may get faster startup if you set this to false
@@ -29,8 +34,12 @@ begin @@ -29,8 +34,12 @@ begin
29 t.cucumber_opts = "--color -p selenium --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" 34 t.cucumber_opts = "--color -p selenium --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
30 end 35 end
31 36
  37 + Cucumber::Rake::Task.new({:solr_stop => 'solr:stop'}, 'Run solr after') do |t|
  38 + end
  39 +
32 desc 'Run all features' 40 desc 'Run all features'
33 - task :all => [:ok, :wip] 41 + task :all => [:solr_start, :ok, :wip, :solr_stop] do
  42 + end
34 end 43 end
35 desc 'Alias for cucumber:ok' 44 desc 'Alias for cucumber:ok'
36 task :cucumber => 'cucumber:ok' 45 task :cucumber => 'cucumber:ok'