Skip to content

Commit

Permalink
Add rcov to bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Nov 19, 2010
1 parent 5da5f14 commit 35b14a9
Show file tree
Hide file tree
Showing 28 changed files with 638 additions and 637 deletions.
1 change: 1 addition & 0 deletions Gemfile
@@ -1,6 +1,7 @@
source 'http://rubygems.org'

gem 'fakeweb'
gem 'rcov'
gem 'rspec'
gem 'diff-lcs'
gem 'jeweler'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -14,6 +14,7 @@ GEM
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
rake (0.8.7)
rcov (0.9.9)
rdoc (2.5.11)
rspec (2.1.0)
rspec-core (~> 2.1.0)
Expand Down Expand Up @@ -48,6 +49,7 @@ DEPENDENCIES
fakeweb
jeweler
rake
rcov
rdoc
rspec
ruby-debug (>= 0.10.3)
Expand Down
1 change: 1 addition & 0 deletions Thorfile
Expand Up @@ -14,6 +14,7 @@ class Default < Thor

RSpec::Core::RakeTask.new(:rcov) do |t|
t.rcov = true
t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*"]
end

begin
Expand Down
54 changes: 27 additions & 27 deletions spec/actions/create_file_spec.rb
Expand Up @@ -30,36 +30,36 @@ def silence!
it "creates a file" do
create_file("doc/config.rb")
invoke!
File.exists?(File.join(destination_root, "doc/config.rb")).must be_true
File.exists?(File.join(destination_root, "doc/config.rb")).should be_true
end

it "does not create a file if pretending" do
create_file("doc/config.rb", {}, :pretend => true)
invoke!
File.exists?(File.join(destination_root, "doc/config.rb")).must be_false
File.exists?(File.join(destination_root, "doc/config.rb")).should be_false
end

it "shows created status to the user" do
create_file("doc/config.rb")
invoke!.must == " create doc/config.rb\n"
invoke!.should == " create doc/config.rb\n"
end

it "does not show any information if log status is false" do
silence!
create_file("doc/config.rb")
invoke!.must be_empty
invoke!.should be_empty
end

it "returns the given destination" do
capture(:stdout) do
create_file("doc/config.rb").invoke!.must == "doc/config.rb"
create_file("doc/config.rb").invoke!.should == "doc/config.rb"
end
end

it "converts encoded instructions" do
create_file("doc/%file_name%.rb.tt")
invoke!
File.exists?(File.join(destination_root, "doc/rdoc.rb.tt")).must be_true
File.exists?(File.join(destination_root, "doc/rdoc.rb.tt")).should be_true
end

describe "when file exists" do
Expand All @@ -72,7 +72,7 @@ def silence!
it "shows identical status" do
create_file("doc/config.rb")
invoke!
invoke!.must == " identical doc/config.rb\n"
invoke!.should == " identical doc/config.rb\n"
end
end

Expand All @@ -82,46 +82,46 @@ def silence!
end

it "shows forced status to the user if force is given" do
create_file("doc/config.rb", {}, :force => true).must_not be_identical
invoke!.must == " force doc/config.rb\n"
create_file("doc/config.rb", {}, :force => true).should_not be_identical
invoke!.should == " force doc/config.rb\n"
end

it "shows skipped status to the user if skip is given" do
create_file("doc/config.rb", {}, :skip => true).must_not be_identical
invoke!.must == " skip doc/config.rb\n"
create_file("doc/config.rb", {}, :skip => true).should_not be_identical
invoke!.should == " skip doc/config.rb\n"
end

it "shows forced status to the user if force is configured" do
create_file("doc/config.rb", :force => true).must_not be_identical
invoke!.must == " force doc/config.rb\n"
create_file("doc/config.rb", :force => true).should_not be_identical
invoke!.should == " force doc/config.rb\n"
end

it "shows skipped status to the user if skip is configured" do
create_file("doc/config.rb", :skip => true).must_not be_identical
invoke!.must == " skip doc/config.rb\n"
create_file("doc/config.rb", :skip => true).should_not be_identical
invoke!.should == " skip doc/config.rb\n"
end

