diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 3337616..a9fff81 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -82,8 +82,8 @@ describe Rscons do Rscons::Environment.new do |env| env.Program('simple', Dir['*.c']) end - File.exists?('simple.o').should be_true - `./simple`.should == "This is a simple C program\n" + expect(File.exists?('simple.o')).to be_true + expect(`./simple`).to eq "This is a simple C program\n" end it 'prints commands as they are executed' do @@ -92,7 +92,7 @@ describe Rscons do env["LD"] = "gcc" env.Program('simple', Dir['*.c']) end - lines.should == [ + expect(lines).to eq [ 'gcc -c -o simple.o -MMD -MF simple.mf simple.c', "gcc -o simple#{env["PROGSUFFIX"]} simple.o", ] @@ -103,7 +103,7 @@ describe Rscons do env = Rscons::Environment.new do |env| env.Program('header', Dir['*.c']) end - lines.should == [ + expect(lines).to eq [ 'CC header.o', "LD header#{env["PROGSUFFIX"]}", ] @@ -114,8 +114,8 @@ describe Rscons do Rscons::Environment.new do |env| env.Program('header', Dir['*.c']) end - File.exists?('header.o').should be_true - `./header`.should == "The value is 2\n" + expect(File.exists?('header.o')).to be_true + expect(`./header`).to eq "The value is 2\n" end it 'rebuilds a C module when a header it depends on changes' do @@ -123,10 +123,10 @@ describe Rscons do env = Rscons::Environment.new do |env| env.Program('header', Dir['*.c']) end - `./header`.should == "The value is 2\n" + expect(`./header`).to eq "The value is 2\n" file_sub('header.h') {|line| line.sub(/2/, '5')} env.process - `./header`.should == "The value is 5\n" + expect(`./header`).to eq "The value is 5\n" end it 'does not rebuild a C module when its dependencies have not changed' do @@ -134,13 +134,13 @@ describe Rscons do env = Rscons::Environment.new do |env| env.Program('header', Dir['*.c']) end - `./header`.should == "The value is 2\n" - lines.should == [ + expect(`./header`).to eq "The value is 2\n" + expect(lines).to eq [ 'CC header.o', "LD header#{env["PROGSUFFIX"]}", ] env.process - lines.should == [] + expect(lines).to eq [] end it "does not rebuild a C module when only the file's timestamp has changed" do @@ -148,15 +148,15 @@ describe Rscons do env = Rscons::Environment.new do |env| env.Program('header', Dir['*.c']) end - `./header`.should == "The value is 2\n" - lines.should == [ + expect(`./header`).to eq "The value is 2\n" + expect(lines).to eq [ 'CC header.o', "LD header#{env["PROGSUFFIX"]}", ] sleep 0.05 file_sub('header.c') {|line| line} env.process - lines.should == [] + expect(lines).to eq [] end it 're-links a program when the link flags have changed' do @@ -164,7 +164,7 @@ describe Rscons do env = Rscons::Environment.new(echo: :command) do |env| env.Program('simple', Dir['*.c']) end - lines.should == [ + expect(lines).to eq [ 'gcc -c -o simple.o -MMD -MF simple.mf simple.c', "gcc -o simple#{env["PROGSUFFIX"]} simple.o", ] @@ -172,7 +172,7 @@ describe Rscons do env["LIBPATH"] += ["libdir"] env.Program('simple', Dir['*.c']) end - lines.should == ["gcc -o simple#{env["PROGSUFFIX"]} simple.o -Llibdir"] + expect(lines).to eq ["gcc -o simple#{env["PROGSUFFIX"]} simple.o -Llibdir"] end it 'builds object files in a different build directory' do @@ -182,9 +182,9 @@ describe Rscons do env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/') env.Program('build_dir', Dir['src/**/*.c']) end - `./build_dir`.should == "Hello from two()\n" - File.exists?('build_one/one.o').should be_true - File.exists?('build_two/two.o').should be_true + expect(`./build_dir`).to eq "Hello from two()\n" + expect(File.exists?('build_one/one.o')).to be_true + expect(File.exists?('build_two/two.o')).to be_true end it 'uses build directories before build root' do @@ -195,7 +195,7 @@ describe Rscons do env.build_root = "build_root" env.Program('build_dir', Dir['src/**/*.c']) end - lines.should == ["CC build/one/one.o", "CC build/two/two.o", "LD build_dir#{env["PROGSUFFIX"]}"] + expect(lines).to eq ["CC build/one/one.o", "CC build/two/two.o", "LD build_dir#{env["PROGSUFFIX"]}"] end it 'uses build_root if no build directories match' do @@ -206,7 +206,7 @@ describe Rscons do env.build_root = "build_root" env.Program('build_dir.exe', Dir['src/**/*.c']) end - lines.should == ["CC build_root/src/one/one.o", "CC build_root/src/two/two.o", "LD build_dir.exe"] + expect(lines).to eq ["CC build_root/src/one/one.o", "CC build_root/src/two/two.o", "LD build_dir.exe"] end it "expands target and source paths starting with ^/ to be relative to the build root" do @@ -219,7 +219,7 @@ describe Rscons do env.Object("^/one.o", "^/one.c") env.Program('build_dir', Dir['src/**/*.c'] + ["^/one.o"]) end - lines.should == [ + expect(lines).to eq [ %q{gcc -c -o build_root/one.o -MMD -MF build_root/one.mf -Isrc/one/ -Isrc/two/ build_root/one.c}, %q{gcc -c -o build_root/src/two/two.o -MMD -MF build_root/src/two/two.mf -Isrc/one/ -Isrc/two/ src/two/two.c}, %Q{gcc -o build_dir#{env["PROGSUFFIX"]} build_root/src/two/two.o build_root/one.o}, @@ -233,15 +233,15 @@ describe Rscons do env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/') env.Program('build_dir', Dir['src/**/*.c']) end - `./build_dir`.should == "Hello from two()\n" - File.exists?('build_one/one.o').should be_true - File.exists?('build_two/two.o').should be_true + expect(`./build_dir`).to eq "Hello from two()\n" + expect(File.exists?('build_one/one.o')).to be_true + expect(File.exists?('build_two/two.o')).to be_true Rscons.clean - File.exists?('build_one/one.o').should be_false - File.exists?('build_two/two.o').should be_false - File.exists?('build_one').should be_false - File.exists?('build_two').should be_false - File.exists?('src/one/one.c').should be_true + expect(File.exists?('build_one/one.o')).to be_false + expect(File.exists?('build_two/two.o')).to be_false + expect(File.exists?('build_one')).to be_false + expect(File.exists?('build_two')).to be_false + expect(File.exists?('src/one/one.c')).to be_true end it 'does not clean created directories if other non-rscons-generated files reside there' do @@ -251,16 +251,16 @@ describe Rscons do env.build_dir(%r{^src/([^/]+)/}, 'build_\\1/') env.Program('build_dir', Dir['src/**/*.c']) end - `./build_dir`.should == "Hello from two()\n" - File.exists?('build_one/one.o').should be_true - File.exists?('build_two/two.o').should be_true + expect(`./build_dir`).to eq "Hello from two()\n" + expect(File.exists?('build_one/one.o')).to be_true + expect(File.exists?('build_two/two.o')).to be_true File.open('build_two/tmp', 'w') { |fh| fh.puts "dum" } Rscons.clean - File.exists?('build_one/one.o').should be_false - File.exists?('build_two/two.o').should be_false - File.exists?('build_one').should be_false - File.exists?('build_two').should be_true - File.exists?('src/one/one.c').should be_true + expect(File.exists?('build_one/one.o')).to be_false + expect(File.exists?('build_two/two.o')).to be_false + expect(File.exists?('build_one')).to be_false + expect(File.exists?('build_two')).to be_true + expect(File.exists?('src/one/one.c')).to be_true end it 'allows Ruby classes as custom builders to be used to construct files' do @@ -282,9 +282,9 @@ EOF env.Program('program', Dir['*.c']) end - lines.should == ["CC program.o", "LD program#{env["PROGSUFFIX"]}"] - File.exists?('inc.h').should be_true - `./program`.should == "The value is 5678\n" + expect(lines).to eq ["CC program.o", "LD program#{env["PROGSUFFIX"]}"] + expect(File.exists?('inc.h')).to be_true + expect(`./program`).to eq "The value is 5678\n" end it 'supports custom builders with multiple targets' do @@ -309,15 +309,15 @@ EOF env.Program("program", Dir["*.c"] + ["inc.c"]) end - lines.should == ["CHGen inc.c", "CC program.o", "CC inc.o", "LD program#{env["PROGSUFFIX"]}"] - File.exists?("inc.c").should be_true - File.exists?("inc.h").should be_true - `./program`.should == "The value is 42\n" + expect(lines).to eq ["CHGen inc.c", "CC program.o", "CC inc.o", "LD program#{env["PROGSUFFIX"]}"] + expect(File.exists?("inc.c")).to be_true + expect(File.exists?("inc.h")).to be_true + expect(`./program`).to eq "The value is 42\n" File.open("inc.c", "w") {|fh| fh.puts "int THE_VALUE = 33;"} env.process - lines.should == ["CHGen inc.c"] - `./program`.should == "The value is 42\n" + expect(lines).to eq ["CHGen inc.c"] + expect(`./program`).to eq "The value is 42\n" end it 'allows cloning Environment objects' do @@ -336,7 +336,7 @@ EOF env.Program('program-release', Dir['src/*.c']) end - lines.should == [ + expect(lines).to eq [ %q{gcc -c -o debug/program.o -MMD -MF debug/program.mf '-DSTRING="Debug Version"' -O2 src/program.c}, %Q{gcc -o program-debug#{debug["PROGSUFFIX"]} debug/program.o}, %q{gcc -c -o release/program.o -MMD -MF release/program.mf '-DSTRING="Release Version"' -O2 src/program.c}, @@ -360,7 +360,7 @@ EOF env.Program('program2', Dir['src/*.c']) end - lines.should == [ + expect(lines).to eq [ %q{gcc -c -o build/program.o -MMD -MF build/program.mf -DSTRING="Hello" -O2 src/program.c}, %Q{gcc -o program#{env1["PROGSUFFIX"]} build/program.o}, %Q{gcc -o program2#{env2["PROGSUFFIX"]} build/program.o}, @@ -372,8 +372,8 @@ EOF Rscons::Environment.new do |env| env.Program('simple', Dir['*.cc']) end - File.exists?('simple.o').should be_true - `./simple`.should == "This is a simple C++ program\n" + expect(File.exists?('simple.o')).to be_true + expect(`./simple`).to eq "This is a simple C++ program\n" end it 'allows overriding construction variables for individual builder calls' do @@ -382,13 +382,13 @@ EOF env.Object("one.o", "one.c", 'CPPFLAGS' => ['-DONE']) env.Program('two_sources', ['one.o', 'two.c']) end - lines.should == [ + expect(lines).to eq [ 'gcc -c -o one.o -MMD -MF one.mf -DONE one.c', 'gcc -c -o two.o -MMD -MF two.mf two.c', "gcc -o two_sources#{env["PROGSUFFIX"]} one.o two.o", ] - File.exists?("two_sources#{env["PROGSUFFIX"]}").should be_true - `./two_sources`.should == "This is a C program with two sources.\n" + expect(File.exists?("two_sources#{env["PROGSUFFIX"]}")).to be_true + expect(`./two_sources`).to eq "This is a C program with two sources.\n" end it 'builds a static library archive' do @@ -397,15 +397,15 @@ EOF env.Program('library', ['lib.a', 'three.c']) env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib']) end - lines.should == [ + expect(lines).to eq [ 'gcc -c -o one.o -MMD -MF one.mf -Dmake_lib one.c', 'gcc -c -o two.o -MMD -MF two.mf -Dmake_lib two.c', 'ar rcs lib.a one.o two.o', 'gcc -c -o three.o -MMD -MF three.mf three.c', "gcc -o library#{env["PROGSUFFIX"]} lib.a three.o", ] - File.exists?("library#{env["PROGSUFFIX"]}").should be_true - `ar t lib.a`.should == "one.o\ntwo.o\n" + expect(File.exists?("library#{env["PROGSUFFIX"]}")).to be_true + expect(`ar t lib.a`).to eq "one.o\ntwo.o\n" end it 'supports build hooks to override construction variables' do @@ -422,7 +422,7 @@ EOF end env.Program('build_hook.exe', Dir['src/**/*.c']) end - `./build_hook`.should == "Hello from two()\n" + expect(`./build_hook`).to eq "Hello from two()\n" lines.should =~ [ 'gcc -c -o build_one/one.o -MMD -MF build_one/one.mf -Isrc/one/ -Isrc/two/ -O1 src/one/one.c', 'gcc -c -o build_two/two.o -MMD -MF build_two/two.mf -Isrc/one/ -Isrc/two/ -O2 src/two/two.c', @@ -438,9 +438,9 @@ EOF fh.puts("foo") end end - lines.should == ["CC simple.o", "LD simple.exe"] - File.exists?('simple.o').should be_true - `./simple.exe`.should == "This is a simple C program\n" + expect(lines).to eq ["CC simple.o", "LD simple.exe"] + expect(File.exists?('simple.o')).to be_true + expect(`./simple.exe`).to eq "This is a simple C program\n" e2 = Rscons::Environment.new do |env| program = env.Program('simple.exe', Dir['*.c']) env.depends(program, "file.ld") @@ -448,16 +448,16 @@ EOF fh.puts("bar") end end - lines.should == ["LD simple.exe"] + expect(lines).to eq ["LD simple.exe"] e3 = Rscons::Environment.new do |env| env.Program('simple.exe', Dir['*.c']) File.unlink("file.ld") end - lines.should == ["LD simple.exe"] + expect(lines).to eq ["LD simple.exe"] Rscons::Environment.new do |env| env.Program('simple.exe', Dir['*.c']) end - lines.should == [] + expect(lines).to eq [] end unless ENV["omit_gdc_tests"] @@ -466,11 +466,11 @@ EOF Rscons::Environment.new(echo: :command) do |env| env.Program("hello-d.exe", Dir["*.d"]) end - lines.should == [ + expect(lines).to eq [ "gdc -c -o main.o main.d", "gdc -o hello-d.exe main.o", ] - `./hello-d`.rstrip.should == "Hello from D!" + expect(`./hello-d`.rstrip).to eq "Hello from D!" end end @@ -480,7 +480,7 @@ EOF env.Object("simple.o", "simple.c") env.Disassemble("simple.txt", "simple.o") end - File.exists?("simple.txt").should be_true + expect(File.exists?("simple.txt")).to be_true File.read("simple.txt").should =~ /Disassembly of section .text:/ end @@ -491,7 +491,7 @@ EOF env.Program("simple", "simplepp.c") end File.read("simplepp.c").should =~ /# \d+ "simple.c"/ - `./simple`.should == "This is a simple C program\n" + expect(`./simple`).to eq "This is a simple C program\n" end it "supports preprocessing C++ sources" do @@ -501,7 +501,7 @@ EOF env.Program("simple", "simplepp.cc") end File.read("simplepp.cc").should =~ /# \d+ "simple.cc"/ - `./simple`.should == "This is a simple C++ program\n" + expect(`./simple`).to eq "This is a simple C++ program\n" end it "supports invoking builders with no sources and a build_root defined" do @@ -539,8 +539,8 @@ EOF env.Program('program', "${src}") end - lines.should == ["CC program.o", "LD program#{env["PROGSUFFIX"]}"] - File.exists?('inc.h').should be_true - `./program`.should == "The value is 678\n" + expect(lines).to eq ["CC program.o", "LD program#{env["PROGSUFFIX"]}"] + expect(File.exists?('inc.h')).to be_true + expect(`./program`).to eq "The value is 678\n" end end diff --git a/spec/rscons/cache_spec.rb b/spec/rscons/cache_spec.rb index 1f72003..96a85a9 100644 --- a/spec/rscons/cache_spec.rb +++ b/spec/rscons/cache_spec.rb @@ -20,7 +20,7 @@ module Rscons $stderr.should_receive(:puts).with(/Warning:.*was.corrupt/) c = Cache.instance c.send(:initialize!) - c.instance_variable_get(:@cache).is_a?(Hash).should be_true + expect(c.instance_variable_get(:@cache).is_a?(Hash)).to be_true end end end @@ -40,7 +40,7 @@ module Rscons fh.should_receive(:puts) File.should_receive(:open).and_yield(fh) build_from(cache).write - cache["version"].should == Rscons::VERSION + expect(cache["version"]).to eq Rscons::VERSION end end @@ -52,12 +52,12 @@ module Rscons it "returns false when target file does not exist" do File.should_receive(:exists?).with("target").and_return(false) - build_from({}).up_to_date?("target", "command", [], empty_env).should be_false + expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_false end it "returns false when target is not registered in the cache" do File.should_receive(:exists?).with("target").and_return(true) - build_from({}).up_to_date?("target", "command", [], empty_env).should be_false + expect(build_from({}).up_to_date?("target", "command", [], empty_env)).to be_false end it "returns false when the target's checksum does not match" do @@ -65,7 +65,7 @@ module Rscons cache = build_from(_cache) File.should_receive(:exists?).with("target").and_return(true) cache.should_receive(:calculate_checksum).with("target").and_return("def") - cache.up_to_date?("target", "command", [], empty_env).should be_false + expect(cache.up_to_date?("target", "command", [], empty_env)).to be_false end it "returns false when the build command has changed" do @@ -73,7 +73,7 @@ module Rscons cache = build_from(_cache) File.should_receive(:exists?).with("target").and_return(true) cache.should_receive(:calculate_checksum).with("target").and_return("abc") - cache.up_to_date?("target", "command", [], empty_env).should be_false + expect(cache.up_to_date?("target", "command", [], empty_env)).to be_false end it "returns false when there is a new dependency" do @@ -83,7 +83,7 @@ module Rscons cache = build_from(_cache) File.should_receive(:exists?).with("target").and_return(true) cache.should_receive(:calculate_checksum).with("target").and_return("abc") - cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env).should be_false + expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_false end it "returns false when a dependency's checksum has changed" do @@ -101,7 +101,7 @@ module Rscons cache.should_receive(:calculate_checksum).with("target").and_return("abc") cache.should_receive(:calculate_checksum).with("dep.1").and_return("dep.1.chk") cache.should_receive(:calculate_checksum).with("dep.2").and_return("dep.2.changed") - cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env).should be_false + expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_false end it "returns false with strict_deps=true when cache has an extra dependency" do @@ -117,7 +117,7 @@ module Rscons cache = build_from(_cache) File.should_receive(:exists?).with("target").and_return(true) cache.should_receive(:calculate_checksum).with("target").and_return("abc") - cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env, strict_deps: true).should be_false + expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env, strict_deps: true)).to be_false end it "returns false when there is a new user dependency" do @@ -130,7 +130,7 @@ module Rscons env.should_receive(:get_user_deps).with("target").and_return(["file.ld"]) File.should_receive(:exists?).with("target").and_return(true) cache.should_receive(:calculate_checksum).with("target").and_return("abc") - cache.up_to_date?("target", "command", ["dep.1"], env).should be_false + expect(cache.up_to_date?("target", "command", ["dep.1"], env)).to be_false end it "returns false when a user dependency checksum has changed" do @@ -153,7 +153,7 @@ module Rscons cache.should_receive(:calculate_checksum).with("dep.2").and_return("dep.2.chk") cache.should_receive(:calculate_checksum).with("extra.dep").and_return("extra.dep.chk") cache.should_receive(:calculate_checksum).with("user.dep").and_return("INCORRECT") - cache.up_to_date?("target", "command", ["dep.1", "dep.2"], env).should be_false + expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], env)).to be_false end it "returns true when no condition for false is met" do @@ -172,7 +172,7 @@ module Rscons cache.should_receive(:calculate_checksum).with("dep.1").and_return("dep.1.chk") cache.should_receive(:calculate_checksum).with("dep.2").and_return("dep.2.chk") cache.should_receive(:calculate_checksum).with("extra.dep").and_return("extra.dep.chk") - cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env).should be_true + expect(cache.up_to_date?("target", "command", ["dep.1", "dep.2"], empty_env)).to be_true end end @@ -189,13 +189,13 @@ module Rscons cache.register_build("the target", "the command", ["dep 1", "dep 2"], env) cached_target = cache.instance_variable_get(:@cache)["targets"]["the target"] cached_target.should_not be_nil - cached_target["command"].should == Digest::MD5.hexdigest("the command".inspect) - cached_target["checksum"].should == "the checksum" - cached_target["deps"].should == [ + expect(cached_target["command"]).to eq Digest::MD5.hexdigest("the command".inspect) + expect(cached_target["checksum"]).to eq "the checksum" + expect(cached_target["deps"]).to eq [ {"fname" => "dep 1", "checksum" => "dep 1 checksum"}, {"fname" => "dep 2", "checksum" => "dep 2 checksum"}, ] - cached_target["user_deps"].should == [ + expect(cached_target["user_deps"]).to eq [ {"fname" => "user.dep", "checksum" => "user.dep checksum"}, ] end @@ -204,7 +204,7 @@ module Rscons describe "#targets" do it "returns a list of targets that are cached" do cache = {"targets" => {"t1" => {}, "t2" => {}, "t3" => {}}} - build_from(cache).targets.should == ["t1", "t2", "t3"] + expect(build_from(cache).targets).to eq ["t1", "t2", "t3"] end end @@ -223,7 +223,7 @@ module Rscons FileUtils.should_receive(:mkdir).with("one/two/four") cache.mkdir_p("one/two/three") cache.mkdir_p("one\\two\\four") - cache.directories.should == ["one/two", "one/two/three", "one/two/four"] + expect(cache.directories).to eq ["one/two", "one/two/three", "one/two/four"] end it "handles absolute paths" do @@ -233,14 +233,14 @@ module Rscons File.should_receive(:exists?).with("/one/two").and_return(false) FileUtils.should_receive(:mkdir).with("/one/two") cache.mkdir_p("/one/two") - cache.directories.should == ["/one/two"] + expect(cache.directories).to eq ["/one/two"] end end describe "#directories" do it "returns a list of directories that are cached" do _cache = {"directories" => {"dir1" => true, "dir2" => true}} - build_from(_cache).directories.should == ["dir1", "dir2"] + expect(build_from(_cache).directories).to eq ["dir1", "dir2"] end end @@ -249,13 +249,13 @@ module Rscons cache = build_from({}) cache.instance_variable_set(:@lookup_checksums, {"f1" => "f1.chk"}) cache.should_not_receive(:calculate_checksum) - cache.send(:lookup_checksum, "f1").should == "f1.chk" + expect(cache.send(:lookup_checksum, "f1")).to eq "f1.chk" end it "calls calculate_checksum when the checksum is not cached" do cache = build_from({}) cache.should_receive(:calculate_checksum).with("f1").and_return("ck") - cache.send(:lookup_checksum, "f1").should == "ck" + expect(cache.send(:lookup_checksum, "f1")).to eq "ck" end end @@ -264,7 +264,7 @@ module Rscons contents = "contents" File.should_receive(:read).with("fname", mode: "rb").and_return(contents) Digest::MD5.should_receive(:hexdigest).with(contents).and_return("the_checksum") - build_from({}).send(:calculate_checksum, "fname").should == "the_checksum" + expect(build_from({}).send(:calculate_checksum, "fname")).to eq "the_checksum" end end end diff --git a/spec/rscons/environment_spec.rb b/spec/rscons/environment_spec.rb index d925766..8802078 100644 --- a/spec/rscons/environment_spec.rb +++ b/spec/rscons/environment_spec.rb @@ -4,7 +4,7 @@ module Rscons it "adds the default builders when they are not excluded" do env = Environment.new env.builders.size.should be > 0 - env.builders.map {|name, builder| builder.is_a?(Builder)}.all?.should be_true + expect(env.builders.map {|name, builder| builder.is_a?(Builder)}.all?).to be_true env.builders.find {|name, builder| name == "Object"}.should_not be_nil env.builders.find {|name, builder| name == "Program"}.should_not be_nil env.builders.find {|name, builder| name == "Library"}.should_not be_nil @@ -12,7 +12,7 @@ module Rscons it "excludes the default builders with exclude_builders: :all" do env = Environment.new(exclude_builders: true) - env.builders.size.should == 0 + expect(env.builders.size).to eq 0 end context "when a block is given" do @@ -30,8 +30,8 @@ module Rscons env["CPPPATH"] << "path1" env2 = env.clone env2["CPPPATH"] << "path2" - env["CPPPATH"].should == ["path1"] - env2["CPPPATH"].should == ["path1", "path2"] + expect(env["CPPPATH"]).to eq ["path1"] + expect(env2["CPPPATH"]).to eq ["path1", "path2"] end it "supports nil, false, true, String, Symbol, Array, Hash, and Integer variables" do @@ -68,9 +68,9 @@ module Rscons describe "#add_builder" do it "adds the builder to the list of builders" do env = Environment.new(exclude_builders: true) - env.builders.keys.should == [] + expect(env.builders.keys).to eq [] env.add_builder(Rscons::Builders::Object.new) - env.builders.keys.should == ["Object"] + expect(env.builders.keys).to eq ["Object"] end end @@ -78,20 +78,20 @@ module Rscons context "with no build directories" do it "returns the name of the source file with suffix changed" do env = Environment.new - env.get_build_fname("src/dir/file.c", ".o").should == "src/dir/file.o" - env.get_build_fname("src\\dir\\other.d", ".a").should == "src/dir/other.a" - env.get_build_fname("source.cc", ".o").should == "source.o" + expect(env.get_build_fname("src/dir/file.c", ".o")).to eq "src/dir/file.o" + expect(env.get_build_fname("src\\dir\\other.d", ".a")).to eq "src/dir/other.a" + expect(env.get_build_fname("source.cc", ".o")).to eq "source.o" end context "with a build_root" do it "uses the build_root unless the path is absolute" do env = Environment.new env.build_root = "build/proj" - env.get_build_fname("src/dir/file.c", ".o").should == "build/proj/src/dir/file.o" - env.get_build_fname("/some/lib.c", ".a").should == "/some/lib.a" - env.get_build_fname("C:\\abspath\\mod.cc", ".o").should == "C:/abspath/mod.o" - env.get_build_fname("build\\proj\\generated.c", ".o").should == "build/proj/generated.o" - env.get_build_fname("build/proj.XX", ".yy").should == "build/proj/build/proj.yy" + expect(env.get_build_fname("src/dir/file.c", ".o")).to eq "build/proj/src/dir/file.o" + expect(env.get_build_fname("/some/lib.c", ".a")).to eq "/some/lib.a" + expect(env.get_build_fname("C:\\abspath\\mod.cc", ".o")).to eq "C:/abspath/mod.o" + expect(env.get_build_fname("build\\proj\\generated.c", ".o")).to eq "build/proj/generated.o" + expect(env.get_build_fname("build/proj.XX", ".yy")).to eq "build/proj/build/proj.yy" end end end @@ -101,10 +101,10 @@ module Rscons env = Environment.new env.build_dir("src", "bld") env.build_dir(%r{^libs/([^/]+)}, 'build/libs/\1') - env.get_build_fname("src/input.cc", ".o").should == "bld/input.o" - env.get_build_fname("libs/lib1/some/file.c", ".o").should == "build/libs/lib1/some/file.o" - env.get_build_fname("libs/otherlib/otherlib.cc", ".o").should == "build/libs/otherlib/otherlib.o" - env.get_build_fname("other_directory/o.d", ".a").should == "other_directory/o.a" + expect(env.get_build_fname("src/input.cc", ".o")).to eq "bld/input.o" + expect(env.get_build_fname("libs/lib1/some/file.c", ".o")).to eq "build/libs/lib1/some/file.o" + expect(env.get_build_fname("libs/otherlib/otherlib.cc", ".o")).to eq "build/libs/otherlib/otherlib.o" + expect(env.get_build_fname("other_directory/o.d", ".a")).to eq "other_directory/o.a" end context "with a build_root" do @@ -114,11 +114,11 @@ module Rscons env.build_dir(%r{^libs/([^/]+)}, 'build/libs/\1') env.build_root = "bldit" - env.get_build_fname("src/input.cc", ".o").should == "bld/input.o" - env.get_build_fname("libs/lib1/some/file.c", ".o").should == "build/libs/lib1/some/file.o" - env.get_build_fname("libs/otherlib/otherlib.cc", ".o").should == "build/libs/otherlib/otherlib.o" - env.get_build_fname("other_directory/o.d", ".a").should == "bldit/other_directory/o.a" - env.get_build_fname("bldit/some/mod.d", ".a").should == "bldit/some/mod.a" + expect(env.get_build_fname("src/input.cc", ".o")).to eq "bld/input.o" + expect(env.get_build_fname("libs/lib1/some/file.c", ".o")).to eq "build/libs/lib1/some/file.o" + expect(env.get_build_fname("libs/otherlib/otherlib.cc", ".o")).to eq "build/libs/otherlib/otherlib.o" + expect(env.get_build_fname("other_directory/o.d", ".a")).to eq "bldit/other_directory/o.a" + expect(env.get_build_fname("bldit/some/mod.d", ".a")).to eq "bldit/some/mod.a" end end end @@ -128,7 +128,7 @@ module Rscons it "allows reading construction variables" do env = Environment.new env["CFLAGS"] = ["-g", "-Wall"] - env["CFLAGS"].should == ["-g", "-Wall"] + expect(env["CFLAGS"]).to eq ["-g", "-Wall"] end end @@ -138,9 +138,9 @@ module Rscons env["CFLAGS"] = ["-g", "-Wall"] env["CFLAGS"] -= ["-g"] env["CFLAGS"] += ["-O3"] - env["CFLAGS"].should == ["-Wall", "-O3"] + expect(env["CFLAGS"]).to eq ["-Wall", "-O3"] env["other_var"] = "val33" - env["other_var"].should == "val33" + expect(env["other_var"]).to eq "val33" end end @@ -150,8 +150,8 @@ module Rscons env["CFLAGS"] = ["-g"] env["CPPPATH"] = ["inc"] env.append("CFLAGS" => ["-Wall"], "CPPPATH" => ["include"]) - env["CFLAGS"].should == ["-Wall"] - env["CPPPATH"].should == ["include"] + expect(env["CFLAGS"]).to eq ["-Wall"] + expect(env["CPPPATH"]).to eq ["include"] end end @@ -234,7 +234,7 @@ module Rscons env["specialflag"] = "-z" template = ["cmd", "-I${path}", "${flags}", "${_source}", "${_dest}"] cmd = env.build_command(template, "_source" => "infile", "_dest" => "outfile") - cmd.should == ["cmd", "-Idir1", "-Idir2", "-x", "-y", "-z", "infile", "outfile"] + expect(cmd).to eq ["cmd", "-Idir1", "-Idir2", "-x", "-y", "-z", "infile", "outfile"] end end @@ -245,11 +245,11 @@ module Rscons env["flags"] = ["-x", "-y", "${specialflag}"] env["specialflag"] = "-z" env["foo"] = {} - env.expand_varref(["-p${path}", "${flags}"]).should == ["-pdir1", "-pdir2", "-x", "-y", "-z"] - env.expand_varref("foo").should == "foo" + expect(env.expand_varref(["-p${path}", "${flags}"])).to eq ["-pdir1", "-pdir2", "-x", "-y", "-z"] + expect(env.expand_varref("foo")).to eq "foo" expect {env.expand_varref("${foo}")}.to raise_error /expand.a.variable.reference/ - env.expand_varref("${specialflag}").should == "-z" - env.expand_varref("${path}").should == ["dir1", "dir2"] + expect(env.expand_varref("${specialflag}")).to eq "-z" + expect(env.expand_varref("${path}")).to eq ["dir1", "dir2"] end end @@ -294,14 +294,14 @@ module Rscons it "records the target when the target method is a known builder" do env = Environment.new - env.instance_variable_get(:@targets).should == {} + expect(env.instance_variable_get(:@targets)).to eq({}) env.Object("target.o", ["src1.c", "src2.c"], var: "val") target = env.instance_variable_get(:@targets)["target.o"] target.should_not be_nil - target[:builder].is_a?(Builder).should be_true - target[:sources].should == ["src1.c", "src2.c"] - target[:vars].should == {var: "val"} - target[:args].should == [] + expect(target[:builder].is_a?(Builder)).to be_true + expect(target[:sources]).to eq ["src1.c", "src2.c"] + expect(target[:vars]).to eq({var: "val"}) + expect(target[:args]).to eq [] end it "raises an error when vars is not a Hash" do @@ -314,13 +314,13 @@ module Rscons it "records the given dependencies in @user_deps" do env = Environment.new env.depends("foo", "bar", "baz") - env.instance_variable_get(:@user_deps).should == {"foo" => ["bar", "baz"]} + expect(env.instance_variable_get(:@user_deps)).to eq({"foo" => ["bar", "baz"]}) end it "records user dependencies only once" do env = Environment.new env.instance_variable_set(:@user_deps, {"foo" => ["bar"]}) env.depends("foo", "bar", "baz") - env.instance_variable_get(:@user_deps).should == {"foo" => ["bar", "baz"]} + expect(env.instance_variable_get(:@user_deps)).to eq({"foo" => ["bar", "baz"]}) end end @@ -337,7 +337,7 @@ module Rscons env.add_builder(ABuilder.new) env.builders["Object"].should_receive(:run).with("mod.o", ["mod.c"], cache, env, anything).and_return("mod.o") env.builders["ABuilder"].should_receive(:run).with("mod2.ab_out", ["mod2.ab_in"], cache, env, anything).and_return("mod2.ab_out") - env.build_sources(["precompiled.o", "mod.c", "mod2.ab_in"], [".o", ".ab_out"], cache, {}).should == ["precompiled.o", "mod.o", "mod2.ab_out"] + expect(env.build_sources(["precompiled.o", "mod.c", "mod2.ab_in"], [".o", ".ab_out"], cache, {})).to eq ["precompiled.o", "mod.o", "mod2.ab_out"] end end @@ -350,11 +350,11 @@ module Rscons end end env.builders["Object"].stub(:run) do |target, sources, cache, env, vars| - vars["CFLAGS"].should == [] + expect(vars["CFLAGS"]).to eq [] end env.run_builder(env.builders["Object"], "build/normal/module.o", ["src/normal/module.c"], "cache", {}) env.builders["Object"].stub(:run) do |target, sources, cache, env, vars| - vars["CFLAGS"].should == ["-O3", "-DSPECIAL"] + expect(vars["CFLAGS"]).to eq ["-O3", "-DSPECIAL"] end env.run_builder(env.builders["Object"], "build/special/module.o", ["src/special/module.c"], "cache", {}) end @@ -438,7 +438,7 @@ module Rscons File.should_receive(:read).with('makefile').and_return(< 1, "two" => :two}) - v["one"].should == 1 - v["two"].should == :two + expect(v["one"]).to eq(1) + expect(v["two"]).to eq(:two) end it "initializes variables from another VarSet" do v = VarSet.new({"one" => 1}) v2 = VarSet.new(v) - v2["one"].should == 1 + expect(v2["one"]).to eq 1 end it "makes a deep copy of the given VarSet" do v = VarSet.new({"array" => [1, 2, 3]}) v2 = VarSet.new(v) v["array"] << 4 - v["array"].should == [1, 2, 3, 4] - v2["array"].should == [1, 2, 3] + expect(v["array"]).to eq([1, 2, 3, 4]) + expect(v2["array"]).to eq([1, 2, 3]) end end @@ -24,11 +24,11 @@ module Rscons it "allows accessing a variable with its verbatim value if type is not specified" do v = VarSet.new({"fuz" => "a string", "foo" => 42, "bar" => :baz, "qax" => [3, 6], "qux" => {a: :b}}) - v["fuz"].should == "a string" - v["foo"].should == 42 - v["bar"].should == :baz - v["qax"].should == [3, 6] - v["qux"].should == {a: :b} + expect(v["fuz"]).to eq("a string") + expect(v["foo"]).to eq(42) + expect(v["bar"]).to eq(:baz) + expect(v["qax"]).to eq([3, 6]) + expect(v["qux"]).to eq({a: :b}) end end @@ -36,8 +36,8 @@ module Rscons it "allows assigning to variables" do v = VarSet.new("CFLAGS" => ["-Wall", "-O3"]) v["CPPPATH"] = ["one", "two"] - v["CFLAGS"].should == ["-Wall", "-O3"] - v["CPPPATH"].should == ["one", "two"] + expect(v["CFLAGS"]).to eq(["-Wall", "-O3"]) + expect(v["CPPPATH"]).to eq(["one", "two"]) end end @@ -128,29 +128,29 @@ module Rscons "cmd" => ["${CC}", "-c", "${CFLAGS}", "-I${CPPPATH}"], "hash" => {}) it "expands to the string itself if the string is not a variable reference" do - v.expand_varref("CC").should == "CC" - v.expand_varref("CPPPATH").should == "CPPPATH" - v.expand_varref("str").should == "str" + expect(v.expand_varref("CC")).to eq("CC") + expect(v.expand_varref("CPPPATH")).to eq("CPPPATH") + expect(v.expand_varref("str")).to eq("str") end it "expands a single variable reference beginning with a '$'" do - v.expand_varref("${CC}").should == "gcc" - v.expand_varref("${CPPPATH}").should == ["dir1", "dir2"] + expect(v.expand_varref("${CC}")).to eq("gcc") + expect(v.expand_varref("${CPPPATH}")).to eq(["dir1", "dir2"]) end it "expands a single variable reference in ${arr} notation" do - v.expand_varref("prefix${CFLAGS}suffix").should == ["prefix-Wallsuffix", "prefix-O2suffix"] - v.expand_varref(v["cmd"]).should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"] + expect(v.expand_varref("prefix${CFLAGS}suffix")).to eq(["prefix-Wallsuffix", "prefix-O2suffix"]) + expect(v.expand_varref(v["cmd"])).to eq(["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]) end it "expands a variable reference recursively" do - v.expand_varref("${compiler}").should == "gcc" - v.expand_varref("${cmd}").should == ["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"] + expect(v.expand_varref("${compiler}")).to eq("gcc") + expect(v.expand_varref("${cmd}")).to eq(["gcc", "-c", "-Wall", "-O2", "-Idir1", "-Idir2"]) end it "resolves multiple variable references in one element by enumerating all combinations" do - v.expand_varref("cflag: ${CFLAGS}, cpppath: ${CPPPATH}, compiler: ${compiler}").should == [ + expect(v.expand_varref("cflag: ${CFLAGS}, cpppath: ${CPPPATH}, compiler: ${compiler}")).to eq([ "cflag: -Wall, cpppath: dir1, compiler: gcc", "cflag: -O2, cpppath: dir1, compiler: gcc", "cflag: -Wall, cpppath: dir2, compiler: gcc", "cflag: -O2, cpppath: dir2, compiler: gcc", - ] + ]) end it "returns an empty string when a variable reference refers to a non-existent variable" do expect(v.expand_varref("${not_here}")).to eq("")