如何在 Windows 10 上为 Ruby Cucumber 设置依赖项?
How do I set up dependencies for Ruby Cucumber on Windows 10?
这是命令提示错误。
我正在使用 windows 10 操作系统。我必须使用 Ruby 和 Cucumber 编写自动化脚本。这需要 devkit,ruby 2.0,sublime text。
我已经为项目创建了一个目录 "pravinpro",我已经安装了 cucumber gem。在命令提示符 运行 之后,它显示错误:
Oops... Invalid Platform
Supported platform are "android" and "iOS".
To run on Desktop no need to mention platform.
您是否熟悉 windows 站点的 rubyinstaller?你遇到了几个问题。首先是 Windows 10 未 明确支持。第二个是 x64 版本是新的。 "The 64-bit versions of Ruby are relatively new on the Windows area and not all the packages have been updated to be compatible with it. To use this version you will require some knowledge about compilers and solving dependency issues, which might be too complicated if you just want to play with the language."
所以我看到两个选项供您选择。首先是尝试在 Windows 10 上安装 ruby 的 32 位版本。然后看看你的 cucumber gem.
是否有更好的运气
第二个是在您的 Windows10 主机上创建一个虚拟机(Virtualbox 是免费的)。您可以安装 Linux 操作系统,例如Centos 7,在来宾和 运行 那里的一切。
我曾在 mingw32 的 windows 上使用 Ruby,但总是发现它不如 linux 上的原生灵活。无论你选择什么,祝你好运。
更新
我让它在 Windows 8.1 上运行。尝试在 Windows 10 上执行这些步骤,让我知道进展如何。
已下载 32 位 Ruby 2.2.4 并将其解压缩到 c:\Ruby22.
已下载 32 位 Ruby Dev Kit for use with Ruby 2.0 and above,我将其解压缩到 c:\Ruby22DevKit.
我创建了两个系统环境变量(系统 -> 高级系统设置 -> 环境变量)RUBY22_HOME=C:\Ruby22 和 Ruby22_DEVKIT_HOME=C:\Ruby22DevKit.
我更新了 Path 系统环境变量,添加到末尾 ;c:\Ruby22\bin;c:\Ruby22DevKit\bin
我打开一个命令window并输入bash.exe(可以在C:\Ruby22DevKit\bin中找到)
gem install cucumber
gem install rspec-expectations
gem install capybara
gem install selenium-webdriver
我 cd 到我的用户主页并且
mkdir RubyCucumberProject
cd RubyCucumberProject
mkdir features
cd features
mkdir step_definitions
mkdir support
touch helloworld.feature
我编辑了 helloworld.features 添加:
Feature: Hello World
@helloworld
Scenario: Hello google
Given I am on the google search page
When I search for "hello world"
Then there should be a result for "www.helloworld.com/"
我 cd 到 step_definitions 和 touch hello_word.rb。我编辑了这个文件添加:
Given(/^I am on the google search page$/) do
visit 'http://www.google.com/advanced_search?hl=en'
end
When(/^I search for "(.*)"$/) do |query|
fill_in 'as_q', :with => query
click_button 'Search'
end
Then /^there should be a result for "(.*)"$/ do |expected_result|
results = all('cite').map { |el| el.text }
results.should include expected_result
end
然后我 cd../support 这样我就在支持文件夹中并输入 touch env.rb 编辑相同添加:
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'rspec'
Capybara.run_server = false
Capybara.default_driver = :selenium
Capybara.default_selector = :css
World(Capybara::DSL)
然后我 cd ../../ 这样我就在项目根文件夹中并输入 cucumber 并且它起作用了。
这是命令提示错误。
我正在使用 windows 10 操作系统。我必须使用 Ruby 和 Cucumber 编写自动化脚本。这需要 devkit,ruby 2.0,sublime text。
我已经为项目创建了一个目录 "pravinpro",我已经安装了 cucumber gem。在命令提示符 运行 之后,它显示错误:
Oops... Invalid Platform
Supported platform are "android" and "iOS".
To run on Desktop no need to mention platform.
您是否熟悉 windows 站点的 rubyinstaller?你遇到了几个问题。首先是 Windows 10 未 明确支持。第二个是 x64 版本是新的。 "The 64-bit versions of Ruby are relatively new on the Windows area and not all the packages have been updated to be compatible with it. To use this version you will require some knowledge about compilers and solving dependency issues, which might be too complicated if you just want to play with the language."
所以我看到两个选项供您选择。首先是尝试在 Windows 10 上安装 ruby 的 32 位版本。然后看看你的 cucumber gem.
是否有更好的运气第二个是在您的 Windows10 主机上创建一个虚拟机(Virtualbox 是免费的)。您可以安装 Linux 操作系统,例如Centos 7,在来宾和 运行 那里的一切。
我曾在 mingw32 的 windows 上使用 Ruby,但总是发现它不如 linux 上的原生灵活。无论你选择什么,祝你好运。
更新
我让它在 Windows 8.1 上运行。尝试在 Windows 10 上执行这些步骤,让我知道进展如何。
已下载 32 位 Ruby 2.2.4 并将其解压缩到 c:\Ruby22.
已下载 32 位 Ruby Dev Kit for use with Ruby 2.0 and above,我将其解压缩到 c:\Ruby22DevKit.
我创建了两个系统环境变量(系统 -> 高级系统设置 -> 环境变量)RUBY22_HOME=C:\Ruby22 和 Ruby22_DEVKIT_HOME=C:\Ruby22DevKit.
我更新了 Path 系统环境变量,添加到末尾 ;c:\Ruby22\bin;c:\Ruby22DevKit\bin 我打开一个命令window并输入bash.exe(可以在C:\Ruby22DevKit\bin中找到)
gem install cucumber
gem install rspec-expectations
gem install capybara
gem install selenium-webdriver
我 cd 到我的用户主页并且
mkdir RubyCucumberProject
cd RubyCucumberProject
mkdir features
cd features
mkdir step_definitions
mkdir support
touch helloworld.feature
我编辑了 helloworld.features 添加:
Feature: Hello World
@helloworld
Scenario: Hello google
Given I am on the google search page
When I search for "hello world"
Then there should be a result for "www.helloworld.com/"
我 cd 到 step_definitions 和 touch hello_word.rb。我编辑了这个文件添加:
Given(/^I am on the google search page$/) do
visit 'http://www.google.com/advanced_search?hl=en'
end
When(/^I search for "(.*)"$/) do |query|
fill_in 'as_q', :with => query
click_button 'Search'
end
Then /^there should be a result for "(.*)"$/ do |expected_result|
results = all('cite').map { |el| el.text }
results.should include expected_result
end
然后我 cd../support 这样我就在支持文件夹中并输入 touch env.rb 编辑相同添加:
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'rspec'
Capybara.run_server = false
Capybara.default_driver = :selenium
Capybara.default_selector = :css
World(Capybara::DSL)
然后我 cd ../../ 这样我就在项目根文件夹中并输入 cucumber 并且它起作用了。