IronRuby, Cucumber, & win32console: Picking up the Gauntlet

Posted in .Net, cucumber, gems, ironruby, ruby on June 20th, 2009 by Will – 3 Comments

Shortly after I published my previous post on getting IronRuby working with Cucumber, I did a git pull and recompile from the IronRuby repo. Well, something changed which broke command line option parsing for igem. I’m happy to report that this commit appears to have fixed the issue. Yay!

Also, I’ve forked IronRuby on GitHub and have made the changes I documented on the previous post to Dev.bat. I plan to track IronRuby closely, so if you don’t want to follow all the directions (I still recommend setting up the shortcut to dev.bat), you can simply clone my repo.

Finally, Shri Borde put out a call on the IronRuby mailing list asking if anyone was interested in porting win32console to IronRuby. As Shri pointed out, this is important because Cucumber makes use of win32console on windows platforms to colorize the output of cucumber runs. This makes it much easier to visualize what works, what’s broken, and what steps you need to write. Since I have more than a passing interest in getting Cucumber working for .Net apps, I am going to pick up the gauntlet and attempt to port it myself. Behold ironruby-win32console. Now, to figure out how to do it…

Cucumber and IronRuby: It Runs!

Posted in .Net, ironruby, ruby on June 14th, 2009 by Will – 6 Comments

Ever since I read about Cucumber, a user acceptance testing tool in Ruby, I’ve wanted to be able to use it, along with IronRuby for my .Net projects. I got it working once, briefly, using the directions on the Cucumber wiki at GitHub. With an uncertain combination of IronRuby updates and Cucumber updates, it stopped working for me. Well, this evening, I decided to delve into it once again, and I am now happy to report that it works! Well, works, as in runs the C# sample provided with the Cucumber gem. I know present to you the steps I took to get it working, from end to end (I’ll assume you have some version of Visual Studio 2008 with C#):

1 – Install MSysGit

Head on over the the MSysGit page, grab the latest Git-1.6.x.y install, and run it. At the time of this writing, I’m using 1.6.2.2-preview20090408

2 – Grab the IronRuby sources

I prefer to do all my development work in C:\Development. Pop open a Git Bash console (Start > Programs > Git > Git Bash) and issue the following commands:

cd /C/Development
git clone git://github.com/ironruby/ironruby.git
git pull

OR, if you’re behind a corporate firewall…

cd /C/Development
git clone http://github.com/ironruby/ironruby.git
git pull

3 – Set Up IronRuby Dev Environment

This comes straight from the dev.bat entry in the IronRuby wiki on GitHub:

We recommend you start your developing by runningC:\path\to\Merlin\Main\Languages\Ruby\Scripts\Dev.bat. This batch file sets up the path, various environment variables, and aliases, which makes it easy to do builds and run tests.

It is recommended to setup a shortcut to Dev.bat on the desktop that you can just click to quickly get the pre-configured environment. To do this, create a shortcut on the Desktop to cmd.exe (where C:\Development\ironruby is the root of your GIT repo) looking like CmdShortcut.png at http://www.ironruby.net/Support/Images. The values of the text fields should be like this:

Target: C:\Windows\System32\cmd.exe /k "c:\Development\IronRuby\Merlin\Main\Languages\Ruby\Scripts\Dev.bat"

Start in: c:\Development\IronRuby\Merlin\Main\Languages\Ruby

I highly recommend reading the rest of that wiki entry. It explains how the IronRuby sources are laid out.

I’m also made a change to Dev.bat. On line 43, after :EnvDone, the script changes the path. I’m going to prepend the path to the IronRuby interpreter, which we’ll compile in the next step. Why prepend? Well, I also have MRI in my path, and I found that the commands in C:\Ruby\bin were getting called instead of the IronRuby versions. This is what I believe was leading to all the difficulties I had in the past. So, the call to SET PATH should look something like this: set PATH=%MERLIN_ROOT%\Bin\debug;%PATH%;%MERLIN_ROOT%\Languages\Ruby\Scripts;%MERLIN_ROOT%\Languages\Ruby\Scripts\bin;%RUBY18_BIN%;%MERLIN_ROOT%\..\External.LCA_RESTRICTED\Languages\IronRuby\mspec\mspec\bin

Addendum – June 14th, 2009

