From 6ae7faed6280f21c8c41e619d363311809e1f057 Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Wed, 6 Apr 2011 16:36:43 -0700 Subject: [PATCH] Fixing blogs spec flows. --HG-- branch : 1.x --- src/Orchard.Specs/Bindings/WebAppHosting.cs | 17 ++++++++++++++++ src/Orchard.Specs/Blogs.feature | 18 ++++++++--------- src/Orchard.Specs/Blogs.feature.cs | 22 ++++++++++----------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/Orchard.Specs/Bindings/WebAppHosting.cs b/src/Orchard.Specs/Bindings/WebAppHosting.cs index 08670ec99..d88d0707e 100644 --- a/src/Orchard.Specs/Bindings/WebAppHosting.cs +++ b/src/Orchard.Specs/Bindings/WebAppHosting.cs @@ -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 diff --git a/src/Orchard.Specs/Blogs.feature b/src/Orchard.Specs/Blogs.feature index 6701fd81e..2afe21106 100644 --- a/src/Orchard.Specs/Blogs.feature +++ b/src/Orchard.Specs/Blogs.feature @@ -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 "]*>.*?My Blog.*?" 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 "http\://localhost/OrchardLocal/my-blog/" 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 "http\://localhost/my-blog/" 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 | diff --git a/src/Orchard.Specs/Blogs.feature.cs b/src/Orchard.Specs/Blogs.feature.cs index 60245a6c4..a8bcbabff 100644 --- a/src/Orchard.Specs/Blogs.feature.cs +++ b/src/Orchard.Specs/Blogs.feature.cs @@ -1,7 +1,7 @@ // ------------------------------------------------------------------------------ // // 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 \"http\\://localhost/OrchardLocal/my-blog/\""); #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 \"http\\://localhost/my-blog/\""); #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",