Sha256: 6658c55064802572bb27e09e345c36f01d8da2ebcaf223c7be80456acffe2171

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'
require 'lib/auto_generate_test_class'
require 'lib/parameterless_auto_generate_test_class'

describe ApiQueryProvider::Base do
  it "should raise an exception being instanciated directly" do
    lambda { real = ApiQueryProvider::Base.new({}) }.should raise_error(Exception, "this class should never be instanciated directly")
  end
  
  it "should not be manipulated if a deriving class is manipulated" do
    AutoGenerateTestClass.new({:foo => :bar})
    
    ApiQueryProvider::Base.instance_methods.include?(:foo).should == false
  end
  
  describe "extend" do
    it "should raise on missing symbol" do
      real = AutoGenerateTestClass.new({})
      
      lambda { real.extend }.should raise_error(Exception, "not all needed values are present")
    end
    
    it "should allow parameterless api calls" do
      HTTParty.stub(:get) { double(:body => %q({ "id" : "1", "name": "test" })) }
    
      real = ParameterlessAutoGenerateTestClass.new({})
      
      lambda { real.extend }.should_not raise_error
    end
  end
  
  describe "extend!" do
    it "should copy additional fields to the current object" do
      HTTParty.stub(:get) { double(:body => %q({ "id" : "1", "name": "test" })) }
      
      real = AutoGenerateTestClass.new({:id => 1})
      
      real.extend!
      
      real.name.should == "test"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
api-query-provider-0.0.1 spec/base_spec.rb