如何在Windows 10上为Ruby Cucumber设置依赖项?

时间:2016-03-30 11:43:46

标签: ruby windows selenium-webdriver cucumber

这是一个命令提示错误。

我使用的是Windows 10操作系统。我必须使用Ruby和Cucumber编写自动化脚本。这需要devkit,ruby 2.0,sublime文本。

我已经创建了一个项目目录作为" pravinpro",我已经安装了黄瓜宝石。在命令提示符下运行它后,它显示错误:

Oops... Invalid Platform
Supported platform are "android" and "iOS".
To run on Desktop no need to mention platform.

Screenshot of the error

1 个答案:

答案 0 :(得分:1)

您熟悉Windows网站的rubyinstaller吗?你遇到了几个问题。首先,明确支持Windows 10 。第二个是x64版本是新的。 " 64位版本的Ruby在Windows领域相对较新,并非所有软件包都已更新为与之兼容。要使用此版本,您将需要一些有关编译器和解决依赖性问题的知识,如果您只是想使用该语言,这可能会过于复杂。"

所以我看到了两个选择。首先是尝试在Windows 10上安装32位版本的ruby。然后看看你是否对黄瓜宝石有更好的运气。

第二种是在Windows 10主机上创建虚拟机(Virtualbox是免费的)。您可以安装Linux操作系统,例如Centos 7,在客人中并从那里开始运行。

我在mingw32中使用过Ruby on windows,但总是发现它不如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

我创建了两个系统环境变量(系统 - &gt;高级系统设置 - &gt;环境变量) RUBY22_HOME = C:\ Ruby22 Ruby22_DEVKIT_HOME = C:\ Ruby22DevKit

我更新了我的Path系统环境变量,添加到结尾; c:\ Ruby22 \ bin; c:\ Ruby22DevKit \ bin 我打开一个命令窗口并输入 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 触摸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 以便我在支持文件夹中输入触摸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 ../../以便我在项目根文件夹中输入黄瓜并且它有效。

相关问题