Natasha,

On 20/11/2008, Natasha Ranney <[EMAIL PROTECTED]> wrote:
> Hi Aidy,
>
> Thanks for your inputs.
>
> I am not very clear what can we use Rspec for? How is it better that
> Test::Unit?

Unit tests can be a way to describe your software system. Traditional
Rspec is a layer above xUnit to make your tests more understandable.

So instead of this

  def test_go_to_google_and_find_google
    browser = Browser.new
    browser.goto("http://google.co.uk";)
    assert(browser.text.include?("Google"))
    browser.close
  end

We have this:

describe Browser do
    it "should go to google and find the word 'Google'" do
    browser = Browser.new
    browser.goto("http://google.co.uk";)
    browser.text.should include("Google")
    browser.close
  end

end

We can also use mocks and stubs

  it "should determine whether the browser is Firefox" do
    browser_factory = mock(:BrowserFactory)
    
browser_factory.should_receive(:create_browser).and_return(FireWatir::Firefox.new)
    browser = Browser.new(browser_factory)
    browser.is_firefox.should == true
  end


Aidy

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to