Class: Cucumber::ThinkingSphinx::InternalWorld

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/thinking_sphinx/internal_world.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInternalWorld

Returns a new instance of InternalWorld.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 11

def initialize
  pwd = Dir.pwd
  @temporary_directory  = "#{pwd}/tmp"
  @migrations_directory = "#{pwd}/features/thinking_sphinx/db/migrations"
  @models_directory     = "#{pwd}/features/thinking_sphinx/models"
  @fixtures_directory   = "#{pwd}/features/thinking_sphinx/db/fixtures"
  @database_file        = "#{pwd}/features/thinking_sphinx/database.yml"

  @adapter  = (ENV['DATABASE'] || 'mysql').gsub /^mysql$/, 'mysql2'
  @database = 'thinking_sphinx'
  @username = ENV['USER']
  @host     = 'localhost'

  if @adapter[/mysql/]
    @username = 'root'
  elsif ENV['TRAVIS']
    @username = 'postgres'
  end
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



8
9
10
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 8

def adapter
  @adapter
end

#databaseObject

Returns the value of attribute database.



8
9
10
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 8

def database
  @database
end

#database_fileObject

Returns the value of attribute database_file.



6
7
8
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 6

def database_file
  @database_file
end

#fixtures_directoryObject

Returns the value of attribute fixtures_directory.



6
7
8
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 6

def fixtures_directory
  @fixtures_directory
end

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 8

def host
  @host
end

#migrations_directoryObject

Returns the value of attribute migrations_directory.



6
7
8
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 6

def migrations_directory
  @migrations_directory
end

#models_directoryObject

Returns the value of attribute models_directory.



6
7
8
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 6

def models_directory
  @models_directory
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 8

def password
  @password
end

#temporary_directoryObject

Returns the value of attribute temporary_directory.



6
7
8
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 6

def temporary_directory
  @temporary_directory
end

#usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 8

def username
  @username
end

Instance Method Details

#configure_databaseObject



44
45
46
47
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 44

def configure_database
  ActiveRecord::Base.establish_connection database_settings
  self
end

#setupObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cucumber/thinking_sphinx/internal_world.rb', line 31

def setup
  make_temporary_directory

  configure_cleanup
  configure_thinking_sphinx
  configure_active_record

  prepare_data
  setup_sphinx

  self
end