Instance of Level
class you declaring in Foo's
constructor and @testb
are two different objects.
You might want to edit your Foo
class this way:
class Foo
def initialize(level)
@x = level # very strange name for such a thing.
@a = @x.level
@b = @x.speed
end
# rest of the class body is the same as yours
# so it is omitted
end
And then do your tests:
level = Level.new() # BTW: no need of instance variables here.
foo = Foo.new(level) # good job. Your foo has "captured" the level.
# et cetera