spec/support/tasks.rb in hexx-rspec-0.4.2 vs spec/support/tasks.rb in hexx-rspec-0.5.1

- old
+ new

@@ -1,32 +1,27 @@ # encoding: utf-8 -RSpec.configure do |config| +::RSpec.configure do |config| - # Array of commands that was sent to system - # - # @return [Array<String>] - def commands - @commands ||= [] - end - # Checks whether a task with given name has been invoked # # @param [String] name # # @return [Boolean] def task_invoked?(name) Rake::Task[name].instance_eval { @already_invoked } end - config.before :example, :tasks do + # Resets Rake application + config.around :example, :tasks do |example| + app, Rake.application = Rake.application, nil + example.run + Rake.application = app + end - # Resets Rake application and reinstalls all tasks to be available - Rake.application = nil - Hexx::RSpec.install_tasks - - # Captures commands that System utility sends to system - # and stores them in {#commands} array. - allow_any_instance_of(Hexx::RSpec::System) - .to receive(:system) { |command| commands << command } + # Reinstalls tasks and mocks system calls + config.before :example, :tasks do + Hexx::RSpec::Tasks.install + allow(Hexx::RSpec).to receive(:[]) end -end + +end # RSpec.configure