jam-cloud/web/spec/requests/instruments_api_spec.rb

51 lines
1.3 KiB
Ruby
Raw Permalink Normal View History

require 'spec_helper'
describe "Instruments API ", :type => :api do
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before do
post '/sessions', "session[email]" => user.email, "session[password]" => user.password
rack_mock_session.cookie_jar["remember_token"].should == user.remember_token
end
it "list instruments" do
get '/api/instruments.json'
instruments = JSON.parse(last_response.body)
found_high = false
found_mid = false
found_low = false
found_user = false
found_junk = false
instruments.each do |instrument|
if instrument["popularity"] == 3
found_mid.should == false
found_low.should == false
found_high = true
elsif instrument["popularity"] == 2
found_high.should == true
found_low.should == false
found_mid = true
elsif instrument["popularity"] == 1
found_high.should == true
found_mid.should == true
found_low = true
elsif instrument["popularity"] == 0
found_user = true
else
found_junk = true
end
end
found_high.should == true
found_mid.should == true
found_low.should == true
found_user.should == false
found_junk.should == false
end
end
end