Here is a simple example using the Ruby Console:
Show the current material:
> printf "%s\n", Sketchup.active_model.materials.current.name
\[Color_D05]
nil
Select a new material in the materials window, check the current material again:
> printf "%s\n", Sketchup.active_model.materials.current.name
\[Color_D05]
nil
Fill a face with the new material, then check the current material:
> printf "%s\n", Sketchup.active_model.materials.current.name
\[Color_F09]
nil
Sketchup.active_model.materials.current does not change until the last step