Hi IronRuby mailing list,
Inspired by a talk by Ben Hall on testing c# with Ruby I thought I'd
give it
a go but
I'm frustratingly stuck at the first hurdle. I've emailed Ben but as
I've
not had an immediate response I thought I'd open it to you good people.
Any way. I thought I'd start off simple and follow Dom Green's blog.
domgreen.com/2010/02/07/pumping-iron-ruby-net-testing/
He's set a class in c# with a simple property (here's mine)
namespace IronRubyAndCSharp
{
public class Person
{
public string FirstName { get; set; }
public Person(string name)
{
FirstName = name;
}
}
}
and tested it like so
require "test/unit"
require "../IronRuby/bin/debug/IronRubyAndCSharp.dll"
class PersonTest < Test::Unit::TestCase
include IronRubyAndCSharp
def test_create_person_called_john
john = Person.new("John")
assert_not_nil(john)
assert_equal("John",Person.FirstName)
end
end
RubyMine(RM) has no problem with the require of the dll but it does have
a
problem recognising the namespace "IronRubyAndCSharp"
and the Person class (squiggly lines ahoy).
When I run the tests in RM I get
NoMethodError: undefined method `FirstName' for
IronRubyAndCSharp::Person:Class
C:/Users/John/Documents/IronRuby/Tests/Person_test.rb:14:in
`test_create_person_called_john'
:0:in `send'
:0:in `each'
C:/Program Files (x86)/IronRuby
0.9.4.0/Lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in
`run_suite'
:0:in `each'
C:\Program Files (x86)\JetBrains\RubyMine
2.0.1\rb\testing\patch\testunit/test/unit/ui/testrunnermediator.rb:36:in
`run_suite'
testrunner.rb:213:in `start_mediator'
C:\Program Files (x86)\JetBrains\RubyMine
2.0.1\rb\testing\patch\testunit/test/unit/ui/teamcity/testrunner.rb:191:in
`start'
testrunnerutilities.rb:28:in `run'
C:/Program Files (x86)/IronRuby
0.9.4.0/Lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
C:/Program Files (x86)/IronRuby
0.9.4.0/Lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
Just in case RubyMine was at fault I dropped out to good old ir.exe
C:\Users\John\Documents\IronRuby\Tests>ir Person_test.rb --name
test_create_pers
on_called_john
Loaded suite Person_test
Started
E
Finished in 0.041992 seconds.
1) Error:
test_create_person_called_john(PersonTest):
NoMethodError: undefined method `FirstName' for
IronRubyAndCSharp::Person:Class
Person_test.rb:14:in `test_create_person_called_john'
:0:in `send'
:0:in `each'
:0:in `each'
testrunner.rb:66:in `start_mediator'
testrunnerutilities.rb:28:in `run'
1 tests, 1 assertions, 0 failures, 1 errors
I've stuck my code up on github
http://github.com/johnnonolan/IronRubyAndCSharp if you feel that was
inclined.
Any pointers, help or whatever much appreciated.
PlzSendMeTehCodez
John(no)
on 2010-02-20 11:16
on 2010-02-20 11:29
ironruby will have 'rubified' the Person class's FirstName method to
first_name and I think you mean to assert against the john instance of
Person (rather than the Person class).
Otherwise it looks pretty close.
Try:
require "test/unit"
require "../IronRuby/bin/debug/IronRubyAndCSharp.dll"
class PersonTest < Test::Unit::TestCase
include IronRubyAndCSharp
def test_create_person_called_john
john = Person.new("John")
assert_not_nil(john)
assert_equal("John",john.first_name)
end
end
On Sat, Feb 20, 2010 at 9:16 PM, John Nolan <johnnonolan@gmail.com>
wrote:
> Hi IronRuby mailing list,
> Inspired by a talk by Ben Hall on testing c# with Ruby I thought I'd give
it
> public string FirstName { get; set; }
> include IronRubyAndCSharp
> NoMethodError: undefined method `FirstName' for
> IronRubyAndCSharp::Person:Class
> C:/Users/John/Documents/IronRuby/Tests/Person_test.rb:14:in
> `test_create_person_called_john'
> :0:in `send'
> :0:in `each'
> C:/Program Files
> (x86)/IronRuby
0.9.4.0/Lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in
`run_suite'
> (x86)/IronRuby 0.9.4.0/Lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
> 1) Error:
> I've stuck my code up on
> github http://github.com/johnnonolan/IronRubyAndCSharp if you feel that
was
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.