-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_spec.rb
More file actions
35 lines (30 loc) · 1.07 KB
/
example_spec.rb
File metadata and controls
35 lines (30 loc) · 1.07 KB
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
require 'bundler/setup'
require 'rack/file'
require 'capybara/rspec'
require 'percy/capybara'
require './custom_loader'
RSpec.configure do |config|
config.include Capybara::DSL
Capybara.default_driver = :selenium
Percy::Capybara.use_loader(CustomLoader)
config.before(:suite) { Percy::Capybara.initialize_build }
config.after(:suite) { Percy::Capybara.finalize_build }
end
Capybara.app = Rack::File.new File.dirname __FILE__
describe "Example page", :type => :request do
it "contains an H1 with text 'Hello World!'" do
visit '/example.html'
expect(page).to have_css 'h1', :text => 'Hello World!'
Percy::Capybara.snapshot(page, name: 'Hello World')
end
end
describe "Click on button, change body", :type => :request do
it "Body is changed'" do
visit '/example.html'
click_button('button')
Percy::Capybara.snapshot(page, name: 'Button is clicked once')
click_button('button2')
Percy::Capybara.snapshot(page, name: 'Button is clicked for the second time')
expect(find('p')).to have_content('Yet a click, this is also sendt to percy')
end
end