Sha256: 779ad39c66716c43ae6993d5243ae735dc1f26e991bc8e73bf11a915cd4b1b59

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ExceptController do
  include RSpec::Rails::ControllerExampleGroup
  
  it "should limit those attribute to ONLY those actions" do
    post :update, :foo => "hi"
    response.code.should == "200"
  end
  
  it "should disallow unknown attributes from those actions" do
    begin
      post :update, :bar => "hi"
      raise "should fail"
    rescue ParamAccessible::Error => e
      e.inaccessible_params.should == %w(bar)
    end
  end
  
  it "should obey nested attributes" do
    post :create, :bar => {:baz => 'hi'}
    response.code.should == "200"
  end
  
  it "should catch invalid nested attributes for those actions" do
    begin
      post :create, :bar => {:foo => 'hi'}
      raise "should fail"
    rescue ParamAccessible::Error => e
      e.inaccessible_params.should == %w(bar[foo])
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
param_accessible-0.0.2 spec/lib/except_spec.rb
param_accessible-0.0.1 spec/lib/except_spec.rb