使用rspec的Aruba,测试失败,因为实际输出为空。没有错误。可能是什么原因?

时间:2018-10-15 15:56:46

标签: ruby testing rspec aruba

我的项目是用python编写的命令行工具。规范测试代码是用aruba和rspec编写的。

App由bin / project运行,当从project dir运行时,它可以正常运行,给定的每个输入都有一个文本输出。

但是,当我运行规格测试时,测试失败,因为aruba的所有输入都为“”。我尝试用command.stderr检查,也没有错误。

阿鲁巴输出空白的原因可能是什么?

我的目录结构是:

- project
    - functional_spec
        -rakefile
        -spec
             -tests.rb
    - bin
        - project.sh
        - run_functional_test.sh
    - app
        - app.py
        - __main__.py

我从项目目录运行bin/run_functional_test,但是运行的命令没有任何输出。

rakefile的内容是:

require "rspec/core/rake_task"

namespace :spec do
  desc "Run the functional suite against the CLI"
  RSpec::Core::RakeTask.new(:functional, [] => [:set_path])

  task :set_path do
    project_bin_dir = File.join(File.dirname(File.expand_path(__FILE__)), '..', 'bin')
    ENV['PATH'] = project_bin_dir + ':'+ ENV['PATH']
  end
end

run_functional_test的内容是:

#!/usr/bin/env ruby

project_bin_dir = File.join(File.dirname(File.expand_path(__FILE__)))
functional_spec_dir = File.join(project_bin_dir, '..', 'functional_spec')
cmd = "cd #{functional_spec_dir}; bundle install; bundle exec rake spec:functional"
puts cmd
system cmd

失败的测试用例之一是:

RSpec.describe 'Test Case', type: :aruba do
  let(:command) { run "start_cli" }
  before(:each) { command.write("sample_input_command") }

  it "sample_input_command runs well" do
    stop_all_commands
    expect(command.output).to end_with("sample output")
  end

0 个答案:

没有答案
相关问题