Hey guys,

 Happy new year!

RSpec lovers, here is the new toy you won't be able to live without:

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

It comes with its own TextMate Bundle:
http://rspec-on-rails-matchers.googlecode.com/files/RSpecOnRailsMatchers.tmbundle.zip

What's the big deal? Well you can now do stuff like that:

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

check the readme file  
http://rspec-on-rails-matchers.googlecode.com/svn/trunk/README
for more info

Enjoy :)

-Matt
--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to