Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add tests

  • Loading branch information...
commit 81801ffdd58d9aaeedbaeb717876eda2c9aaa99f 1 parent 0e8d993
@nov authored
View
20 spec/smartfm/model/item_spec.rb
@@ -2,15 +2,25 @@
smart = Smartfm::Item.find(33158, :include_sentences => true)
-describe Smartfm::Item do
- it "should respond to attribute methods" do
- Smartfm::Item::ATTRIBUTES.each do |attr|
+Smartfm::Item::ATTRIBUTES.each do |attr|
+ describe Smartfm::Item, "##{attr}" do
+ it "should be accessible" do
smart.should respond_to(attr)
end
- Smartfm::Item::Response::ATTRIBUTES.each do |attr|
+ 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
- Smartfm::Item::Cue::ATTRIBUTES.each do |attr|
+ 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
View
14 spec/smartfm/model/like_spec.rb
@@ -2,10 +2,18 @@
matake_likes = Smartfm::User.find('matake').likes
-describe Smartfm::Like do
- it "should respond to attribute methods" do
- Smartfm::Like::ATTRIBUTES.each do |attr|
+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
View
43 spec/smartfm/model/list_spec.rb
@@ -2,19 +2,46 @@
core_2000 = Smartfm::List.find(705)
-describe Smartfm::List do
- it "should respond to attribute methods" do
- Smartfm::List::ATTRIBUTES.each do |attr|
+Smartfm::List::ATTRIBUTES.each do |attr|
+ describe Smartfm::List, "##{attr}" do
+ it "should be accessible" do
core_2000.should respond_to(attr)
end
- Smartfm::List::Application::ATTRIBUTES.each do |attr|
- core_2000.iknow.should respond_to(attr)
- core_2000.dictation.should respond_to(attr)
- core_2000.brainspeed.should respond_to(attr)
+ 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)
@@ -40,4 +67,4 @@
like.should be_a(Smartfm::Like)
end
end
-end
+end
View
54 spec/smartfm/model/user_spec.rb
@@ -1,25 +1,44 @@
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
matake = Smartfm::User.find('matake')
+matake_study = matake.study
-describe Smartfm::User do
- it "should respond to attribute methods" do
- Smartfm::User::ATTRIBUTES.each do |attr|
+Smartfm::User::ATTRIBUTES.each do |attr|
+ describe Smartfm::User, "##{attr}" do
+ it "should be accessible" do
matake.should respond_to(attr)
end
- Smartfm::User::Profile::ATTRIBUTES.each do |attr|
+ 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
- Smartfm::User::Study::ATTRIBUTES.each do |attr|
- matake.study.should respond_to(attr)
+ 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
- Smartfm::User::Study::Result::ATTRIBUTES.each do |attr|
- matake.study.results.each do |result|
- result.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
- Smartfm::User::Study::TotalSummary::ATTRIBUTES.each do |attr|
- matake.study.total_summary.should respond_to(attr)
+ 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
@@ -84,18 +103,15 @@
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 => 'iknow').should be_a(Smartfm::User::Study)
- matake.study(:application => 'dictation').should be_a(Smartfm::User::Study)
- matake.study(:application => 'brainspeed').should be_a(Smartfm::User::Study)
+ 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|
+ matake_study.results.should be_a(Array)
+ matake_study.results.each do |result|
result.should be_a(Smartfm::User::Study::Result)
end
end
@@ -103,6 +119,6 @@
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)
+ matake_study.total_summary.should be_a(Smartfm::User::Study::TotalSummary)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.