poise / halite

Write as a gem, release as a cookbook.
https://github.com/poise/halite
Apache License 2.0
42 stars 9 forks source link

chefspec missing dependency #10

Closed eedwards-sk closed 6 years ago

eedwards-sk commented 6 years ago

I'm requiring halite in my gemspec spec.add_runtime_dependency 'halite', '~> 1.8'

I've ran bundle install

I have a spec_helper generated with bundle gem

I've added require 'halite/spec_helper' and config.include Halite::SpecHelper

require "bundler/setup"
require "my_org/my_gem"
require 'halite/spec_helper'

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

  config.include Halite::SpecHelper
end

I've added require 'halite/rake_tasks' to my rakefile

When running rake from the project folder

/Users/username/.chefdk/gem/ruby/2.4.0/gems/halite-1.8.0/lib/halite/spec_helper.rb:18:in `require': cannot load such file -- chefspec (LoadError)
    from /Users/username/.chefdk/gem/ruby/2.4.0/gems/halite-1.8.0/lib/halite/spec_helper.rb:18:in `<top (required)>'

If I'm parsing this correctly then it appears that chefspec is not being specified as a dependency in the gemspec, and thus isn't getting installed by bundle install.

eedwards-sk commented 6 years ago

To confirm my suspicion, adding an explicit dependency to my consuming gem's gemspec for chefspec allows rake to succeed.

Is there a reason that it's not an explicit dependency for halite?

coderanger commented 6 years ago

It isn't a dependency because it's optional. Only needed if you want to use ChefSpec.