Skip to content

Commit

Permalink
Make it compatible with 1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Günnewig committed Jul 6, 2015
1 parent fe385e0 commit 3b52099
Show file tree
Hide file tree
Showing 40 changed files with 537 additions and 216 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Style/ClassCheck:
Style/ClassVars:
Enabled: false

Metrics/ClassLength:
Enabled: false

# Cop supports --auto-correct.
# Configuration parameters: PreferredMethods.
Style/CollectionMethods:
Expand Down
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

55 changes: 35 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,62 @@
source 'https://rubygems.org'

# Use dependencies from gemspec
gemspec

group :development, :test do
end

# Debug aruba
group :debug do
gem 'pry', '~> 0.10.1'

platform :mri_20 do
platform :mri_20, :mri_21, :mri_22 do
gem 'byebug', '~> 4.0.5'
gem 'pry-byebug', '~> 3.1.0'
end

gem 'pry-stack_explorer', '~> 0.4.9'
platform :mri_19, :mri_20, :mri_21, :mri_22 do
gem 'pry-stack_explorer', '~> 0.4.9'
end

gem 'pry-doc', '~> 0.8.0'
end

group :development, :test do
gem 'bcat', '~> 0.6.2'
gem 'kramdown', '~> 1.7.0'
# Run development tasks
gem 'rake', '~> 10.4.2'

platform :mri_19, :mri_20, :mri_21, :mri_22 do
# Reporting
gem 'bcat', '~> 0.6.2'
gem 'kramdown', '~> 1.7.0'
end

# Code Coverage
gem 'simplecov', '~> 0.10'
gem 'rake', '~> 10.4.2'

# Test api
gem 'rspec', '~> 3.3.0'
gem 'fuubar', '~> 2.0.0'
gem 'cucumber-pro', '~> 0.0'
gem 'rubocop', '~> 0.32.0'

gem 'license_finder', '~> 2.0.4'
# Make aruba compliant to ruby community guide
platform :mri_19, :mri_20, :mri_21, :mri_22 do
gem 'rubocop', '~> 0.32.0'
end

platform :mri_19, :mri_20, :mri_21, :mri_22 do
gem 'cucumber-pro', '~> 0.0'
end

platform :mri_19, :mri_20, :mri_21, :mri_22 do
# License compliance
gem 'license_finder', '~> 2.0.4'
end

gem 'relish', '~> 0.7.1'
platform :mri_19, :mri_20, :mri_21, :mri_22 do
# Upload documentation
gem 'relish', '~> 0.7.1'
end
end

platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'rubinius-developer_tools'
end

# Use source from sibling folders (if available) instead of gems
# %w[cucumber].each do |g|
# if File.directory?(File.dirname(__FILE__) + "/../#{g}")
# @dependencies.reject!{|dep| dep.name == g}
# gem g, :path => "../#{g}"
# end
# end
14 changes: 12 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@ RSpec::Core::RakeTask.new do |spec|
spec.rspec_opts = ['--color', '--format documentation']
end

require 'rubocop/rake_task'
RuboCop::RakeTask.new
if RUBY_VERSION < '1.9'
begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new
rescue LoadError
desc 'Stub task to make rake happy'
task(:rubocop) {}
end
else
require 'rubocop/rake_task'
RuboCop::RakeTask.new
end

desc "Run tests, both RSpec and Cucumber"
task :test => [ :rubocop, :spec, :cucumber, :cucumber_wip]
Expand Down
9 changes: 7 additions & 2 deletions aruba.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.email = '[email protected]'
s.homepage = 'http://github.com/cucumber/aruba'

s.add_runtime_dependency 'cucumber', '~> v1.3.19'
s.add_runtime_dependency 'cucumber', '~> 1.3.19'
s.add_runtime_dependency 'childprocess', '~> 0.5.6'
s.add_runtime_dependency 'rspec-expectations', '~> 3.3.0'
s.add_runtime_dependency 'contracts', '~> 0.9'
Expand All @@ -19,7 +19,12 @@ Gem::Specification.new do |s|

