0
嗨,我正在学习水豚,我试过各种答案,所以我无法继续。我正试图用水豚测试一个应用程序。访问不起作用,错误表明它需要在'它'或示例/可执行块等内,但是下面的代码,背景和场景等不起作用,执行不在内部。无法使用水豚,不知道我去哪里错了'背景'和'它'等不起作用
结果::
C:\Ruby223\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Users/xxx/RubymineProjects/xxx-app/spec/features/xxxxx.rb
"aaa"
Process finished with exit code 0
我不想把事情弄糟的Rails应用程序,所以我想从那里我可以执行测试,然后与开发者帮助Rails应用程序集成一个独立的文件。
require 'capybara/dsl'
require 'capybara'
require 'capybara/rspec'
require 'rspec'
feature "Signing in" do
p 'aaa'
background do
p 'aaa1'
Capybara.register_driver :selenium_chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.run_server = false
Capybara.current_driver = :selenium_chrome
Capybara.app_host = 'http://www.google.com'
end
scenario "Signing in with correct credentials" do
p 'aaa2'
visit '/q=?alkjaaa'
within("#session") do
fill_in 'email', with: '[email protected]'
fill_in 'password', with: 'caplin'
end
click_button 'Signin'
expect(page).to have_content 'results'
end
given(:other_user) { User.make(email: '[email protected]', password: 'rous') }
scenario "Signing in as another user" do
p 'aaa'
visit '/sessions/new'
within("#session") do
fill_in 'Email', with: other_user.email
fill_in 'Password', with: other_user.password
end
click_button 'Signin'
expect(page).to have_content 'Invalid email or password'
end
end
你可以让我知道如何设置这RubyMine的运行configuraion而不更改测试场景的名字,每次 –
@KiulLogoto对不起,我不使用RubyMine的,所以我不知道。也许https://www.jetbrains.com/help/ruby/2016.2/using-rspec-in-ruby-projects.html将帮助 –