Plugins - RSpec on rails matchers

StarAdd to favorites

In your view spec:

it "should render new form" do
render "/users/new.html.erb"

response.should have_form_posting_to(users_path) do
with_text_field_for(:user_name)
with_text_area_for(:user_address)
with_text_field_for(:user_login)
with_text_field_for(:user_email)
with_submit_button
end
end

In your model spec:

describe User do
before(:each) do
@user = User.new
end

it "should have many posts" do
@user.should have_many(:posts)
end

it "should belong to a group" do
@user.should belong_to(:group)
end

it do
@user.should validate_presence_of(:email)
end

it do
@user.should validate_uniqueness_of(:email)
end

it do
@user.should validate_uniqueness_of(:login)
end

it do
@user.should validate_presence_of(:login)
end

it do
@user.should validate_presence_of(:name)
end

it do
@user.should validate_length_of(:password, :between => 4..40)
end

it do
@user.should validate_confirmation_of(:password)
end

end

Josh Knowles - Bryan Helmkamp - Matt Aimonetti

http://code.google.com/p/rspec-on-rails-matchers/

http://rspec-on-rails-matchers.googlecode.com/svn/trunk/

Rails' (MIT)

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Testing

Tags

Comments

Add a comment
gmarik 8 May 2008

on GitHub now http://github.com/joshknowles/rspec-on-rails-matchers

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?