After some feedback on this post from Jimmy Schementi and Jim Deville of the IronRuby team, you’re going to want to set another environment variable, called GEM_BIN. We will reference this variable later, when we go to install gems for IronRuby. After the line that sets GEM_PATH, about line 16, you want to include this additional line: set GEM_BIN=%MERLIN_ROOT%\Languages\Ruby\Scripts\Bin

Adding this will allow us to tell Ruby Gems where to put the scripts needed to run cucumber, or any other gem. I’ve chosen %MERLIN_ROOT%\Languages\Ruby\Scripts\Bin, on Jimmy’s suggestion, because it is already in the path set by Dev.bat, and IronRuby distributes a number of other wrapper scripts, such as igem, irake, and irails in this directory.

4 – Compile IronRuby

Pop open the IronRuby Development console (the shortcut you created in the previous step), and run brbd (Build RuBy Debug).

5 – Install the Cucumber Gem

IronRuby comes with a command called igem, which runs the gem command using IronRuby, as opposed to the standard MRI. In that same development console, run: igem install –-no-rdoc -–no-ri –-bindir %GEM_BIN% cucumber

That’s a lot to type! We could stick all these options into a .gemrc file in our home directory, but this is problematic if you have and use multiple versions of Ruby on your machine (and you most likely will). Any suggestions for accommodating the scenario of multiple Ruby versions with seperate Gem locations would be very much appreciated! Now, back to the show!

I’m choosing to include the –-no-rdoc and -–no-ri because RDoc and RI generation is slooooow, and I can’t recall the last time I looked at either.

I’m also passing the –-bindir argument so that the wrapper scripts for the gems I install will be placed into a directory that is in my path, but will not get overwritten every time I recompile IronRuby.

This will install the gem files into C:\Development\ironruby\Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ironruby\gems\1.8\gems\cucumber-xxxx, where xxxx is the latest version of Cucumber. I’m going to use cucumber-xxxx in the next step to signify the folder that cucumber gets installed into.

This will also install the cucumber & cucumber.bat wrapper scripts into C:\Development\ironruby\Merlin\Main\Bin\debugC:\Development\ironruby\Merlin\Main\Languages\Ruby\Scripts\Bin

6 – Verify that it Works

Here comes the cool part. In that same IronRuby dev console window, do the following:

cd C:\Development\ironruby\Merlin\External.LCA_RESTRICTED\Languages\Ruby\redist-libs\ironruby\gems\1.8\gems\cucumber-xxxx\examples\cs
compile.bat
cucumber features

This is the output that I got:

*** WARNING: You must "gem install win32console" (1.2.0 or higher) to get colour
ed output on MRI/Windows
Feature: Addition
  In order to avoid silly mistakes
  As a math idiot
  I want to be told the sum of two numbers

unknown:0: warning: multiple values for a block parameter (2 for 1)
unknown:0: warning: multiple values for a block parameter (2 for 1)
  Scenario Outline: Add two numbers                    # features/addition.feature:6
unknown:0: warning: multiple values for a block parameter (2 for 1)
    Given I have entered
 into the calculator # features/step_definitons/calculator_steps.rb:9
unknown:0: warning: multiple values for a block parameter (2 for 1)
    And I have entered
 into the calculator   # features/step_definitons/calculator_steps.rb:9
unknown:0: warning: multiple values for a block parameter (2 for 1)
    When I press add                                   # features/step_definitons/calculator_steps.rb:13
unknown:0: warning: multiple values for a block parameter (2 for 1)
    Then the result should be  on the screen   # features/step_definitons/calculator_steps.rb:17

    Examples:
      | input_1 | input_2 | output |
      | 20      | 30      | 50     |
      | 2       | 5       | 7      |
      | 0       | 40      | 40     |

3 scenarios (3 passed)
12 steps (12 passed)
0m3.734s

Notice that there are still some warnings. I know John Lam and the rest of the IronRuby team are working hard for to get this working for the 1.0 release, due on or about July 23rd, 2009. Most importantly, though, it functions now. Cool beans!

SUPER KIND-OF IMPORTANT NOTE!

Any time you rebuild IronRuby, the C# compiler will erase the contents of the directory C:\Development\IronRuby\Merlin\Main\Bin\Debug. This includes the cucumber and cucumber.bat files. The only way I know to rectify this is to igem install -–no-rdoc -–no-ri cucumber once again. Thanks to feedback from the IronRuby team, I’ve detailed a fix above. You will only have to install gems once, regardless of how often you recompile IronRuby.

