Skip to content
Permalink
Browse files

Removing `rack` usage from gemspec

Adding gemspec test to prevent missing files from being included
Testing `Net::HTTP::Post` with `Minitest::Mock`
  • Loading branch information...
robertodecurnex committed Mar 29, 2016
1 parent 2c7249e commit 348e864a4c0f5f0fa249d034655aaad9084c3ac4
Showing with 94 additions and 34 deletions.
  1. +1 −0 .gitignore
  2. +46 −33 spectro.gemspec
  3. +38 −1 test/minitest/spectro/test_http_client.rb
  4. +9 −0 test/minitest/test_gemspec.rb
@@ -4,3 +4,4 @@
Gemfile.lock
coverage/*
sample/Gemfile.lock
test/files/.spectro/undefined.yml
@@ -1,36 +1,49 @@
require 'rake'

Gem::Specification.new do |s|
s.authors = ['Roberto Decurnex']
s.date = '2015-01-13'
s.email = 'decurnex.roberto@gmail.com'
s.homepage = 'http://github.com/robertodecurnex/spectro'
s.license = 'MIT'
s.name = 'spectro'
s.summary = 'Specs driven social meta-programming'
s.version = '0.2'

s.bindir = 'bin'
s.executables << 'spectro'

s.files = FileList['lib/**/*.rb'].to_a

s.extra_rdoc_files = [
'LICENSE',
'README.md',
'spectro.png'
]

s.required_ruby_version = '>= 2.0.0'

s.add_runtime_dependency 'colorize'
s.add_runtime_dependency 'thor'

s.add_development_dependency 'codeclimate-test-reporter'
s.add_development_dependency 'guard'
s.add_development_dependency 'guard-rake'
s.add_development_dependency 'minitest'
s.add_development_dependency 'rake'
s.add_development_dependency 'yard'
s.authors = ['Roberto Decurnex']
s.date = '2015-01-13'
s.email = 'decurnex.roberto@gmail.com'
s.homepage = 'http://github.com/robertodecurnex/spectro'
s.license = 'MIT'
s.name = 'spectro'
s.summary = 'Specs driven social meta-programming'
s.version = '0.2'

s.bindir = 'bin'
s.executables << 'spectro'

s.files = [
'lib/spectro.rb',
'lib/spectro/client.rb',
'lib/spectro/compiler.rb',
'lib/spectro/config.rb',
'lib/spectro/database.rb',
'lib/spectro/exception.rb',
'lib/spectro/http_client.rb',
'lib/spectro/mock.rb',
'lib/spectro/spec.rb',
'lib/spectro/exception/undefined_method_definition.rb',
'lib/spectro/exception/unknown_mock_response.rb',
'lib/spectro/spec/parser.rb',
'lib/spectro/spec/rule.rb',
'lib/spectro/spec/signature.rb'
]

s.extra_rdoc_files = [
'LICENSE',
'README.md',
'spectro.png'
]

s.required_ruby_version = '>= 2.0.0'

s.add_runtime_dependency 'colorize'
s.add_runtime_dependency 'thor'

s.add_development_dependency 'codeclimate-test-reporter'
s.add_development_dependency 'guard'
s.add_development_dependency 'guard-rake'
s.add_development_dependency 'minitest'
s.add_development_dependency 'rake'
s.add_development_dependency 'yard'
end

@@ -7,9 +7,46 @@ def setup
end

def test_upload_undefined_specs
expected_body = <<-BODY
---
undefined_sample.rb:
- !ruby/object:Spectro::Spec
md5: 23d8f3f75459cc94364520d99717a284
rules:
- !ruby/object:Spectro::Spec::Rule
output: !ruby/class 'TrueClass'
params: []
signature: !ruby/object:Spectro::Spec::Signature
name: i_am_undefined
output_type: TrueClass
params_types: []
sample.rb:
- !ruby/object:Spectro::Spec
md5: 94dd639208a00598a7248336398ad769
rules:
- !ruby/object:Spectro::Spec::Rule
output: true
params:
- false
signature: !ruby/object:Spectro::Spec::Signature
name: unknown_lambda
output_type: TrueClass
params_types:
- FalseClass
BODY

Dir.chdir('test/files') do
mock = Minitest::Mock.new
mock.expect :request, true do |request|
assert_equal Net::HTTP::Post, request.class
assert_equal expected_body, request.body
end

Spectro::Compiler.compile
@http_client.upload_undefined_specs
Net::HTTP.stub :new, mock do
@http_client.upload_undefined_specs
mock.verify
end
end
end

@@ -0,0 +1,9 @@
class TestGemspec < Minitest::Test

def test_included_files
gem_specification = eval(File.read('spectro.gemspec'))
expected_files = (['LICENSE', 'README.md', 'bin/spectro'] + FileList['lib/**/*.rb'].to_a + ['spectro.png'])
assert_equal expected_files, gem_specification.files
end

end

0 comments on commit 348e864

Please sign in to comment.
You can’t perform that action at this time.