Sha256: 13cc933cba7eb14f6b486babe38d6caeec5d42830e387b4ab57861f00a83a711

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe 'Stories', :vcr do
  let(:story_id) { 123 }
  let(:query) { "Steve Jobs" }
  let(:comment) { "Thanks for sharing this, I really appreciate it." }

  before do
    DesignerNews.reset!
    @client = DesignerNews::Client.new
  end

  context '.story' do
    it 'returns the User info as JSON' do
      @client.story(story_id)
      assert_requested :get, designer_news_url("stories/#{story_id}")
    end
  end

  context '.search' do
    it 'returns the matching Story objects' do
      pending
      @client.search_stories(query)
      assert_requested :get, designer_news_url("stories/search?query=#{query}")
    end
  end

  context '.stories' do
    it 'returns the frontpage' do
      @client.stories
      assert_requested :get, designer_news_url("stories?page=1")
    end

    it 'returns the second page' do
      @client.stories(2)
      assert_requested :get, designer_news_url("stories?page=2")
    end
  end

  context '.recent_stories' do
    it 'returns the most recent stories' do
      @client.recent_stories
      assert_requested :get, designer_news_url("stories/recent?page=1")
    end

    it 'returns the second most recent stories' do
      @client.recent_stories(2)
      assert_requested :get, designer_news_url("stories/recent?page=2")
    end
  end

  context '.upvote_story' do
    it 'upvotes a story' do
      @client.upvote_story(story_id)
      assert_requested :post, designer_news_url("stories/#{story_id}/upvote")
    end
  end

  context '.reply_to_story' do
    it 'replies to a story' do
      @client.reply_to_story(story_id, comment)
      assert_requested :post, designer_news_url("stories/#{story_id}/reply")
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dn-0.1.0 spec/designer_news/client/stories_spec.rb