spec/mergit/processor_spec.rb in mergit-0.1.0 vs spec/mergit/processor_spec.rb in mergit-1.0.0
- old
+ new
@@ -120,9 +120,47 @@
it "should call scan_file()" do
subject.should_receive(:scan_file).with(Pathname.new('../../../lib/mergit/version.rb').expand_path(__FILE__)).once
end
end
+
+ context "given a line with MERGIT: skip" do
+ let(:ruby_string) { "this should never be seen # MERGIT: skip " }
+ after { subject.scan_line ruby_string }
+
+ it "should not call emit" do
+ subject.should_not_receive(:emit)
+ end
+ end
+
+ context "with a replacements" do
+ let(:replacements) do
+ {
+ 'VERSION' => '1.2.3',
+ /PROG\s*NAME/ => 'Awesome Program',
+ }
+ end
+
+ context "matching on a string" do
+ let(:ruby_string) { "puts 'The version is VERSION'" }
+ let(:expected_string) { ruby_string.sub('VERSION', '1.2.3') }
+ after { subject.scan_line ruby_string }
+
+ it "should replace VERSION" do
+ subject.should_receive(:emit).with(expected_string)
+ end
+ end
+
+ context "matching on a regexp" do
+ let(:ruby_string) { "puts 'The program is PROGNAME.'" }
+ let(:expected_string) { ruby_string.sub('PROGNAME', 'Awesome Program') }
+ after { subject.scan_line ruby_string }
+
+ it "should replace PROGNAME" do
+ subject.should_receive(:emit).with(expected_string)
+ end
+ end
+ end
end
describe "string_split" do
subject { Mergit::Processor.new(search_path, replacements, :string => '') }
let(:example_parts) { [ 'one', '', 'two', 'three' ] }