spec/rubykhan_spec.rb in rubykhan-0.0.1 vs spec/rubykhan_spec.rb in rubykhan-0.0.2
- old
+ new
@@ -1,11 +1,40 @@
require 'spec_helper'
-describe Rubykhan do
+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
- describe ".new" do
+ it "returns a KhanAcademy::Topic" do
+ expect(KhanAcademy::Topic.new('probability')).to be_a KhanAcademy::Topic
+ end
end
- describe ".configure" do
+ 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
\ No newline at end of file