Suppose we have the following Controller with an argible-ized action:
class CalculatorController < ApplicationController
argible(:first => :to_i, :second => :to_i)
def add(first, second)
@result = first + second
end
end
And here is the associated RSpec test:
describe CalculatorController, "add action" do
controller_name :calculator
it "should add argument values" do
post :add, :first => "18", :second => "2"
controller.instance_variable_get(:@result).should == 20
end
end
You can see from the test that you do not need to do anything special to test your argible annotated action methods. Just call the action with whatever parameter name and values your action requires.
1 comment:
argibley.RSpec.tacular
Post a Comment