Skip to content

Commit

Permalink
[Specs] Change all the occurences of sut to subject
Browse files Browse the repository at this point in the history
See #92
  • Loading branch information
fabiopelosin committed Apr 8, 2014
1 parent 5315237 commit 52908b5
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 174 deletions.
24 changes: 12 additions & 12 deletions spec/dependency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ module Pod
describe 'In general' do

it 'can be initialized with no requirements' do
sut = Dependency.new('bananas')
sut.name.should == 'bananas'
subject = Dependency.new('bananas')
subject.name.should == 'bananas'
end

it 'can be initialized with multiple requirements' do
sut = Dependency.new('bananas', '> 1.0', '< 2.0')
sut.requirement.to_s.should == '< 2.0, > 1.0'
subject = Dependency.new('bananas', '> 1.0', '< 2.0')
subject.requirement.to_s.should == '< 2.0, > 1.0'
end

it 'can be initialized with a requirement on a pre-release version' do
sut = Dependency.new('bananas', '> 1.0-pre')
sut.requirement.should == '> 1.0-pre'
subject = Dependency.new('bananas', '> 1.0-pre')
subject.requirement.should == '> 1.0-pre'
end

it 'can be initialized with an external source' do
Expand Down Expand Up @@ -104,15 +104,15 @@ module Pod
end

it 'can store a specific version which is used in place of the requirements' do
sut = Dependency.new('cocoapods', '> 1.0')
sut.specific_version = Version.new('1.23')
sut.requirement.as_list.should == ['= 1.23']
subject = Dependency.new('cocoapods', '> 1.0')
subject.specific_version = Version.new('1.23')
subject.requirement.as_list.should == ['= 1.23']
end

it 'can handle specific version with head information' do
sut = Dependency.new('cocoapods', '> 1.0')
sut.specific_version = Version.new('HEAD based on 1.23')
sut.requirement.as_list.should == ['= 1.23']
subject = Dependency.new('cocoapods', '> 1.0')
subject.specific_version = Version.new('HEAD based on 1.23')
subject.requirement.as_list.should == ['= 1.23']
end

#--------------------------------------#
Expand Down
36 changes: 18 additions & 18 deletions spec/requirement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ module Pod
describe 'In general' do

it 'can be initialized with a string' do
sut = Requirement.new('<= 1.0')
sut.to_s.should == '<= 1.0'
subject = Requirement.new('<= 1.0')
subject.to_s.should == '<= 1.0'
end

it 'defaults to the equality operator on initialization' do
sut = Requirement.new('1.0')
sut.to_s.should == '= 1.0'
subject = Requirement.new('1.0')
subject.to_s.should == '= 1.0'
end

it 'can be initialized with an array of versions' do
sut = Requirement.new([Version.new('1.0'), Version.new('2.0')])
sut.to_s.should == '= 1.0, = 2.0'
subject = Requirement.new([Version.new('1.0'), Version.new('2.0')])
subject.to_s.should == '= 1.0, = 2.0'
end

it 'can be initialized with a pre-release version' do
sut = Requirement.new(Version.new('1.0-beta'))
sut.to_s.should == '= 1.0-beta'
subject = Requirement.new(Version.new('1.0-beta'))
subject.to_s.should == '= 1.0-beta'
end

it 'raises if initialized with an invalid input' do
Expand All @@ -42,28 +42,28 @@ module Pod

it 'can be created with a requirement' do
req = Requirement.new('<= 1.0')
sut = Requirement.create(req)
sut.should == req
subject = Requirement.create(req)
subject.should == req
end

it 'can be created with a version' do
sut = Requirement.create(Version.new('1.0'))
sut.to_s.should == '= 1.0'
subject = Requirement.create(Version.new('1.0'))
subject.to_s.should == '= 1.0'
end

it 'can be created with an array of versions' do
sut = Requirement.create([Version.new('1.0'), Version.new('2.0')])
sut.to_s.should == '= 1.0, = 2.0'
subject = Requirement.create([Version.new('1.0'), Version.new('2.0')])
subject.to_s.should == '= 1.0, = 2.0'
end

it 'can be created with a string' do
sut = Requirement.create('1.0')
sut.to_s.should == '= 1.0'
subject = Requirement.create('1.0')
subject.to_s.should == '= 1.0'
end

it 'can be created with a nil input' do
sut = Requirement.create(nil)
sut.to_s.should == '>= 0'
subject = Requirement.create(nil)
subject.to_s.should == '>= 0'
end

end
Expand Down
14 changes: 7 additions & 7 deletions spec/source/abstract_data_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,45 @@ module Pod
describe Source::AbstractDataProvider do

before do
@sut = Source::AbstractDataProvider.new
@subject = Source::AbstractDataProvider.new
end

#-------------------------------------------------------------------------#

describe 'Optional methods' do
it 'raises for the #name method' do
should.raise StandardError do
@sut.name
@subject.name
end.message.should.match /Abstract method/
end

it 'raises for the #type method' do
should.raise StandardError do
@sut.type
@subject.type
end.message.should.match /Abstract method/
end

it 'raises for the #pods method' do
should.raise StandardError do
@sut.pods
@subject.pods
end.message.should.match /Abstract method/
end

it 'raises for the #versions method' do
should.raise StandardError do
@sut.versions('Pod')
@subject.versions('Pod')
end.message.should.match /Abstract method/
end

it 'raises for the #specification method' do
should.raise StandardError do
@sut.specification('Pod', '0.1.0')
@subject.specification('Pod', '0.1.0')
end.message.should.match /Abstract method/
end

it 'raises for the #specification_contents method' do
should.raise StandardError do
@sut.specification_contents('Pod', '0.1.0')
@subject.specification_contents('Pod', '0.1.0')
end.message.should.match /Abstract method/
end
end
Expand Down
24 changes: 12 additions & 12 deletions spec/source/acceptor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ module Pod
@spec = Specification.from_file(@spec_path)
Specification.any_instance.stubs(:dependencies).returns([])
@repo = fixture('spec-repos/test_repo')
@sut = Source::Acceptor.new(@repo)
@subject = Source::Acceptor.new(@repo)
end

#-------------------------------------------------------------------------#

describe 'In general' do

it 'returns the source that should accept the podspecs' do
@sut.source.name.should == 'test_repo'
@subject.source.name.should == 'test_repo'
end

it 'accepts a valid specification' do
errors = @sut.analyze(@spec)
errors = @subject.analyze(@spec)
errors.should == []
end

it 'accepts a given path with a valid specification' do
errors = @sut.analyze_path(@spec_path)
errors = @subject.analyze_path(@spec_path)
errors.should == []
end

it 'handles gracefully malformed specifications' do
File.any_instance.stubs(:read).returns('raise')
errors = @sut.analyze_path(@spec_path)
errors = @subject.analyze_path(@spec_path)
errors.should == ['Unable to load the specification.']
end
end
Expand All @@ -48,25 +48,25 @@ module Pod

it 'checks if the source of the specification did change' do
@spec.source = { :git => 'http://EVIL-GORILLA-FORK/banana-lib.git', :tag => 'v1.0' }
errors = @sut.analyze(@spec).join("\n")
errors = @subject.analyze(@spec).join("\n")
errors.should.match /The source of the spec doesn't match/
end

it "doesn't check if the source of the specification did change for HTTP sources" do
@spec.source = { :http => 'http://banana-lib/lib.zip' }
errors = @sut.analyze(@spec).join("\n")
errors = @subject.analyze(@spec).join("\n")
errors.should.not.match /The source of the spec doesn't match/
end

it "doesn't fail if the new source of the specification is a redirect" do
@spec.source = { :git => 'http://NEW-URL/banana-lib.git', :tag => 'v1.0' }
errors = @sut.analyze(@spec).join("\n")
errors = @subject.analyze(@spec).join("\n")
errors.should.not.match /The source of the spec doesn't match/
end

it 'rejects a Git based specification without tag if there is at least one tagged version' do
@spec.source = { :git => 'http://banana-corp.local/banana-lib.git', :commit => 'SHA' }
errors = @sut.analyze(@spec).join("\n")
errors = @subject.analyze(@spec).join("\n")
errors.should.match /There is already at least one versioned specification/
end

Expand All @@ -77,14 +77,14 @@ module Pod
previous_spec.source = { :git => repo, :commit => 'SHA_1' }
@spec.version = '0.0.1'
@spec.source = { :git => repo, :commit => 'SHA_2' }
@sut.stubs(:related_specifications).returns(nil)
errors = @sut.analyze(@spec, previous_spec).join("\n")
@subject.stubs(:related_specifications).returns(nil)
errors = @subject.analyze(@spec, previous_spec).join("\n")
errors.should.match /Attempt to rewrite the commit/
end

it 'checks that the dependencies of the specification are available' do
Specification.any_instance.unstub(:dependencies)
errors = @sut.analyze(@spec).join("\n")
errors = @subject.analyze(@spec).join("\n")
errors.should.match /Unable to find a specification for the.*monkey.*dependency/
end

Expand Down

0 comments on commit 52908b5

Please sign in to comment.