s.rubygems_version = ">= 1.6.1"
s.required_ruby_version = '>= 1.8.7'
s.post_install_message = 'From aruba >= 1.0 ruby 1.8.7-support is discontinued. aruba >= 1.0 will also require "cucumber 2" for the feature steps. The rest of aruba should be usable by whatever testing framework you are using.'
s.post_install_message = <<-EOS
With aruba >= 1.0
* "ruby 1.8.7"-support is discontinued
* aruba requires "cucumber 2" for the feature steps. The rest of aruba should be usable by whatever testing framework you are using
* "aruba/reporting" will be removed. Please use `@debug`-tag + `byebug`, `debugger`, `pry` to troubleshoot your feature tests
EOS

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
Expand Down
10 changes: 5 additions & 5 deletions features/api/cd.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Change current working directory
"""
require 'spec_helper'
RSpec.describe 'cd to directory', type: :aruba do
RSpec.describe 'cd to directory', :type => :aruba do
before(:each) do
create_directory 'new_dir.d'
cd 'new_dir.d'
Expand All @@ -37,7 +37,7 @@ Feature: Change current working directory
"""
require 'spec_helper'
RSpec.describe 'cd to directory', type: :aruba do
RSpec.describe 'cd to directory', :type => :aruba do
before(:each) { cd 'new_dir.d' }
before(:each) { run_simple 'pwd' }
Expand All @@ -52,7 +52,7 @@ Feature: Change current working directory
"""
require 'spec_helper'
RSpec.describe 'cd to directory', type: :aruba do
RSpec.describe 'cd to directory', :type => :aruba do
before(:each) do
create_directory 'new_dir.d/subdir.d'
end
Expand All @@ -76,7 +76,7 @@ Feature: Change current working directory
"""
require 'spec_helper'
RSpec.describe 'cd to directory', type: :aruba do
RSpec.describe 'cd to directory', :type => :aruba do
before(:each) do
create_directory 'new_dir.d/subdir.d'
end
Expand All @@ -103,7 +103,7 @@ Feature: Change current working directory
"""
require 'spec_helper'
RSpec.describe 'cd to directory', type: :aruba do
RSpec.describe 'cd to directory', :type => :aruba do
before(:each) do
create_directory 'new_dir.d/subdir.d'
end
Expand Down
3 changes: 2 additions & 1 deletion features/commands/exit_statuses.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Feature: Check exit status of commands
When I run `cli`
Then the exit status should be 0
"""
When I run `env`
When I run `cucumber`
Then the features should all pass

Expand Down Expand Up @@ -132,5 +133,5 @@ Feature: Check exit status of commands
When I run `cucumber`
Then the features should not all pass with:
"""
process still alive after 1 seconds
expected that command "cli" has finished in time
"""
2 changes: 2 additions & 0 deletions features/configuration/exit_timeout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Feature: Configure timeout for command execution
Scenario: Modify value
Given a file named "bin/cli" with:
"""
#!/usr/bin/env sh
sleep 1
"""
And a file named "features/support/aruba.rb" with:
Expand All @@ -37,6 +38,7 @@ Feature: Configure timeout for command execution
Scenario: Fails if takes longer
Given a file named "bin/cli" with:
"""
#!/usr/bin/env sh
sleep 5
"""
And a file named "features/support/aruba.rb" with:
Expand Down
6 changes: 5 additions & 1 deletion features/fixtures/cli-app/lib/cli/app.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'cli/app/version'

Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
if RUBY_VERSION < '1.9'
::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
else
::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
end

module Cli
module App
Expand Down
1 change: 1 addition & 0 deletions features/fixtures/cli-app/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

require 'cli/app'
require 'aruba/rspec'
2 changes: 1 addition & 1 deletion features/fixtures/copy/file.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
asdf
a
1 change: 1 addition & 0 deletions features/hooks/after/command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Feature: After command hooks
You can configure Aruba to run blocks of code after it has run
a command. The command will be passed to the block.

@announce
Scenario: Run a simple command with a after hook
Given a file named "test.rb" with:
"""
Expand Down
48 changes: 48 additions & 0 deletions features/matchers/timeouts.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Feature: Check if a timeout occured during command execution

If you want to check if a command takes to long to finish it's work

Background:
Given I use a fixture named "cli-app"

Scenario: Check if command runs to long
Given a file named "bin/cli" with:
"""
#!/usr/bin/env sh
sleep 1
"""
And a file named "spec/timeout_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Long running command', :type => :aruba do
before(:each) { aruba.config.exit_timeout = 0 }
before(:each) { run('cli') }
it { expect(last_command).to run_too_long }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Check if command finishes in time
Given a file named "bin/cli" with:
"""
#!/usr/bin/env sh
exit 0
"""
And a file named "spec/timeout_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Short running command', :type => :aruba do
before(:each) { aruba.config.exit_timeout = 5 }
before(:each) { run('cli') }
it { expect(last_command).to have_finished_in_time }
end
"""
When I run `rspec`
Then the specs should all pass
10 changes: 7 additions & 3 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
require 'rspec/expectations'

Before do |scenario|
command_name = case scenario
when Cucumber::RunningTestCase::Scenario
command_name = if scenario.respond_to?(:feature) && scenario.respond_to?(:name)
"#{scenario.feature.title} #{scenario.name}"
else
raise TypeError.new("Don't know how to extract command name from #{scenario.class}")
Expand All @@ -24,6 +23,11 @@
set_env('SIMPLECOV_COMMAND_NAME', command_name)

simplecov_setup_pathname = Pathname.new(__FILE__).expand_path.parent.join('simplecov_setup')

# set environment variable so child processes will merge their coverage data with parent process's coverage data.
set_env('RUBYOPT', "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}")
if RUBY_VERSION < '1.9'
set_env('RUBYOPT', "-r rubygems -r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}")
else
set_env('RUBYOPT', "-r#{simplecov_setup_pathname} #{ENV['RUBYOPT']}")
end
end
Loading

0 comments on commit 3b52099

Please sign in to comment.