GithubHelp home page GithubHelp logo

Comments (4)

joestump avatar joestump commented on June 19, 2024

Also getting this, which might be related. I can't set an attribute that is set as default['some']['attribute'] without an exception being thrown.

/usr/local/Cellar/ruby/2.0.0-p353/bin/ruby -S rspec ./spec/cran_spec.rb
F

Failures:

  1) rstudio::server should include the r cookbook
     Failure/Error: node['rstudio']['cran']['packages'] = 'aadsf'
     NoMethodError:
       undefined method `[]' for nil:NilClass
     # ./spec/cran_spec.rb:12:in `block (3 levels) in <top (required)>'
     # ./spec/cran_spec.rb:11:in `new'
     # ./spec/cran_spec.rb:11:in `block (2 levels) in <top (required)>'
     # ./spec/cran_spec.rb:17:in `block (2 levels) in <top (required)>'

Finished in 1.22 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/cran_spec.rb:16 # rstudio::server should include the r cookbook
/usr/local/Cellar/ruby/2.0.0-p353/bin/ruby -S rspec ./spec/cran_spec.rb failed

Here's the spec

require 'spec_helper'

describe 'rstudio::server' do
#  before do
#    Fauxhai.mock(platform: 'ubuntu', version: '12.04') do |node|
#      # node['rstudio']['cran']['packages'] = 'aadsf'
#      node['languages']['ruby']['version'] = 'ree'
#    end
#  end
  let(:chef_run) do
    ChefSpec::Runner.new do |node|
      node['rstudio']['cran']['packages'] = 'aadsf'
    end.converge(described_recipe)
  end

  it('should include the r cookbook') do
    expect(chef_run).to include_recipe('r')
  end
end

from fauxhai.

sethvargo avatar sethvargo commented on June 19, 2024

That cookbook you posted is a 404. Since ChefSpec 2.0, you don't ever call fauxhai directly - it's used under the covers. Make a new Chef runner with the platform you want:

describe 'rstudio::server' do
  let(:chef_run) { ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04').converge(described_recipe) }

  it 'includes the r cookbook' do
    expect(chef_run).to include_recipe('r')
  end
end

You can also configure these options globally. All of this is explained in the ChefSpec configuration documentation and ChefSpec attribute setting documentation.

from fauxhai.

joestump avatar joestump commented on June 19, 2024

Ah, got it. 👍

from fauxhai.

dasomx77 avatar dasomx77 commented on June 19, 2024

Hey there Seth, I pretty much have the same issue as the one above and your solution doesn't seem to help solve the issue. I get

Failure/Error: ChefSpec::Runner.new do |node|
     ArgumentError:
       Cannot find a platform for node[fauxhai.local]

when trying to run:

let(:dummy_class) {
    Class.new {include Cookbook_name::Helper_module }
    ChefSpec::Runner.new(platform: 'ubuntu', version: '12.04') do |node|
      node.default.set['Cookbook_name']['attribute_name'] = '/aaa/va/files/'
    end.converge(described_recipe)
}

and given the stack trace, this is where it fails:

it 'should have the directory we are looking for' do
  expect(chef_run).to create_directory('/aaa/va/files/')
end

any idea what I might be doing wrong?
Thanks

from fauxhai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.