Skip to content

Instantly share code, notes, and snippets.

@datapimp
Created February 11, 2011 03:17
Show Gist options
  • Select an option

  • Save datapimp/821867 to your computer and use it in GitHub Desktop.

Select an option

Save datapimp/821867 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe ReadingsController do
include Devise::TestHelpers
before(:all) do
sandbox = WMX::Sandbox.new
@receipt = Factory.create :receipt
@user = @receipt.user
@section = sandbox.create_section_with_readings(1, :content_package => @receipt.content_package)
@reading = @section.readings.first
end
it "should require me to be logged in" do
get :index, :format => :json
JSON.parse( response.body )["errors"].keys.should include("authentication")
end
it "should require me to pass a client_id" do
get :index, :auth_token => @user.authentication_token, :format => :json
JSON.parse( response.body )["errors"].keys.should include("client_id")
end
it "should return some readings for a valid request" do
get :index, :auth_token => @user.authentication_token, :client_id => @user.client_id, :section => @section.id, :format => :json
readings = assigns(:readings)
readings.should include(@reading)
end
it "should show the content for a reading for content type of html" do
@reading.stub!(:extracted_html_file_content)
get :show, :auth_token => @user.authentication_token, :client_id => @user.client_id, :id => @reading.id, :format => :json
@reading = assigns(:reading)
@reading.should == @reading
end
it "should show the reading json for a content type of json" do
get :show, :auth_token => @user.authentication_token, :client_id => @user.client_id, :id => @reading.id, :format => :json
@reading = assigns(:reading)
@reading.should == @reading
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment