Fix bots issues?

...Happy now? Please?
This commit is contained in:
g0tmi1k
2018-05-15 10:47:55 +01:00
parent 59368a72bd
commit cf2881fda6
3 changed files with 9 additions and 24 deletions

View File

@@ -46,21 +46,18 @@ class WpTarget < WebSite
def json_get_users(url)
# Variables
users = []
data = ""
# Make the request
response = Browser.get(url)
# If not HTTP 200, return false
return false if response.code != 200
return false unless response.code == 200
# Able to view the output?
if valid_json?(response.body)
# Read in JSON
data = JSON.parse(response.body)
else
return false
end
return false unless valid_json?(response.body)
# Read in JSON
data = JSON.parse(response.body)
# If there is nothing there, return false
return false if data.empty?
@@ -83,9 +80,9 @@ class WpTarget < WebSite
table = Terminal::Table.new(headings: ['ID', 'Name', 'URL'],
rows: users)
puts table
else
return false
return true
end
return false
end
end
end

View File

@@ -62,9 +62,9 @@ class WpTarget < WebSite
table = Terminal::Table.new(headings: ['Name'],
rows: users)
puts table
else
return false
return true
end
return false
end
end
end

View File

@@ -207,18 +207,6 @@ describe 'WebSite' do
end
end
describe '#rss_url' do
it 'returns nil if the url is not found' do
stub_request(:get, web_site.url).to_return(body: 'No RSS link in this body !')
expect(web_site.rss_url).to be_nil
end
it "returns 'http://lamp-wp/wordpress-3.5/?feed=rss2'" do
stub_request_to_fixture(url: web_site.url, fixture: fixtures_dir + '/rss_url/wordpress-3.5.htm')
expect(web_site.rss_url).to be === 'http://lamp-wp/wordpress-3.5/?feed=rss2'
end
end
describe '::has_log?' do
let(:log_url) { web_site.uri.merge('log.txt').to_s }
let(:pattern) { %r{PHP Fatal error} }