Created
February 11, 2011 03:17
-
-
Save datapimp/821867 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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