[rspec-devel] [ rspec-Bugs-10313 ] pre_commit_rails: doesn't always build correctly
noreply at rubyforge.org
noreply at rubyforge.org
Sun Apr 29 02:57:29 EDT 2007
Bugs item #10313, was opened at 2007-04-23 12:38
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10313&group_id=797
Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Antti Tarvainen (tarvaina)
>Assigned to: David Chelimsky (dchelimsky)
Summary: pre_commit_rails: doesn't always build correctly
Initial Comment:
First the cause: The PreCommit#silent_sh method is supposed to return the output of the command it runs, but it always returns "". This is easily fixed:
Index: pre_commit/lib/pre_commit/pre_commit.rb
===================================================================
--- pre_commit/lib/pre_commit/pre_commit.rb (revision 1802)
+++ pre_commit/lib/pre_commit/pre_commit.rb (working copy)
@@ -20,10 +20,10 @@
def silent_sh(cmd, &block)
output = nil
IO.popen(cmd) do |io|
- io.each_line do |line|
+ output = io.read
+ output.each_line do |line|
block.call(line) if block
end
- output = io.read
end
output
end
The reason this is a bug report and not a patch is that fixing silent_sh breaks the build. Here is my understanding of what is happening:
1. Rake against Rails Edge fails. (This is ok.) Since it fails, destroy_purchase is not called, and generated rspec_resource files are left in the example_rails_app.
2. Rake starts to build agains Rails 1.2.3, but fails since it cannot create the rspec_resource files again.
In the current trunk, the rake task doesn't notice that rspec_resource generation failed (since it doesn't get the output back from silent_sh), and continues the rake task. Thus, the rspec_resources in tests against 1.2.3 are actually created with Rails edge.
Attached is a diff of not-very-bdd specs for repeating parts of this. You can run them in trunk root with
ruby rspec/bin/spec pre_commit/spec
I will look into this myself later today to see if I can patch it. I'll let you know.
----------------------------------------------------------------------
>Comment By: David Chelimsky (dchelimsky)
Date: 2007-04-29 06:57
Message:
Fixed with patch 10315.
See http://rubyforge.org/tracker/index.php?func=detail&aid=10315&group_id=797&atid=3151
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10313&group_id=797
More information about the rspec-devel
mailing list