2022-08-31 03:33:08 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe EmberCli do
|
2023-09-04 20:56:34 +08:00
|
|
|
describe ".ember_version" do
|
2022-08-31 03:33:08 +08:00
|
|
|
it "works" do
|
|
|
|
expect(EmberCli.ember_version).to match(/\A\d+\.\d+/)
|
|
|
|
end
|
|
|
|
end
|
2023-11-13 18:34:06 +08:00
|
|
|
|
|
|
|
describe "cache" do
|
|
|
|
after { EmberCli.clear_cache! }
|
|
|
|
|
|
|
|
def simulate_request_cache_clearance
|
|
|
|
# this method is defined by ActiveSupport::CurrentAttributes
|
|
|
|
# and is called before/after every web request
|
|
|
|
EmberCli.reset
|
|
|
|
end
|
|
|
|
|
|
|
|
context "in development" do
|
|
|
|
before { Rails.env.stubs(:development?).returns(true) }
|
|
|
|
|
|
|
|
it "cache works, and is cleared before/after each web request" do
|
|
|
|
EmberCli.cache[:foo] = "bar"
|
|
|
|
expect(EmberCli.cache[:foo]).to eq("bar")
|
|
|
|
|
|
|
|
simulate_request_cache_clearance
|
|
|
|
|
|
|
|
expect(EmberCli.cache[:foo]).to eq(nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "in production" do
|
|
|
|
before { Rails.env.stubs(:development?).returns(false) }
|
|
|
|
|
|
|
|
it "cache works, and can be cleared" do
|
|
|
|
EmberCli.cache[:foo] = "bar"
|
|
|
|
expect(EmberCli.cache[:foo]).to eq("bar")
|
|
|
|
|
|
|
|
simulate_request_cache_clearance
|
|
|
|
|
|
|
|
# In production, persists across requests
|
|
|
|
expect(EmberCli.cache[:foo]).to eq("bar")
|
|
|
|
|
|
|
|
# But still can be manually cleared
|
|
|
|
EmberCli.clear_cache!
|
|
|
|
expect(EmberCli.cache[:foo]).to eq(nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-08-31 03:33:08 +08:00
|
|
|
end
|