Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rename model => models, rest_client => rest_clients

  • Loading branch information...
commit aeeb04218ccdaacabd235860ee578b18e0434560 1 parent f301d7c
Nov Matake authored
42 spec/smartfm/models/base_spec.rb
View
@@ -0,0 +1,42 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+subclasses = [ Smartfm::Item, Smartfm::List, Smartfm::Sentence, Smartfm::User ]
+
+subclasses.each do |klass|
+
+ describe klass, '.attributes' do
+ it "should return Array of attributes" do
+ klass.attributes.should be_a(Array)
+ end
+ end
+
+ if klass.respond_to?(:recent)
+ describe klass, '.find' do
+ it "should return nil if NOT FOUND" do
+ klass.find(-1).should be_nil
+ end
+ end
+ end
+
+ if klass.respond_to?(:recent)
+ describe klass, '.recent' do
+ it "should return Array" do
+ klass.recent.should be_a(Array)
+ # blank response should be []
+ klass.recent(:per_page => 20, :page => 100000000000000).should be_empty
+ klass.recent(:per_page => 20, :page => 100000000000000).should_not be_nil
+ end
+ end
+ end
+
+ if klass.respond_to?(:matching)
+ describe klass, '.recent' do
+ it "should return Array" do
+ klass.matching("hello").should be_a(Array)
+ klass.matching(rand_string).should be_empty
+ klass.matching(rand_string).should_not be_nil
+ end
+ end
+ end
+
+end
60 spec/smartfm/models/item_spec.rb
View
@@ -0,0 +1,60 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+smart = Smartfm::Item.find(33158, :include_sentences => true)
+
+Smartfm::Item::ATTRIBUTES.each do |attr|
+ describe Smartfm::Item, "##{attr}" do
+ it "should be accessible" do
+ smart.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::Item::Response::ATTRIBUTES.each do |attr|
+ describe Smartfm::Item::Response, "##{attr}" do
+ it "should be accessible" do
+ smart.responses.first.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::Item::Cue::ATTRIBUTES.each do |attr|
+ describe Smartfm::Item::Cue, "##{attr}" do
+ it "should be accessibles" do
+ smart.cue.should respond_to(attr)
+ end
+ end
+end
+
+describe Smartfm::Item, '#cue' do
+ it "should return a instance o Smartfm::Item::Cue" do
+ smart.cue.should be_a(Smartfm::Item::Cue)
+ end
+end
+
+describe Smartfm::Item, '#responses' do
+ it "should return a Array of Smartfm::Item::Response" do
+ smart.responses.should be_a(Array)
+ smart.responses.each do |response|
+ response.should be_a(Smartfm::Item::Response)
+ end
+ end
+end
+
+describe Smartfm::Item, '#sentences' do
+ it "should return a Array of Smartfm::Sentence" do
+ smart.sentences.should be_a(Array)
+ smart.sentences.each do |sentence|
+ sentence.should be_a(Smartfm::Sentence)
+ end
+ end
+end
+
+describe Smartfm::Item, '#likes' do
+ it "should return a Array of Smartfm::Like" do
+ smart.likes.should be_a(Array)
+ smart.likes.each do |like|
+ like.should be_a(Smartfm::Like)
+ end
+ end
+end
19 spec/smartfm/models/like_spec.rb
View
@@ -0,0 +1,19 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+matake_likes = Smartfm::User.find('matake').likes
+
+Smartfm::Like::ATTRIBUTES.each do |attr|
+ describe Smartfm::Like, "##{attr}" do
+ it "should be accessible" do
+ matake_likes.first.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::Like::ATTRIBUTES.each do |attr|
+ describe Smartfm::Like, "##{attr}" do
+ it "should not be nil" do
+ matake_likes.first.should_not be_nil
+ end
+ end
+end
70 spec/smartfm/models/list_spec.rb
View
@@ -0,0 +1,70 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+core_2000 = Smartfm::List.find(705)
+
+Smartfm::List::ATTRIBUTES.each do |attr|
+ describe Smartfm::List, "##{attr}" do
+ it "should be accessible" do
+ core_2000.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::List::READONLY_ATTRIBUTES.each do |attr|
+ describe Smartfm::List, "##{attr}" do
+ it "should not be nil" do
+ core_2000.should_not be_nil
+ end
+ end
+end
+
+[:iknow, :dictation, :brainspeed].each do |application|
+ Smartfm::List::Application::ATTRIBUTES.each do |attr|
+ describe Smartfm::List::Application, "##{attr}" do
+ it "should be accessible for #{application}" do
+ core_2000.send(application).should respond_to(attr)
+ end
+ it "should not be nil for #{application}" do
+ core_2000.send(application).send(attr).should_not be_nil unless attr == :progress
+ end
+ end
+ end
+ describe Smartfm::List::Application, "#available?" do
+ it "should be true for #{application}" do
+ core_2000.send(application).available?.should be_true
+ end
+ end
+end
+
+describe Smartfm::List::Application, "#progress" do
+ it "should be nil for brainspeed" do
+ core_2000.brainspeed.progress.should be_nil
+ end
+end
+
+describe Smartfm::List, '#items' do
+ it "should return a Array of Smartfm::Item" do
+ core_2000.items.should be_a(Array)
+ core_2000.items.each do |item|
+ item.should be_a(Smartfm::Item)
+ end
+ end
+end
+
+describe Smartfm::List, '#sentences' do
+ it "should return a Array of Smartfm::Sentence" do
+ core_2000.sentences.should be_a(Array)
+ core_2000.sentences.each do |sentence|
+ sentence.should be_a(Smartfm::Sentence)
+ end
+ end
+end
+
+describe Smartfm::List, '#likes' do
+ it "should return a Array of Smartfm::Like" do
+ core_2000.likes.should be_a(Array)
+ core_2000.likes.each do |like|
+ like.should be_a(Smartfm::Like)
+ end
+ end
+end
11 spec/smartfm/models/notification_spec.rb
View
@@ -0,0 +1,11 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+matake_notifications = Smartfm::User.find('matake').notifications
+
+Smartfm::Notification::ATTRIBUTES.each do |attr|
+ describe Smartfm::Notification, "##{attr}" do
+ it "should be accessible" do
+ matake_notifications.first.should respond_to(attr)
+ end
+ end
+end
11 spec/smartfm/models/sentence_spec.rb
View
@@ -0,0 +1,11 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+smartest = Smartfm::Sentence.find(10828)
+
+Smartfm::Sentence::ATTRIBUTES.each do |attr|
+ describe Smartfm::Sentence, "##{attr}" do
+ it "should be accessible" do
+ smartest.should respond_to(attr)
+ end
+ end
+end
124 spec/smartfm/models/user_spec.rb
View
@@ -0,0 +1,124 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+matake = Smartfm::User.find('matake')
+matake_study = matake.study
+
+Smartfm::User::ATTRIBUTES.each do |attr|
+ describe Smartfm::User, "##{attr}" do
+ it "should be accessible" do
+ matake.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::User::Profile::ATTRIBUTES.each do |attr|
+ describe Smartfm::User::Profile, "##{attr}" do
+ it "should be accessible" do
+ matake.profile.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::User::Study::ATTRIBUTES.each do |attr|
+ describe Smartfm::User::Study, "##{attr}" do
+ it "should be accessible" do
+ matake_study.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::User::Study::Result::ATTRIBUTES.each do |attr|
+ describe Smartfm::User::Study::Result, "##{attr}" do
+ it "should be accessible" do
+ matake_study.results.first.should respond_to(attr)
+ end
+ end
+end
+
+Smartfm::User::Study::TotalSummary::ATTRIBUTES.each do |attr|
+ describe Smartfm::User::Study::TotalSummary, "##{attr}" do
+ it "shoud be accessible" do
+ matake_study.total_summary.should respond_to(attr)
+ end
+ end
+end
+
+describe Smartfm::User, '#items' do
+ it "should return a Array of Smartfm::Item or []" do
+ matake.items.should be_a(Array)
+ matake.items.each do |item|
+ item.should be_a(Smartfm::Item)
+ end
+ matake.items(:page => 10000000000).should be_empty
+ matake.items(:page => 10000000000).should_not be_nil
+ end
+end
+
+describe Smartfm::User, '#lists' do
+ it "should return a Array of Smartfm::List or []" do
+ matake.lists.should be_a(Array)
+ matake.lists.each do |list|
+ list.should be_a(Smartfm::List)
+ end
+ matake.lists(:page => 10000000000).should be_empty
+ matake.lists(:page => 10000000000).should_not be_nil
+ end
+end
+
+describe Smartfm::User, '#friends' do
+ it "should return a Array of Smartfm::User" do
+ matake.friends.should be_a(Array)
+ matake.friends.each do |friend|
+ friend.should be_a(Smartfm::User)
+ end
+ end
+end
+
+describe Smartfm::User, '#followers' do
+ it "should return a Array of Smartfm::User" do
+ matake.followers.should be_a(Array)
+ matake.followers.each do |follower|
+ follower.should be_a(Smartfm::User)
+ end
+ end
+end
+
+describe Smartfm::User, '#likes' do
+ it "should return a Array of Smartfm::Like" do
+ matake.likes.should be_a(Array)
+ matake.likes.each do |like|
+ like.should be_a(Smartfm::Like)
+ end
+ end
+end
+
+describe Smartfm::User, '#notifications' do
+ it "should return a Array of Smartfm::Notification" do
+ matake.notifications.should be_a(Array)
+ matake.notifications.each do |notification|
+ notification.should be_a(Smartfm::Notification)
+ end
+ end
+end
+
+describe Smartfm::User, '#study' do
+ it "should return a instance of Smartfm::User::Study" do
+ matake_study.should be_a(Smartfm::User::Study)
+ matake.study(:application => 'fuckin_windows').should be_nil
+ end
+end
+
+describe Smartfm::User::Study, '#results' do
+ it "should return a Array of Smartfm::User::Study::Result" do
+ matake_study.results.should be_a(Array)
+ matake_study.results.each do |result|
+ result.should be_a(Smartfm::User::Study::Result)
+ end
+ end
+end
+
+describe Smartfm::User::Study, '#total_summary' do
+ it "should return a Array of Smartfm::User::Study::TotalSummary" do
+ matake_study.total_summary.should be_a(Smartfm::User::Study::TotalSummary)
+ end
+end
9 spec/smartfm/rest_clients/base_spec.rb
View
@@ -0,0 +1,9 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+subclasses = [ Smartfm::RestClient::Item, Smartfm::RestClient::List, Smartfm::RestClient::Sentence, Smartfm::RestClient::User ]
+
+describe Smartfm::RestClient::Base do
+ it "should be a Class" do
+ true
+ end
+end
7 spec/smartfm/rest_clients/item_spec.rb
View
@@ -0,0 +1,7 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe Smartfm::RestClient::Item, '::ACTIONS' do
+ it "should be a Hash" do
+ Smartfm::RestClient::Item::ACTIONS.should be_a(Hash)
+ end
+end
7 spec/smartfm/rest_clients/like_spec.rb
View
@@ -0,0 +1,7 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe Smartfm::RestClient::User, '::ACTIONS' do
+ it "should be a Hash" do
+ Smartfm::RestClient::Like::ACTIONS.should be_a(Hash)
+ end
+end
7 spec/smartfm/rest_clients/list_spec.rb
View
@@ -0,0 +1,7 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe Smartfm::RestClient::List, '::ACTIONS' do
+ it "should be a Hash" do
+ Smartfm::RestClient::List::ACTIONS.should be_a(Hash)
+ end
+end
7 spec/smartfm/rest_clients/notification_spec.rb
View
@@ -0,0 +1,7 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe Smartfm::RestClient::User, '::ACTIONS' do
+ it "should be a Hash" do
+ Smartfm::RestClient::Notification::ACTIONS.should be_a(Hash)
+ end
+end
7 spec/smartfm/rest_clients/sentence_spec.rb
View
@@ -0,0 +1,7 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe Smartfm::RestClient::Sentence, '::ACTIONS' do
+ it "should be a Hash" do
+ Smartfm::RestClient::Sentence::ACTIONS.should be_a(Hash)
+ end
+end
7 spec/smartfm/rest_clients/user_spec.rb
View
@@ -0,0 +1,7 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
+
+describe Smartfm::RestClient::User, '::ACTIONS' do
+ it "should be a Hash" do
+ Smartfm::RestClient::User::ACTIONS.should be_a(Hash)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.