<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
Are you looking for something like this<div><br class="webkit-block-placeholder"></div><div>lambda { @audience.stats = 'Market Goblin' }.should raise_error</div><div><br class="webkit-block-placeholder"></div><div><br><div><div>On 30/01/2008, at 1:48 PM, Andrew WC Brown wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div>Trying to spec the following but don't know if I'm using the right matcher.</div><div>How do I spec? Plz, sugar on tops.</div><div><br class="webkit-block-placeholder"></div><div>Audience.stats</div><div> - should have a stats of 80 when passed a flux of 10</div><div>- should return an error when passed a string (ERROR - 1)</div><div><br class="webkit-block-placeholder"></div><div>1)</div><div>TypeError in 'Audience.stats should return an error when passed a string'</div> <div>String can't be coerced into Fixnum</div><div>./audience.rb:11:in `*'</div><div>./audience.rb:11:in `stats='</div><div>./audience_spec.rb:29:</div><div><br class="webkit-block-placeholder"></div><div>Finished in 0.006333 seconds</div> <div><br class="webkit-block-placeholder"></div><div>2 examples, 1 failure</div><div>monsterbox:spec andrew_wc_brown$ </div><div><br class="webkit-block-placeholder"></div></div><div><br class="webkit-block-placeholder"></div> <div><br class="webkit-block-placeholder"></div><div>class Audience</div><div> </div><div> attr_accessor :stats</div><div> </div><div> def initialize(name = nil,value = nil) </div><div> @name ||= 'all'</div> <div> @value ||= value</div><div> end</div><div> </div><div> def stats=(flux)</div><div> @stats = @value * flux / 0.025</div><div> end</div><div><br class="webkit-block-placeholder"></div><div> def market_share</div> <div> "The Market share is for #{@name} at a high of #{@stats}"</div><div> end</div><div> </div><div>end</div><div><br class="webkit-block-placeholder"></div><div>describe "Audience.stats" do</div> <div> </div><div>before :all do</div><div> @audience = Audience.new(nil,20)</div><div>end</div><div> </div><div> it "should have a stats of 80 when passed a flux of 10" do</div><div> @audience.stats = 10</div> <div> @audience.stats.should == 8000</div><div> end</div><div> </div><div> it "should return an error when passed a string" do</div><div> @audience.stats = 'Market Goblin'</div><div> @audience.stats.should raise_error</div> <div> end</div><div>end</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">rspec-users mailing list</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a></div> </blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br></div></span></span></span></span></span> </div><br></div></body></html>