小编And*_*nza的帖子

如何声明RSpec中的示例之间共享的变量?

假设我有以下规范:

...
describe Thing do

  it 'can read data' do
     @data = get_data_from_file  # [ '42', '36' ]
     expect(@data.count).to eq 2
  end

  it 'can process data' do
     expect(@data[0].to_i).to eq 42  # Fails because @data is nil
  end

end
...
Run Code Online (Sandbox Code Playgroud)

我想要的只是在给定的描述上下文中共享一个变量.我会在一个例子中写一个值,然后在另一个例子中读取它.我怎么做?

ruby variables rspec

36
推荐指数
2
解决办法
3万
查看次数

Watir-Webdriver,PhantomJS和重定向到https的URL

我在使用PhantomJS和Watir-Webdriver时遇到了麻烦.我有"http"方案的URL,返回HTTP 301永久移动并重定向到新的"https"位置.两个例子:

  1. http://make.crowdflower.com
  2. http://click.alfabank.ru

我写了一个脚本:

require 'watir-webdriver'
b = Watir::Browser.new :phantomjs, :args => ['--ignore-ssl-errors=true']
b.goto 'http://make.crowdflower.com'
puts b.title
puts b.url
b.close
Run Code Online (Sandbox Code Playgroud)

输出是:

(empty line)
about:blank
Run Code Online (Sandbox Code Playgroud)

版本是:Ruby 2.1.0,watir-webdriver 0.6.11,phantomjs 1.9.7.

我想知道为什么会这样.任何建议都非常感谢.

ruby ssl watir-webdriver phantomjs

2
推荐指数
1
解决办法
1193
查看次数

标签 统计

ruby ×2

phantomjs ×1

rspec ×1

ssl ×1

variables ×1

watir-webdriver ×1