it "shows conflict status to ther user" do
create_file("doc/config.rb").must_not be_identical
create_file("doc/config.rb").should_not be_identical
$stdin.should_receive(:gets).and_return('s')
file = File.join(destination_root, 'doc/config.rb')

content = invoke!
content.must =~ /conflict doc\/config\.rb/
content.must =~ /Overwrite #{file}\? \(enter "h" for help\) \[Ynaqdh\]/
content.must =~ /skip doc\/config\.rb/
content.should =~ /conflict doc\/config\.rb/
content.should =~ /Overwrite #{file}\? \(enter "h" for help\) \[Ynaqdh\]/
content.should =~ /skip doc\/config\.rb/
end

it "creates the file if the file collision menu returns true" do
create_file("doc/config.rb")
$stdin.should_receive(:gets).and_return('y')
invoke!.must =~ /force doc\/config\.rb/
invoke!.should =~ /force doc\/config\.rb/
end

it "skips the file if the file collision menu returns false" do
create_file("doc/config.rb")
$stdin.should_receive(:gets).and_return('n')
invoke!.must =~ /skip doc\/config\.rb/
invoke!.should =~ /skip doc\/config\.rb/
end

it "executes the block given to show file content" do
Expand All @@ -140,31 +140,31 @@ def silence!
create_file("doc/config.rb")
invoke!
revoke!
File.exists?(@action.destination).must be_false
File.exists?(@action.destination).should be_false
end

it "does not raise an error if the file does not exist" do
create_file("doc/config.rb")
revoke!
File.exists?(@action.destination).must be_false
File.exists?(@action.destination).should be_false
end
end

describe "#exists?" do
it "returns true if the destination file exists" do
create_file("doc/config.rb")
@action.exists?.must be_false
@action.exists?.should be_false
invoke!
@action.exists?.must be_true
@action.exists?.should be_true
end
end

describe "#identical?" do
it "returns true if the destination file and is identical" do
create_file("doc/config.rb")
@action.identical?.must be_false
@action.identical?.should be_false
invoke!
@action.identical?.must be_true
@action.identical?.should be_true
end
end
end
44 changes: 22 additions & 22 deletions spec/actions/directory_spec.rb
Expand Up @@ -28,21 +28,21 @@ def exists_and_identical?(source_path, destination_path)
source = File.join(source_root, source_path, file)
destination = File.join(destination_root, destination_path, file)

File.exists?(destination).must be_true
FileUtils.identical?(source, destination).must be_true
File.exists?(destination).should be_true
FileUtils.identical?(source, destination).should be_true
end
end

describe "#invoke!" do
it "raises an error if the source does not exist" do
lambda {
invoke! "unknown"
}.must raise_error(Thor::Error, /Could not find "unknown" in any of your source paths/)
}.should raise_error(Thor::Error, /Could not find "unknown" in any of your source paths/)
end

it "should not create a directory in pretend mode" do
invoke! "doc", "ghost", :pretend => true
File.exists?("ghost").must be_false
File.exists?("ghost").should be_false
end

it "copies the whole directory recursively to the default destination" do
Expand All @@ -59,13 +59,13 @@ def exists_and_identical?(source_path, destination_path)
invoke! ".", "tasks", :recursive => false

file = File.join(destination_root, "tasks", "group.thor")
File.exists?(file).must be_true
File.exists?(file).should be_true

file = File.join(destination_root, "tasks", "doc")
File.exists?(file).must be_false
File.exists?(file).should be_false

file = File.join(destination_root, "tasks", "doc", "README")
File.exists?(file).must be_false
File.exists?(file).should be_false
end

it "copies files from the source relative to the current path" do
Expand All @@ -78,48 +78,48 @@ def exists_and_identical?(source_path, destination_path)
it "copies and evaluates templates" do
invoke! "doc", "docs"
file = File.join(destination_root, "docs", "rdoc.rb")
File.exists?(file).must be_true
File.read(file).must == "FOO = FOO\n"
File.exists?(file).should be_true
File.read(file).should == "FOO = FOO\n"
end

it "copies directories" do
invoke! "doc", "docs"
file = File.join(destination_root, "docs", "components")
File.exists?(file).must be_true
File.directory?(file).must be_true
File.exists?(file).should be_true
File.directory?(file).should be_true
end