Unit Testing ASP.Net?

Posted in Uncategorized on May 18th, 2009 by Will – 2 Comments

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.

Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle – and for the launch will be giving out FREE licenses to bloggers and their readers.

The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you’ll get a license automatically (even if more than 60 submit) during the first week of this announcement.

Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

Go ahead, click the following link for more information on how to get your free license.

Continuous Improvement, Days 3 + 4: Team City ROCKS!

Posted in Continuous Improvement on February 12th, 2009 by Will – Be the first to comment

Day 3

I gave a presentation to my team yesterday morning about Continuous Integration and how I was implementing it with TeamCity. It was intended to be a quick, 5-minute job. It ended up be a half hour discussion, a back-and-forth. My team was engaged, asking questions, and enthusiastic about what I was doing; they understood why this is a good thing. Rock on!

So, I’ve really been able to step into a leadership role this week. My primary focus has been attempting to understanding a troublesome application that the client had never been satisfied with, yet the organization is now dependant upon (Policies and Procedures… BIG deal in Hospital), and guiding a contractor on the changes that need to be made (I guess I’ve been wearing my architect hat). It’s nice that I’ve been able to think of things at a higher level of abstraction and describe this to the programmer to that we write better code. I guess you can say I’m doing some BDD, but without the tests to verify the behavior. I know, I know. Baby steps.

Another major project I’ve been working on involves work by an outside vendor. They keep their code in a Subversion repository. To support my team’s part of the development, I set up a VisualSVN server on our local source-control server. Working with the vendor, we set up a bunch of svn:externals in my repo to pull their stuff in. Why is this important? Well, it was this combination of externals, combined with the fact that they require different authentication than my local workstation credentials, that made setting this project up in TeamCity, um… challenging. I was able to finally get it working with some guidance from Kirill Maximov (I think of the JetBrains team). The confusion was mostly mine. Once I understood that the external files were pushed in from the external VCS, instead of the local VCS root pulling in the externals, I was able to get things working. Yay!

Day 4

Today started off with some fire extinguishing. At my organization, we have an SSL VPN that allows us to customize the login screens with a set of templates. Since the login screens look like they are a part of our public web site, In order to reduce the maintenance overhead, I opted to share the style sheets with the login templates. Because we have to support IE 6 (the organization is still predominantly IE 6), I use conditional comments to server an additional stylesheet to IE 6 only, that overrides the main styles. Well, a software update over the weekend caused the VPN appliance to strip all HTML comments from the templates. This, of course, broke the login pages (in that some elements overlapped the form fields, preventing people, like the Center Director, from logging remotely). We were getting nowhere fast with the vendor, so I changed the markup of the pages to use tables to mimic a 2-column grid. Fire extinguished.

Next, it was off to a meeting with a client. She was overall very happy with the progress made so far, but she had some bugs she wanted to demonstrate to me. I also wanted to talk to her about her expectations for the administration part. I figured that this would be a great opportunity to try out the BDD style of describing a feature that cucumber promotes:

As a  [Role]
I want [Feature]
So that [Benefit]

(or some variant thereof)

Once the client took me through the bugs she found, I walked her through the process of documenting the administration feature. It was great! There was this continual back and forth, and in the end, we both had a better understanding of how the feature should work. I know the process could be improved, but this was once heck of a start! I highly recommend this method to everyone.

During lunch, I decided to try and capitalize on the enthusiasm my team showed for my work so far. One of the topics that came up during the team meeting was a concern that we were still using Visual SourceSafe 6 (yeah, I know), which, as someone pointed out, is about 10 years old. Everyone in attendance was in agreement that we should upgrade. As I was researching upgrading to VSS 2005, I found out that this version keeps the database compatibility with VSS 6, while introducing a new workflow. One of the biggest gripes I have with VSS 6 is the Lock-Modify-Unlock (LMU) mode of operation. Very outdated, and very counter-productive, especially in the following scenario:

Developer A is tasked with a non-trivial implementation of a new feature
Developer B is tasked with fixing a bug, and traces it down to one of the files Developer A is working on.

