Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View .gitignore
1 2 3 4 5 6 7
source :rubygems
 
gem 'capybara'
gem 'rspec'
 
gem 'axlsx'
gem 'mini_magick'
View .gitignore
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
GEM
remote: http://rubygems.org/
specs:
addressable (2.2.8)
axlsx (1.1.7)
nokogiri (>= 1.4.1)
rake (>= 0.8.7)
rubyzip (>= 0.9.5)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.3.3)
ffi (~> 1.0.6)
diff-lcs (1.1.3)
ffi (1.0.11)
libwebsocket (0.1.3)
addressable
mime-types (1.19)
mini_magick (3.4)
subexec (~> 0.2.1)
multi_json (1.3.6)
nokogiri (1.5.5)
rack (1.4.1)
rack-test (0.6.1)
rack (>= 1.0)
rake (0.9.2.2)
rspec (2.10.0)
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
rubyzip (0.9.9)
selenium-webdriver (2.24.0)
childprocess (>= 0.2.5)
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
subexec (0.2.2)
xpath (0.1.4)
nokogiri (~> 1.3)
 
PLATFORMS
ruby
 
DEPENDENCIES
axlsx
capybara
mini_magick
rspec
View .gitignore
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# coding: utf-8
require_relative './spec_helper'
 
describe 'http://regional.rubykaigi.org/okayama01' do
before do
visit '/okayama01'
end
 
it 'タイトルに、"岡山Ruby会議01" と表示されていること' do
should have_css('h2', text: '岡山Ruby会議01')
end
 
it 'タイムテーブルが掲載されていること' do
should have_css('h3', text: 'タイムテーブル')
end
 
it 'すでに満員になっており、参加登録できないこと' do
find('.registration_external').click_link('https://ssl.kokucheese.com/event/entry/33608/')
should have_css('#lastmessage', text: '現在、お申し込みはできません。')
should have_css('.alert', text: 'お申し込みが定員に達しました。')
end
end
View .gitignore
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
# coding: utf-8
 
require 'capybara/dsl'
 
require 'axlsx'
require 'mini_magick'
 
Capybara.default_driver = :selenium
Capybara.app_host = 'http://regional.rubykaigi.org'
 
RSpec.configure do |config|
config.include Capybara::DSL
 
def excel
@@excel ||= Axlsx::Package.new
end
 
def worksheet_for_spec
@@worksheet_for_spec ||= excel.workbook.add_worksheet(name: 'Spec') do |sheet|
excel.workbook.styles do |style|
black_cell = style.add_style :bg_color => '000000', :fg_color => 'FFFFFF', :sz => 14, :alignment => { :horizontal=> :center }
sheet.add_row %w(検証項目 ○/×), style: black_cell
end
end
end
 
def output_dir
File.join(File.dirname(__FILE__), '..', 'output')
end
 
def serial_number
@@serial_number ||= 0
@@serial_number += 1
end
 
config.after :each do
metadata = self.example.metadata
description = [*metadata[:example_group][:description_args], *metadata[:description_args]].join('-')
 
spec_number = serial_number
 
excel.workbook.styles do |style|
border = style.add_style :border => { :style => :thick, :color =>"AAAAAA" }
worksheet_for_spec.add_row [description, self.example.exception ? '×' : ''], style: border
end
 
image_src = File.join(output_dir, '%s.png' % [spec_number])
page.driver.browser.save_screenshot(image_src)
 
image_data = MiniMagick::Image.open(image_src)
 
excel.workbook.add_worksheet(name: 'ScreenShot_%s' % [spec_number]) do |sheet|
sheet.add_image(image_src: image_src) do |image|
image.width = image_data[:width]
image.height = image_data[:height]
end
end
end
 
config.after :suite do
excel.use_shared_strings = true # for Numbers
excel.serialize(File.join(output_dir, 'okayama01_spec.xlsx'))
end
end
Owner

Setup

$ git clone git://gist.github.com/3062485.git gist-3062485
$ cd gist-3062485
$ bundle install

Run

$ bundle exec rspec

And open output/okayama01_spec.xlsx file.

Owner

This gist is a sample for my presentation "capybara で快適なテスト生活を".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.