Sha256: 38b03ec5449cdeef57032c89369a5ce8205dfb600f584da2b7cd5a896c266a91

Contents?: true

Size: 1.99 KB

Versions: 6

Compression:

Stored size: 1.99 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))

Merb.start(
  :merb_root => File.dirname(__FILE__) / "test_app",
  :fork_for_class_load => false
)
Merb::Config[:log_stream] = File.open("/dev/null", "w")
Merb.reset_logger!

describe "an app tested using the webrat proxies" do
  describe("#visits") do
    it "supports visits" do
      visits("/testing")
    end
  
    it "can use the Merb expectations with visits" do
      visits("/testing").should be_successful
    end
  
    it "supports visits intermixed with request" do
      request("/testing")
      resp = visits("/testing/next")
      resp.should have_xpath("//p")
    end
  end
  
  describe("#click_link") do
    it "supports click_link" do
      visit "/testing"
      click_link "Next"
    end
    
    it "can use the Merb expectations with click_link" do
      visit "/testing"
      resp = click_link "Next"
      resp.should have_xpath("//p[contains(., 'Got to next')]")
    end
    
    it "supports click_link after a request" do
      request("/testing")
      resp = click_link "Next"
      resp.should have_xpath("//p[contains(., 'Got to next')]")
    end
  end
  
  describe "filling in forms" do
    it "lets you fill in text fields" do
      visit "/testing/show_form"
      fill_in "Name", :with => "Merby"
      fill_in "Address", :with => "82 South Park"
      click_button "Submit!"
    end
    
    it "returns the response when you fill in text fields" do
      visit "/testing/show_form"
      fill_in "name", :with => "Merby"
      fill_in "address", :with => "82 South Park"
      resp = click_button "Submit!"
      resp.should have_xpath("//p[contains(., 'Merby')]")
    end
    
    it "lets you check checkboxes" do
      visit "/testing/show_form"
      check "Tis truez"
    end
    
    it "returns the response when you check checkboxes" do
      visit "/testing/show_form"
      check "Tis truez"
      resp = click_button "Submit!"
      resp.should have_xpath("//p[contains(., 'truez: 1')]")
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
merb-core-1.1.3 spec10/public/webrat/webrat_spec.rb
merb-core-1.1.2 spec10/public/webrat/webrat_spec.rb
merb-core-1.1.1 spec10/public/webrat/webrat_spec.rb
merb-core-1.1.0 spec10/public/webrat/webrat_spec.rb
merb-core-1.1.0.rc1 spec10/public/webrat/webrat_spec.rb
merb-core-1.1.0.pre spec10/public/webrat/webrat_spec.rb