Module: DeployRubygem::RSpecTesting
- Defined in:
- lib/deploy_rubygem/rspec.rb,
lib/deploy_rubygem/rspec/chef.rb,
lib/deploy_rubygem/rspec/ruby.rb,
lib/deploy_rubygem/rspec/inspec.rb
Overview
Using Project to deploy and manage Project
Instance Method Summary collapse
- #check_current_version(gem_name, version) ⇒ Object
- #help_rspec(helper) ⇒ Object
- #install_gem_via_git(gem_obj) ⇒ Object
- #testing_chef(chefrepo) ⇒ Object
- #testing_gem(gem_obj) ⇒ Object
- #testing_inspec(inspector) ⇒ Object
- #testing_project(gem_obj) ⇒ Object
- #testing_workstation(chefrepo) ⇒ Object
Instance Method Details
#check_current_version(gem_name, version) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/deploy_rubygem/rspec/ruby.rb', line 29 def check_current_version(gem_name, version) RSpec.describe [gem_name, version].join(', ') do it 'has a version number' do expect(version).not_to be nil end it "has not the actual version #{version} publish" do gem_version = Gem::Version.new(version) version_to_check = "#{gem_name} (#{gem_version})" expect(`gem list -r #{gem_name}`).not_to include(version_to_check) end end end |
#help_rspec(helper) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/deploy_rubygem/rspec.rb', line 12 def help_rspec(helper) helper.extend DeployRubygem RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = '.rspec_status' # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_with :rspec do |c| c.syntax = :expect end yield(config) if block_given? end end |
#install_gem_via_git(gem_obj) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/deploy_rubygem/rspec/ruby.rb', line 19 def install_gem_via_git(gem_obj) RSpec.describe "Install #{gem_obj.project_name}" do it "Change to #{gem_obj} folder" do change_repo = gem_obj.change_to_project_folder expect(change_repo).not_to be nil expect(Dir.pwd).to eq(gem_obj.path) end end end |
#testing_chef(chefrepo) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/deploy_rubygem/rspec/chef.rb', line 16 def testing_chef(chefrepo) RSpec.describe "Accept Chef License #{chefrepo.project_name}" do it 'Accept the Chef License' do extend DeployRubygem expect(`#{chef_accept_cmd}`).not_to be nil end end end |
#testing_gem(gem_obj) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/deploy_rubygem/rspec/ruby.rb', line 8 def testing_gem(gem_obj) RSpec.describe "Testing #{gem_obj}" do it 'has a Project Name' do expect(gem_obj.project_name).not_to be nil end it 'has Project Options' do expect(gem_obj.).not_to be nil end end end |
#testing_inspec(inspector) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/deploy_rubygem/rspec/inspec.rb', line 8 def testing_inspec(inspector) inspect_test = InspecTestor.new(inspector[:inspec_path], inspector[:input_file], inspector[:waiver_file]) RSpec.describe "Testing #{inspect_test} at #{Dir.pwd}" do it 'Should be a kind of Html' do test_html = inspect_test.save_as_html('/tmp/html/deploy_rubygem_kind_of_html.html') expect(test_html).to be true end it 'Should be a kind of Json' do expect(inspect_test.test_json).to be_kind_of(InspecTestorResult) expect(inspect_test.test_json.status).to eq 'loaded' end it 'Should be successfull' do expect(inspect_test.test_json.success_result).to eq inspector[:success_result] expect(inspect_test.test_json.success_control).to eq inspector[:success_control] expect(inspect_test.test_json.failed_result).to eq inspector[:failed_result] expect(inspect_test.test_json.failed_control).to eq inspector[:failed_control] expect(inspect_test.test_json.pending_result).to eq inspector[:pending_result] expect(inspect_test.test_json.pending_control).to eq inspector[:pending_control] end end end |
#testing_project(gem_obj) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/deploy_rubygem/rspec.rb', line 29 def testing_project(gem_obj) RSpec.describe "Testing gem #{gem_obj.project_name}" do it 'should not be null' do expect(gem_obj).not_to be nil end it 'should be a Project' do expect(gem_obj).to be_kind_of(DeployRubygem::Project) end it 'should get a Project Name' do expect(gem_obj.project_name).to eq(gem_obj.project_name) end end end |
#testing_workstation(chefrepo) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/deploy_rubygem/rspec/chef.rb', line 25 def testing_workstation(chefrepo) RSpec.describe "Install #{chefrepo.project_name}" do it "Change to #{chefrepo} folder" do change_repo = chefrepo.change_to_project_folder expect(change_repo).not_to be nil expect(Dir.pwd).to eq(chefrepo.path) end it 'Change to Chef repo folder' do change_repo = chefrepo.change_to_chefrepo expect(change_repo).not_to be nil expect(change_repo).to eq(chefrepo.chefrepo_path) expect(Dir.pwd).to eq(chefrepo.chefrepo_path) end unless chefrepo.cookbooks.nil? it 'Should list his cookbooks dependencies' do cookbooks = chefrepo.cookbooks expect(cookbooks).not_to be nil expect(cookbooks).to be_kind_of(Array) end end end end |