spec/git_gsub_spec.rb in git-gsub-0.0.6 vs spec/git_gsub_spec.rb in git-gsub-0.0.7
- old
+ new
@@ -1,10 +1,15 @@
require 'rspec'
require 'tmpdir'
require 'git/gsub'
require 'pry'
+RSpec.configure do |config|
+ config.filter_run :focus => true
+ config.run_all_when_everything_filtered = true
+end
+
describe 'git-gsub' do
def run_in_directory_with_a_file(filename, content)
Dir.mktmpdir do |dir|
Dir.chdir dir do
dirname = File.dirname(filename)
@@ -37,18 +42,36 @@
it 'should escape well' do
run_in_directory_with_a_file 'README.md', %(<h1 class="foo">) do
Git::Gsub.run [%(<h1 class="foo">), %(<h1 class="bar">)]
expect(File.read('README.md')).to eq %(<h1 class="bar">)
end
+ end
- run_in_directory_with_a_file 'README.md', %(git/gsub) do
- Git::Gsub.run [%(git/gsub), %(svn/sub)]
- expect(File.read('README.md')).to eq %(svn/sub)
+ it do
+ run_in_directory_with_a_file 'README.md', %(Hello this is @git) do
+ Git::Gsub.run [%(@git), %(@@svn)]
+ expect(File.read('README.md')).to eq %(Hello this is @@svn)
end
+ end
+ it do
+ run_in_directory_with_a_file 'README.md', %(Hello this is "git") do
+ Git::Gsub.run [%("git"), %('svn')]
+ expect(File.read('README.md')).to eq %(Hello this is 'svn')
+ end
+ end
+
+ it do
run_in_directory_with_a_file 'README.md', %({git{svn}) do
Git::Gsub.run [%({git{svn}), %({hg{svn})]
expect(File.read('README.md')).to eq %({hg{svn})
+ end
+ end
+
+ it do
+ run_in_directory_with_a_file 'README.md', %(foo@example.com) do
+ Git::Gsub.run [%(@example), %(bar@example)]
+ expect(File.read('README.md')).to eq %(foobar@example.com)
end
end
it 'should not create backup file' do
run_in_directory_with_a_file 'README.md', 'Git Subversion Bzr' do