Aruba not working with RSpec 3?

旧时模样 提交于 2019-12-12 15:32:52

问题


I'm trying to test a ruby command line script but am having troubles running tests with Cucumber-less Aruba in RSpec 3.

Some weird errors, some obvious ones.

e.g. weird:

 1) test does something
   Failure/Error: run_simple("cli_test.rb -h", true)
     ArgumentError:
   wrong number of arguments (2 for 1)
 # .../.gem/ruby/2.2.0/gems/aruba-0.6.2/lib/aruba/api.rb:632:in `assert_exit_status'
 # .../.gem/ruby/2.2.0/gems/aruba-0.6.2/lib/aruba/api.rb:750:in `run_simple'
 # ./spec/cli_test_spec.rb:17:in `block (2 levels) in <top (required)>'

Looking in the code, I can't even see what's triggering this. Trying to use Pry or Pry-byebug to check out the erroneous 2 args isn't working on it either (a whole bunch of other errors).

Then, e.g. obvious:

 1) test does something
   Failure/Error: check_file_presence(["bin/cli_test.rb"], true)
     only the `receive` or `receive_messages` matchers are supported with 
     `expect(...).to`, but you have provided: 
     #<RSpec::Matchers::BuiltIn::BePredicate:0x007fb36c88d6b0>
 # ... error lines ...

& here, the errors are obviously correct, Aruba is using Rspec 2 syntax.

So I added

config.expect_with :rspec do |c|
  c.syntax = [:should, :expect]
end

to my rspec config, but still not working.

Any ideas? Tips? Examples of this working anywhere?

Thanks in advance.


回答1:


There are some conflicts using the examples for RSpec 2, specially if you are requiring aruba\api and messing up with the include/extend lines many of them have.

This is the smallest example to get Aruba working. You might want to fine tune your configuration with the PATH env and things like that

require 'aruba/rspec'

describe "Ruba example", :type => :aruba do 
  it 'shows root content' do
    run 'ls /'
    expect(all_stdout).to include('tmp')
    expect(all_stdout).to include('var')
    expect(all_stdout).to include('usr')   
  end 
end


来源:https://stackoverflow.com/questions/28298665/aruba-not-working-with-rspec-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!