Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dist] Simplify smoketest spec helper
- Loading branch information
1 parent
8754d86
commit 42fc604
Showing
2 changed files
with
34 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,52 @@ | ||
require 'capybara/dsl' | ||
# OBS Appliance spec helper. | ||
# | ||
# for capybara rspec support | ||
require 'support/capybara' | ||
|
||
SCREENSHOT_DIR = "/tmp/rspec_screens" | ||
|
||
RSpec.configure do |config| | ||
#rspec-expectations config goes here. | ||
config.expect_with :rspec do |expectations| | ||
# to disable deprecated should syntax | ||
expectations.syntax = :expect | ||
end | ||
config.before(:suite) do | ||
FileUtils.rm_rf(SCREENSHOT_DIR) | ||
FileUtils.mkdir_p(SCREENSHOT_DIR) | ||
end | ||
config.after(:each) do |example| | ||
if example.exception | ||
take_screenshot(example) | ||
dump_page(example) | ||
end | ||
end | ||
# Limits the available syntax to the non-monkey patched | ||
config.disable_monkey_patching! | ||
config.include Capybara::DSL | ||
config.fail_fast = 1 | ||
end | ||
|
||
# for capybara rspec support | ||
require 'support/capybara' | ||
|
||
SCREENSHOT_DIR = "/tmp/rspec_screens" | ||
def dump_page(example) | ||
filename = File.basename(example.metadata[:file_path]) | ||
line_number = example.metadata[:line_number] | ||
dump_name = "dump-#{filename}-#{line_number}.html" | ||
dump_path = File.join(SCREENSHOT_DIR, dump_name) | ||
page.save_page(dump_path) | ||
end | ||
|
||
def take_screenshot(example) | ||
meta = example.metadata | ||
filename = File.basename(meta[:file_path]) | ||
line_number = meta[:line_number] | ||
filename = File.basename(example.metadata[:file_path]) | ||
line_number = example.metadata[:line_number] | ||
screenshot_name = "screenshot-#{filename}-#{line_number}.png" | ||
screenshot_path = File.join(SCREENSHOT_DIR, screenshot_name) | ||
page.save_screenshot(screenshot_path) | ||
puts meta[:full_description] + "\n Screenshot: #{screenshot_path}" | ||
end | ||
|
||
def obs_login (user,password) | ||
|
||
def login | ||
visit "/user/login" | ||
fill_in 'user_login', with: user | ||
fill_in 'user_password', with: password | ||
click_button('Log In »') | ||
first(:link,'Logout') | ||
fill_in 'user_login', with: 'Admin' | ||
fill_in 'user_password', with: 'opensuse' | ||
click_button('log-in-button') | ||
|
||
expect(page).to have_link('link-to-user-home') | ||
end | ||
|
||
def logout | ||
within("div#subheader") do | ||
click_link('Logout') | ||
end | ||
expect(page).to have_no_link('link-to-user-home') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters