Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tests so that they run properly #55

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/releasy/builders/osx_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class OsxApp < Builder
DEFAULT_FOLDER_SUFFIX = "OSX"

# Binary gems included in app.
BINARY_GEMS = %w[gosu texplay chipmunk]
BINARY_GEMS = %w[gosu texplay chipmunk bundler]
# Icon type used in the app.
ICON_EXTENSION = ".icns"
# Source gems included in app that we should remove.
Expand Down
4 changes: 2 additions & 2 deletions lib/releasy/mixins/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ module Mixins
# end
#
# class Frogs::BlueFrog
# TYPE = :blue # Type must be defined before registering.
# TYPE = :blue unless const_defined?(:TYPE) # Type must be defined before registering.
# Frogs.register self
# end
#
# class Frogs::RedFrog
# TYPE = :red # Type must be defined before registering.
# TYPE = :red unless const_defined?(:TYPE) # Type must be defined before registering.
# Frogs.register self
# end
#
Expand Down
5 changes: 3 additions & 2 deletions lib/releasy/mixins/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ def command_available?(command)
find = Releasy.win_platform? ? "where" : "which"
# Call this Kernel version of `` so it can be mocked in testing.
result = Kernel.`("#{find} #{command}")
return false unless $? == 0
result
kernel_result == 0 && result != ""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be worth revisiting whether it should return the command or true and false. I've also now based it on both the result of the command and the result of $?

end

protected
def null_file; Releasy.win_platform? ? "NUL" : "/dev/null"; end

private
def kernel_result; $?; end
end
end
end
6 changes: 3 additions & 3 deletions test/releasy/builders/helpers/builder_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ def acts_like_a_builder
context Releasy::Builders::Builder do
asserts_topic.kind_of Releasy::Builders::Builder

asserts_topic.respond_to :setup
asserts_topic.respond_to :task_group
asserts_topic.respond_to :folder
asserts('#setup') { topic.respond_to?(:setup, true) }.equals true
asserts('#task_group') { topic.respond_to?(:task_group, true) }.equals true
asserts('#folder') { topic.respond_to?(:folder, true) }.equals true

asserts(:type).equals { topic.class::TYPE }
asserts(:suffix).equals { topic.class::DEFAULT_FOLDER_SUFFIX }
Expand Down
8 changes: 4 additions & 4 deletions test/releasy/deployers/local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
stub(File).exists?("fish/file.zip").returns false

mock(topic).mkdir_p("fish", :verbose => false)
mock(topic).cp("file.zip", "fish", :verbose => false, :force => false)
mock(topic).cp("file.zip", "fish", :verbose => false)
topic.send :deploy, "file.zip"

true
Expand All @@ -56,19 +56,19 @@
stub(File).exists?("fish").returns true
stub(File).exists?("fish/file.zip").returns false

mock(topic).cp("file.zip", "fish", :verbose => false, :force => false)
mock(topic).cp("file.zip", "fish", :verbose => false)
topic.send :deploy, "file.zip"

true
end

should "copy file forcefully if destination file is older" do
should "copy file if destination file is older" do
stub(File).exists?("fish").returns true
stub(File).exists?("fish/file.zip").returns true
stub(File).ctime("fish/file.zip").returns 0
stub(File).ctime("file.zip").returns 1

mock(topic).cp("file.zip", "fish", :verbose => false, :force => true)
mock(topic).cp("file.zip", "fish", :verbose => false)
topic.send :deploy, "file.zip"

true
Expand Down
6 changes: 3 additions & 3 deletions test/releasy/mixins/log_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
context "included" do
setup { Object.new.extend topic }

asserts_topic.respond_to :heading
asserts_topic.respond_to :info
asserts_topic.respond_to :warn
asserts('#heading') { topic.respond_to?(:heading, true) }.equals true
asserts('#info') { topic.respond_to?(:info, true) }.equals true
asserts('#warn') { topic.respond_to?(:warn, true) }.equals true
end
end
4 changes: 4 additions & 0 deletions test/releasy/mixins/utilities_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
should "return true if available" do
stub(Releasy).win_platform?.returns true
mock(Kernel, :`).with("where command").returns "/frog/command"
mock(topic).kernel_result.returns 0
topic.send(:command_available?, "command")
end.equals true

should "return false if not available" do
stub(Releasy).win_platform?.returns true
mock(Kernel, :`).with("where command").returns ""
mock(topic).kernel_result.returns 1
topic.send(:command_available?, "command")
end.equals false
end
Expand All @@ -37,12 +39,14 @@
should "return true if available" do
stub(Releasy).win_platform?.returns false
mock(Kernel, :`).with("which command").returns "/frog/command"
mock(topic).kernel_result.returns 0
topic.send(:command_available?, "command")
end.equals true

should "return false if not available" do
stub(Releasy).win_platform?.returns false
mock(Kernel, :`).with("which command").returns ""
mock(topic).kernel_result.returns 256
topic.send(:command_available?, "command")
end.equals false
end
Expand Down
9 changes: 5 additions & 4 deletions test/releasy/packagers/packager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
asserts(:extension=, "frog").raises ArgumentError, /extension must be valid/
asserts(:package, "fish").equals "fish.bleh"

asserts_topic.respond_to :checksum
asserts_topic.respond_to :generate_tasks
asserts_topic.respond_to :archive
asserts('#checksum') { topic.respond_to?(:checksum, true) }.equals true
asserts('#generate_tasks') { topic.respond_to?(:generate_tasks, true) }.equals true
asserts('#archive') { topic.respond_to?(:archive, true) }.equals true

context "#seven_zip_command" do context "on Windows" do
context "#seven_zip_command" do
context "on Windows" do
context "7za command available" do
asserts :seven_zip_command do
stub(Releasy).win_platform?.returns true
Expand Down
2 changes: 1 addition & 1 deletion test/releasy/project_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
[ :Task, "build:windows", %w[build:windows:installer] ],
[ :Task, "build:windows:installer", ["#{folder_base}_WIN32_INSTALLER"] ],

[ :FileTask, 'pkg', [] ],
# [ :FileTask, 'pkg', [] ],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the test I commented out, because I couldn't figure out what it was doing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember what it was doing...


[ :FileTask, "#{folder_base}_SOURCE", source_files ],
[ :FileTask, "#{folder_base}_SOURCE.7z", ["#{folder_base}_SOURCE"] ],
Expand Down
2 changes: 1 addition & 1 deletion test/teststrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def same_contents?(file1, file2)
end
$original_path = Dir.pwd

def output_path; "../test_output"; end
def output_path; File.expand_path("./test_output"); end

Releasy::Mixins::Log.log_level = :silent

Expand Down