Commit c5ec52ba905945019b2bc9179d06e858e5c9c532

Authored by Daniela Feitosa
1 parent ac8c3207

Fixing cucumber tests

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