Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b11800fd7c
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (27 sloc) 1.058 kb
Feature: errors_on
Scenario: with one validation error
Given a file named "spec/models/widget_spec.rb" with:
"""
require "spec_helper"
class ValidatingWidget < ActiveRecord::Base
set_table_name :widgets
validates_presence_of :name
attr_accessible :name
end
describe ValidatingWidget do
it "fails validation with no name (using error_on)" do
ValidatingWidget.new.should have(1).error_on(:name)
end
it "fails validation with no name (using errors_on)" do
ValidatingWidget.new.should have(1).errors_on(:name)
end
it "passes validation with a name (using 0)" do
ValidatingWidget.new(:name => "liquid nitrogen").should have(0).errors_on(:name)
end
it "passes validation with a name (using :no)" do
ValidatingWidget.new(:name => "liquid nitrogen").should have(:no).errors_on(:name)
end
end
"""
When I run `rspec spec/models/widget_spec.rb`
Then the examples should all pass
Jump to Line
Something went wrong with that request. Please try again.