Skip to content

Commit

Permalink
update testing gems, including ffaker, rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
matthutchinson committed Jul 13, 2016
1 parent f846726 commit add09ad
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 75 deletions.
4 changes: 4 additions & 0 deletions .rubocop_todo.yml
Expand Up @@ -55,3 +55,7 @@ Style/CaseIndentation:
# Offense count: 28
Style/Documentation:
Enabled: false

# Bug with this cop https://github.com/bbatsov/rubocop/issues/3283
Lint/ShadowedException:
Enabled: false
8 changes: 4 additions & 4 deletions features/step_definitions/lolcommits_steps.rb
Expand Up @@ -165,7 +165,7 @@ def default_loldir
end

When(/^I do a git commit with commit message "(.*?)"$/) do |commit_msg|
filename = Faker::Lorem.words(1).first
filename = FFaker::Lorem.words(1).first
steps %(
Given a 98 byte file named "#{filename}"
And I successfully run `git add #{filename}`
Expand All @@ -174,7 +174,7 @@ def default_loldir
end

When(/^I do a git commit$/) do
step %(I do a git commit with commit message "#{Faker::Lorem.sentence}")
step %(I do a git commit with commit message "#{FFaker::Lorem.sentence}")
end

When(/^I do (\d+) git commits$/) do |n|
Expand All @@ -190,7 +190,7 @@ def default_loldir
end

When(/^I do a mercurial commit with commit message "(.*?)"$/) do |commit_msg|
filename = Faker::Lorem.words(1).first
filename = FFaker::Lorem.words(1).first
steps %(
Given a 98 byte file named "#{filename}"
And I successfully run `hg add #{filename}`
Expand All @@ -199,7 +199,7 @@ def default_loldir
end

When(/^I do a mercurial commit$/) do
step %(I do a mercurial commit with commit message "#{Faker::Lorem.sentence}")
step %(I do a mercurial commit with commit message "#{FFaker::Lorem.sentence}")
end

When(/^I do (\d+) mercurial commits$/) do |n|
Expand Down
2 changes: 1 addition & 1 deletion features/support/path_helpers.rb
Expand Up @@ -24,7 +24,7 @@ def reject_paths_with_cmd(cmd)
# add the temporary directory with git in it back into the path
newpaths << tmpbindir

# use aruba/api set_env to set PATH, which will be automaticaly restored
# use aruba/api set_environment_variable to set PATH, which will be automaticaly restored
set_env 'PATH', newpaths.join(File::PATH_SEPARATOR)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/lolcommits/backends/installation_git.rb
Expand Up @@ -42,7 +42,7 @@ def self.do_enable
f.write(hook_script)
end

FileUtils.chmod 0755, HOOK_PATH
FileUtils.chmod 0o755, HOOK_PATH
HOOK_PATH
end

Expand Down
2 changes: 1 addition & 1 deletion lib/lolcommits/configuration.rb
Expand Up @@ -124,7 +124,7 @@ def self.loldir_for(basename)
if File.directory? loldir
begin
# ensure 755 permissions for loldir
File.chmod(0755, loldir)
File.chmod(0o755, loldir)
rescue Errno::EPERM
# abort if permissions cannot be met
puts "FATAL: directory '#{loldir}' should be present and writeable by user '#{ENV['USER']}'"
Expand Down
3 changes: 2 additions & 1 deletion lib/lolcommits/plugins/dot_com.rb
Expand Up @@ -27,7 +27,8 @@ def run_postcapture
:key => configuration['api_key'],
:t => t,
:token => Digest::SHA1.hexdigest(configuration['api_secret'] + t)
})
}
)
rescue => e
log_error(e, "ERROR: HTTMultiParty POST FAILED #{e.class} - #{e.message}")
end
Expand Down
23 changes: 12 additions & 11 deletions lib/lolcommits/plugins/lol_protonet.rb
Expand Up @@ -37,17 +37,18 @@ def random_object
end

