Fixing blogs spec flows.

--HG--
branch : 1.x
This commit is contained in:
Andre Rodrigues
2011-04-06 16:36:43 -07:00
parent 27befad56b
commit 6ae7faed62
3 changed files with 37 additions and 20 deletions

View File

@@ -221,6 +221,23 @@ namespace Orchard.Specs.Bindings {
WhenIGoTo(urlPath);
}
[When(@"I follow ""([^""]+)"" where class name has ""([^""]+)""")]
public void WhenIFollowClass(string linkText, string className) {
var link = _doc.DocumentNode
.SelectNodes("//a[@href]").Where(elt =>
(elt.InnerText == linkText ||
(elt.Attributes["title"] != null && elt.Attributes["title"].Value == linkText)) &&
elt.Attributes["class"].Value.IndexOf(className, StringComparison.OrdinalIgnoreCase) != -1).SingleOrDefault();
if (link == null) {
throw new InvalidOperationException(string.Format("Could not find an anchor with matching text '{0}' and class '{1}'. Document: {2}", linkText, className, _doc.DocumentNode.InnerHtml));
}
var href = link.Attributes["href"].Value;
var urlPath = HttpUtility.HtmlDecode(href);
WhenIGoTo(urlPath);
}
[When(@"I fill in")]
public void WhenIFillIn(Table table) {
var inputs = _doc.DocumentNode

View File

@@ -17,7 +17,7 @@ Scenario: I can create a new blog and blog post
And I hit "Save"
And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Routable.Title | My Post |
@@ -39,7 +39,7 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
And I hit "Save"
And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Routable.Title | My Post |
@@ -50,7 +50,7 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
And I should see "Hi there."
When I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Routable.Title | My Post |
@@ -61,7 +61,7 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
And I should see "Hi there, again."
When I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Routable.Title | My Post |
@@ -83,7 +83,7 @@ Scenario: I can create a new blog and blog post and when I change the slug of th
Then I should see "<h1[^>]*>.*?My Blog.*?</h1>"
When I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Routable.Title | My Post |
@@ -114,7 +114,7 @@ Scenario: When viewing a blog the user agent is given an RSS feed of the blog's
And I hit "Save"
And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Routable.Title | My Post |
@@ -151,7 +151,7 @@ Scenario: The virtual path of my installation when not at the root is reflected
And I hit "Save"
And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
Then I should see "<span>http\://localhost/OrchardLocal/my-blog/</span>"
Scenario: The virtual path of my installation when at the root is reflected in the URL example for the slug field when creating a blog or blog post
@@ -164,7 +164,7 @@ Scenario: The virtual path of my installation when at the root is reflected in t
And I hit "Save"
And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
Then I should see "<span>http\://localhost/my-blog/</span>"
Scenario: I set my blog to be the content for the home page and the posts for the blog be rooted to the app
@@ -177,7 +177,7 @@ Scenario: I set my blog to be the content for the home page and the posts for th
And I hit "Save"
And I go to "admin/blogs"
And I follow "My Blog"
And I follow "New Post"
And I follow "New Post" where class name has "primaryAction"
And I fill in
| name | value |
| Routable.Title | My Post |

View File

@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.4.0.0
// SpecFlow Version:1.5.0.0
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
@@ -14,7 +14,7 @@ namespace Orchard.Specs
using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.4.0.0")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.5.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Blog")]
@@ -97,7 +97,7 @@ this.ScenarioSetup(scenarioInfo);
#line 19
testRunner.And("I follow \"My Blog\"");
#line 20
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line hidden
TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
"name",
@@ -157,7 +157,7 @@ this.ScenarioSetup(scenarioInfo);
#line 41
testRunner.And("I follow \"My Blog\"");
#line 42
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line hidden
TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
"name",
@@ -183,7 +183,7 @@ this.ScenarioSetup(scenarioInfo);
#line 52
testRunner.And("I follow \"My Blog\"");
#line 53
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line hidden
TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
"name",
@@ -209,7 +209,7 @@ this.ScenarioSetup(scenarioInfo);
#line 63
testRunner.And("I follow \"My Blog\"");
#line 64
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line hidden
TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] {
"name",
@@ -270,7 +270,7 @@ this.ScenarioSetup(scenarioInfo);
#line 85
testRunner.And("I follow \"My Blog\"");
#line 86
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line hidden
TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
"name",
@@ -349,7 +349,7 @@ this.ScenarioSetup(scenarioInfo);
#line 116
testRunner.And("I follow \"My Blog\"");
#line 117
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line hidden
TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] {
"name",
@@ -452,7 +452,7 @@ this.ScenarioSetup(scenarioInfo);
#line 153
testRunner.And("I follow \"My Blog\"");
#line 154
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line 155
testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/my-blog/</span>\"");
#line hidden
@@ -490,7 +490,7 @@ this.ScenarioSetup(scenarioInfo);
#line 166
testRunner.And("I follow \"My Blog\"");
#line 167
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line 168
testRunner.Then("I should see \"<span>http\\://localhost/my-blog/</span>\"");
#line hidden
@@ -529,7 +529,7 @@ this.ScenarioSetup(scenarioInfo);
#line 179
testRunner.And("I follow \"My Blog\"");
#line 180
testRunner.And("I follow \"New Post\"");
testRunner.And("I follow \"New Post\" where class name has \"primaryAction\"");
#line hidden
TechTalk.SpecFlow.Table table16 = new TechTalk.SpecFlow.Table(new string[] {
"name",