it "does not copy .empty_directory files" do
invoke! "doc", "docs"
file = File.join(destination_root, "docs", "components", ".empty_directory")
File.exists?(file).must be_false
File.exists?(file).should be_false
end

it "copies directories even if they are empty" do
invoke! "doc/components", "docs/components"
file = File.join(destination_root, "docs", "components")
File.exists?(file).must be_true
File.exists?(file).should be_true
end

it "does not copy empty directories twice" do
content = invoke!("doc/components", "docs/components")
content.must_not =~ /exist/
content.should_not =~ /exist/
end

it "logs status" do
content = invoke!("doc")
content.must =~ /create doc\/README/
content.must =~ /create doc\/config\.rb/
content.must =~ /create doc\/rdoc\.rb/
content.must =~ /create doc\/components/
content.should =~ /create doc\/README/
content.should =~ /create doc\/config\.rb/
content.should =~ /create doc\/rdoc\.rb/
content.should =~ /create doc\/components/
end

it "yields a block" do
checked = false
invoke!("doc") do |content|
checked ||= !!(content =~ /FOO/)
end
checked.must be_true
checked.should be_true
end
end

Expand All @@ -128,9 +128,9 @@ def exists_and_identical?(source_path, destination_path)
invoke! "doc"
revoke! "doc"

File.exists?(File.join(destination_root, "doc", "README")).must be_false
File.exists?(File.join(destination_root, "doc", "config.rb")).must be_false
File.exists?(File.join(destination_root, "doc", "components")).must be_false
File.exists?(File.join(destination_root, "doc", "README")).should be_false
File.exists?(File.join(destination_root, "doc", "config.rb")).should be_false
File.exists?(File.join(destination_root, "doc", "components")).should be_false
end
end
end
22 changes: 11 additions & 11 deletions spec/actions/empty_directory_spec.rb
Expand Up @@ -24,28 +24,28 @@ def base

describe "#destination" do
it "returns the full destination with the destination_root" do
empty_directory('doc').destination.must == File.join(destination_root, 'doc')
empty_directory('doc').destination.should == File.join(destination_root, 'doc')
end

it "takes relative root into account" do
base.inside('doc') do
empty_directory('contents').destination.must == File.join(destination_root, 'doc', 'contents')
empty_directory('contents').destination.should == File.join(destination_root, 'doc', 'contents')
end
end
end

describe "#relative_destination" do
it "returns the relative destination to the original destination root" do
base.inside('doc') do
empty_directory('contents').relative_destination.must == 'doc/contents'
empty_directory('contents').relative_destination.should == 'doc/contents'
end
end
end

describe "#given_destination" do
it "returns the destination supplied by the user" do
base.inside('doc') do
empty_directory('contents').given_destination.must == 'contents'
empty_directory('contents').given_destination.should == 'contents'
end
end
end
Expand All @@ -54,26 +54,26 @@ def base
it "copies the file to the specified destination" do
empty_directory("doc")
invoke!
File.exists?(File.join(destination_root, "doc")).must be_true
File.exists?(File.join(destination_root, "doc")).should be_true
end

it "shows created status to the user" do
empty_directory("doc")
invoke!.must == " create doc\n"
invoke!.should == " create doc\n"
end

it "does not create a directory if pretending" do
base.inside("foo", :pretend => true) do
empty_directory("ghost")
end
File.exists?(File.join(base.destination_root, "ghost")).must be_false
File.exists?(File.join(base.destination_root, "ghost")).should be_false
end

describe "when directory exists" do
it "shows exist status" do
empty_directory("doc")
invoke!
invoke!.must == " exist doc\n"
invoke!.should == " exist doc\n"
end
end
end
Expand All @@ -83,16 +83,16 @@ def base
empty_directory("doc")
invoke!
revoke!
File.exists?(@action.destination).must be_false
File.exists?(@action.destination).should be_false
end
end

describe "#exists?" do
it "returns true if the destination file exists" do
empty_directory("doc")
@action.exists?.must be_false
@action.exists?.should be_false
invoke!
@action.exists?.must be_true
@action.exists?.should be_true
end
end
end

0 comments on commit 35b14a9

Please sign in to comment.