Skip to content

Commit

Permalink
Merge pull request #11 from enkessler/dev
Browse files Browse the repository at this point in the history
Test updates and fixes
  • Loading branch information
dbwest committed Apr 29, 2019
2 parents 6fceaf9 + 3d92fe4 commit cdeaec6
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 25 deletions.
18 changes: 15 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
os:
- linux
- osx

language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.2
- 2.3.3
- 2.3.8
- 2.4.5
- 2.5.3
- 2.6.0
- jruby-9.1.7.0

gemfile:
- gemfiles/cuke_modeler0.gemfile
- gemfiles/cuke_modeler1.gemfile

matrix:
exclude:
# Travis does not provide 1.9.3 on OSX
- rvm: 1.9.3
os: osx


script: bundle exec rake cuke_slicer:ci_build
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019 Grange Insurance
Copyright (c) 2015-2019 Grange Insurance

MIT License

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Basic stuff:
[![Gem Version](https://badge.fury.io/rb/cql.svg)](https://rubygems.org/gems/cuke_slicer)
[![Gem Version](https://badge.fury.io/rb/cuke_slicer.svg)](https://rubygems.org/gems/cuke_slicer)
[![Project License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/mit-license.php)
[![Downloads](https://img.shields.io/gem/dt/cql.svg)](https://rubygems.org/gems/cuke_slicer)
[![Downloads](https://img.shields.io/gem/dt/cuke_slicer.svg)](https://rubygems.org/gems/cuke_slicer)

User stuff:
[![Yard Docs](http://img.shields.io/badge/Documentation-API-blue.svg)](https://www.rubydoc.info/gems/cuke_slicer)
Expand Down
12 changes: 12 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ namespace 'cuke_slicer' do
end
end

desc 'Check documentation with RDoc'
task :check_for_outdated_dependencies do
output = `bundle outdated`
puts output

if output =~ /requested/
raise Rainbow('Some dependencies are out of date!').red
else
puts Rainbow('All direct dependencies up to date!').green
end
end

desc 'Run all of the tests'
task :test_everything => [:clear_coverage] do
rspec_args = '--tag ~@wip --pattern "spec/**/*_spec.rb" --force-color'
Expand Down
6 changes: 3 additions & 3 deletions cuke_slicer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency "cuke_modeler", "< 2.0"

spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake" , '~> 11.0'
spec.add_development_dependency 'bundler', '< 3.0'
spec.add_development_dependency 'rake', '< 13.0.0'
spec.add_development_dependency "rspec", '~> 3.0'
spec.add_development_dependency "cucumber", '~> 2.0'
spec.add_development_dependency 'cucumber', '< 5.0.0'
spec.add_development_dependency "simplecov", '~> 0.0'
spec.add_development_dependency "racatt", '~> 1.0'
spec.add_development_dependency 'coveralls', '< 1.0.0'
Expand Down
20 changes: 10 additions & 10 deletions features/test_case_extraction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ Feature: Test case extraction
| path/to/a_test.feature:11 |
| path/to/a_test.feature:14 |

# Scenario: Extraction from 'empty' files
# Given the following feature file "empty.feature":
# """
# Feature: Nothing here yet
# """
# And the following feature file "really_empty.feature":
# """
# """
# When test cases are extracted from them
# Then no test cases are found
Scenario: Extraction from 'empty' files
Given the following feature file "empty.feature":
"""
Feature: Nothing here yet
"""
And the following feature file "really_empty.feature":
"""
"""
When test cases are extracted from them
Then no test cases are found

Scenario: Extraction from a directory
Given the directory "test_directory"
Expand Down
5 changes: 4 additions & 1 deletion gemfiles/cuke_modeler0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ source 'https://rubygems.org'

gemspec :path => "../"

gem 'cuke_modeler', '~> 0.0'
# Bundle is not using the latest in the CukeModeler 0.x series for some reason, so being explicit here
gem 'cuke_modeler', '0.4.1'
# gem 'cuke_modeler', '~> 0.0' # This really should be sufficient...


if RUBY_VERSION =~ /^1\./
gem 'cucumber', '< 3.0.0' # Ruby 1.9.x support dropped after this version
gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
Expand Down
1 change: 1 addition & 0 deletions gemfiles/cuke_modeler1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'cuke_modeler', '~> 1.0'


if RUBY_VERSION =~ /^1\./
gem 'cucumber', '< 3.0.0' # Ruby 1.9.x support dropped after this version
gem 'json', '< 2.0' # The 'json' gem drops pre-Ruby 2.x support on/after this version
gem 'tins', '< 1.7' # The 'tins' gem requires Ruby 2.x on/after this version
gem 'term-ansicolor', '< 1.4' # The 'term-ansicolor' gem requires Ruby 2.x on/after this version
Expand Down
47 changes: 42 additions & 5 deletions spec/slicer_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
expect { slicer.slice(@default_file_directory, :file_line) }.to_not raise_error
end

# it 'can slice an empty feature file' do
# File.open(test_file, 'w') { |file| file.write('') }
#
# expect { slicer.slice(test_file, :file_line) }.to_not raise_error
# end
it 'can slice an empty feature file' do
File.open(test_file, 'w') { |file| file.write('') }

expect { slicer.slice(test_file, :file_line) }.to_not raise_error
end

it 'can slice a feature that has no tests' do
File.open(test_file, 'w') { |file| file.write('Feature: Empty feature') }
Expand Down Expand Up @@ -92,6 +92,43 @@
expect { slicer.slice(test_file, :file_line) }.to raise_error(ArgumentError, /syntax.*lexing problem.*#{test_file}/i)
end

it 'does not swallow unexpected exceptions while slicing' do
begin
$old_method = CukeModeler::Parsing.method(:parse_text)

# Custom error type in order to ensure that we are throwing the correct thing
module CukeSlicer
class TestError < StandardError
end
end

# Monkey patch the parsing method to throw the error that we need for testing
module CukeModeler
module Parsing
class << self
def parse_text(*args)
raise(CukeSlicer::TestError, 'something went wrong')
end
end
end
end


File.write(test_file, 'junk text')

expect { slicer.slice(test_file, :file_line) }.to raise_error(CukeSlicer::TestError, 'something went wrong')
ensure
# Making sure that our changes don't escape a test and ruin the rest of the suite
module CukeModeler
module Parsing
class << self
define_method(:parse_text, $old_method)
end
end
end
end
end

end

end
Expand Down

0 comments on commit cdeaec6

Please sign in to comment.