ChefSpec - Is there anyway to change the node attributes for different contexts?

Hi I have a ChefSpec test below, I have looked around on Google but could not find the best way to manipulate the node attributes (from recipe) in different context blocks in ChefSpec file. Please let me know if there is a better way to change the node attributes in 'context' level or 'it' block level?

require 'spec_helper'

iis = {
    sites: [
        {.....,
        app_pools: [....]
        }
    ]
}

iis_override = {
    site: {...}
}
    
describe 'myCookbook::iis' do

    let(:chef_run) do
        ChefSpec::SoloRunner.new do |node|
            node.default['is_dev_machine'] = false
        end.converge(described_recipe)
        # Case 1: node['iis_override'] doesnt exist
    end

    # There are 2 cases here:
    # 1: node['iis_override'] exists or not null
    # 2: node['iis_override'] does not exist
    iis[:sites].each do |site|  
        context "if node['iis_override'] DOESNT exist" do 
            it 'adds the default app pool' do
                expect(chef_run).to add_iis_pool('DefaultAppPool').with(
                    ...
                )
            end
            ## More complicated 'it' blocks below
        end

        context "if node['iis_override'] DOES exist" do 
            #How to correctly set node attribute for iis_override?
            #These 2 lines NOT WORKING because they only work in 'it' block
            #However, I want to change the node attribute in the context level because 
            # I have many 'it' blocks under this context and dont want to duplicate this process
            chef_run.node.normal['iis_override'] = iis_override
            chef_run.converge(described_recipe)

            it 'adds the default app pool' do
                expect(chef_run).to add_iis_pool('DefaultAppPool').with(
                    ...
                )
            end
            ## More complicated 'it' blocks below similar to the previous context
        end
    end
end

Thanks

What version of ChefSpec are you using? With v7+, test setup has become much easier to write and read. For setting node attributes at different levels in different contexts, see the ChefSpec README section on Node Attributes.

Here's my attempt at a ChefSpec v7 refresh of your tests:

require 'spec_helper'

iis = {
    sites: [
        {.....,
        app_pools: [....]
        }
    ]
}

iis_override = {
    site: {...}
}
    
describe 'myCookbook::iis' do
  # the Chef run is implied, no need to set it up with the let
  platform 'ubuntu' # or whatever your target platform is
  default_attributes['is_dev_machine'] = false

  iis[:sites].each do |site|
    # recommend another context to represent each site as
    # the collection of sites is iterated over
    context "for #{site['something']['identifiable']}" do

      context "when iis_override is not set (default)" do 
        it 'adds the default app pool' do
          is_expected.to add_iis_pool('DefaultAppPool').with(
            ...
           )
         end
         ## More complicated 'it' blocks below
       end

      context "when iis_override is set" do
        normal_attrbutes['iis_override'] = iis_override

        it 'adds the default app pool' do
          is_expected.to add_iis_pool('DefaultAppPool').with(
            ...
          )
        end
      end

    end
  end
end