Sha256: 913d03a982dd1fb05138d3eeab09994a2893229ca00724dd8daf2c62ec3a70cb

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

require "spec_helper"

describe "Dejavu" do
  describe "creation" do
    before do
      visit new_product_path
      fill_in "Name", :with => "Mug"
      fill_in "Code", :with => "PT"
      click_button "Create Product"
    end

    it "should redirect me to the new product page after a failed creation" do
      current_path.should == new_product_path
    end

    it "should show the existing errors" do
      page.should have_content("Code is too short")
    end

    it "should have the fields prefilled with the previously entered values" do
      field_should_have "product_name", "Mug"
      field_should_have "product_code", "PT"
    end
  end

  describe "update" do
    before do
      @p = Product.create! :name => "A mug", :code => "PX54"

      visit edit_product_path(@p)
      fill_in "Name", :with => "UA"
      click_button "Update Product"
    end

    it "should redirect me to the edit product page after a failed update" do
      current_path.should == edit_product_path(@p)
    end

    it "should show the existing errors" do
      page.should have_content("Name is too short")
    end

    it "should have the fields prefilled with the previously entered values" do
      field_should_have "product_name", "UA"
      field_should_have "product_code", "PX54"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dejavu-0.1.2 spec/integration/dejavu_spec.rb
dejavu-0.1.1 spec/integration/dejavu_spec.rb
dejavu-0.1.0 spec/integration/dejavu_spec.rb