def random_adjective
adjectives = ['awesome', 'great', 'interesting', 'cool', 'EPIC', 'gut', 'good', 'pansy',
'powerful', 'boring', 'quirky', 'untested', 'german', 'iranian', 'neutral', 'crazy', 'well tested',
'jimmy style', 'nasty', 'bibliographical (we received complaints about the original wording)',
'bombdiggidy', 'narly', 'spiffy', 'smashing', 'xing style',
'leo apotheker style', 'black', 'white', 'yellow', 'shaggy', 'tasty', 'mind bending', 'JAY-Z',
'Kanye (the best ever)', '* Toby Keith was here *', 'splendid', 'stupendulous',
'(freedom fries!)', '[vote RON PAUL]', '- these are not my glasses -', 'typical pansy',
'- ze goggles zey do nothing! -', 'almost working', 'legen- wait for it -', '-dairy!',
' - Tavonius would be proud of this - ', 'Meg FAILMAN!', '- very brofessional of you -',
'heartbleeding', 'juciy', 'supercalifragilisticexpialidocious', 'failing', 'loving'
]
adjectives = [
'awesome', 'great', 'interesting', 'cool', 'EPIC', 'gut', 'good', 'pansy',
'powerful', 'boring', 'quirky', 'untested', 'german', 'iranian', 'neutral', 'crazy', 'well tested',
'jimmy style', 'nasty', 'bibliographical (we received complaints about the original wording)',
'bombdiggidy', 'narly', 'spiffy', 'smashing', 'xing style',
'leo apotheker style', 'black', 'white', 'yellow', 'shaggy', 'tasty', 'mind bending', 'JAY-Z',
'Kanye (the best ever)', '* Toby Keith was here *', 'splendid', 'stupendulous',
'(freedom fries!)', '[vote RON PAUL]', '- these are not my glasses -', 'typical pansy',
'- ze goggles zey do nothing! -', 'almost working', 'legen- wait for it -', '-dairy!',
' - Tavonius would be proud of this - ', 'Meg FAILMAN!', '- very brofessional of you -',
'heartbleeding', 'juciy', 'supercalifragilisticexpialidocious', 'failing', 'loving'
]
adjectives.sample
end

Expand Down
3 changes: 2 additions & 1 deletion lib/lolcommits/plugins/lol_slack.rb
Expand Up @@ -53,7 +53,8 @@ def run_postcapture
:filetype => 'jpg',
:filename => runner.sha,
:title => runner.message + "[#{runner.vcs_info.repo}]",
:channels => configuration['channels'])
:channels => configuration['channels']
)

debug response
rescue => e
Expand Down
24 changes: 13 additions & 11 deletions lib/lolcommits/plugins/lol_tumblr.rb
Expand Up @@ -81,20 +81,22 @@ def configured?
end

def client
@client ||= Tumblr.new(:consumer_key => TUMBLR_CONSUMER_KEY,
:consumer_secret => TUMBLR_CONSUMER_SECRET,
:oauth_token => configuration['access_token'],
:oauth_token_secret => configuration['secret']
)
@client ||= Tumblr.new(
:consumer_key => TUMBLR_CONSUMER_KEY,
:consumer_secret => TUMBLR_CONSUMER_SECRET,
:oauth_token => configuration['access_token'],
:oauth_token_secret => configuration['secret']
)
end

def oauth_consumer
@oauth_consumer ||= OAuth::Consumer.new(TUMBLR_CONSUMER_KEY,
TUMBLR_CONSUMER_SECRET,
:site => TUMBLR_API_ENDPOINT,
:request_endpoint => TUMBLR_API_ENDPOINT,
:http_methdo => :get
)
@oauth_consumer ||= OAuth::Consumer.new(
TUMBLR_CONSUMER_KEY,
TUMBLR_CONSUMER_SECRET,
:site => TUMBLR_API_ENDPOINT,
:request_endpoint => TUMBLR_API_ENDPOINT,
:http_method => :get
)
end

