Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated IronRuby, fixed C# specs, fixed errors that came out of using…

… System.Linq for list operations when possible
  • Loading branch information...
commit 939319febe205a43d6837e50fe3fe4740708fd58 1 parent 39143f0
@casualjim casualjim authored
View
2  IronRubyMvc.Tests/Controllers/RubyActionDescriptorFixture.cs
@@ -131,7 +131,7 @@ protected override void EstablishContext()
_rubyEngine.ExecuteScript(script.ToString());
_controllerDescriptor =
- MockRepository.GenerateStub<RubyControllerDescriptor>(_rubyEngine.GetRubyClass("SamuraisController"));
+ MockRepository.GenerateStub<RubyControllerDescriptor>(_rubyEngine.GetRubyClass("SamuraisController"), _rubyEngine);
}
protected override RubyActionDescriptor CreateSut()
View
6 IronRubyMvc.Tests/Controllers/RubyControllerDescriptorSpec.cs
@@ -181,9 +181,11 @@ public void should_have_the_correct_ruby_controller_class()
}
[Observation]
- public void should_have_an_empty_actions_list()
+ public void should_have_at_least_one_action_in_the_canonical_actions_list()
{
- Sut.GetCanonicalActions().ShouldBeEmpty();
+ var actions = Sut.GetCanonicalActions();
+ actions.ShouldNotBeEmpty();
+
}
}
View
14 IronRubyMvc.Tests/Controllers/RubyControllerSpec.cs
@@ -253,9 +253,21 @@ public class when_asked_to_execute_an_action : when_a_controller_is_initialized
{
private Action _action;
+ protected override void EstablishContext()
+ {
+ base.EstablishContext();
+
+ var form = new NameValueCollection();
+ var queryString = new NameValueCollection();
+ _httpContextMock.HttpRequest.Expect(r => r.Form).Returns(form);
+ _httpContextMock.HttpRequest.Expect(r => r.QueryString).Returns(queryString);
+ }
+
protected override void Because()
{
- _action = () => ((IController)Sut).Execute(new RequestContext(_httpContextMock.Object, new RouteData{Values = {{"action", "my_action"}}}));
+ var context = new RequestContext(_httpContextMock.Object, new RouteData {Values = {{"action", "my_action"}}});
+
+ _action = () => ((IController)Sut).Execute(context);
}
[Observation]
View
7 IronRubyMvc.Tests/Core/RubyEngineSpec.cs
@@ -48,13 +48,14 @@ protected override void Because()
[Observation]
public void it_should_have_a_global_routes_variable()
{
- _engine.GetGlobalVariable<object>("routes").ShouldNotBeNull();
+ _engine.Context.GetGlobalVariable("routes").ShouldNotBeNull();
+// _engine.GetGlobalVariable<object>("routes").ShouldNotBeNull();
}
[Observation]
public void routes_should_be_a_ruby_route_collection()
{
- _engine.GetGlobalVariable<object>("routes").ShouldBeAnInstanceOf<RubyRoutes>();
+ _engine.Context.GetGlobalVariable("routes").ShouldBeAnInstanceOf<RubyRoutes>();
}
[Observation]
@@ -98,7 +99,7 @@ protected override void Because()
[Observation]
public void it_should_not_have_a_global_routes_variable()
{
- _engine.GetGlobalVariable<object>("routes").ShouldBeNull();
+ _engine.Context.GetGlobalVariable("routes").ShouldBeNull();
}
View
4 IronRubyMvc.Tests/IronRubyMvcLibrary.Tests.csproj
@@ -51,6 +51,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\IronRuby.dll</HintPath>
</Reference>
+ <Reference Include="IronRuby.Libraries, Version=0.4.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\dependencies\IronRuby.Libraries.dll</HintPath>
+ </Reference>
<Reference Include="Microsoft.Scripting, Version=0.9.5.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dependencies\Microsoft.Scripting.dll</HintPath>
View
17 IronRubyMvc/Core/RubyEngine.cs
@@ -48,7 +48,7 @@ public RubyEngine(ScriptRuntime runtime, IPathProvider pathProvider)
/// Gets the context.
/// </summary>
/// <value>The context.</value>
- private RubyContext Context { get; set; }
+ internal RubyContext Context { get; set; }
/// <summary>
/// Gets the engine.
@@ -123,11 +123,14 @@ public IEnumerable<string> MethodNames(IController controller)
public IEnumerable<string> MethodNames(RubyClass controllerClass)
{
var names = new List<string>();
- controllerClass.EnumerateMethods((_, methodName, __) =>
- {
- names.Add(methodName);
- return false;
- });
+ using (Context.ClassHierarchyLocker())
+ {
+ controllerClass.EnumerateMethods((_, methodName, __) =>
+ {
+ names.Add(methodName);
+ return false;
+ });
+ }
return names;
}
@@ -265,7 +268,7 @@ public void RequireRubyFile(string path)
public void RequireRubyFile(string path, ReaderType readerType)
{
Engine.CreateScriptSource(readerType == ReaderType.File
- ? (StreamContentProvider)new VirtualPathStreamContentProvider(path)
+ ? (StreamContentProvider)new VirtualPathStreamContentProvider(path, PathProvider)
: new AssemblyStreamContentProvider(path, typeof (IRubyEngine).Assembly), null, Encoding.ASCII).Execute();
}
View
6 IronRubyMvc/Core/VirtualPathStreamContentProvider.cs
@@ -11,17 +11,19 @@ namespace System.Web.Mvc.IronRuby.Core
public class VirtualPathStreamContentProvider : StreamContentProvider
{
private readonly string _fileName;
+ private readonly IPathProvider _pathProvider;
- public VirtualPathStreamContentProvider(string fileName)
+ public VirtualPathStreamContentProvider(string fileName, IPathProvider pathProvider)
{
_fileName = fileName;
+ _pathProvider = pathProvider;
}
#region Overrides of StreamContentProvider
public override Stream GetStream()
{
- return HostingEnvironment.VirtualPathProvider.GetFile(_fileName).Open();
+ return _pathProvider.Open(_fileName);
}
#endregion
View
2  IronRubyMvc/Extensions/IDictionaryExtensions.cs
@@ -71,7 +71,7 @@ private static IEnumerable<TITarget> ToFilters<TITarget>(this IDictionary<object
var hasKey = filterDescriptions.ContainsKey(key);
if (hasKey)
{
- filters.AddRange((filterDescriptions[key] as RubyArray).Cast<TITarget>());
+ filters.AddRange((filterDescriptions[key] as RubyArray).CastTo<TITarget>());
}
return filters;
}
View
11 IronRubyMvc/Extensions/IEnumerableExtensions.cs
@@ -95,5 +95,16 @@ internal static IEnumerable<SelectListItem> ToSelectListItemList(this IEnumerabl
});
return result;
}
+
+ internal static IEnumerable<TTarget> CastTo<TTarget>(this IEnumerable collection) where TTarget : class
+ {
+ var result = new List<TTarget>();
+ collection.ForEach(item =>
+ {
+ var casted = (typeof(TTarget) == typeof(string)) ? item.ToString() as TTarget : item as TTarget;
+ if (casted.IsNotNull()) result.Add(casted);
+ });
+ return result;
+ }
}
}
View
BIN  dependencies/IronRuby.Libraries.Yaml.dll
Binary file not shown
View
BIN  dependencies/IronRuby.Libraries.Yaml.pdb
Binary file not shown
View
BIN  dependencies/IronRuby.Libraries.dll
Binary file not shown
View
BIN  dependencies/IronRuby.Libraries.pdb
Binary file not shown
View
BIN  dependencies/IronRuby.dll
Binary file not shown
View
BIN  dependencies/IronRuby.pdb
Binary file not shown
View
BIN  dependencies/Microsoft.Scripting.Core.dll
Binary file not shown
View
BIN  dependencies/Microsoft.Scripting.Core.pdb
Binary file not shown
View
BIN  dependencies/Microsoft.Scripting.ExtensionAttribute.dll
Binary file not shown
View
BIN  dependencies/Microsoft.Scripting.ExtensionAttribute.pdb
Binary file not shown
View
BIN  dependencies/Microsoft.Scripting.dll
Binary file not shown
View
BIN  dependencies/Microsoft.Scripting.pdb
Binary file not shown

0 comments on commit 939319f

Please sign in to comment.
Something went wrong with that request. Please try again.