Permalink
Browse files

Updated to latest git rev. Fixes the solution to allow for hitting F5…

…. Fixes a bug when no filters have been defined. Integrates instance variables with the view data dictionary

Signed-off-by: Jimmy Schementi <jschementi@gmail.com>
  • Loading branch information...
casualjim authored and jschementi committed Mar 7, 2009
1 parent 1fb4020 commit bbe735d45ff1aef8a32bbe60e003abb0a39deddd
Showing with 240 additions and 462 deletions.
  1. +28 −0 IronRubyMvc.Tests/Controllers/RubyActionDescriptorFixture.cs
  2. +0 −77 IronRubyMvc.Tests/Core/AssemblyResourceReaderSpec.cs
  3. +0 −133 IronRubyMvc.Tests/Core/DefaultScriptRunnerSpec.cs
  4. +0 −1 IronRubyMvc.Tests/Core/EmbeddedTestResource.txt
  5. +0 −1 IronRubyMvc.Tests/Core/EmbeddedTestScript.rb
  6. +0 −86 IronRubyMvc.Tests/Core/FileReaderSpec.cs
  7. +11 −7 IronRubyMvc.Tests/Core/RouteCollectionSpec.cs
  8. +1 −0 IronRubyMvc.Tests/Core/RubyEngineSpec.cs
  9. +0 −105 IronRubyMvc.Tests/Core/ScopedScriptRunnerSpec.cs
  10. +0 −1 IronRubyMvc.Tests/Core/TestFile.txt
  11. +14 −17 IronRubyMvc.Tests/IronRubyMvcLibrary.Tests.csproj
  12. +22 −0 IronRubyMvc.sln
  13. +2 −0 IronRubyMvc/Controllers/RubyController.cs
  14. +1 −0 IronRubyMvc/Controllers/RubyControllerFactory.cs
  15. +2 −7 IronRubyMvc/Controllers/controller.rb
  16. +12 −5 IronRubyMvc/Core/RubyEngine.cs
  17. +83 −8 IronRubyMvc/Core/RubyRoutes.cs
  18. +2 −2 IronRubyMvc/Extensions/IEnumerableExtensions.cs
  19. +16 −4 IronRubyMvc/System.Web.Mvc.IronRuby.csproj
  20. +7 −0 IronRubyMvcLibrarySpecs/IronRubyMvcLibrarySpecs.stproj
  21. BIN IronRubyMvcLibrarySpecs/bin/IronRuby.Libraries.dll
  22. BIN IronRubyMvcLibrarySpecs/bin/IronRuby.Libraries.pdb
  23. BIN IronRubyMvcLibrarySpecs/bin/IronRuby.dll
  24. BIN IronRubyMvcLibrarySpecs/bin/IronRuby.pdb
  25. BIN IronRubyMvcLibrarySpecs/bin/Microsoft.Scripting.Core.dll
  26. BIN IronRubyMvcLibrarySpecs/bin/Microsoft.Scripting.Core.pdb
  27. BIN IronRubyMvcLibrarySpecs/bin/Microsoft.Scripting.ExtensionAttribute.dll
  28. BIN IronRubyMvcLibrarySpecs/bin/Microsoft.Scripting.ExtensionAttribute.pdb
  29. BIN IronRubyMvcLibrarySpecs/bin/Microsoft.Scripting.dll
  30. BIN IronRubyMvcLibrarySpecs/bin/Microsoft.Scripting.pdb
  31. +4 −0 IronRubyMvcWeb/Controllers/HomeController.rb
  32. +3 −8 IronRubyMvcWeb/Controllers/ProductsController.rb
  33. +16 −0 IronRubyMvcWeb/IronRubyMvcWeb.csproj
  34. +3 −0 IronRubyMvcWeb/Routes.rb
  35. +13 −0 Pictures/Pictures.csproj
  36. BIN VS Templates/IronRubyMvcController.zip
  37. BIN VS Templates/RubyActionFilter.zip
  38. BIN VS Templates/RubyAuthorizationFilter.zip
  39. BIN VS Templates/RubyExceptionFilter.zip
  40. BIN VS Templates/RubyResultFilter.zip
  41. BIN VS Templates/RubyRoutes.zip
  42. BIN dependencies/IronRuby.Libraries.Yaml.dll
  43. BIN dependencies/IronRuby.Libraries.Yaml.pdb
  44. BIN dependencies/IronRuby.Libraries.dll
  45. BIN dependencies/IronRuby.Libraries.pdb
  46. BIN dependencies/IronRuby.dll
  47. BIN dependencies/IronRuby.pdb
  48. BIN dependencies/Microsoft.Dynamic.dll
  49. BIN dependencies/Microsoft.Dynamic.pdb
  50. BIN dependencies/Microsoft.Scripting.Core.dll
  51. BIN dependencies/Microsoft.Scripting.Core.pdb
  52. BIN dependencies/Microsoft.Scripting.ExtensionAttribute.dll
  53. BIN dependencies/Microsoft.Scripting.ExtensionAttribute.pdb
  54. BIN dependencies/Microsoft.Scripting.dll
  55. BIN dependencies/Microsoft.Scripting.pdb
