README in remarkable_rails-3.0.0 vs README in remarkable_rails-3.0.1

- old
+ new

@@ -1,2 +1,83 @@ -Remarkable Rails -================ += Remarkable Rails + +Remarkable Rails is a collection of matchers to Rails. This package has some +ActionController matchers and soon some ActionView matchers. + +Whenever using the Remarkable Rails gem and ActiveRecord, it will automatically +add your ActiveRecord matchers. So just one line is needed to install both: + + sudo gem install remarkable_rails + +== Matchers & Macros + +The supported matchers and macros are: + + assign_to, filter_params, render_with_layout, respond_with, + respond_with_content_type, route, set_session and set_the_flash matchers. + +In Remarkable 3.0, we also ported and extended redirect to and render template +from rspec rails matchers to provide I18n. You can also do: + + render_template 'edit', :layout => 'default' + respond_with 404, :content_type => Mime::XML, :body => /Not found/ + +== Macro stubs + +Another cool feature in Remarkable 3.0 is macro stubs, which makes your mocks +and stubs DRY and easier to maintain. An rspec default scaffold would be: + + describe TasksController do + def mock_task(stubs={}) + @task ||= mock_model(Task, stubs) + end + + describe “responding to #POST create” do + it "exposes a newly created task as @task" do + Task.should_receive(:new).with({'these' => 'params'}). + and_return(mock_task(:save => true)) + post :create, :task => {:these => 'params'} + assigns[:task].should equal(mock_task) + end + + it "redirects to the created task" do + Task.stub!(:new).and_return(mock_task(:save => true)) + post :create, :task => {} + response.should redirect_to(task_url(mock_task)) + end + end + end + +An equivalent in remarkable would be: + + describe TasksController do + mock_models :task + + describe :post => :create, :task => { :these => 'params' } do + expects :new, :on => Task, with => {'these' => 'params'}, :returns => mock_task + expects :save, :on => mock_task, :returns => true + + should_assign_to :task, :with => mock_task + should_redirect_to { task_url(mock_task) } + end + end + +It automatically performs the action before running each macro. In assign_to, +it executes the expects as expectations (:should_receive), and in redirect_to +it executes the expects as stubs (:stub!), just as above. + +There are also params and mime methods: + + describe TasksController + params :project_id => 42 + mime Mime::HTML + + describe :get => :show, :id => 37 do + should_assign_to :project, :task + + describe Mime::XML do + should_assign_to :project, :task + end + end + end + +And much more. Be sure to check macro stubs documentation.