spec/flipper/ui_spec.rb in flipper-ui-0.7.1 vs spec/flipper/ui_spec.rb in flipper-ui-0.7.2
- old
+ new
@@ -1,16 +1,16 @@
require 'helper'
-describe Flipper::UI do
+RSpec.describe Flipper::UI do
describe "Initializing middleware with flipper instance" do
let(:app) { build_app(flipper) }
it "works" do
flipper.enable :some_great_feature
get "/features"
- last_response.status.should be(200)
- last_response.body.should include("some_great_feature")
+ expect(last_response.status).to be(200)
+ expect(last_response.body).to include("some_great_feature")
end
end
describe "Initializing middleware lazily with a block" do
let(:app) {
@@ -18,12 +18,12 @@
}
it "works" do
flipper.enable :some_great_feature
get "/features"
- last_response.status.should be(200)
- last_response.body.should include("some_great_feature")
+ expect(last_response.status).to be(200)
+ expect(last_response.body).to include("some_great_feature")
end
end
describe "Request method unsupported by action" do
it "raises error" do
@@ -36,9 +36,61 @@
# See https://github.com/jnunemaker/flipper/issues/80
it "can route features with names that match static directories" do
post "features/refactor-images/actors",
{"value" => "User:6", "operation" => "enable", "authenticity_token" => "a"},
"rack.session" => {:csrf => "a"}
- last_response.status.should be(302)
- last_response.headers["Location"].should eq("/features/refactor-images")
+ expect(last_response.status).to be(302)
+ expect(last_response.headers["Location"]).to eq("/features/refactor-images")
+ end
+
+ it "should not have an application_breadcrumb_href by default" do
+ expect(Flipper::UI.application_breadcrumb_href).to be(nil)
+ end
+
+ context "with application_breadcrumb_href not set" do
+ before do
+ @original_application_breadcrumb_href = Flipper::UI.application_breadcrumb_href
+ Flipper::UI.application_breadcrumb_href = nil
+ end
+
+ after do
+ Flipper::UI.application_breadcrumb_href = @original_application_breadcrumb_href
+ end
+
+ it 'does not add App breadcrumb' do
+ get "/features"
+ expect(last_response.body).to_not include('<a href="/myapp">App</a>')
+ end
+ end
+
+ context "with application_breadcrumb_href set" do
+ before do
+ @original_application_breadcrumb_href = Flipper::UI.application_breadcrumb_href
+ Flipper::UI.application_breadcrumb_href = "/myapp"
+ end
+
+ after do
+ Flipper::UI.application_breadcrumb_href = @original_application_breadcrumb_href
+ end
+
+ it 'does add App breadcrumb' do
+ get "/features"
+ expect(last_response.body).to include('<a href="/myapp">App</a>')
+ end
+ end
+
+ context "with application_breadcrumb_href set to full url" do
+ before do
+ @original_application_breadcrumb_href = Flipper::UI.application_breadcrumb_href
+ Flipper::UI.application_breadcrumb_href = "https://myapp.com/"
+ end
+
+ after do
+ Flipper::UI.application_breadcrumb_href = @original_application_breadcrumb_href
+ end
+
+ it 'does add App breadcrumb' do
+ get "/features"
+ expect(last_response.body).to include('<a href="https://myapp.com/">App</a>')
+ end
end
end