Sha256: 4ae790493da54ccc40336b48d0aaa59e38984b267d91b813b72217d824a761de

Contents?: true

Size: 1.41 KB

Versions: 19

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe GnipApi::Apis::PowerTrack::Rule do
  before do
    configure_gem
  end
  
  it 'creates a rule' do
    expect(Proc.new{GnipApi::Apis::PowerTrack::Rule.new}).not_to raise_error
  end

  describe 'rule' do
    before do
      @value = 'something'
      @tag = 'tag'
      @rule = GnipApi::Apis::PowerTrack::Rule.new :value => @value, :tag => @tag
    end

    it 'has a value' do
      expect(@rule.value).to eq(@value)
    end
    
    it 'has a tag' do
      expect(@rule.tag).to eq(@tag)
    end
  end

  describe '#attributes' do
    context 'with tag' do
      before do
        @rule = GnipApi::Apis::PowerTrack::Rule.new(:value => 'r1', :tag => 't1')
        @attributes = {:value => 'r1', :tag => 't1'}
      end
      
      it 'returns hash with attributes' do
        expect(@rule.attributes).to eq(@attributes)
      end
    end

    context 'without tag' do
      before do
        @rule = GnipApi::Apis::PowerTrack::Rule.new(:value => 'r1')
        @attributes = {:value => 'r1'}
      end
      
      it 'returns hash with attributes' do
        expect(@rule.attributes).to eq(@attributes)
      end
    end
  end

  describe '#to_json' do
    before do
      @rule = GnipApi::Apis::PowerTrack::Rule.new :value => 'value', :tag => 'tag'
      @json = {:value => 'value', :tag => 'tag'}.to_json
    end
    
    it 'converts to json' do
      expect(@rule.to_json).to eq(@json)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gnip_api-1.1.3 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.1.2 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.1.1 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.1.0 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.0.6 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.0.5 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.0.4 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.0.3 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.0.2 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.0.1 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-1.0.0 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.9 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.8 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.7 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.6 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.5 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.4 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.3 spec/gnip_api/apis/power_track/rule_spec.rb
gnip_api-0.0.2 spec/gnip_api/apis/power_track/rule_spec.rb