Sha256: 4a2b2d921ac102c614335f68603e2fdd5812ff090badb2e4299fe2b39e0d3e4c
Contents?: true
Size: 968 Bytes
Versions: 12
Compression:
Stored size: 968 Bytes
Contents
require 'spec_helper' describe Alchemy::Admin::BaseController do describe '#options_from_params' do subject { controller.send(:options_from_params) } context "params[:options] is a JSON string" do before { controller.stub(:params).and_return(options: '{"hallo":"World"}') } it "parses the string into an object" do expect(subject).to be_an_instance_of(Hash) expect(subject).to eq({hallo: 'World'}) end end context "params[:options] is already an object" do before { controller.stub(:params).and_return(options: {hallo: "World"}) } it "parses the string into an object" do expect(subject).to be_an_instance_of(Hash) end end context "params[:options] is not present" do before { controller.stub(:params).and_return({}) } it "returns ampty object" do expect(subject).to be_an_instance_of(Hash) expect(subject).to eq({}) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems