Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
cleaned up specs, removed "should" repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
christospappas committed Feb 23, 2011
1 parent 4264f9c commit 8264bf9
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
1 change: 0 additions & 1 deletion lib/streama/definition_dsl.rb
Expand Up @@ -24,7 +24,6 @@ def self.data_methods(*args)
end
data_methods :actor, :target, :referrer


end

end
16 changes: 8 additions & 8 deletions spec/lib/activity_spec.rb
Expand Up @@ -16,7 +16,7 @@
end

describe '.define' do
it "should register and return a valid definition" do
it "registers and return a valid definition" do
@definition.is_a?(Streama::Definition).should be true
end
end
Expand All @@ -28,12 +28,12 @@
@activity = Streama::Activity.new_with_data(:new_enquiry, {:actor => @actor, :target => enquiry, :referrer => listing})
end

it "should return a list of stream entries" do
it "returns a list of stream entries" do
5.times { |n| User.create(:full_name => "Receiver #{n}") }
@activity.publish.size.should eq 6
end

it "should override the streams recievers if option passed" do
it "overrides the streams recievers if option passed" do
send_to = []
2.times { |n| send_to << User.create(:full_name => "Custom Receiver #{n}") }
5.times { |n| User.create(:full_name => "Receiver #{n}") }
Expand All @@ -45,7 +45,7 @@
@activity.publish
end

it "should update metadata" do
it "updates metadata" do
@actor.full_name = "testing"
@actor.save
@activity.publish
Expand All @@ -55,7 +55,7 @@
end

describe '.new' do
it "should create a new activity" do
it "creates a new activity" do
activity = Streama::Activity.new_with_data(:new_enquiry, {:actor => user, :target => enquiry, :referrer => listing})
activity.should be_an_instance_of Streama::Activity
end
Expand All @@ -67,15 +67,15 @@
@activity = Streama::Activity.new_with_data(:new_enquiry, {:actor => user, :target => enquiry, :referrer => listing})
end

it "should load an actor instance" do
it "loads an actor instance" do
@activity.instance(:actor).should be_instance_of User
end

it "should load a target instance" do
it "loads a target instance" do
@activity.instance(:target).should be_instance_of Enquiry
end

it "should load an referrer instance" do
it "loads a referrer instance" do
@activity.instance(:referrer).should be_instance_of Listing
end

Expand Down
12 changes: 6 additions & 6 deletions spec/lib/actor_spec.rb
Expand Up @@ -21,17 +21,17 @@
5.times { |n| User.create(:full_name => "Receiver #{n}") }
end

it "should push activity to receivers" do
it "pushes activity to receivers" do
response = user.publish_activity(:new_enquiry, :target => enquiry, :referrer => listing)
response.size.should eq 6
end

it "should push to a defined stream" do
it "pushes to a defined stream" do
response = user.publish_activity(:new_enquiry, :target => enquiry, :referrer => listing, :receivers => :friends)
response.size.should eq 6
end

it "should raise an error if no target defined" do
it "raises an error if no target defined" do
lambda { user.publish_activity(:new_enquiry) }.should raise_error Streama::ActivityNotSaved
end

Expand All @@ -45,15 +45,15 @@
user.publish_activity(:new_comment, :target => listing)
end

it "should retrieve the stream for an actor" do
it "retrieves the stream for an actor" do
user.activity_stream.size.should eq 2
end

it "should retrieve the stream and filter to a particular activity type" do
it "retrieves the stream and filter to a particular activity type" do
user.activity_stream(:type => :new_comment).size.should eq 1
end

it "should paginate the stream" do
it "paginates the stream" do

10.times { user.publish_activity(:new_comment, :target => listing) }

Expand Down
10 changes: 5 additions & 5 deletions spec/lib/definition_dsl_spec.rb
Expand Up @@ -4,30 +4,30 @@

let(:definition_dsl) {Streama::DefinitionDSL.new(:new_enquiry)}

it "Should initialize with name" do
it "initializes with name" do
definition_dsl.attributes[:name].should eq :new_enquiry
end

it "should add an actor to the definition" do
it "adds an actor to the definition" do
dsl = definition_dsl
dsl.actor(:user, :store => [:id, :full_name])
dsl.attributes[:actor].should eq :user => { :store=>[:id, :full_name] }
end

it "should add multiple actors to the definition" do
it "adds multiple actors to the definition" do
dsl = definition_dsl
dsl.actor(:user, :store => [:id, :full_name])
dsl.actor(:company, :store => [:id, :name])
dsl.attributes[:actor].should eq :user => { :store=>[:id, :full_name] }, :company => { :store=>[:id, :name] }
end

it "should add a target to the definition" do
it "adds a target to the definition" do
dsl = definition_dsl
dsl.target(:listing, :store => [:id, :title])
dsl.attributes[:target].should eq :listing => { :store=>[:id, :title] }
end

it "should add a referrer to the definition" do
it "adds a referrer to the definition" do
dsl = definition_dsl
dsl.referrer(:company, :store => [:id, :name])
dsl.attributes[:referrer].should eq :company => { :store=>[:id, :name] }
Expand Down
16 changes: 8 additions & 8 deletions spec/lib/definition_spec.rb
Expand Up @@ -16,34 +16,34 @@
@definition = Streama::Definition.new(@definition_dsl)
end

it "should assign @actor" do
it "assigns @actor" do
@definition.actor.has_key?(:user).should be true
end
it "should assign @target" do
it "assigns @target" do
@definition.target.has_key?(:enquiry).should be true
end

it "should assign @referrer" do
it "assigns @referrer" do
@definition.referrer.has_key?(:listing).should be true
end

end

describe '.register' do

it "should register a definition and return new definition" do
it "registers a definition and return new definition" do
Streama::Definition.register(definition_dsl).is_a?(Streama::Definition).should eq true
end

it "should return false if invalid definition" do
it "returns false if invalid definition" do
Streama::Definition.register(false).should be false
end

end

describe '.registered' do

it "should return registered definitions" do
it "returns registered definitions" do
Streama::Definition.register(definition_dsl)
Streama::Definition.registered.size.should be > 0
end
Expand All @@ -52,11 +52,11 @@

describe '.find' do

it "should return the definition by name" do
it "returns the definition by name" do
Streama::Definition.find(:new_enquiry).name.should eq :new_enquiry
end

it "should raise an exception if invalid activity" do
it "raises an exception if invalid activity" do
lambda { Streama::Definition.find(:unknown_activity) }.should raise_error Streama::UndefinedActivity
end

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/stream_spec.rb
Expand Up @@ -21,17 +21,17 @@
@activity = Streama::Activity.new_with_data(:new_enquiry, {:actor => user, :target => enquiry, :referrer => listing})
end

it "should raise an exception if the activity hasn't been saved" do
it "raises an exception if the activity hasn't been saved" do
lambda { Streama::Stream.deliver(@activity, User.all ) }.should raise_error Streama::ActivityNotSaved
end

it "should insert activity into receivers stream" do
it "inserts activity into receivers stream" do
@activity.save
Streama::Stream.deliver(@activity, User.all )
Streama::Stream.count.should eq 6
end

it "should check if stream is valid before batch insert"
it "checks if stream is valid before batch insert"

end

Expand Down
4 changes: 2 additions & 2 deletions streama.gemspec
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{streama}
s.version = "0.1.3"
s.version = "0.1.4"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Christos Pappas"]
s.date = %q{2011-02-14}
s.date = %q{2011-02-15}
s.description = %q{Streama is a simple activity stream gem for use with the Mongoid ODM framework.}
s.email = %q{christos.pappas@gmail.com}
s.extra_rdoc_files = [
Expand Down

0 comments on commit 8264bf9

Please sign in to comment.