I'm playing a 3rd level rogue, and I'm looking at at taking a few levels of sorcerer for the Draconic bloodline's claws, and as a prerequisite for the arcane trickster prestige class. Since I'm going to be casting spells as a source of a lot of my damage, I'm curious about what is required to be able to add sneak attack damage to a spell. Since a lot of the sorcerer spells have a long range, I'd also like to know when I can add sneak attack damage to a ranged spell, and how this compares to the rules for sneak attack damage from a ranged weapon.
Sneak Attacks with spells follow the normal rules for sneak attacks
Specifically, the phrasing of sneak attack only specifies weapons in the section on nonlethal damage (which cannot normally be dealt with spells anyways). Touch attacks, ranged touch attacks and other such attacks caused as part of spells may therefore be used to deliver sneak attacks so long as they fulfill the normal conditions of a sneak attack.
In other words, sneak attacks with spells must meet the following conditions:
The 3.5 rule limiting volley attacks (such as scorching ray) to 1 sneak attack unless they are made using a full-round action is technically not a part of Pathfinder, though it is a perfectly reasonable ruling on the DM's part.
An Arcane Trickster's Surprise Spells ability is an exception to the above rules—one could, for example, cast a fireball in the surprise round and sneak attack a large number of opponents.
Damage Type: Sneak attack damage is of the same type as the original damage, with the added subtype of precision.
I want to add that you should check out the write-up here about Sorcerer bloodlines for the Arcane Trickster: http://rpg.stackexchange.com/a/41406/2458
For many Arcane Tricksters, Scorching Ray is really their bread and butter spell. When you take 4 levels of Sorcerer your BAB falls behind heavily. So it's hard for you to be on the front lines. Using Ray spells, you get to attack Touch AC, which makes you dramatically better at this.
In the post above I list several bloodlines that actually get a Ranged Touch Attack as a spell-like ability which helps support the strategy of sneaking around and firing spells with Sneak Attack damage. However the Draconic Bloodline ability could also really help with your damage on Scorching Ray.
Being a 10th level arcane trickster.
This isn't a true sneak attack, so it's apparently not subject to the 30ft range limit, nor does it apply to all the other instances you can normally sneak attack.
The subtext I get from the combat section is that spells are not "attacks" and therefore do not benefit from sneak attack, except in special cases such as the arcane trickster.