<commit_before>describe "A Bureau in the Open State" do
  before do
    class UIViewController < UIResponder
      include Bureau::Controller
    end
    class SomeController < UIViewController; end
    @x = UIViewController.new
    @y = UIViewController.new
    class X
      attr_accessor :num
      def initialize; @num = 5; end
      def do_nothing; end
      def change_num; @num = 10; end
    end
    @z = X.new
    @structure = [
      {
        drawers:
        [
          {target: @z, action: :do_nothing},
          {controller: @x},
        ]
      },
      {
        drawers:
        [
          {controller: SomeController},
        ]
      },
      {
        drawers:
        [
          {target: @z, action: :change_num},
          {controller: @y, open: true},
        ]
      },
    ]
    @bureau = Bureau::Bureau.new(structure:@structure, state: :open)
  end

  it "removes the previously open drawer when a new one with a controller is tapped" do
    new_active_path = NSIndexPath.indexPathForRow(1, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:new_active_path)
    @bureau.structure.last[:drawers].last[:open].should.not == true
    @bureau.childViewControllers.should.not.include @y
    @bureau.view.subviews.should.not.include @y.view
  end

  it "does not remove the previously open drawer when a new one without a controller is tapped" do
    new_active_path = NSIndexPath.indexPathForRow(0, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:new_active_path)
    @bureau.structure.last[:drawers].last[:open].should == true
    @bureau.childViewControllers.should.include @y
    @bureau.view.subviews.should.include @y.view
  end

  it "opens the touched drawer when a new one with a controller is tapped" do
    new_active_path = NSIndexPath.indexPathForRow(1, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:new_active_path)
    @bureau.structure[0][:drawers][1][:open].should == true
    @bureau.childViewControllers.should.include @x
    @bureau.view.subviews.should.include @x.view
    @x.view.frame.should == Bureau::Frame::closed
  end

  it "executes the action of a target/action drawer when one is tapped" do
    tapped_path = NSIndexPath.indexPathForRow(0, inSection:2)
    @z.num.should == 5
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:tapped_path)
    @z.num.should == 10
  end

  it "instantiates controllers set as classes when tapped" do
    tapped_path = NSIndexPath.indexPathForRow(0, inSection:1)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:tapped_path)
    @bureau.open_drawer[:controller_instance].should.be.instance_of SomeController
    @bureau.open_drawer[:controller_instance].bureau.should == @bureau
  end

  it "re-instantiates controllers set as classes when tapped" do
    first_tapped_path = NSIndexPath.indexPathForRow(0, inSection:1)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:first_tapped_path)
    old_instance = @bureau.open_drawer[:controller_instance]
    second_tapped_path = NSIndexPath.indexPathForRow(1, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:second_tapped_path)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:first_tapped_path)
    new_instance = @bureau.open_drawer[:controller_instance]
    new_instance.should.not == old_instance
  end
end<commit_msg>Updated tests to send params to Frame::open and Frame::closed methods.<commit_after>describe "A Bureau in the Open State" do
  before do
    class UIViewController < UIResponder
      include Bureau::Controller
    end
    class SomeController < UIViewController; end
    @x = UIViewController.new
    @y = UIViewController.new
    class X
      attr_accessor :num
      def initialize; @num = 5; end
      def do_nothing; end
      def change_num; @num = 10; end
    end
    @z = X.new
    @structure = [
      {
        drawers:
        [
          {target: @z, action: :do_nothing},
          {controller: @x},
        ]
      },
      {
        drawers:
        [
          {controller: SomeController},
        ]
      },
      {
        drawers:
        [
          {target: @z, action: :change_num},
          {controller: @y, open: true},
        ]
      },
    ]
    @bureau = Bureau::Bureau.new(structure:@structure, state: :open)
  end

  it "removes the previously open drawer when a new one with a controller is tapped" do
    new_active_path = NSIndexPath.indexPathForRow(1, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:new_active_path)
    @bureau.structure.last[:drawers].last[:open].should.not == true
    @bureau.childViewControllers.should.not.include @y
    @bureau.view.subviews.should.not.include @y.view
  end

  it "does not remove the previously open drawer when a new one without a controller is tapped" do
    new_active_path = NSIndexPath.indexPathForRow(0, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:new_active_path)
    @bureau.structure.last[:drawers].last[:open].should == true
    @bureau.childViewControllers.should.include @y
    @bureau.view.subviews.should.include @y.view
  end

  it "opens the touched drawer when a new one with a controller is tapped" do
    new_active_path = NSIndexPath.indexPathForRow(1, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:new_active_path)
    @bureau.structure[0][:drawers][1][:open].should == true
    @bureau.childViewControllers.should.include @x
    @bureau.view.subviews.should.include @x.view
    @x.view.frame.should == Bureau::Frame::closed(@bureau.orientations, @bureau.open_drawer[:controller].view.frame)
  end

  it "executes the action of a target/action drawer when one is tapped" do
    tapped_path = NSIndexPath.indexPathForRow(0, inSection:2)
    @z.num.should == 5
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:tapped_path)
    @z.num.should == 10
  end

  it "instantiates controllers set as classes when tapped" do
    tapped_path = NSIndexPath.indexPathForRow(0, inSection:1)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:tapped_path)
    @bureau.open_drawer[:controller_instance].should.be.instance_of SomeController
    @bureau.open_drawer[:controller_instance].bureau.should == @bureau
  end

  it "re-instantiates controllers set as classes when tapped" do
    first_tapped_path = NSIndexPath.indexPathForRow(0, inSection:1)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:first_tapped_path)
    old_instance = @bureau.open_drawer[:controller_instance]
    second_tapped_path = NSIndexPath.indexPathForRow(1, inSection:0)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:second_tapped_path)
    @bureau.tableView(@bureau.table, didSelectRowAtIndexPath:first_tapped_path)
    new_instance = @bureau.open_drawer[:controller_instance]
    new_instance.should.not == old_instance
  end
end
{'fraction_non_alphanumeric': 0.103234190008663, 'fraction_numerical': 0.006352873231302339, 'mean_word_length': 3.605718085106383, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2182337', 'n_tokens_mistral': 2272, 'n_tokens_neox': 2201, 'n_words': 463}