With the LMU model, either Developer A has to jump through hoops to save their work elsewhere and undo their checkout so Developer B can work, or Developer B has to wait to fix the bug until Developer A finishes their feature some time in the future. In either case, some form of merging will need to take place.

VSS 2005 introduces the Copy-Modify-Merge (CMM) mode of operation more familiar to Subversion users. So, I opened a discussion with my team about enabling this option during the upgrade. There was some initial resistance, based on a perceived notion that forcing developers to talk to each other about the content of the changes to a file during a merge would somehow introduce more bugs into the code. I countered that this communication was desirable, as it forced more discussion of the code and increased the number of developers with knowledge of a given module of code. This, in turn, reduced the risk to the organization of the dreaded “hit by a bus” scenario. Plus, I proposed that we timebox the CMM mode of operation to a month, and analyze the results afterwards. This was enough to get the dissenters on board, and the blessing of my Team Lead and my Manager. FTW!

I’m sure some of you can see where I’m going with this; Ultimately, I aim to get us out of VSS altogether, and into Subversion. Why subversion? Once we’re on the CMM model in VSS, moving to subversion will be far less of a shock than, say, git. Not that git is out of the question in the future, but git hasn’t clicked for me yet (I haven’t used it much yet), and I would need to train the rest of the team on git. That’s more than I can handle right now. Baby steps.

Finally today, I followed the suggestion of TeamCity and migrated from the local HSQL database to a full-blown database server. In my case, this meant SQL Server 2005. Not exactly the smoothest ride with Integrated Windows (formerly NTLM) authentication, by which I mean no one explicitly documented the process end-to end. The key, it turns out, is to add the ntlmauth.dll to the TeamCity bin directory. Of course, after that, be sure that you change the the account that your TeamCity web service runs as to be the same user that you’re going to connect to the database with. Remember, we’re talking Windows Authentication here, NOT SQL Server Authentication.

So, in summary:

  • My team is wicked receptive to all the concepts I’ve introduced so far
  • My team includes skeptics, but open-minded skeptics willing to compromise
  • TeamCity ROCKS because its not tied to a specific VCS, and there are plugins for just about any VCS
  • TeamCity also ROCKS because it is helping expose flaws in the structure of our projects that is making things more difficult than it needs to be

My plans for world domination improving my development team are progressing nicely.

Continuous Improvement: Day 2

Posted in Continuous Improvement on February 10th, 2009 by Will – 3 Comments

Just a short post tonight. It was a long, hectic day, and I didn’t get enough sleep last night.

Day two on my journey of Continuous Improvement saw me getting one of my team’s projects set up to automatically build through TeamCity. After fixing a couple project reference issues, I was able to get our public website project building. We use the Visual Studio 2008 Web Site model; we do not precompile the project in any way before deploying to production. This caused a problem in TeamCity. This is because the Build target for Web Site Projects doesn’t do anything. Instead I had to set the build target to Publish. This causes the web site to be precompiled. I did this all on my lunch break :) I’ve recommended to my manager that he include the cost of an enterprise license in his budget for the next fiscal year.

Once I got the automated build working, I was wicked excited. I spoke with a fellow Senior Developer and our Lead Analyst about what I had accomplished. Both were equally excited. they basically had the same thing to say:

We know our current process is broken. I’m glad you’re doing something about it.

Rock on!

I gave my manager a quick update on what I’ve accomplished so far. He was equally excited. Then he asked the million dollar question:

Does what you have done require your team members to change their workflow?

To which I happily replied: No. This was the right answer at this stage of the game. We’re shooting for low-to-no friction to get the ball rolling.

What I meant was: Not Yet! ;)

I’m presenting my work so far to the team tomorrow at our weekly meeting (note to self: include replacement of weekly, hour-long meeting with daily, 15-minute stand ups in future plans).

Continuous Improvement, Day 1: Hello, TeamCity!

Posted in Continuous Improvement on February 9th, 2009 by Will – 1 Comment

Wow, is that post title an oxymoron? What was the tag line on my blog again? ;)

Today was the start of my journey on the road of Continuous Improvement. One of the big things I took away from acts_as_conference was “Just F***in Do It”. Or, put a little more eloquently by Corey Haines (who I later found out was paraphrasing Ghandi):

Be the trouble you want to see.

