我试图在Ubuntu上为我的环境运行测试,但每次测试都失败并出现错误:
undefined method 'expect' for #<RSpec::ExampleGroups::Anonymous:0x000000011ef270>
我正在运行的ruby测试脚本:
RSpec.configure do |config|
config.color = true
config.formatter = 'doc'
end
RSpec.describe do
it 'Ruby version 2.2.3 or greater is installed!' do
expect(RUBY_VERSION).to be >= "2.2"
end
it 'Chrome is installed!' do
chrome_search = `which google-chrome`
expect(chrome_search).to_not be_empty, "Chrome isn't installed."
end
it 'Heroku Toolbelt is installed!' do
heroku = `which heroku`
expect(heroku).to_not be_empty, 'Heroku Toolbelt is not installed.'
end
it 'Atom or Sublime Text is installed!' do
subl_search = `which subl`
expect(subl_search).to_not be_empty, "Couldn't find either Sublime Text installed on your system."
end
it 'Atom or Sublime Text Command Line Tools are installed!' do
atom = `which atom`
subl = `which subl`
expect([ atom , subl ]).to_not satisfy { |s|
s.all?{|search| search.empty? }
}, "Your text editor is not configured to be launched from your Command Line."
end
it 'DBeaver is installed' do
dbeaver_search = `dpkg --get-selections | grep dbeaver`
expect(dbeaver_search).to match(/.?dbeaver.?/), "DBeaver is not installed."
end
it 'Postgres is installed!' do
postgres = `which psql`
expect(postgres).to_not be_empty, 'Postgres is not installed.'
end
it 'MySQL is installed.' do
mysql = `which mysql`
expect(mysql).to_not be_empty, "MySQL is not installed"
end
it 'Git is installed' do
git = `which git`
expect(git).to_not be_empty, "Git is not installed"
end
end
完整堆栈跟踪。该文件似乎是一个错误导致所有测试失败。我不确定问题是什么。我猜测我的rspec安装不正确吗?
stevenbuchko:~$ rspec '/home/stevenbuchko/WynCode/env_test.rb'
Ruby version 2.2.3 or greater is installed! (FAILED - 1)
Chrome is installed! (FAILED - 2)
Heroku Toolbelt is installed! (FAILED - 3)
Atom or Sublime Text is installed! (FAILED - 4)
Atom or Sublime Text Command Line Tools are installed! (FAILED - 5)
DBeaver is installed (FAILED - 6)
Postgres is installed! (FAILED - 7)
MySQL is installed. (FAILED - 8)
Git is installed (FAILED - 9)
Failures:
1) Ruby version 2.2.3 or greater is installed!
Failure/Error: expect(RUBY_VERSION).to be >= "2.2"
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x0000000281f478>
# ./WynCode/env_test.rb:8:in `block (2 levels) in <top (required)>'
2) Chrome is installed!
Failure/Error: expect(chrome_search).to_not be_empty, "Chrome isn't installed."
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x0000000281a888>
# ./WynCode/env_test.rb:12:in `block (2 levels) in <top (required)>'
3) Heroku Toolbelt is installed!
Failure/Error: expect(heroku).to_not be_empty, 'Heroku Toolbelt is not installed.'
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x00000002818e20>
# ./WynCode/env_test.rb:16:in `block (2 levels) in <top (required)>'
4) Atom or Sublime Text is installed!
Failure/Error: expect(subl_search).to_not be_empty, "Couldn't find either Sublime Text installed on your system."
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x000000028139c0>
# ./WynCode/env_test.rb:20:in `block (2 levels) in <top (required)>'
5) Atom or Sublime Text Command Line Tools are installed!
Failure/Error:
expect([ atom , subl ]).to_not satisfy { |s|
s.all?{|search| search.empty? }
}, "Your text editor is not configured to be launched from your Command Line."
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x00000002812160>
# ./WynCode/env_test.rb:25:in `block (2 levels) in <top (required)>'
6) DBeaver is installed
Failure/Error: expect(dbeaver_search).to match(/.?dbeaver.?/), "DBeaver is not installed."
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x00000002810680>
# ./WynCode/env_test.rb:31:in `block (2 levels) in <top (required)>'
7) Postgres is installed!
Failure/Error: expect(postgres).to_not be_empty, 'Postgres is not installed.'
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x0000000280f4b0>
# ./WynCode/env_test.rb:35:in `block (2 levels) in <top (required)>'
8) MySQL is installed.
Failure/Error: expect(mysql).to_not be_empty, "MySQL is not installed"
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x0000000280dcf0>
# ./WynCode/env_test.rb:39:in `block (2 levels) in <top (required)>'
9) Git is installed
Failure/Error: expect(git).to_not be_empty, "Git is not installed"
NoMethodError:
undefined method `expect' for #<RSpec::ExampleGroups::Anonymous:0x0000000280c0f8>
# ./WynCode/env_test.rb:43:in `block (2 levels) in <top (required)>'
Finished in 0.13526 seconds (files took 0.55814 seconds to load)
9 examples, 9 failures
Failed examples:
rspec ./WynCode/env_test.rb:7 # Ruby version 2.2.3 or greater is installed!
rspec ./WynCode/env_test.rb:10 # Chrome is installed!
rspec ./WynCode/env_test.rb:14 # Heroku Toolbelt is installed!
rspec ./WynCode/env_test.rb:18 # Atom or Sublime Text is installed!
rspec ./WynCode/env_test.rb:22 # Atom or Sublime Text Command Line Tools are installed!
rspec ./WynCode/env_test.rb:29 # DBeaver is installed
rspec ./WynCode/env_test.rb:33 # Postgres is installed!
rspec ./WynCode/env_test.rb:37 # MySQL is installed.
rspec ./WynCode/env_test.rb:41 # Git is installed