diff --git a/spec/rscons/environment_spec.rb b/spec/rscons/environment_spec.rb index dc81980..2579d33 100644 --- a/spec/rscons/environment_spec.rb +++ b/spec/rscons/environment_spec.rb @@ -28,6 +28,14 @@ module Rscons env.builders.find {|name, builder| name == "Program"}.should_not be_nil env.builders.find {|name, builder| name == "Library"}.should be_nil end + + context "when a block is given" do + it "yields self and invokes #process()" do + env = Environment.new do |env| + env.should_receive(:process) + end + end + end end describe "#clone" do @@ -39,6 +47,15 @@ module Rscons env["CPPPATH"].should == ["path1"] env2["CPPPATH"].should == ["path1", "path2"] end + + context "when a block is given" do + it "yields self and invokes #process()" do + env = Environment.new + env.clone do |env2| + env2.should_receive(:process) + end + end + end end describe "#add_builder" do @@ -228,6 +245,25 @@ module Rscons end end + describe "#run_builder" do + it "tweaks the construction variables using given tweakers and invokes the builder" do + env = Environment.new + env.add_tweaker do |build_op| + if build_op[:sources].first =~ %r{src/special} + build_op[:vars]["CFLAGS"] += ["-O3", "-DSPECIAL"] + end + end + env.builders["Object"].stub(:run) do |target, sources, cache, env, vars| + vars["CFLAGS"].should == [] + 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"] + end + env.run_builder(env.builders["Object"], "build/special/module.o", ["src/special/module.c"], "cache", {}) + end + end + describe ".parse_makefile_deps" do it 'handles dependencies on one line' do File.should_receive(:read).with('makefile').and_return(<