So, as it turns out, I’ve garnered a certain level of respect with my manager. Basically, my manager provided me with an opportunity to plant the seed of the ideas (which, admittedly, are still germinating in me) that I’ve been able to gave name to recently. Guess what. He was totally receptive! Awesome! I mentioned Continuous Integration, gave him a brief schpeil on the potential benefits, and, perhaps the real selling point, a free tool (recommended by Cory Foy) to do it with. “Great!”

Awesome!

Between helping the new contractor get adjusted, dealing with a SharePoint migration issue, and warding off other departments from dumping their vendor issues on my shoulders, I installed Team City on our source control server (did I mention that I hate VSS? Note to self: migrating it to SVN should be in my Continuous Improvement plan). WOW. I mean, WOW! That was dead freaking simple! I struggled with CruiseControl.NET for what must have been a week, and I had no working build system (recall the part about VSS). FAIL! I spent a whopping half an hour setting up a build, with system tray monitor AND Visual Studio integration. PASS! However, the build failed, exposing a flaw in the project file. Developer FAIL!

Poet Mattie J.T. Stepanek once wrote:

Every journey begins with but a small step and every day is a chance for a new, small step in the right direction.

Baby steps, folks, baby steps.

A Confession: I don’t do TDD, but I know I should

Posted in Continuous Improvement, testing on February 8th, 2009 by Will – 2 Comments

So, I was at acts_as_conference 2009 this past weekend. I met a lot of great people, especially the two Coreys: Cory Foy and Corey Haines, who were kind enough to spend a lot of time having very thoughtful discussions with me. The thing that struck me the most was the attitude of everyone in attendance: your code is your craft, your art, your expression of you. As such, you should exhibit pride in your work. The way we, as programmers, have to do that is working code, and the way you prove that is with tests.

This morning, I read an article from one of the Pivotal Labs guys that sums it up pretty well:

In short, if you write software, and you’re not writing tests, then you’re not doing your job.

I don’t mean not doing your job like a waiter who doesn’t take your order quickly enough; I mean not doing your job like a surgeon who operates without washing his or her hands. As in completely unacceptable performance.

This is an idea that Corey Haines also echoed, though he put it more severly: if you’re not writing tests, you are negligent.

I was reluctant to agree at first, but that is largely because all of the code I, and my team, write and maintain on a daily basis contains exactly ZERO tests. None. Nada. Zip. 0. I need to change this. I’m working through some ideas on how to accomplish this, and I plan to chronicle it here with a series of blog posts.

To that end, I’ve listened to a couple of the Alt.Net podcasts, some Hanselminutes podcasts, and I intend to read up a bit on LEAN manufacturing to really get my head around these ideas. My goal is to figure out the best way to imporve my team and our work; to turn us in to craftsmen (and women). In the mean time, if you have any sage advice on books I should read, approaches I should consider, tools we could/should use, even suggestions on the way we structure our projects, I am open and receptive.

I am an empty vessel. I invite you to fill me up.

Rails 2.3.0 + IIS7 + FastCGI = Rails on Windows FTW!

Posted in rails, ruby on February 8th, 2009 by Will – 6 Comments

I love Rails, and I run Windows.

There, I said it. I know many Railers scoff at us, mock us, etc. Whatever. I run Windows (Vista, specifically). I’m a Microsoft.Net Web Developer at my day job. My company has invested heavily in the Microsoft platform. I don’t like WebForms (why is a topic for another post), and, because of Rails, I know there is a better way to do web development. Yes, I know about ASP.Net MVC, but I have yet to try it. What I have tried is Rails, and I know that a Microsoft stack is the way to get it into my day-to-day work.

So, a couple of days ago, with the announcement of Rails 2.3.0 rc1 I decided to see if I could get the latest Rails running under IIS 7 on my Vista notebook. I tried to find directions on how to accomplish this, but none were very straight forward. So, I’ve decided to document the process here for myself and other WinRailers.

read more »

Hello world!

Posted in Uncategorized on October 7th, 2008 by Will – Be the first to comment

Ok, so I’m finally blogging again. Why? A SharePoint contractor at my office today asked me if I had written up a blog post about the SharePoint Master Page I had created to match the branding of my company’s web site (which I also deisgned and implemented). So, I intend to use my blog as a platform for showcasing this, and other, works of mine.

So, stay tuned not only for blog posts, but also full-blown articles on web development, web design, and pretty much anything else that interrests me.