spec/figaro/application_spec.rb in figaro-1.0.0.rc1 vs spec/figaro/application_spec.rb in figaro-1.0.0

- old
+ new

@@ -1,16 +1,12 @@ -require "spec_helper" - require "tempfile" module Figaro describe Application do before do - Application.any_instance.stub( - default_path: "/path/to/app/config/application.yml", - default_environment: "development" - ) + allow_any_instance_of(Application).to receive(:default_path) { "/path/to/app/config/application.yml" } + allow_any_instance_of(Application).to receive(:default_environment) { "development" } end describe "#path" do it "uses the default" do application = Application.new @@ -40,11 +36,11 @@ it "follows a changing default" do application = Application.new expect { - application.stub(default_path: "/app/env.yml") + allow(application).to receive(:default_path) { "/app/env.yml" } }.to change { application.path }.from("/path/to/app/config/application.yml").to("/app/env.yml") end end @@ -84,11 +80,11 @@ it "follows a changing default" do application = Application.new expect { - application.stub(default_environment: "test") + allow(application).to receive(:default_environment) { "test" } }.to change { application.environment }.from("development").to("test") end end @@ -162,14 +158,14 @@ it "follows a changing default path" do path_1 = yaml_to_path("foo: bar") path_2 = yaml_to_path("foo: baz") application = Application.new - application.stub(default_path: path_1) + allow(application).to receive(:default_path) { path_1 } expect { - application.stub(default_path: path_2) + allow(application).to receive(:default_path) { path_2 } }.to change { application.configuration }.from("foo" => "bar").to("foo" => "baz") end @@ -177,25 +173,25 @@ application = Application.new(path: yaml_to_path(<<-YAML)) foo: bar test: foo: baz YAML - application.stub(default_environment: "development") + allow(application).to receive(:default_environment) { "development" } expect { - application.stub(default_environment: "test") + allow(application).to receive(:default_environment) { "test" } }.to change { application.configuration }.from("foo" => "bar").to("foo" => "baz") end end describe "#load" do let!(:application) { Application.new } before do - application.stub(configuration: { "foo" => "bar" }) + allow(application).to receive(:configuration) { { "foo" => "bar" } } end it "merges values into ENV" do expect { application.load @@ -217,36 +213,36 @@ end it "sets keys that have already been set internally" do application.load - application.stub(configuration: { "foo" => "baz" }) + allow(application).to receive(:configuration) { { "foo" => "baz" } } expect { application.load }.to change { ::ENV["foo"] }.from("bar").to("baz") end it "warns when a key isn't a string" do - application.stub(configuration: { foo: "bar" }) + allow(application).to receive(:configuration) { { foo: "bar" } } expect(application).to receive(:warn) application.load end it "warns when a value isn't a string" do - application.stub(configuration: { "foo" => ["bar"] }) + allow(application).to receive(:configuration) { { "foo" => ["bar"] } } expect(application).to receive(:warn) application.load end it "allows nil values" do - application.stub(configuration: { "foo" => nil }) + allow(application).to receive(:configuration) { { "foo" => nil } } expect { application.load }.not_to change { ::ENV["foo"]