[rspec-users] catching errors, rspec basics

Shane Mingins smingins at elctech.com
Tue Jan 29 19:59:04 EST 2008


Hmmmm

I just ran this and 2 examples, 0 failures

class Audience

   attr_accessor :stats

   def initialize(name = nil,value = nil)
     @name ||= 'all'
     @value ||= value
   end

   def stats=(flux)
     @stats = @value * flux / 0.025
   end

   def market_share
     "The Market share is for #{@name} at a high of #{@stats}"
   end

end


describe "Audience.stats" do

   before :all do
     @audience = Audience.new(nil,20)
   end

   it  "should have a stats of 80 when passed a flux of 10" do
     @audience.stats = 10
     @audience.stats.should == 8000
   end

   it "should return an error when passed a string" do
     lambda {@audience.stats = 'Market Goblin'}.should raise_error
   end

end
On 30/01/2008, at 1:55 PM, Andrew WC Brown wrote:

> try it, does the same thing ='(
>
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080130/bce87bd0/attachment-0001.html 


More information about the rspec-users mailing list