Replace integration test with unit test
This commit is contained in:
parent
2b29c498fa
commit
5d5c22e104
@ -17,40 +17,4 @@ describe "brew test" do
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
describe "using inreplace" do
|
||||
it "replaces text in file", :integration_test do
|
||||
install_test_formula "testball", <<~RUBY
|
||||
test do
|
||||
(testpath/"file.txt").write "1"
|
||||
inreplace testpath/"file.txt" do |s|
|
||||
s.gsub! "1", "2"
|
||||
end
|
||||
assert_equal "2", (testpath/"file.txt").read
|
||||
end
|
||||
RUBY
|
||||
|
||||
expect { brew "test", "--verbose", "testball" }
|
||||
.to output(/Testing testball/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "fails when assertion fails", :integration_test do
|
||||
install_test_formula "testball", <<~RUBY
|
||||
test do
|
||||
(testpath/"file.txt").write "1"
|
||||
inreplace testpath/"file.txt" do |s|
|
||||
s.gsub! "1", "2"
|
||||
end
|
||||
assert_equal "3", (testpath/"file.txt").read
|
||||
end
|
||||
RUBY
|
||||
|
||||
expect { brew "test", "--verbose", "testball" }
|
||||
.to output(/Testing testball/).to_stdout
|
||||
.and output(/Expected: "3"\n Actual: "2"/).to_stderr
|
||||
.and be_a_failure
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -464,6 +464,26 @@ describe Formula do
|
||||
|
||||
expect { f.inreplace([]) }.to raise_error(BuildError)
|
||||
end
|
||||
|
||||
specify "replaces text in file" do
|
||||
file = Tempfile.new("test")
|
||||
File.binwrite(file, <<~EOS)
|
||||
ab
|
||||
bc
|
||||
cd
|
||||
EOS
|
||||
f = formula do
|
||||
url "https://brew.sh/test-1.0.tbz"
|
||||
end
|
||||
f.inreplace(file.path) do |s|
|
||||
s.gsub!("bc", "yz")
|
||||
end
|
||||
expect(File.binread(file)).to eq <<~EOS
|
||||
ab
|
||||
yz
|
||||
cd
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
describe "::installed_with_alias_path" do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user