子域,使用黄瓜或水豚和 rspec 进行测试
我的项目的部分开发已经完成。我们的 公司要求我为开发的代码编写cucumber测试用例 以及今后的发展。 路由文件有两个子域:admin 和hosts.Devise 也是 被使用。
现在我安装了黄瓜并编写了第一个场景 第一个故事,当非注册用户登陆主页时,进入 有效的电子邮件并被重定向到下一页..该页面没有 密码字段。
Scenario: Non registered user lands on beta home page.
Given: I am on the homepage
When: I enter valid email with "[email protected]".
Then: I should be redirected to request invitation page.
问题出在我的路由文件中,
constraints :subdomain => ADMIN_SUBDOMAIN do
....
root :to => admin#index
end
constraints :subdomain => HOST do
...
root :to => home#index.
end
现在我如何指定 path.rb 文件来查找 root_path 该特定子域。 子域约束之外没有写入 root_path。 这是我第一次进行测试。 我真的很坚持这一点。非常感谢任何帮助。
我刚刚从某人那里得知这可以使用水豚来实现。如果是这样,请您提供一些想法。
Some part of the development of my project has been done.Our
company asks me to write cucumber test cases for the developed code
and for the henceforth development as well.
The routes file have two subdomains for admin and hosts.Devise is also
being used.
Now i installed cucumber and have written the first scenario for the
first story when the non registerd user lands on the home page,enters
a valid email and gets redirected to the next page..the page has no
password field.
Scenario: Non registered user lands on beta home page.
Given: I am on the homepage
When: I enter valid email with "[email protected]".
Then: I should be redirected to request invitation page.
The problem is in my routes file, I have,
constraints :subdomain => ADMIN_SUBDOMAIN do
....
root :to => admin#index
end
constraints :subdomain => HOST do
...
root :to => home#index.
end
Now how do i specify the path.rb file to look for the root_path in
that specific subdomain.
Theres no root_path written outside the subdomain constraints.
This is my first time with testing.
I am really stuck onto this.Any help is deeply appreciated.
I just got to know from somebody that this can be implemented using capybara.If so ,could you please give a little idea about it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明这很简单。Capybara 提供了一个 default_host 方法。
所以我只需要提到,
然后 webstep
Update:
default_host 不应该被使用,因为它在文档中没有提到。
相反,尝试在访问中使用绝对路径。
Turned out it was pretty simple.Capybara provides a default_host method.
So I just needed to mention,
And then the webstep
Update:
default_host is not supposed to be used as it is not mentioned in the docs.
Instead try using absolute path in visit.