def config_with_default(key, default = nil)
Expand Down
3 changes: 1 addition & 2 deletions lib/lolcommits/plugins/lolsrv.rb
Expand Up @@ -29,8 +29,7 @@ def sync
end

def existing_lols
lols = JSON.parse(
RestClient.get(configuration['server'] + '/lols'))
lols = JSON.parse(RestClient.get(configuration['server'] + '/lols'))
lols.map { |lol| lol['sha'] }
rescue => e
log_error(e, "ERROR: existing lols could not be retrieved #{e.class} - #{e.message}")
Expand Down
25 changes: 13 additions & 12 deletions lib/lolcommits/plugins/uploldz.rb
Expand Up @@ -25,18 +25,19 @@ def run_postcapture
puts 'Repo is empty, skipping upload'
else
debug "Posting capture to #{configuration['endpoint']}"
RestClient.post(configuration['endpoint'],
{
:file => File.new(runner.main_image),
:message => runner.message,
:repo => runner.vcs_info.repo,
:author_name => runner.vcs_info.author_name,
:author_email => runner.vcs_info.author_email,
:sha => runner.sha,
:key => configuration['optional_key']
},
:Authorization => authorization_header
)
RestClient.post(
configuration['endpoint'],
{
:file => File.new(runner.main_image),
:message => runner.message,
:repo => runner.vcs_info.repo,
:author_name => runner.vcs_info.author_name,
:author_email => runner.vcs_info.author_email,
:sha => runner.sha,
:key => configuration['optional_key']
},
:Authorization => authorization_header
)
end
rescue => e
log_error(e, "ERROR: RestClient POST FAILED #{e.class} - #{e.message}")
Expand Down
26 changes: 13 additions & 13 deletions lolcommits.gemspec
Expand Up @@ -29,15 +29,17 @@ Gem::Specification.new do |s|
s.requirements << 'a webcam'

# hold back upgrading (and why)
s.add_runtime_dependency('rest-client', '=1.8') # yam gem requires uses this older version
s.add_runtime_dependency('mime-types', '=2.99') # ~> 3.0+ requires Ruby >= 2.0
s.add_development_dependency('tins', '=1.6.0') # ~> 1.7.0+ requires Ruby >= 2.0
s.add_runtime_dependency('rest-client', '=1.8') # yam gem requires uses this older version
s.add_runtime_dependency('mime-types', '=2.99') # ~> 3.0+ requires Ruby >= 2.0
s.add_runtime_dependency('json', '~> 1.8.3') # ~> 2.0+ requires Ruby >= 2.0 (lolsrv)
s.add_development_dependency('tins', '=1.6.0') # ~> 1.7.0+ requires Ruby >= 2.0
s.add_development_dependency('rake', '~> 10.5.0') # ~> 11+ introduces lots of warnings from other deps

# core
s.add_runtime_dependency('choice', '~> 0.2.0')
s.add_runtime_dependency('methadone', '~> 1.8.0')
s.add_runtime_dependency('mercurial-ruby', '~> 0')

s.add_runtime_dependency('choice', '~> 0.2.0')
s.add_runtime_dependency('mercurial-ruby', '~> 0.7.12')
s.add_runtime_dependency('mini_magick', '~> 4.5.1')
s.add_runtime_dependency('launchy', '~> 2.4.3')
s.add_runtime_dependency('open4', '~> 1.3.4')
Expand All @@ -46,23 +48,21 @@ Gem::Specification.new do |s|
# plugin gems
s.add_runtime_dependency('twitter', '~> 5.13.0') # twitter
s.add_runtime_dependency('oauth', '~> 0.4.7') # twitter oauth
s.add_runtime_dependency('json', '~> 1.8.1') # lolsrv

