Last active
August 29, 2015 14:07
-
-
Save wvengen/40245e1f56be24158620 to your computer and use it in GitHub Desktop.
Foodsoft screenshot generation (prototype)
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
# Generate screenshots for documentation (initial prototype) | |
# store file in spec/integration/ | |
# run with rspec: `rspec spec/integration/screenshots.rb` | |
# please note that this uses the db_seeds branch from pr foodcoops#315 | |
require_relative '../spec_helper' | |
require 'fileutils' | |
SCREENSHOT_DIR = Rails.root.join('doc/user/screenshots') | |
describe 'screenshots', :type => :feature do | |
describe :type => :feature, :js => true do | |
before do | |
page.driver.browser.manage.window.resize_to(800, 600) | |
DatabaseCleaner.clean | |
require Rails.root.join('db/seeds/small.en.seeds.rb') | |
# @todo i18n these | |
FoodsoftConfig[:name] = 'Foodcoop Demo' | |
end | |
it 'general' do | |
login user.nick, 'secret' | |
visit root_path | |
save 'dashboard' | |
visit group_order_path(user.ordergroup.group_orders.last.id) | |
save 'group order' | |
end | |
end | |
# Save screenshot | |
def save(name) | |
name = name.downcase.gsub /\s+/, '_' | |
FileUtils.mkdir_p SCREENSHOT_DIR | |
save_screenshot File.join(SCREENSHOT_DIR, "#{name}.png") | |
end | |
# @return [User] An ordinary user (one not in any workgroups) | |
def user | |
@user ||= User.where("id NOT IN (#{Workgroup.joins(:users).select(:user_id).to_sql})").first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment