Class: PrestaShopAutomation::PrestaShop
- Inherits:
-
Capybara::Session
- Object
- Capybara::Session
- PrestaShopAutomation::PrestaShop
- Includes:
- CarriersActions, CartRulesActions, GeneralActions, GeneralHelpers, InstallerActions, OrdersActions, ProductsActions, SettingsActions, TaxesActions, UsersActions, RSpec::Expectations, RSpec::Matchers
- Defined in:
- lib/prestashop-automation.rb
Instance Method Summary collapse
-
#all(*args) ⇒ Object
Rspec defines this method, but we want the one from Capybara::Session.
- #clear_cookies ⇒ Object
- #dump_database(target) ⇒ Object
-
#initialize(options) ⇒ PrestaShop
constructor
A new instance of PrestaShop.
- #load_database(src) ⇒ Object
- #quit ⇒ Object
- #restore(dump = nil) ⇒ Object
- #save ⇒ Object
Methods included from UsersActions
Methods included from InstallerActions
#add_module_from_repo, #database_exists, #drop_database, #install, #install_module, #prepare_database, #update_all_modules
Methods included from OrdersActions
#add_product_to_cart, #add_products_to_cart, #order_current_cart_5_steps, #order_current_cart_opc, #validate_order
Methods included from CartRulesActions
#create_cart_rule, #delete_cart_rule
Methods included from CarriersActions
Methods included from TaxesActions
#create_tax, #create_tax_group, #create_tax_group_from_rate
Methods included from ProductsActions
Methods included from SettingsActions
#set_ecotax_option, #set_friendly_urls, #set_gift_wrapping_option, #set_order_process_type, #set_rounding_method, #set_rounding_rule
Methods included from GeneralActions
#get_menu, #goto_admin_tab, #goto_back_office, #goto_front_office, #goto_module_configuration, #login_to_back_office, #login_to_front_office, #logout_of_back_office, #logout_of_front_office
Methods included from GeneralHelpers
#click, #click_button_named, #click_label_for, #expect_not_to, #expect_to, #get_cookies_string, #get_select_options, #onoff, #select_by_value, #select_by_value_jqChosen, #select_random_option, #standard_success_check, #version_gte, #visit, #wait_until
Constructor Details
#initialize(options) ⇒ PrestaShop
Returns a new instance of PrestaShop.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/prestashop-automation.rb', line 52 def initialize @front_office_url = [:front_office_url] @back_office_url = [:back_office_url] @installer_url = [:installer_url] @admin_email = [:admin_email] || '[email protected]' @admin_password = [:admin_password] || '123456789' @default_customer_email = [:default_customer_email] || '[email protected]' @default_customer_password = [:default_customer_password] || '123456789' @database_user = [:database_user] || 'root' @database_password = [:database_password] || '' @database_name = [:database_name] @database_prefix = [:database_prefix] || 'ps_' @database_port = [:database_port] || '3306' @database_host = [:database_host] || 'localhost' @filesystem_path = [:filesystem_path] @version = [:version] @dumps = [] super :selenium_with_long_timeout end |
Instance Method Details
#all(*args) ⇒ Object
Rspec defines this method, but we want the one from Capybara::Session
48 49 50 |
# File 'lib/prestashop-automation.rb', line 48 def all *args Capybara::Session.instance_method(:all).bind(self).call *args end |
#clear_cookies ⇒ Object
113 114 115 |
# File 'lib/prestashop-automation.rb', line 113 def reset! end |
#dump_database(target) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/prestashop-automation.rb', line 79 def dump_database target if database_exists cmd = "mysqldump -uroot " if @database_password.to_s.strip != '' cmd += "-p#{Shellwords.shellescape @database_password} " end cmd += "-h#{Shellwords.shellescape @database_host} " cmd += "-P#{@database_port} " cmd += "#{Shellwords.shellescape @database_name} " cmd += "> #{Shellwords.shellescape target}" `#{cmd}` if !$?.success? throw "Could not dump database!" end return true else return false end end |
#load_database(src) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/prestashop-automation.rb', line 99 def load_database src prepare_database cmd = "mysql -uroot " if @database_password.to_s.strip != '' cmd += "-p#{Shellwords.shellescape @database_password} " end cmd += "-h#{Shellwords.shellescape @database_host} " cmd += "-P#{@database_port} " cmd += "#{Shellwords.shellescape @database_name} " cmd += "< #{Shellwords.shellescape src}" `#{cmd}` return $?.success? end |
#quit ⇒ Object
75 76 77 |
# File 'lib/prestashop-automation.rb', line 75 def quit driver.browser.quit end |
#restore(dump = nil) ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'lib/prestashop-automation.rb', line 133 def restore dump=nil unless dump dump = @dumps.pop end if dump[:database] load_database dump[:database].path end end |
#save ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/prestashop-automation.rb', line 117 def save out = { :database => nil, :files => nil } if database_exists out[:database] = Tempfile.new 'prestashop-db' dump_database out[:database].path end @dumps << out return out end |