Patrick Collins wrote in post #1035294:
>>     Motrocicle.create
>
> I don't know if this helps, but I am pretty sure "Motrocicle.create"
> isn't what
> you intended to call.
>
> Also, I'd like to point out that:
>
>>       def self.find (name)
>>         found = nil
>>         ObjectSpace.each_object(Motorcycle) { |o|
>>           found = o if o.name == name
>>         }
>>         return found
>>       end
>>
>
> Is very inefficient because it's going to keep iterating through all the
> objects even after it's found the one it's looking for.
>
>   def self.find(name)
>     ObjectSpace.each_object(Motorcycle) do |o|
>       return o if o.name == name
>     end
>   end
>
> Will return found object immediately or nil if nothing is found.
>
> Patrick J. Collins
> http://collinatorstudios.com

ok that was just and error when i copy the code to this post this is the 
rspec output with the problem corrected and the "manual script" also 
includes, (by the way thanks for the advice, your find method is better, 
i dont know how could i just miss it, thanks :D).

q_ro@thor:~/Escritorio/motorcycle_test_app$ rspec motoapp.rb
2
#<Motorcycle:0x7f6e5d4ade68>
800 pounds
500 pounds
red
black
green
blue
true
false
.FFFFFFF

Failures:

  1) Motorcycle finding a motorcycle by name should return an instance 
of the Motorcycle class
     Failure/Error: Unable to find matching line from backtrace
       expected 0 to be a kind of Motorcycle
     # ./motoapp.rb:75

  2) Motorcycle#weight should have a weight of 800 pounds for the 1200 
RT
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `weight' for 0:Fixnum
     # ./motoapp.rb:81

  3) Motorcycle#weight should have a weight of 500 pounds for the 600 GS
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `weight' for 0:Fixnum
     # ./motoapp.rb:85

  4) Motorcycle#available colors should find 'red' and 'black' as 
available colors for the BMW 1200 RT
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `available_colors' for 0:Fixnum
     # ./motoapp.rb:91

  5) Motorcycle#available colors should find 'green' and 'blue' as 
available colors for the BMW 600 GS
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `available_colors' for 0:Fixnum
     # ./motoapp.rb:95

  6) Motorcycle#has_abs? should be true for a motorcycle that appears in 
abs_motorcycles.txt
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `has_abs?' for 0:Fixnum
     # ./motoapp.rb:101

  7) Motorcycle#has_abs? should be false for a motorcycle that does not 
appear in abs_motorcycles.txt
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `has_abs?' for 0:Fixnum
     # ./motoapp.rb:105

Finished in 0.0119 seconds
8 examples, 7 failures


i really don't get it.

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to