From 2ed91f99026389e9d3eacba43b0ff38870c317bf Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Wed, 25 Jul 2018 18:28:55 +0900 Subject: [PATCH 01/46] Remove spec files Signed-off-by: Kenji Okimoto --- .../application_controller_spec.rb | 84 -------- .../fluentd/agents_controller_spec.rb | 61 ------ spec/controllers/misc_controller_spec.rb | 68 ------- spec/controllers/polling_controller_spec.rb | 39 ---- spec/controllers/sessions_controller_spec.rb | 5 - spec/decorators/plugin_decorator_spec.rb | 37 ---- spec/factories/fluentd.rb | 11 - spec/factories/plugins.rb | 8 - spec/factories/user.rb | 6 - spec/features/dashboard_spec.rb | 42 ---- .../fluentd/setting/histories_spec.rb | 110 ---------- .../fluentd/setting/in_forward_spec.rb | 6 - spec/features/fluentd/setting/in_http_spec.rb | 6 - .../fluentd/setting/in_monitor_agent_spec.rb | 6 - spec/features/fluentd/setting/notes_spec.rb | 27 --- .../fluentd/setting/out_forward_spec.rb | 38 ---- .../fluentd/setting/out_stdout_spec.rb | 6 - .../fluentd/setting/running_backup_spec.rb | 106 ---------- spec/features/fluentd_status_spec.rb | 36 ---- .../fluentd_ui_update_available_spec.rb | 33 --- spec/features/out_elasticsearch_spec.rb | 28 --- spec/features/out_forward_spec.rb | 36 ---- spec/features/out_tdlog_spec.rb | 26 --- spec/features/sessions_spec.rb | 79 -------- spec/features/setting_spec.rb | 95 --------- .../configurable_daemon_settings.rb | 17 -- .../shared_examples/login_required.rb | 4 - spec/features/source_and_output_spec.rb | 158 --------------- spec/features/users_spec.rb | 53 ----- spec/grok_converter_spec.rb | 50 ----- spec/lib/file_reverse_reader_spec.rb | 93 --------- spec/lib/fluentd-ui_spec.rb | 35 ---- spec/lib/regexp_preview/multi_line_spec.rb | 111 ---------- spec/lib/regexp_preview/single_line_spec.rb | 185 ----------------- spec/models/fluent_gem_spec.rb | 104 ---------- spec/models/fluentd/agent/common_spec.rb | 82 -------- spec/models/fluentd/agent_spec.rb | 134 ------------ .../models/fluentd/setting/in_forward_spec.rb | 131 ------------ spec/models/fluentd/setting/in_http_spec.rb | 31 --- .../fluentd/setting/in_monitor_agent_spec.rb | 31 --- spec/models/fluentd/setting/in_syslog_spec.rb | 98 --------- spec/models/fluentd/setting/in_tail_spec.rb | 53 ----- .../fluentd/setting/out_elasticsearch_spec.rb | 31 --- spec/models/fluentd/setting/out_mongo_spec.rb | 62 ------ spec/models/fluentd/setting/out_s3_spec.rb | 128 ------------ .../models/fluentd/setting/out_stdout_spec.rb | 31 --- spec/models/fluentd/setting/out_tdlog_spec.rb | 46 ----- spec/models/fluentd_log_spec.rb | 171 ---------------- spec/models/fluentd_spec.rb | 164 --------------- spec/models/plugin_spec.rb | 191 ------------------ spec/models/user_spec.rb | 59 ------ spec/spec_helper.rb | 85 -------- spec/support/config_histories.rb | 57 ------ spec/support/fixtures/error0.log | 12 -- spec/support/fixtures/error2.log | 130 ------------ spec/support/fixtures/error3.log | 7 - spec/support/fixtures/error4.log | 1 - spec/support/fixtures/multiline_example.log | 5 - spec/support/fluentd_agent_common_behavior.rb | 181 ----------------- .../support/fluentd_agent_restart_strategy.rb | 94 --------- spec/support/javascript_macro.rb | 21 -- spec/support/login_macro.rb | 10 - spec/support/stub_daemon.rb | 12 -- 63 files changed, 3867 deletions(-) delete mode 100644 spec/controllers/application_controller_spec.rb delete mode 100644 spec/controllers/fluentd/agents_controller_spec.rb delete mode 100644 spec/controllers/misc_controller_spec.rb delete mode 100644 spec/controllers/polling_controller_spec.rb delete mode 100644 spec/controllers/sessions_controller_spec.rb delete mode 100644 spec/decorators/plugin_decorator_spec.rb delete mode 100644 spec/factories/fluentd.rb delete mode 100644 spec/factories/plugins.rb delete mode 100644 spec/factories/user.rb delete mode 100644 spec/features/dashboard_spec.rb delete mode 100644 spec/features/fluentd/setting/histories_spec.rb delete mode 100644 spec/features/fluentd/setting/in_forward_spec.rb delete mode 100644 spec/features/fluentd/setting/in_http_spec.rb delete mode 100644 spec/features/fluentd/setting/in_monitor_agent_spec.rb delete mode 100644 spec/features/fluentd/setting/notes_spec.rb delete mode 100644 spec/features/fluentd/setting/out_forward_spec.rb delete mode 100644 spec/features/fluentd/setting/out_stdout_spec.rb delete mode 100644 spec/features/fluentd/setting/running_backup_spec.rb delete mode 100644 spec/features/fluentd_status_spec.rb delete mode 100644 spec/features/fluentd_ui_update_available_spec.rb delete mode 100644 spec/features/out_elasticsearch_spec.rb delete mode 100644 spec/features/out_forward_spec.rb delete mode 100644 spec/features/out_tdlog_spec.rb delete mode 100644 spec/features/sessions_spec.rb delete mode 100644 spec/features/setting_spec.rb delete mode 100644 spec/features/shared_examples/configurable_daemon_settings.rb delete mode 100644 spec/features/shared_examples/login_required.rb delete mode 100644 spec/features/source_and_output_spec.rb delete mode 100644 spec/features/users_spec.rb delete mode 100644 spec/grok_converter_spec.rb delete mode 100644 spec/lib/file_reverse_reader_spec.rb delete mode 100644 spec/lib/fluentd-ui_spec.rb delete mode 100644 spec/lib/regexp_preview/multi_line_spec.rb delete mode 100644 spec/lib/regexp_preview/single_line_spec.rb delete mode 100644 spec/models/fluent_gem_spec.rb delete mode 100644 spec/models/fluentd/agent/common_spec.rb delete mode 100644 spec/models/fluentd/agent_spec.rb delete mode 100644 spec/models/fluentd/setting/in_forward_spec.rb delete mode 100644 spec/models/fluentd/setting/in_http_spec.rb delete mode 100644 spec/models/fluentd/setting/in_monitor_agent_spec.rb delete mode 100644 spec/models/fluentd/setting/in_syslog_spec.rb delete mode 100644 spec/models/fluentd/setting/in_tail_spec.rb delete mode 100644 spec/models/fluentd/setting/out_elasticsearch_spec.rb delete mode 100644 spec/models/fluentd/setting/out_mongo_spec.rb delete mode 100644 spec/models/fluentd/setting/out_s3_spec.rb delete mode 100644 spec/models/fluentd/setting/out_stdout_spec.rb delete mode 100644 spec/models/fluentd/setting/out_tdlog_spec.rb delete mode 100644 spec/models/fluentd_log_spec.rb delete mode 100644 spec/models/fluentd_spec.rb delete mode 100644 spec/models/plugin_spec.rb delete mode 100644 spec/models/user_spec.rb delete mode 100644 spec/spec_helper.rb delete mode 100644 spec/support/config_histories.rb delete mode 100644 spec/support/fixtures/error0.log delete mode 100644 spec/support/fixtures/error2.log delete mode 100644 spec/support/fixtures/error3.log delete mode 100644 spec/support/fixtures/error4.log delete mode 100644 spec/support/fixtures/multiline_example.log delete mode 100644 spec/support/fluentd_agent_common_behavior.rb delete mode 100644 spec/support/fluentd_agent_restart_strategy.rb delete mode 100644 spec/support/javascript_macro.rb delete mode 100644 spec/support/login_macro.rb delete mode 100644 spec/support/stub_daemon.rb diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb deleted file mode 100644 index 75a4daf1e..000000000 --- a/spec/controllers/application_controller_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'spec_helper' - -class DummyController < ApplicationController; end - -describe DummyController do - controller DummyController do - skip_before_action :login_required - def index - render plain: "Hello World" - end - end - - describe '#set_locale' do - let!(:default_locale) { :en } - - before do - I18n.locale = I18n.default_locale #initialize - end - - context 'with params[:lang]' do - before do - get 'index', params: { lang: param_lang } - end - - context 'and in available_locales' do - let(:param_lang) { :ja } - - it 'params[:lang] will be set as locale' do - expect(I18n.locale).to eq :ja - end - end - - context 'and out of available_locales' do - let(:param_lang) { :ka } - - it 'defalut locale will be set as locale' do - expect(I18n.locale).to eq default_locale - end - end - end - - context 'with session[:prefer_lang]' do - before do - controller.session[:prefer_lang] = :ja - end - - it 'session[:prefer_lang] will be set as locale' do - get 'index' - expect(I18n.locale).to eq :ja - end - end - - context 'with request.env["HTTP_ACCEPT_LANGUAGE"]' do - before do - request.stub(:env).and_return({ "HTTP_ACCEPT_LANGUAGE" => accept_language }) - get 'index' - end - - context 'accept_language is available' do - let(:accept_language) { 'ja' } - - it 'session[:prefer_lang] will be set as locale' do - expect(I18n.locale).to eq :ja - end - end - - context 'accept_language is not available but start with en' do - let(:accept_language) { 'en-us' } - - it ':en will be set as locale' do - expect(I18n.locale).to eq :en - end - end - - context 'accept_language is not available' do - let(:accept_language) { 'ka' } - - it 'default_locale will be set as locale' do - expect(I18n.locale).to eq default_locale - end - end - end - end -end diff --git a/spec/controllers/fluentd/agents_controller_spec.rb b/spec/controllers/fluentd/agents_controller_spec.rb deleted file mode 100644 index 14820bc2c..000000000 --- a/spec/controllers/fluentd/agents_controller_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe Fluentd::AgentsController do - let(:log) { double('log').as_null_object } - - before do - allow(controller).to receive(:current_user).and_return true - allow(controller).to receive(:find_fluentd).and_return(nil) - controller.instance_variable_set(:@fluentd, double(agent: @agent = double(:agent))) - end - - describe "when the action succeeds" do - it "stops" do - expect(@agent).to receive(:stop).and_return true - put :stop - end - - it "starts" do - expect(@agent).to receive(:start).and_return true - put :start - end - - it "restarts" do - expect(@agent).to receive(:restart).and_return true - put :restart - end - - it "reaload" do - expect(@agent).to receive(:reload).and_return true - put :reload - end - end - - describe "when the action does not succeed" do - it "stops" do - expect(@agent).to receive(:stop).and_return false - put :stop - end - - it "starts" do - expect(@agent).to receive(:start).and_return false - expect(@agent).to receive(:log).and_return(log) - expect(log).to receive(:tail).with(1) - put :start - end - - it "restarts" do - expect(@agent).to receive(:restart).and_return false - expect(@agent).to receive(:log).and_return(log) - expect(log).to receive(:tail).with(1) - put :restart - end - - it "reload" do - expect(@agent).to receive(:reload).and_return false - expect(@agent).to receive(:log).and_return(log) - expect(log).to receive(:tail).with(1) - put :reload - end - end -end diff --git a/spec/controllers/misc_controller_spec.rb b/spec/controllers/misc_controller_spec.rb deleted file mode 100644 index f47c163ca..000000000 --- a/spec/controllers/misc_controller_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'spec_helper' - -describe MiscController do - let(:instance) { Fluentd.new(id: nil, variant: "fluentd_gem", log_file: "dummy.log", pid_file: "dummy.pid", config_file: "dummy.conf") } - - class DummyAagent - def log - Struct.new(:read).new(read: "dummy_log_content") - end - - def version - "dummy version" - end - end - - let!(:dummy_agent) { DummyAagent.new } - let!(:fluentd_log_content) { dummy_agent.log.read } - let!(:fluentd_version) { dummy_agent.version } - let(:fluentd_ui_log_content) { <<-LOG.strip_heredoc } - log1 - log2 - log3 - LOG - - let!(:dummy_log_path) { "tmp/dummy.log" } - let!(:expand_dir) { Rails.root.join("tmp/system_info") } - - before do - allow(controller).to receive(:current_user).and_return true - - #dummy log for fluentd-ui.log - File.open(dummy_log_path, 'w') { |file| file.write(fluentd_ui_log_content) } - controller.stub(:log_path) { dummy_log_path } - - instance.stub(:agent).and_return(dummy_agent) - Fluentd.stub(:instance).and_return(instance) - end - - describe 'download_info' do - before do - get 'download_info' - - #expand files in zip - Zip::File.open(Rails.root.join("tmp/system_info.zip")) do |zip_file| - FileUtils.mkdir_p(expand_dir) - - zip_file.each do |f| - f_path = File.join(expand_dir, f.name) - zip_file.extract(f, f_path) unless File.exist?(f_path) - end - end - end - - #remove all temp files for this spec - after do - FileUtils.rm Rails.root.join("tmp/system_info.zip") - FileUtils.rm_r expand_dir - FileUtils.rm dummy_log_path - end - - it 'write files' do - expect(File.read(File.join(expand_dir, "fluentd.log"))).to eq "#{fluentd_log_content}\n" - expect(File.read(File.join(expand_dir, "fluentd-ui.log"))).to eq "#{fluentd_ui_log_content}" - expect(File.read(File.join(expand_dir, "env.txt"))).to match "RAILS_ENV=test" - expect(File.read(File.join(expand_dir, "versions.txt"))).to match "fluentd: #{fluentd_version}" - end - end -end diff --git a/spec/controllers/polling_controller_spec.rb b/spec/controllers/polling_controller_spec.rb deleted file mode 100644 index 2d9588559..000000000 --- a/spec/controllers/polling_controller_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' - -describe PollingController do - describe 'polling for alerts' do - before do - allow(controller).to receive(:current_user).and_return true - end - - after do - response.should be_successful - end - - it 'may find nothing' do - expect(controller).to receive(:uninstalling_gems).and_return [] - expect(controller).to receive(:installing_gems).and_return [] - get :alerts - end - - it 'may find gems being uninstalled' do - expect(controller).to receive(:uninstalling_gems).and_return [ - double(gem_name: "foobar", version: "1.0.0") - ] - - allow(controller).to receive(:installing_gems).and_return [] - - get :alerts - end - - it 'may find gems being installed' do - expect(controller).to receive(:installing_gems).and_return [ - double(gem_name: "bazbang", version: "0.0.1") - ] - - allow(controller).to receive(:uninstalling_gems).and_return [] - - get :alerts - end - end -end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb deleted file mode 100644 index 702c5591f..000000000 --- a/spec/controllers/sessions_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe SessionsController do - -end diff --git a/spec/decorators/plugin_decorator_spec.rb b/spec/decorators/plugin_decorator_spec.rb deleted file mode 100644 index 0d131a561..000000000 --- a/spec/decorators/plugin_decorator_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe PluginDecorator do - let(:decorated_plugin) { build(:plugin).decorate } - - describe "#status" do - subject { decorated_plugin.status } - - context "plugin is processing" do - before { decorated_plugin.stub(:processing?).and_return(true) } - - it "returns the term for processing" do - expect(subject).to eq I18n.t("terms.processing") - end - end - - context "plugin isn't while processing" do - before { decorated_plugin.stub(:processing?).and_return(false) } - - context "plugin is already installed" do - before { decorated_plugin.stub(:installed?).and_return(true) } - - it "returns the term for installed" do - expect(subject).to eq I18n.t("terms.installed") - end - end - - context "plugin isn't installed yet" do - before { decorated_plugin.stub(:installed?).and_return(false) } - - it "returns the term for not installed" do - expect(subject).to eq I18n.t("terms.not_installed") - end - end - end - end -end diff --git a/spec/factories/fluentd.rb b/spec/factories/fluentd.rb deleted file mode 100644 index aff33b931..000000000 --- a/spec/factories/fluentd.rb +++ /dev/null @@ -1,11 +0,0 @@ -FactoryBot.define do - factory :fluentd do - dir = Rails.root.join("tmp/fluentd-test").to_s - FileUtils.mkdir_p(dir) - - variant "fluentd_gem" - log_file dir + "/fluentd.log" - pid_file dir + "/fluentd.pid" - config_file dir + "/fluentd.conf" - end -end diff --git a/spec/factories/plugins.rb b/spec/factories/plugins.rb deleted file mode 100644 index 010699bc5..000000000 --- a/spec/factories/plugins.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Read about factories at https://github.com/thoughtbot/factory_bot - -FactoryBot.define do - factory :plugin do - gem_name "fluent-plugin-dummy" - version "1.2.3" - end -end diff --git a/spec/factories/user.rb b/spec/factories/user.rb deleted file mode 100644 index e5f5e63ea..000000000 --- a/spec/factories/user.rb +++ /dev/null @@ -1,6 +0,0 @@ -FactoryBot.define do - factory :user do - name "admin" - password "changeme" - end -end diff --git a/spec/features/dashboard_spec.rb b/spec/features/dashboard_spec.rb deleted file mode 100644 index 398da1f2b..000000000 --- a/spec/features/dashboard_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'spec_helper' - -describe 'dashboard' do - let!(:exists_user) { build(:user) } - - before { login_with exists_user } - - context 'no configuration' do - before { visit '/' } - - it do - page.should have_css('h1', text: 'fluentd') - page.should have_link(I18n.t('terms.setup', target: 'fluentd')) - page.should have_link(I18n.t('terms.setup', target: 'td-agent')) - end - end - - context 'fluentd is stop', stub: :daemon do - before { visit '/' } - - it do - page.should have_css('h1', text: I18n.t('fluentd.show.page_title')) - page.should have_css('h4', text: I18n.t('fluentd.common.stopped')) - page.should have_css('h4', text: I18n.t('fluentd.common.fluentd_info')) - end - end - - context 'fluentd is running', stub: :daemon do - before do - # XXX i have no idea to not use stub... - Fluentd::Agent::TdAgent.any_instance.stub(:running?).and_return(true) - - visit '/' - end - - it do - page.should have_css('h1', text: I18n.t('fluentd.show.page_title')) - page.should have_css('h4', text: I18n.t('fluentd.common.running')) - page.should have_css('h4', text: I18n.t('fluentd.common.fluentd_info')) - end - end -end diff --git a/spec/features/fluentd/setting/histories_spec.rb b/spec/features/fluentd/setting/histories_spec.rb deleted file mode 100644 index 0c5e3f331..000000000 --- a/spec/features/fluentd/setting/histories_spec.rb +++ /dev/null @@ -1,110 +0,0 @@ -require "spec_helper" - -describe "histories", stub: :daemon do - let!(:exists_user) { build(:user) } - include_context 'daemon has some config histories' - - before do - login_with exists_user - end - - describe 'index' do - before do - visit '/daemon/setting/histories' - end - - it 'show histories#index' do - page.should have_css('h1', text: I18n.t('fluentd.settings.histories.index.page_title')) - expect(all('.row tr').count).to eq 9 + 1 # links to hisotries#show + 1 table header - end - - it 'will go to histories#show' do - all('.row tr td a').first.click - - page.should have_css('h1', text: I18n.t('fluentd.settings.histories.show.page_title')) - end - end - - describe 'show' do - let!(:last_backup_file) { Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order.first) } - let!(:new_file) { Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order[1]) } - - before do - visit "/daemon/setting/histories/#{last_backup_file.file_id}" - end - - it 'show histories#show' do - page.should have_css('h1', text: I18n.t('fluentd.settings.histories.show.page_title')) - - page.should has_text?(last_backup_file.content) - end - - describe 'diff' do - context 'has diff' do - it 'shows diff between current and target' do - page.should has_text?("- type http") - page.should has_text?("+ type forward") - page.should has_text?("- port 8899") - page.should has_text?("+ port 24224") - end - end - - context 'has no diff' do - before do - visit "/daemon/setting/histories/#{new_file.file_id}" - end - - it 'shows no diff message' do - page.should have_text(I18n.t('messages.no_diff')) - end - end - end - - it 'update config and redirect to setting#show' do - click_link I18n.t("terms.reuse") - - page.should have_css('h1', text: I18n.t('fluentd.settings.show.page_title')) - page.should have_text(I18n.t('messages.config_successfully_copied', brand: 'fluentd') ) - page.should has_text?(last_backup_file.content) - end - - describe "configtest" do - let(:daemon) { build(:fluentd, variant: "fluentd_gem") } # To use fluentd_gem for real dry-run checking - before do - daemon.agent.config_write config - daemon.agent.config_write "# dummy" - backup = Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order.first) - visit "/daemon/setting/histories/#{backup.file_id}" - click_link I18n.t("terms.configtest") - end - - context "invalid configfile" do - let(:config) { <<-CONFIG } - - type aaaaaaaaaaaa - - CONFIG - - it do - page.should_not have_css('.alert-success') - page.should have_css('.alert-danger') - page.should have_text(%Q|Unknown input plugin 'aaaaaaaaaaaa'|) - end - end - - context "valid configfile" do - let(:config) { <<-CONFIG } - - type syslog - tag syslog - - CONFIG - - it do - page.should have_css('.alert-success') - page.should_not have_css('.alert-danger') - end - end - end - end -end diff --git a/spec/features/fluentd/setting/in_forward_spec.rb b/spec/features/fluentd/setting/in_forward_spec.rb deleted file mode 100644 index 1b1d94b94..000000000 --- a/spec/features/fluentd/setting/in_forward_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "spec_helper" - -describe "in_forward", stub: :daemon, js: true do - before { login_with exists_user } - it_should_behave_like "configurable daemon settings", "in_forward", "port", "12345" -end diff --git a/spec/features/fluentd/setting/in_http_spec.rb b/spec/features/fluentd/setting/in_http_spec.rb deleted file mode 100644 index 4ae08d4b8..000000000 --- a/spec/features/fluentd/setting/in_http_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "spec_helper" - -describe "in_http", js: true, stub: :daemon do - before { login_with exists_user } - it_should_behave_like "configurable daemon settings", "in_http", "port", "12345" -end diff --git a/spec/features/fluentd/setting/in_monitor_agent_spec.rb b/spec/features/fluentd/setting/in_monitor_agent_spec.rb deleted file mode 100644 index 1f988358d..000000000 --- a/spec/features/fluentd/setting/in_monitor_agent_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "spec_helper" - -describe "in_monitor_agent", js: true, stub: :daemon do - before { login_with exists_user } - it_should_behave_like "configurable daemon settings", "in_monitor_agent", "port", "12345" -end diff --git a/spec/features/fluentd/setting/notes_spec.rb b/spec/features/fluentd/setting/notes_spec.rb deleted file mode 100644 index a869416c1..000000000 --- a/spec/features/fluentd/setting/notes_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require "spec_helper" - -describe "notes", stub: :daemon do - let!(:exists_user) { build(:user) } - include_context 'daemon has some config histories' - - before { login_with exists_user } - - describe 'update' do - let(:note_field) { ".note-content" } - let(:updating_content) { "This config file is for ..." } - - before do - visit '/daemon/setting/histories' - within first("form") do - first(note_field).set updating_content - click_button(I18n.t('terms.save')) - end - end - - it "update a content of a note" do - within first("form") do - first(note_field).value.should eq updating_content - end - end - end -end diff --git a/spec/features/fluentd/setting/out_forward_spec.rb b/spec/features/fluentd/setting/out_forward_spec.rb deleted file mode 100644 index cafd8eafb..000000000 --- a/spec/features/fluentd/setting/out_forward_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "spec_helper" - -describe "out_forward", js: true, stub: :daemon do - before { login_with exists_user } - - let(:type) { "out_forward" } - let(:page_url) { send("daemon_setting_#{type}_path") } - let(:form_values) { { - Pattern: "*", - Name: "name", - Host: "localhost", - Port: "9999", - } } - - it "Updated config after submit" do - daemon.agent.config.should_not include("type file") # out_forward's Secondary hidden field - form_values.each_pair do |k,v| - daemon.agent.config.should_not include(v) - end - visit page_url - within("form") do - form_values.each_pair do |k,v| - fill_in k, with: v - end - end - click_button I18n.t("fluentd.common.finish") - form_values.each_pair do |k,v| - daemon.agent.config.should include(v) - end - end - - it "Click to append Server fields", js: true do - visit page_url - all(".js-multiple").length.should == 1 - first(".js-multiple .js-append").click - all(".js-multiple").length.should == 2 - end -end diff --git a/spec/features/fluentd/setting/out_stdout_spec.rb b/spec/features/fluentd/setting/out_stdout_spec.rb deleted file mode 100644 index aa962ad25..000000000 --- a/spec/features/fluentd/setting/out_stdout_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require "spec_helper" - -describe "out_stdout", js: true, stub: :daemon do - before { login_with exists_user } - it_should_behave_like "configurable daemon settings", "out_stdout", "pattern", "stdout.**" -end diff --git a/spec/features/fluentd/setting/running_backup_spec.rb b/spec/features/fluentd/setting/running_backup_spec.rb deleted file mode 100644 index 8500fb7f0..000000000 --- a/spec/features/fluentd/setting/running_backup_spec.rb +++ /dev/null @@ -1,106 +0,0 @@ -require "spec_helper" - -describe "running_backup", stub: :daemon do - let!(:exists_user) { build(:user) } - include_context 'daemon has some config histories' - - before do - login_with exists_user - end - - context 'has no running backup file' do - before do - visit '/daemon/setting/running_backup' - end - - describe 'show' do - it 'has no content, no reuse bottun' do - expect(page).to have_text(I18n.t('fluentd.common.never_started_yet', brand: 'fluentd')) - expect(page).not_to have_css('pre') - expect(page).not_to have_text(I18n.t("terms.reuse")) - end - end - end - - context 'has running backup file' do - include_context 'daemon had been started once' - - before do - visit '/daemon/setting/running_backup' - end - - describe 'show' do - it 'has content, reuse bottun' do - expect(page).not_to have_text(I18n.t('fluentd.common.never_started_yet', brand: 'fluentd')) - expect(page).to have_text(backup_content) - expect(page).to have_text(I18n.t("terms.reuse")) - end - - describe 'diff' do - context 'has diff' do - it 'shows diff between current and running' do - diff = page.first(".diff pre").native.inner_text - expect(diff).to include("- type http") - expect(diff).to include("- port 8899") - expect(diff).to include("+ Running backup file content") - end - end - - context 'has no diff' do - before do - daemon.agent.config_write backup_content - visit '/daemon/setting/running_backup' - end - - it 'shows no diff message' do - page.should have_text(I18n.t('messages.no_diff')) - end - end - end - - it 'update config and redirect to setting#show' do - click_link I18n.t("terms.reuse") - - page.should have_css('h1', text: I18n.t('fluentd.settings.show.page_title')) - page.should have_text(I18n.t('messages.config_successfully_copied', brand: 'fluentd') ) - page.should have_text(backup_content) - end - - describe "configtest" do - let(:backup_content){ config } - let(:daemon) { build(:fluentd, variant: "fluentd_gem") } # To use fluentd_gem for real dry-run checking - before do - click_link I18n.t("terms.configtest") - end - - context "invalid configfile" do - let(:config) { <<-CONFIG } - - type aaaaaaaaaaaa - - CONFIG - - it do - page.should_not have_css('.alert-success') - page.should have_css('.alert-danger') - page.should have_text(%Q|Unknown input plugin 'aaaaaaaaaaaa'|) - end - end - - context "valid configfile" do - let(:config) { <<-CONFIG } - - type syslog - tag syslog - - CONFIG - - it do - page.should have_css('.alert-success') - page.should_not have_css('.alert-danger') - end - end - end - end - end -end diff --git a/spec/features/fluentd_status_spec.rb b/spec/features/fluentd_status_spec.rb deleted file mode 100644 index 7fe69e896..000000000 --- a/spec/features/fluentd_status_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'dashboard' do - let!(:exists_user) { build(:user) } - - before { login_with exists_user } - - context 'no configuration' do - before { visit '/' } - - it do - page.should_not have_css(".fluentd-status") - end - end - - context 'fluentd is stop', stub: :daemon do - before { visit '/' } - - it do - page.should have_css(".fluentd-status .stopped") - end - end - - context 'fluentd is running', stub: :daemon do - before do - # XXX i have no idea to not use stub... - Fluentd::Agent::TdAgent.any_instance.stub(:running?).and_return(true) - - visit '/' - end - - it do - page.should have_css(".fluentd-status .running") - end - end -end diff --git a/spec/features/fluentd_ui_update_available_spec.rb b/spec/features/fluentd_ui_update_available_spec.rb deleted file mode 100644 index 963a91329..000000000 --- a/spec/features/fluentd_ui_update_available_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "spec_helper" - -describe "fluentd-ui updates checking" do - let(:exists_user) { build(:user) } - before { login_with(exists_user) } - - describe "Show popup if newer version is available" do - let(:version) { "9999.99" } - let(:message) { I18n.t("messages.available_new_fluentd_ui", version: FluentdUI.latest_version, update_url: misc_information_path, title: "dummy") } - before { FluentdUI.latest_version = version } - after { FluentdUI.latest_version = ::FluentdUI::VERSION } - - it do - visit root_path - page.should have_css('.alert-info') - page.should have_content(version) - page.body.should include(message) - end - end - - describe "Not shown popup if newer version is not available" do - let(:version) { ::FluentdUI::VERSION } - let(:message) { I18n.t("messages.available_new_fluentd_ui", version: FluentdUI.latest_version, update_url: misc_information_path, title: "dummy") } - - it do - visit root_path - page.should_not have_css('.alert-info') - page.should_not have_content(version) - page.body.should_not include(message) - end - end - -end diff --git a/spec/features/out_elasticsearch_spec.rb b/spec/features/out_elasticsearch_spec.rb deleted file mode 100644 index 0ef910b58..000000000 --- a/spec/features/out_elasticsearch_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "spec_helper" - -describe "out_elasticsearch", stub: :daemon do - let(:exists_user) { build(:user) } - let(:match) { "test.out_forward.#{Time.now.to_i}.*" } - let(:location) { daemon_setting_out_elasticsearch_path } - - before do - login_with exists_user - end - - it "Shown form" do - visit location - page.should have_css('input[name="setting[pattern]"]') - end - - it "Updated config after submit", js: true do - daemon.agent.config.should_not include(match) - visit location - within('form') do - fill_in "Pattern", with: match - fill_in "Index name", with: "index" - fill_in "Type name", with: "type_name" - end - click_button I18n.t("fluentd.common.finish") - daemon.agent.config.should include(match) - end -end diff --git a/spec/features/out_forward_spec.rb b/spec/features/out_forward_spec.rb deleted file mode 100644 index df5d12f1a..000000000 --- a/spec/features/out_forward_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require "spec_helper" - -describe "out_forward", stub: :daemon do - let(:exists_user) { build(:user) } - let(:match) { "test.out_forward.#{Time.now.to_i}.*" } - - before do - login_with exists_user - end - - it "Shown form" do - visit daemon_setting_out_forward_path - page.should have_css('input[name="setting[pattern]"]') - end - - it "Appendable server setting", js: true do - visit daemon_setting_out_forward_path - all('.js-nested-column .js-append', visible: false).length.should == 1 - all('.js-append').first.click - all('.js-nested-column .js-append', visible: false).length.should == 2 - end - - it "Updated config after submit", js: true do - skip "Maybe validation failed" - daemon.agent.config.should_not include(match) - visit daemon_setting_out_forward_path - within('form') do - fill_in "Pattern", with: match - fill_in "setting_server_0__host", with: "foobar" - fill_in "setting_server_0__port", with: "9999" - fill_in "Path", with: "/tmp/foo" - end - click_button I18n.t("fluentd.common.finish") - daemon.agent.config.should include(match) - end -end diff --git a/spec/features/out_tdlog_spec.rb b/spec/features/out_tdlog_spec.rb deleted file mode 100644 index 7e1446fab..000000000 --- a/spec/features/out_tdlog_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require "spec_helper" - -describe "out_tdlog", stub: :daemon do - let(:exists_user) { build(:user) } - let(:api_key) { "dummydummy" } - - before do - login_with exists_user - end - - it "Shown form with filled in td.*.* on match" do - visit daemon_setting_out_tdlog_path - page.should have_css('input[name="setting[pattern]"]') - end - - it "Updated config after submit" do - skip "validation failed" - daemon.agent.config.should_not include(api_key) - visit daemon_setting_out_tdlog_path - within('form') do - fill_in "Apikey", with: api_key - end - click_button I18n.t("fluentd.common.finish") - daemon.agent.config.should include(api_key) - end -end diff --git a/spec/features/sessions_spec.rb b/spec/features/sessions_spec.rb deleted file mode 100644 index 39978b0fc..000000000 --- a/spec/features/sessions_spec.rb +++ /dev/null @@ -1,79 +0,0 @@ -require 'spec_helper' - -describe "sessions" do - let(:exists_user) { build(:user) } - let(:submit_label) { I18n.t("terms.sign_in") } - let(:after_sign_in_location) { daemon_path } - - describe "sign in with default password" do - before do - login_with user - end - - context "correct credentials" do - let(:user) { exists_user } - it "login success, then redirect to root_path, and redirect_to daemon_path from root_path" do - current_path.should == after_sign_in_location - end - end - - context "wrong credentials" do - let(:user) { build(:user, password: "passw0rd") } - - it "current location is not root_path" do - current_path.should_not == after_sign_in_location - end - - it "display form for retry" do - page.body.should have_css('form') - end - end - end - - describe "sign in with modified password" do - let(:user) { build(:user, password: password) } - let(:new_password) { "newpassword" } - let(:old_password) { Settings.default_password } - - before do - exists_user.update_attributes(current_password: Settings.default_password, password: new_password, password_confirmation: new_password) - - login_with user - end - - after do - # reset password to the default - FileUtils.rm_f(User::ENCRYPTED_PASSWORD_FILE) - end - - context "correct password" do - let(:password) { new_password } - it "login success" do - current_path.should == after_sign_in_location - end - end - - context "wrong password" do - let(:password) { old_password } - it "login failed" do - current_path.should_not == after_sign_in_location - end - end - end - - describe "sign out process" do - let(:submit_label) { I18n.t("terms.sign_in") } - before do - login_with exists_user - end - - before do - visit root_path - click_link I18n.t("terms.sign_out") - end - - it "at sign in page after sign out" do - current_path.should == new_sessions_path - end - end -end diff --git a/spec/features/setting_spec.rb b/spec/features/setting_spec.rb deleted file mode 100644 index 682dc673b..000000000 --- a/spec/features/setting_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'spec_helper' - -describe 'setting', stub: :daemon do - let!(:exists_user) { build(:user) } - include_context 'daemon has some config histories' - include_context 'daemon had been started once' - - before do - login_with exists_user - - daemon.agent.config_write 'GREAT CONFIG HERE' - - visit '/daemon/setting' - end - - it 'shows setting' do - page.should have_css('h1', text: I18n.t('fluentd.settings.show.page_title')) - page.should have_link(I18n.t('terms.edit')) - page.should have_css('pre', text: 'GREAT CONFIG HERE') - expect(all('.row tr').count).to eq Settings.histories_count_in_preview + 1 # links to hisotries#show + 1 table header - page.should have_link(I18n.t('fluentd.settings.show.link_to_histories')) - page.should have_text(I18n.t('fluentd.settings.running_backup.title')) - end - - it 'will go to histories#index' do - click_link I18n.t('fluentd.settings.show.link_to_histories') - - page.should have_css('h1', text: I18n.t('fluentd.settings.histories.index.page_title')) - end - - it 'will go to histories#show' do - all('.row tr td a').first.click - - page.should have_css('h1', text: I18n.t('fluentd.settings.histories.show.page_title')) - end - - it 'edits setting' do - click_link I18n.t('terms.edit') - - page.should have_css('h1', text: I18n.t('fluentd.settings.edit.page_title')) - page.should have_css('p.text-danger', text: I18n.t('terms.notice_restart_for_config_edit', brand: 'fluentd')) - - fill_in 'config', with: 'YET ANOTHER CONFIG' - - click_button I18n.t('terms.update') - - current_path.should == '/daemon/setting' - page.should have_css('pre', text: 'YET ANOTHER CONFIG') - end - - describe "config" do - before do - Fluentd::Agent::TdAgent.any_instance.stub(:dryrun).with(an_instance_of(String)).and_return(true) - daemon.agent.config_write conf - click_link I18n.t('terms.edit') - end - - context "plain config" do - let(:conf) { <<-'CONF' } - - type forward - - CONF - - it 'configtest' do - click_button I18n.t('terms.configtest') - page.should have_css('.alert-success') - end - - it "update & restart check" do - click_button I18n.t('terms.update') - daemon.agent.config.gsub("\r\n", "\n").should == conf # CodeMirror exchange \n -> \r\n - end - end - - context "embedded config" do - let(:conf) { <<-'CONF' } - - type forward - id "foo#{Time.now.to_s}" - - CONF - - it 'configtest' do - click_button I18n.t('terms.configtest') - page.should have_css('.alert-success') - end - - it "update & restart check" do - click_button I18n.t('terms.update') - daemon.agent.config.gsub("\r\n", "\n").should == conf # CodeMirror exchange \n -> \r\n - end - end - end -end diff --git a/spec/features/shared_examples/configurable_daemon_settings.rb b/spec/features/shared_examples/configurable_daemon_settings.rb deleted file mode 100644 index 34a2b4e83..000000000 --- a/spec/features/shared_examples/configurable_daemon_settings.rb +++ /dev/null @@ -1,17 +0,0 @@ -shared_examples_for "configurable daemon settings" do |type, form_name, form_value| - it "Shown form with filled in td.*.* on match" do - visit send("daemon_setting_#{type}_path") - page.should have_css("input[name=\"setting[#{form_name}]\"]") - end - - it "Updated config after submit" do - daemon.agent.config.should_not include(form_value) - visit send("daemon_setting_#{type}_path") - within("form") do - fill_in form_name.capitalize, with: form_value - end - click_button I18n.t("fluentd.common.finish") - daemon.agent.config.should include(form_value) - end - -end diff --git a/spec/features/shared_examples/login_required.rb b/spec/features/shared_examples/login_required.rb deleted file mode 100644 index 5364b2a11..000000000 --- a/spec/features/shared_examples/login_required.rb +++ /dev/null @@ -1,4 +0,0 @@ -shared_examples_for "login required" do - before { visit url } - it { current_path.should == new_sessions_path } -end diff --git a/spec/features/source_and_output_spec.rb b/spec/features/source_and_output_spec.rb deleted file mode 100644 index 5240dd79e..000000000 --- a/spec/features/source_and_output_spec.rb +++ /dev/null @@ -1,158 +0,0 @@ -require "spec_helper" - -describe "source_and_output", js: true, stub: :daemon do - let(:exists_user) { build(:user) } - - before do - login_with exists_user - end - - before do - daemon.agent.config_write config_contents - visit source_and_output_daemon_setting_path - end - - context "config is blank" do - let(:config_contents) { "" } - it do - page.should have_content(I18n.t("fluentd.settings.source_and_output.setting_empty")) - page.should have_css(".input .empty") - page.should have_css(".output .empty") - end - end - - context "config is given" do - let(:config_contents) { <<-CONF.strip_heredoc } - - # http://docs.fluentd.org/articles/in_forward - type forward - port 24224 - - - - # http://docs.fluentd.org/articles/out_stdout - type stdout - - - - type s3 - aws_key_id fofoaiofa - aws_sec_key aaaaaaaaaaaaaae - s3_bucket test - s3_endpoint s3-us-west-1.amazonaws.com - format out_file - include_time_key false - add_newline false - output_tag true - output_time true - store_as gzip - use_ssl true - buffer_type memory - - CONF - - it do - page.should_not have_content(I18n.t("fluentd.settings.source_and_output.setting_empty")) - - page.should have_css('.input .card .card-header') - page.should have_css('.output .card .card-header') - end - - it ".card-body is hidden by default and click .card-header for display" do - page.should_not have_css('.input .card .card-body') - page.should_not have_css('.output .card .card-body') - all(".input .card .card-header").first.click - page.should have_css('.input .card .card-body') - all(".output .card .card-header").first.click - page.should have_css('.output .card .card-body') - end - - it "display plugin name" do - within ".input" do - page.should have_content("forward") - end - - within ".output" do - page.should have_content("stdout") - page.should have_content("s3") - end - end - end - - describe "edit, update, delete" do - let(:config_contents) { <<-CONF.strip_heredoc } - - type forward - port 24224 - - CONF - let(:new_config) { <<-CONF.strip_heredoc } - - type http - port 8899 - - CONF - - before do - all(".input .card .card-header").first.click - end - - it "click edit button transform textarea, then click cancel button to be reset" do - skip "Doesn't work on Poltergeist" - page.should_not have_css('.input textarea') - find(".btn", text: I18n.t('terms.edit')).click - page.evaluate_script(<<-JS).should == config_contents - document.querySelector("textarea").codemirror.getValue() - JS - page.evaluate_script <<-JS - var cm = document.querySelector('textarea').codemirror; - cm.setValue(JSON.parse(#{new_config.to_json})); - JS - find(".btn", text: I18n.t('terms.cancel')).click - content = wait_until do - page.evaluate_script("document.querySelector('.input pre').textContent") - end - content.should == config_contents - daemon.agent.config.strip.should == config_contents.strip - end - - it "click edit button transform textarea, then click update button to be stored" do - skip "Doesn't work on Poltergeist" - page.should_not have_css('.input textarea') - find(".btn", text: I18n.t('terms.edit')).click - page.evaluate_script(<<-JS).should == config_contents - document.querySelector("textarea").codemirror.getValue() - JS - page.evaluate_script <<-JS - var cm = document.querySelector('textarea').codemirror; - cm.setValue(JSON.parse(#{new_config.to_json})); - JS - find(".btn", text: I18n.t('terms.save')).click - content = wait_until do - page.evaluate_script("document.querySelector('.input pre').textContent") - end - content.should == new_config - daemon.agent.config.strip.should == new_config.strip - end - - it "click delete button transform textarea" do - skip "accept_confirm does not work properly" - page.should have_css('.input .card-body') - accept_confirm do - find(".btn", text: I18n.t('terms.destroy')).click - end - page.should_not have_css('.input .card-body') - daemon.agent.config.strip.should == "" - end - - it "click delete button then cancel it" do - skip "accept_confirm does not work properly" - page.should have_css('.input .card-body') - dismiss_confirm do - find(".btn", text: I18n.t('terms.destroy')).click - end - page.should have_css('.input .card-body') - daemon.agent.config.strip.should == config_contents.strip - end - end -end diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb deleted file mode 100644 index 177deb14e..000000000 --- a/spec/features/users_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require "spec_helper" - -describe "users" do - describe "visit edit page before login" do - let(:url) { user_path } - it_should_behave_like "login required" - end - - describe "edit" do - let!(:user) { build(:user) } - - before do - login_with user - end - - after do - # reset password to the default - FileUtils.rm_f(User::ENCRYPTED_PASSWORD_FILE) - end - - describe 'to change password' do - let(:current_password) { user.password } - let(:password) { 'new_password' } - - before do - visit user_path - fill_in 'user[current_password]', with: current_password - - fill_in 'user[password]', with: password - fill_in 'user[password_confirmation]', with: password_confirmation - click_button I18n.t("terms.update_password") - end - - context 'when valid new password/confirmation is input' do - let(:password_confirmation) { password } - - it 'should update users password with new password' do - expect(page).to have_css('.alert-success') - expect(user.stored_digest).to eq user.digest(password) - end - end - - context 'when invalid new password/confirmation is input' do - let(:password_confirmation) { 'invalid_password' } - - it 'should not update users password with new password' do - expect(page).to have_css('.alert-danger') - expect(user.stored_digest).to eq user.digest(current_password) - end - end - end - end -end diff --git a/spec/grok_converter_spec.rb b/spec/grok_converter_spec.rb deleted file mode 100644 index e2b0ce1ab..000000000 --- a/spec/grok_converter_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper' - -describe GrokConverter do - describe "#convert_to_regexp" do - let(:grok) { GrokConverter.new } - - subject { grok.convert_to_regexp(pattern) } - - context "load" do - before { grok.load_patterns(Rails.root + "vendor/patterns/") } - - context "basic key" do - let(:pattern) { "%{USER:username} is a user" } - - it do - subject.names.should == ["username"] - end - - it do - subject.match("foobar is a user").should be_truthy - end - end - - context "without name" do - let(:pattern) { "%{USER} is a user" } - - it do - subject.names.should == [] - end - - it do - subject.match("foobar2 is a user").should be_truthy - end - end - - context "not exists key" do - let(:pattern) { "%{USER:username} %{USER} %{NOT_EXISTS_KEY:key} foo bar" } - - it do - subject.names.should == ["username", "key"] - end - - it do - subject.match("someuser user2 foo bar").should be_truthy - end - end - end - end -end - diff --git a/spec/lib/file_reverse_reader_spec.rb b/spec/lib/file_reverse_reader_spec.rb deleted file mode 100644 index 264cbd112..000000000 --- a/spec/lib/file_reverse_reader_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -# coding: utf-8 - -require "enumerator" -require 'spec_helper' - -describe FileReverseReader do - let(:instance) { FileReverseReader.new(io) } - let(:io) { File.open(logfile) } - - describe "#each_line" do - let(:instance) { FileReverseReader.new(io, step) } - subject { instance.enum_for(:each_line) } - let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) } - - context "read at once" do - - context "small file (read at once)" do - let(:step) { File.size(logfile) } - - it { subject.count.should == File.open(logfile).each_line.count } - it "reverse order" do - subject.to_a.should == File.open(logfile).each_line.to_a.map(&:strip).reverse - end - end - - context "large file" do - let(:step) { 2 } - - it { subject.count.should == File.open(logfile).each_line.count } - it "reverse order" do - subject.to_a.should == File.open(logfile).each_line.to_a.map(&:strip).reverse - end - end - end - end - - describe "#binary_file?" do - let(:logfile) { File.expand_path("./tmp/log.log", Rails.root) } - before { File.open(logfile, "wb"){|f| f.write content} } - subject { instance.binary_file? } - - context "contain ascii only" do - let(:content) { "ABCDE" } - it { should == false } - end - - context "contain non-ascii" do - let(:content) { "\x89NG" } - it { should == true } - end - end - - describe "#tail" do - let(:logfile) { File.expand_path("./tmp/log.log", Rails.root) } - before { File.open(logfile, "wb"){|f| f.write(content) } } - - describe "count" do - let(:log_lines) { 100 } - let(:content) { "foo\n" * log_lines } - subject { instance.tail(count) } - - context "2" do - let(:count) { 2 } - it { subject.to_a.size.should == count } - end - - context "50" do - let(:count) { 50 } - it { subject.to_a.size.should == count } - end - - context "over log lines" do - let(:count) { log_lines + 100 } - it { subject.to_a.size.should == log_lines } - end - end - - describe "non-ascii encoding" do - subject { instance.tail } - - context "compatible with utf-8" do - let(:content) { "utf8あいう\n" } - it { subject.to_a.should == [content.strip] } - end - - context "incompatible with utf-8" do - let(:content) { "eucあいう\n".encode('euc-jp') } - it { subject.to_a.should == [] } - end - end - end -end - diff --git a/spec/lib/fluentd-ui_spec.rb b/spec/lib/fluentd-ui_spec.rb deleted file mode 100644 index dfb5e1468..000000000 --- a/spec/lib/fluentd-ui_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe FluentdUI do - describe ".update_available?" do - let(:current_version) { ::FluentdUI::VERSION } - before { FluentdUI.latest_version = latest_version } - subject { FluentdUI.update_available? } - - context "nothing" do - let(:latest_version) { current_version } - it { should be_falsey } - end - - context "available" do - let(:latest_version) { current_version.succ } - it { should be_truthy } - end - end - - describe ".fluentd_version" do - before { Fluentd.stub(:instance).and_return(target) } - subject { FluentdUI.fluentd_version } - - context "not setup yet" do - let(:target) { nil } - it { should be_nil } - end - - context "did setup" do - let(:target) { build(:fluentd) } - let(:version) { "1.1.1" } - it { should == target.agent.version } - end - end -end diff --git a/spec/lib/regexp_preview/multi_line_spec.rb b/spec/lib/regexp_preview/multi_line_spec.rb deleted file mode 100644 index 4e5927dc7..000000000 --- a/spec/lib/regexp_preview/multi_line_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -require 'spec_helper' - -describe RegexpPreview::MultiLine do - describe "#matches" do - subject { parser.matches } - let(:parser) { RegexpPreview::MultiLine.new(target_path, "multiline", plugin_config) } - - describe "simple usage" do - let(:target_path) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) } - - let :plugin_config do - plugin_config = { - "format_firstline" => "/foo/", - "time_format" => "time_format", - } - plugin_config["format1"] = "/(?foo)\n/" - plugin_config["format2"] = "/(?bar)/" - 3.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i| - plugin_config["format#{i}"] = "//" - end - plugin_config - end - - it "should include matches info" do - matches_info = { - whole: "foo\nbar\nbaz\n1\n2\n3\n4\n5\n6\n10\n11\n12", - matches: [ - { - key: "foo", matched: "foo", pos: [0, 3] - }, - { - key: "bar", matched: "bar", pos: [4, 7] - } - ] - } - expect(subject[:matches]).to include matches_info - end - end - - describe "detect only continuos patterns" do - let(:target_path) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) } - let(:plugin_config) do - plugin_config = { - "format_firstline" => "/foo/", - "time_format" => "time_format", - } - plugin_config["format1"] = "/(?foo)\n/" - plugin_config["format2"] = "/(?baz)/" - 3.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i| - plugin_config["format#{i}"] = "//" - end - plugin_config - end - - it "shouldn't match" do - expect(subject[:matches]).to eq [] - end - end - - describe "example on document" do - # http://docs.fluentd.org/articles/in_tail - let(:target_path) { File.expand_path("./spec/support/fixtures/multiline_example.log", Rails.root) } - - let :plugin_config do - plugin_config = { - "format_firstline" => "/\\d{4}-\\d{1,2}-\\d{1,2}/", - "format1" => "/^(?