Sha256: a64a6e5c2af1e79f889fd239fbae93a56a44dc8880021c70d880c6cf6ab12b0a

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe VkontakteApi::Utils do
  describe ".flatten_arguments" do
    before(:each) do
      @arg1 = double("First argument")
      @arg2 = double("Second argument")
      @flat_arg1 = double("Flattened first argument")
      @flat_arg2 = double("Flattened second argument")
      
      VkontakteApi::Utils.stub(:flatten_argument) do |arg|
        case arg
        when @arg1 then @flat_arg1
        when @arg2 then @flat_arg2
        end
      end
    end
    
    it "sends each value to .flatten_argument" do
      flat_arguments = VkontakteApi::Utils.flatten_arguments(arg1: @arg1, arg2: @arg2)
      flat_arguments.should == { arg1: @flat_arg1, arg2: @flat_arg2 }
    end
  end
  
  describe ".flatten_argument" do
    context "with a flat argument" do
      before(:each) do
        @argument = :flat
      end
      
      it "leaves it untouched" do
        subject.send(:flatten_argument, @argument).should == @argument
      end
    end
    
    context "with an array argument" do
      before(:each) do
        @array_argument = [1, 2, 3]
      end
      
      it "joins the elements with a comma" do
        flat_argument = subject.send(:flatten_argument, @array_argument)
        flat_argument.should == '1,2,3'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vkontakte_api-1.2 spec/vkontakte_api/utils_spec.rb