public
Rubygem
Description: BDD that talks to domain experts first and code second
Homepage: http://cukes.info/
Clone URL: git://github.com/aslakhellesoy/cucumber.git
Getting down to business with IronRuby
aslakhellesoy (author)
Wed Dec 03 11:18:58 -0800 2008
commit  30094a6fc3f061c706e4ef0b2f0f2dec8f5c0c69
tree    ea1a53bb266eb0fb95b579d33d7d5e77aa09bb3d
parent  d68fc2debcbfb63724e3606bedcb827b74c65543
...
11
12
13
14
15
16
17
18
19
20
21
22
23
...
11
12
13
 
 
 
 
 
 
 
14
15
16
0
@@ -11,13 +11,6 @@ cucumber.yml
0
 examples/calculator_ruby_features/Rakefile
0
 examples/calculator_ruby_features/features/addition.rb
0
 examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb
0
-examples/cs/README.textile
0
-examples/cs/Rakefile
0
-examples/cs/features/hello.feature
0
-examples/cs/features/step_definitons/hello_steps.rb
0
-examples/cs/features/step_definitons/tree_steps.rb
0
-examples/cs/features/tree.feature
0
-examples/cs/src/Hello.cs
0
 examples/dos_line_endings/Rakefile
0
 examples/dos_line_endings/features/dos_line_endings.feature
0
 examples/i18n/README.textile
...
1
 
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
6
7
8
9
 
 
 
 
 
 
 
10
11
 
 
 
12
13
 
 
 
 
 
14
15
16
 
 
 
 
17
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
22
 
...
 
1
2
 
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
 
57
58
59
60
61
62
63
64
 
65
66
67
68
 
69
70
71
72
73
74
75
 
76
77
78
79
80
81
 
 
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 
110
0
@@ -1,22 +1,110 @@
0
-h1. Using Cucumber with Java
0
+h1. Using Cucumber with C#
0
 
0
-This directory contains code to demonstrate how Cucumber can be used to develop Java code.
0
-You need JRuby 1.1.3 or higher installed and JRuby's bin directory on your PATH.
0
+This directory contains code to demonstrate how Cucumber can be used to develop C# code.
0
+You need both IronRuby and MRI (Matz Ruby Interpreter).
0
+
0
+h2. Installing MRI
0
+
0
+You'll need MRI to build IronRuby. You also need MRI to install gems since IronRuby can
0
+not install its own gems yet (although it can use them). When you have installed IronRuby you 
0
+can use gems installed into MRI from IronRuby.
0
+
0
+Just download the latest Ruby One click installer from RubyForge and run it with the defaults.
0
+When you open a new command prompt you should be able to run:
0
+
0
+<pre>ruby --version</pre>
0
+
0
+and
0
+
0
+<pre>rake --version</pre>
0
+
0
+h2. Installing IronRuby
0
+
0
+With MRI installed we can install IronRuby. At the time of this writing there is no installer
0
+for IronRuby, so you have to download the IronRuby sources from the Subversion repository and build 
0
+it yourself.
0
+
0
+If you don't have Subversion installed, install the Subversion command line toolset (or TortoiseSvn
0
+if you have command line fobia).
0
+
0
+h3. Get IronRuby sources
0
+
0
+<pre>svn checkout http://ironruby.rubyforge.org/svn/trunk ironruby
0
+cd ironruby
0
+</pre>
0
+
0
+Note: *checkout* means "pull down a copy of the sources to my local machine". It's not the same
0
+as checkout in TFS or Visual SourceSafe (which I truly hope you have moved past).
0
+
0
+h3. Build IronRuby
0
+
0
+Open a Visual Studio command prompt and cd to where you downloaded the IronRuby sources. Build it:
0
+
0
+<code>rake build</code>
0
+
0
+When you have completed this step you should be able to run
0
+
0
+<code>build\debug\ir.exe <code>
0
+
0
+This should give you a new prompt (Interactive IronRuby shell). Just type <code>exit</code>
0
+and hit enter. You have installed IronRuby!
0
+
0
+You can now close your Visual Studio command prompt. From here on a regular command prompt
0
+will suffice.
0
 
0
 h2. Installing required gems
0
 
0
-jruby -S gem install aslakhellesoy-cucumber
0
-jruby -S gem install diff-lcs
0
+Since IronRuby doesn't yet know how to install gems you have to install them using MRI:
0
+
0
+<pre>gem install cucumber
0
+ruby gem install rspec
0
+</pre>
0
+
0
+h2. Creating a cucumber wrapper script for IronRuby
0
 
0
-h2. Running the scenarios
0
+When Cucumber is installed, a cucumber.bat script is placed under your MRI's bin directory.
0
+This script will run cucumber with MRI. We'll make a similar one that will launch Cucumber
0
+with IronRuby.
0
 
0
-Open a shell in this directory (java) and execute the following command:
0
+Create an empty file called <code>icucumber.bat</code> in MRI's bin directory.
0
+Open it in your favourite text editor (I hope you have installed something better than
0
+Notepad, but it will do). 
0
+
0
+On my system icucumber.bat looks like this (You may have to change the paths).
0
 
0
 <pre><code>
0
-jruby -S rake features
0
+@ECHO OFF
0
+REM This is to tell IronRuby where to find gems.
0
+SET GEM_PATH=%~dp0..\lib\ruby\gems\1.8
0
+@"C:\scm\ironruby\build\debug\ir.exe" "%~dp0cucumber" %*
0
 </code></pre>
0
 
0
-This will compile the java code and package it in a jar file, and then run Cucumber against
0
-that code.
0
+Tip: <code>%~dp0</code> evaluates to "current script's directory with trailing backslash" in case
0
+you're wondering what this is.
0
+
0
+Now you should be able to run Cucumber:
0
+
0
+<code>icucumber --help<code>
0
+
0
+h2. Running the Cucumber C# example
0
+
0
+Open a command prompt and cd to the Cucumber examples directory for C#. If you have installed MRI to the default
0
+location you'll find them under <code>C:\ruby\lib\ruby\gems\1.8\gems\cucumber-X.Y.Z\examples</code>
0
+
0
+(Replace <code>X.Y.Z</code> with the Cucumber version you installed above)
0
+
0
+h3. Run the plain ruby example
0
+
0
+<pre><code>
0
+cd i18n\en
0
+icucumber features
0
+</code></pre>
0
+
0
+h3. Run the C# example
0
+
0
+<pre><code>
0
+cd cs
0
+icucumber features
0
+</code></pre>
0
 
0
-There is a deliberate error. See if you can fix it!
0
+There is a deliberate error in the C# code. See if you can fix it!
...
8
9
10
11
 
12
13
...
8
9
10
 
11
12
13
0
@@ -8,5 +8,5 @@ end
0
 task :features => :compile
0
 
0
 task :compile do
0
-  sh "csc /target:library /out:Cucumber.Demo.dll src\\Hello.cs"
0
+  sh "csc /target:library /out:Demo.dll src\\demo\\Calculator.cs"
0
 end
0
\ No newline at end of file
...
24
25
26
27
28
29
30
31
...
24
25
26
 
 
 
 
 
0
@@ -24,8 +24,3 @@ end
0
 Then /the result class should be (\w*)/ do |class_name|
0
   @result.class.name.should == class_name
0
 end
0
-
0
-Given /it should rain on (\w+)/ do |day|
0
-  @calc.rain?(day).should == true
0
-end
0
-
...
7
8
9
10
11
12
13
...
7
8
9
 
 
 
 
0
@@ -7,7 +7,3 @@ $CUCUMBER_IRONRUBY    = Config::CONFIG['sitedir'] =~ /IronRuby/
0
 $CUCUMBER_WINDOWS     = Config::CONFIG['host_os'] =~ /mswin|mingw/
0
 $CUCUMBER_WINDOWS_MRI = $CUCUMBER_WINDOWS && !$CUCUMBER_JRUBY && !$CUCUMBER_IRONRUBY
0
 $CUCUMBER_RAILS       = defined?(Rails)
0
-
0
-if $CUCUMBER_IRONRUBY
0
-  ENV['GEM_PATH'] ||= "C:/ruby/lib/ruby/gems/1.8"
0
-end
...
41
42
43
 
 
 
 
 
 
 
 
44
45
46
...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
0
@@ -41,6 +41,14 @@ module Cucumber
0
           format_error(strip_pos, proc, e)
0
         rescue => e
0
           method_line = "#{__FILE__}:#{__LINE__ - 6}:in `execute_in'"
0
+
0
+          # IronRuby returns nil for backtrace...
0
+          if e.backtrace.nil?
0
+            def e.backtrace
0
+              @cucumber_backtrace ||= []
0
+            end
0
+          end
0
+
0
           method_line_pos = e.backtrace.index(method_line)
0
           if method_line_pos
0
             strip_pos = method_line_pos - (Pending === e ? PENDING_ADJUSTMENT : REGULAR_ADJUSTMENT) 

Comments