s.add_runtime_dependency('yam', '~> 2.5.0') # yammer
s.add_runtime_dependency('httmultiparty', '~> 0.3.16') # dot_com
s.add_runtime_dependency('tumblr_client', '~> 0.8.5') # tumblr

# development gems
s.add_development_dependency('rdoc', '~> 4.2.0')
s.add_development_dependency('rake', '~> 10.4.2')
s.add_development_dependency('rdoc', '~> 4.2.2')

# testing gems
s.add_development_dependency('aruba', '~> 0.6.2')
s.add_development_dependency('ffaker', '~> 1.25.0')
s.add_development_dependency('coveralls', '~> 0.7.2')
s.add_development_dependency('minitest', '~> 5.5.1')
s.add_development_dependency('travis', '~> 1.7.4')
s.add_development_dependency('rubocop', '~> 0.37.2')

s.add_development_dependency('rubocop', '~> 0.41.0')
s.add_development_dependency('travis', '~> 1.8.2')
s.add_development_dependency('minitest', '~> 5.9.0')
s.add_development_dependency('coveralls', '~> 0.8.13')
s.add_development_dependency('ffaker', '~> 2.2.0')
s.add_development_dependency('cucumber', '~> 2.4.0')
end
22 changes: 10 additions & 12 deletions test/lolcommits_test.rb
@@ -1,8 +1,6 @@
# -*- encoding : utf-8 -*-
if RUBY_VERSION >= '2.0.0'
require 'coveralls'
Coveralls.wear!
end
require 'coveralls'
Coveralls.wear!

require 'minitest/autorun'

Expand All @@ -20,18 +18,18 @@ class LolTest < MiniTest::Test
# this will test the permissions but only locally, important before building a gem package!
#
def test_permissions
impact_perms = File.lstat(Lolcommits::Loltext::DEFAULT_FONT_PATH).mode & 0777
imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')).mode & 0777
videosnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')).mode & 0777
commandcam_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')).mode & 0777
impact_perms = File.lstat(Lolcommits::Loltext::DEFAULT_FONT_PATH).mode & 0o777
imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')).mode & 0o777
videosnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')).mode & 0o777
commandcam_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')).mode & 0o777

assert impact_perms == 0644 || impact_perms == 0664,
assert impact_perms == 0o644 || impact_perms == 0o664,
"expected perms of 644/664 but instead got #{format '%o', impact_perms}"
assert imagesnap_perms == 0755 || imagesnap_perms == 0775,
assert imagesnap_perms == 0o755 || imagesnap_perms == 0o775,
"expected perms of 755/775 but instead got #{format '%o', imagesnap_perms}"
assert videosnap_perms == 0755 || videosnap_perms == 0775,
assert videosnap_perms == 0o755 || videosnap_perms == 0o775,
"expected perms of 755/775 but instead got #{format '%o', videosnap_perms}"
assert commandcam_perms == 0755 || commandcam_perms == 0775,
assert commandcam_perms == 0o755 || commandcam_perms == 0o775,
"expected perms of 755/775 but instead got #{format '%o', commandcam_perms}"
end
end
8 changes: 3 additions & 5 deletions test/plugins_test.rb
@@ -1,8 +1,6 @@
# -*- encoding : utf-8 -*-
if RUBY_VERSION >= '2.0.0'
require 'coveralls'
Coveralls.wear!
end
require 'coveralls'
Coveralls.wear!

require 'minitest/autorun'
require 'ffaker'
Expand All @@ -29,7 +27,7 @@ def test_tranzlate
#
# issue #136, https://github.com/mroth/lolcommits/issues/136
def test_lol_twitter_build_tweet
long_commit_message = Faker::Lorem.sentence(500)
long_commit_message = FFaker::Lorem.sentence(500)
plugin = Lolcommits::LolTwitter.new(nil)
max_tweet_size = 116
suffix = '... #lolcommits'
Expand Down

0 comments on commit add09ad

Please sign in to comment.