From 991889eed62806738a71e19bd2640b46be5df3c2 Mon Sep 17 00:00:00 2001 From: Petr Blaho Date: Mon, 11 Feb 2013 12:16:25 +0100 Subject: [PATCH] Adds support for integration testing with aruba and rspec using custom example groups This prepares code for #35 and #36 --- spec/spec_helper.rb | 3 ++ .../integration_example_group.rb | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 spec/spec_helper.rb create mode 100644 spec/support/example_groups/integration_example_group.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..90b1eea --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,3 @@ +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[File.join("./spec/support/**/*.rb")].each {|f| require f} diff --git a/spec/support/example_groups/integration_example_group.rb b/spec/support/example_groups/integration_example_group.rb new file mode 100644 index 0000000..503e667 --- /dev/null +++ b/spec/support/example_groups/integration_example_group.rb @@ -0,0 +1,36 @@ +require 'active_support/concern' +require 'aruba/api' + +module IntegrationExampleGroup + extend ActiveSupport::Concern + + included do + metadata[:type] = :integration + + let(:executable) { "aeolus" } + let(:command) { "" } + let(:params) { "" } + let(:cmd) { [ executable, command, params ].select{|s| !s.empty?}.join(' ') } + + before(:each) do + run_simple(unescape(cmd), false) + end + + subject do + groups = example.example_group.ancestors.clone + groups << example.example_group + if groups.find{|g| g.metadata[:example_group][:description] == "stdout"} + all_stdout + elsif groups.find{|g| g.metadata[:example_group][:description] == "stderr"} + all_stderr + end + end + end + + RSpec.configure do |config| + config.include Aruba::Api + config.include self, + :type => :integration, + :example_group => { :file_path => %r(spec/integration) } + end +end