Sha256: 8ce3230cd42785723f6cd5966676a5e14ac03e13455dd1cb75a61d4cd7f7d0a8

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe 'RubyKhan' do
  describe '.new' do
    before do
      stub_request(:get, 'http://www.KhanAcademy.org/api/v1/topic/probability').
      to_return(body: fixture('probability.json'))
    end

    it "returns a KhanAcademy::Topic" do
      expect(KhanAcademy::Topic.new('probability')).to be_a KhanAcademy::Topic
    end
  end

  describe 'TopicTree' do
    before do
      stub_request(:get, 'http://www.KhanAcademy.org/api/v1/topictree').
      to_return(body: fixture('topictree.json'))
    end

    it "returns a hash of topics" do
      all = KhanAcademy::TopicTree.new
      expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/topictree')).to have_been_made

      expect(all.topics['cs']).to eq "programming"
    end
  end

  describe 'new topic' do
    before do
      stub_request(:get, 'http://www.KhanAcademy.org/api/v1/topic/probability').
      to_return(body: fixture('probability.json'))
    end

    it 'fetches a hash about the topic' do
      probability = KhanAcademy::Topic.new('probability')
      expect(a_request(:get, 'http://www.KhanAcademy.org/api/v1/topic/probability')).to have_been_made
      expect(probability.title).to eq "Probability and statistics"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubykhan-0.0.8 spec/rubykhan_spec.rb
rubykhan-0.0.7 spec/rubykhan_spec.rb
rubykhan-0.0.6 spec/rubykhan_spec.rb
rubykhan-0.0.5 spec/rubykhan_spec.rb
rubykhan-0.0.4 spec/rubykhan_spec.rb