Class: AcceptanceTest
- Inherits:
-
Object
- Object
- AcceptanceTest
- Includes:
- Singleton
- Defined in:
- lib/acceptance_test/version.rb,
lib/acceptance_test/acceptance_test.rb
Constant Summary collapse
- VERSION =
"1.11.7"
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#driver_manager ⇒ Object
readonly
Returns the value of attribute driver_manager.
-
#screenshot_maker ⇒ Object
readonly
Returns the value of attribute screenshot_maker.
Instance Method Summary collapse
- #configure(hash = {}) ⇒ Object
- #configure_turnip(report_file, title) ⇒ Object
- #create_shared_context(name) ⇒ Object
- #enable_external_source(data_reader) ⇒ Object
- #extend_turnip ⇒ Object
- #ignore_case_in_steps ⇒ Object
-
#initialize ⇒ AcceptanceTest
constructor
A new instance of AcceptanceTest.
- #setup(page = nil, metadata = {}) ⇒ Object
- #teardown(page = nil, metadata = {}, exception = nil) ⇒ Object
Constructor Details
#initialize ⇒ AcceptanceTest
Returns a new instance of AcceptanceTest.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/acceptance_test/acceptance_test.rb', line 15 def initialize Capybara.default_driver = :selenium @config = HashWithIndifferentAccess.new @config[:browser] = ENV['BROWSER'] || 'firefox' @config[:screenshots_dir] = File.('tmp') @config[:timeout_in_seconds] = ENV['TIMEOUT_IN_SECONDS'] || 20 @screenshot_maker = ScreenshotMaker.new config[:screenshots_dir] @driver_manager = DriverManager.new end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/acceptance_test/acceptance_test.rb', line 13 def config @config end |
#driver_manager ⇒ Object (readonly)
Returns the value of attribute driver_manager.
13 14 15 |
# File 'lib/acceptance_test/acceptance_test.rb', line 13 def driver_manager @driver_manager end |
#screenshot_maker ⇒ Object (readonly)
Returns the value of attribute screenshot_maker.
13 14 15 |
# File 'lib/acceptance_test/acceptance_test.rb', line 13 def screenshot_maker @screenshot_maker end |
Instance Method Details
#configure(hash = {}) ⇒ Object
29 30 31 |
# File 'lib/acceptance_test/acceptance_test.rb', line 29 def configure hash={} config.merge!(HashWithIndifferentAccess.new(hash)) end |
#configure_turnip(report_file, title) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/acceptance_test/acceptance_test.rb', line 92 def configure_turnip report_file, title # configure turnip formatter require 'turnip_formatter' RSpec.configure do |config| config.add_formatter RSpecTurnipFormatter, report_file end TurnipFormatter.configure do |config| config.title = title end # configure gnawrnip Gnawrnip.configure do |c| c.make_animation = true c.max_frame_size = 1024 # pixel end Gnawrnip.ready! end |
#create_shared_context(name) ⇒ Object
76 77 78 |
# File 'lib/acceptance_test/acceptance_test.rb', line 76 def create_shared_context name SharedContextBuilder.instance.build name, self end |
#enable_external_source(data_reader) ⇒ Object
88 89 90 |
# File 'lib/acceptance_test/acceptance_test.rb', line 88 def enable_external_source data_reader GherkinExt.enable_external_source data_reader end |
#extend_turnip ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/acceptance_test/acceptance_test.rb', line 80 def extend_turnip shared_context_name = "#{random_name}AcceptanceTest" SharedContextBuilder.instance.build shared_context_name, self TurnipExt.shared_context_with_turnip shared_context_name end |
#ignore_case_in_steps ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/acceptance_test/acceptance_test.rb', line 115 def ignore_case_in_steps require 'turnip/builder' Turnip::Builder::Step.class_eval do def initialize *params description = params[0] new_description = "" words = description.split(/\s/) first_word = words.first if ["I", "(I)"].include?(first_word) new_description += first_word else new_description += first_word.downcase end words.delete first_word words.each do |word| new_description += " " if word =~ /a..z|A..z|0..9/ new_description += word.downcase else new_description += word end end params[0] = new_description super end end end |
#setup(page = nil, metadata = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/acceptance_test/acceptance_test.rb', line 33 def setup page=nil, ={} driver = driver() browser = browser() driver_name = driver_manager.register_driver(driver, browser, config[:selenium_url], config[:capabilities]) driver_manager.use_driver(driver_name, page) driver_manager.setup_browser_binary config[:browser].to_sym, config[:browser_binaries] Capybara.app_host = config[:webapp_url] Capybara.configure do |conf| conf.default_wait_time = config[:timeout_in_seconds].to_i conf.match = :first conf.ignore_hidden_elements = false end end |
#teardown(page = nil, metadata = {}, exception = nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/acceptance_test/acceptance_test.rb', line 54 def teardown page=nil, ={}, exception=nil driver = driver() if driver and exception and page and not [:webkit].include? driver screenshot_maker.basedir = File.(config[:screenshots_dir]) screenshot_maker.make page, puts [:full_description] puts "Screenshot: #{screenshot_maker.screenshot_url()}" end Capybara.app_host = nil Capybara.configure do |conf| conf.default_wait_time = 2 end # Capybara.current_driver = Capybara.default_driver # Capybara.javascript_driver = Capybara.default_driver end |