Skip to content

Commit effec2d

Browse files
committed
test for user_agent filter
1 parent cdeb09d commit effec2d

File tree

4 files changed

+132
-70
lines changed

4 files changed

+132
-70
lines changed

spec/app_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'spec_helper'
22

33
describe 'app', vcr: true do
4+
45
it '/' do
56
get '/'
67

@@ -43,6 +44,15 @@
4344
expect(doc.at_css("h3.work a").text.strip).to eq("LauBasin_TUIM05MV_Mottl")
4445
end
4546

47+
let!(:user_agent) { {'HTTP_USER_AGENT'=>'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' } }
48+
49+
it '/works/10.7272/q6g15xs4 as Googlebot' do
50+
get '/works/10.7272/q6g15xs4', nil, user_agent
51+
52+
doc = Nokogiri::HTML(last_response.body)
53+
expect(doc.at("#myTabContent")).to be_nil
54+
end
55+
4656
it '/people' do
4757
get '/people'
4858

spec/fixtures/vcr_cassettes/app/works/10_1594/ieda/100037.yml

+23-70
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/fixtures/vcr_cassettes/app/works/10_7272/q6g15xs4_as_Googlebot.yml

+95
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/spec_helper.rb

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
require 'capybara-screenshot/rspec'
1515
require 'tilt/haml'
1616
require 'rack/handler/webrick'
17+
require "crawler_detect"
18+
1719

1820
require File.join(File.dirname(__FILE__), '..', 'app.rb')
1921

@@ -46,6 +48,7 @@ def app
4648
config.order = :random
4749
end
4850

51+
4952
Capybara.register_driver :cuprite do |app|
5053
Capybara::Cuprite::Driver.new(app, {
5154
timeout: 60,
@@ -67,6 +70,7 @@ def app
6770
config.ignore_hidden_elements = true
6871
end
6972

73+
7074
WebMock.disable_net_connect!(
7175
allow: ['codeclimate.com:443', ENV['PRIVATE_IP'], ENV['HOSTNAME']],
7276
allow_localhost: true

0 commit comments

Comments
 (0)