@@ -12,6 +12,9 @@
using System.Web.Mvc.IronRuby.Controllers;
using System.Web.Mvc.IronRuby.Core;
using System.Web.Mvc.IronRuby.Tests.Core;
+using IronRuby;
+using IronRuby.Runtime;
+using Microsoft.Scripting.Hosting;
using Moq.Mvc;
using Rhino.Mocks;
using Xunit;
@@ -20,6 +23,31 @@
namespace System.Web.Mvc.IronRuby.Tests.Controllers
{
+ public abstract class with_ironruby_initialized<SystemUnderTest> : InstanceContextSpecification<SystemUnderTest>
+ where SystemUnderTest : class
+ {
+ protected static ScriptRuntime _scriptRuntime;
+ protected RubyContext _context;
+ protected ScriptEngine _engine;
+
+ protected override void EstablishContext()
+ {
+ if (_scriptRuntime == null)
+ {
+ var rubySetup = Ruby.CreateRubySetup();
+ rubySetup.Options["InterpretedMode"] = true;
+
+ var runtimeSetup = new ScriptRuntimeSetup();
+ runtimeSetup.LanguageSetups.Add(rubySetup);
+ runtimeSetup.DebugMode = true;
+
+ _scriptRuntime = Ruby.CreateRuntime(runtimeSetup);
+ }
+ _engine = _scriptRuntime.GetRubyEngine();
+ _context = Ruby.GetExecutionContext(_engine);
+ }
+ }
+
public abstract class with_ironruby_and_an_engine_initialized<SystemUnderTest> :
with_ironruby_initialized<SystemUnderTest> where SystemUnderTest : class
{
@@ -1,77 +0,0 @@
-#region Usings
-
-using System;
-using System.Web.Mvc.IronRuby.Core;
-using System.Web.Mvc.IronRuby.Core;
-using Xunit;
-
-#endregion
-
-namespace System.Web.Mvc.IronRuby.Tests.Core
-{
- [Concern(typeof (AssemblyResourceReader))]
- public class when_reading_a_resource_and_an_existing_path_is_given :
- InstanceContextSpecification<AssemblyResourceReader>
- {
- private string _resourcePath;
- private string _result;
-
- protected override void EstablishContext()
- {
- _resourcePath = "IronRubyMvcLibrary.Tests.Core.EmbeddedTestResource.txt";
- }
-
- protected override AssemblyResourceReader CreateSut()
- {
- return new AssemblyResourceReader(typeof (when_reading_a_resource_and_an_existing_path_is_given).Assembly);
- }
-
- protected override void Because()
- {
- _result = Sut.Read(_resourcePath);
- }
-
- [Observation]
- public void it_should_read_the_contents_correctly()
- {
- _result.ShouldBeEqualTo("Content for TestResource.");
- }
- }
-
- [Concern(typeof (AssemblyResourceReader))]
- public class when_reading_a_resource_and_a_non_existing_path_is_given :
- InstanceContextSpecification<AssemblyResourceReader>
- {
- private Action _action;
- private string _resourcePath;
- private string _result;
-
- protected override void EstablishContext()
- {
- _resourcePath = "IronRubyMvc.Tests.Core.EmbeddedTestResource9876.txt";
- }
-
- protected override AssemblyResourceReader CreateSut()
- {
- return new AssemblyResourceReader(typeof (when_reading_a_resource_and_an_existing_path_is_given).Assembly);
- }
-
- protected override void Because()
- {
- _action = The.Action(() => _result = Sut.Read(_resourcePath));
- _action();
- }
-
- [Observation]
- public void should_not_throw_any_exceptions()
- {
- _action.ShouldNotThrowAnyExceptions();
- }
-
- [Observation]
- public void should_return_an_empty_string()
- {
- _result.ShouldBeEmpty();
- }
- }
-}
@@ -1,133 +0,0 @@
-#region Usings
-
-using System;
-using System.Web.Mvc.IronRuby.Core;
-using IronRuby;
-using IronRuby.Runtime;
-using System.Web.Mvc.IronRuby.Core;
-using Microsoft.Scripting.Hosting;
-using Xunit;
-
-#endregion
-
-namespace System.Web.Mvc.IronRuby.Tests.Core
-{
- public abstract class with_ironruby_initialized<SystemUnderTest> : InstanceContextSpecification<SystemUnderTest>
- where SystemUnderTest : class
- {
- protected static ScriptRuntime _scriptRuntime;
- protected RubyContext _context;
- protected ScriptEngine _engine;
-
- protected override void EstablishContext()
- {
- if (_scriptRuntime == null)
- {
- var rubySetup = Ruby.CreateRubySetup();
- rubySetup.Options["InterpretedMode"] = true;
-
- var runtimeSetup = new ScriptRuntimeSetup();
- runtimeSetup.LanguageSetups.Add(rubySetup);
- runtimeSetup.DebugMode = true;
-
- _scriptRuntime = Ruby.CreateRuntime(runtimeSetup);
- }
- _engine = _scriptRuntime.GetRubyEngine();
- _context = Ruby.GetExecutionContext(_engine);
- }
- }
-
- [Concern(typeof (DefaultScriptRunner))]
- public class when_no_file_is_provided : with_ironruby_initialized<DefaultScriptRunner>
- {
- private Action _action;
-
- protected override DefaultScriptRunner CreateSut()
- {
- return new DefaultScriptRunner(_engine, string.Empty,
- new AssemblyResourceReader(typeof (RubyExperiments).Assembly));
- }
-
- protected override void Because()
- {
- _action = () => Sut.ExecuteFile(string.Empty);
- }
-
- [Observation]
- public void then_it_should_return_a_string()
- {
- _action.ShouldThrowAn<NullReferenceException>();
- }
- }
-
- [Concern(typeof (DefaultScriptRunner))]
- public class when_no_reader_is_provided : with_ironruby_initialized<DefaultScriptRunner>
- {
- private Action _action;
-
- protected override DefaultScriptRunner CreateSut()
- {
- return new DefaultScriptRunner(_engine, string.Empty, null);
- }
-
- protected override void Because()
- {
- _action = () => Sut.ExecuteFile("IronRubyMvcLibrary.Tests.Core.EmbeddedTestScript.rb");
- }
-
- [Observation]
- public void then_it_should_return_a_string()
- {
- _action.ShouldThrowAn<NullReferenceException>();
- }
- }
-
-
- [Concern(typeof (DefaultScriptRunner))]
- public class when_an_existing_file_is_provided : with_ironruby_initialized<DefaultScriptRunner>
- {
- private string result;
-
- protected override DefaultScriptRunner CreateSut()
- {
- return new DefaultScriptRunner(_engine, string.Empty,
- new AssemblyResourceReader(typeof (RubyExperiments).Assembly));
- }
-
- protected override void Because()
- {
- var obj = Sut.ExecuteFile("IronRubyMvcLibrary.Tests.Core.EmbeddedTestScript.rb");
- result = obj.ToString();
- }
-
- [Observation]
- public void then_it_should_return_a_string()
- {
- Assert.Equal("It works", result);
- }
- }
-
- [Concern(typeof (DefaultScriptRunner))]
- public class when_a_piece_of_script_is_provided : with_ironruby_initialized<DefaultScriptRunner>
- {
- private string result;
-
- protected override DefaultScriptRunner CreateSut()
- {
- return new DefaultScriptRunner(_engine, string.Empty,
- new AssemblyResourceReader(typeof (RubyExperiments).Assembly));
- }
-
- protected override void Because()
- {
- var obj = Sut.ExecuteScript("\"It works from script\".to_clr_string");
- result = obj.ToString();
- }
-
- [Observation]
- public void then_it_should_return_a_string()
- {
- Assert.Equal("It works from script", result);
- }
- }
-}
@@ -1 +0,0 @@
-Content for TestResource.
@@ -1 +0,0 @@
-"It works".to_clr_string
@@ -1,86 +0,0 @@
-#region Usings
-
-using System;
-using System.IO;
-using System.Web.Mvc.IronRuby.Core;
-using System.Web.Mvc.IronRuby.Core;
-using Xunit;
-
-#endregion
-
-namespace System.Web.Mvc.IronRuby.Tests.Core
-{
- [Concern(typeof (FileReader))]
- public class when_reading_a_file_and_an_existing_path_is_given : InstanceContextSpecification<FileReader>
- {
- private string _filePath;
- private IPathProvider _pathProvider;
- private string _result;
-
- protected override void EstablishContext()
- {
- _filePath = Path.Combine(Environment.CurrentDirectory, "Core\\TestFile.txt");
- _pathProvider = Dependency<IPathProvider>();
-
- _pathProvider.WhenToldTo(prov => prov.FileExists(_filePath)).Return(true);
- _pathProvider.WhenToldTo(prov => prov.Open(_filePath)).Return(new FileStream(_filePath, FileMode.Open));
- }
-
- protected override FileReader CreateSut()
- {
- return new FileReader(_pathProvider);
- }
-
- protected override void Because()
- {
- _result = Sut.Read(_filePath);
- }
-
- [Observation]
- public void it_should_read_the_contents_correctly()
- {
- _result.ShouldBeEqualTo("Content for TestResource.");
- }
- }
-
- [Concern(typeof (FileReader))]
- public class when_reading_a_file_and_a_non_existing_path_is_given : InstanceContextSpecification<FileReader>
- {
- private Action _action;
- private string _filePath;
- private IPathProvider _pathProvider;
- private string _result;
-
- protected override void EstablishContext()
- {
- _filePath = Path.Combine(Environment.CurrentDirectory, "Core\\TestFile2.txt");
- _pathProvider = Dependency<IPathProvider>();
-
- _pathProvider.WhenToldTo(prov => prov.FileExists(_filePath)).Return(false);
- //_pathProvider.WhenToldTo(prov => prov.Open(_filePath)).Return(string.Empty);
- }
-
- protected override FileReader CreateSut()
- {
- return new FileReader(_pathProvider);
- }
-
- protected override void Because()
- {
- _action = The.Action(() => _result = Sut.Read(_filePath));
- _action();
- }
-
- [Observation]
- public void should_not_throw_any_exceptions()
- {
- _action.ShouldNotThrowAnyExceptions();
- }
-
- [Observation]
- public void should_return_an_empty_string()
- {
- _result.ShouldBeEmpty();
- }
- }
-}
@@ -6,6 +6,7 @@
using System.Web.Routing;
using System.Web.Mvc.IronRuby.Core;
using System.Web.Mvc.IronRuby.Extensions;
+using IronRuby.Builtins;
using Xunit;
#endregion
@@ -51,10 +52,13 @@ public class when_more_values_are_mapped : InstanceContextSpecification<RubyRout
protected override void EstablishContext()
{
- var routes = new RouteCollection();
- routes.Add("my_controller",
- new Route("my_controller", new MvcRouteHandler())
- {Constraints = new Hashtable().ToRouteDictionary()});
+ var routes = new RouteCollection
+ {
+ {
+ "my_controller", new Route("my_controller", new MvcRouteHandler())
+ {Constraints = new Hashtable().ToRouteDictionary()}
+ }
+ };
_routeCollection = routes;
}
@@ -65,9 +69,9 @@ protected override RubyRoutes CreateSut()
protected override void Because()
{
- Sut.MapRoute("my_controller", "my_controller", null);
- Sut.MapRoute("my_controller2", "my_controller3", null);
- Sut.MapRoute("my_controller3", "my_controller2", null);
+ Sut.MapRoute("my_controller", "my_controller");
+ Sut.MapRoute("my_controller2", "my_controller3");
+ Sut.MapRoute("my_controller3", "my_controller2");
}
[Observation]
@@ -7,6 +7,7 @@
using System.Web.Mvc;
using System.Web.Mvc.IronRuby.Controllers;
using System.Web.Mvc.IronRuby.Core;
+using System.Web.Mvc.IronRuby.Tests.Controllers;
using System.Web.Mvc.IronRuby.ViewEngine;
using System.Web.Routing;
using IronRuby.Builtins;
Oops, something went wrong.

0 comments on commit bbe735d

Please sign in to comment.